diff options
Diffstat (limited to 'kstyles')
-rw-r--r-- | kstyles/asteroid/asteroid.cpp | 79 | ||||
-rw-r--r-- | kstyles/highcolor/highcolor.cpp | 113 | ||||
-rw-r--r-- | kstyles/highcontrast/highcontrast.cpp | 39 | ||||
-rw-r--r-- | kstyles/keramik/keramik.cpp | 159 | ||||
-rw-r--r-- | kstyles/keramik/keramik.h | 4 | ||||
-rw-r--r-- | kstyles/light/lightstyle-v2.cpp | 106 | ||||
-rw-r--r-- | kstyles/light/lightstyle-v3.cpp | 115 | ||||
-rw-r--r-- | kstyles/plastik/plastik.cpp | 17 |
8 files changed, 301 insertions, 331 deletions
diff --git a/kstyles/asteroid/asteroid.cpp b/kstyles/asteroid/asteroid.cpp index 05a669e18..a5e8f88cd 100644 --- a/kstyles/asteroid/asteroid.cpp +++ b/kstyles/asteroid/asteroid.cpp @@ -192,10 +192,9 @@ void AsteroidStyle::drawKStylePrimitive(KStylePrimitive ksp, switch (ksp) { case KPE_SliderGroove: { - const TQSlider* slider = (const TQSlider*)w; int x, y, v, h; r.rect(&x, &y, &v, &h); - bool horizontal = slider->orientation() ==Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; int gcenter = (horizontal ? h : v) / 2; int pad = 3; @@ -225,12 +224,11 @@ void AsteroidStyle::drawKStylePrimitive(KStylePrimitive ksp, case KPE_SliderHandle: { - const TQSlider* slider = (const TQSlider*)w; int x, y, x2, y2, xmin, xmax, ymin, ymax, v, h; int pcenter; r.coords(&xmin, &ymin, &xmax, &ymax); r.rect(&x, &y, &v, &h); - bool horizontal = slider->orientation() ==Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; if (horizontal) { x = v / 5 + xmin; @@ -1023,7 +1021,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, #ifndef TQT_NO_TABBAR case CE_TabBarTab: { - if ( !w || !w->parentWidget() || !o.tab() ) + if ( ceData.parentWidgetData.widgetObjectTypes.isEmpty() || !o.tab() ) break; const TQTab * t = o.tab(); @@ -1280,11 +1278,10 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, // ### Take into account totalSteps() for busy indicator - const TQProgressBar* pb = (const TQProgressBar*)w; TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, w); - double progress = pb->progress(); + double progress = ceData.currentStep; bool reverse = TQApplication::reverseLayout(); - int steps = pb->totalSteps(); + int steps = ceData.totalSteps; if (!cr.isValid()) return; @@ -1356,10 +1353,8 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, } case CE_PushButton: { - const TQPushButton *pb = dynamic_cast<const TQPushButton *>(w); - // Get rid of ugliness in Konqueror and KDevelop tab bar buttons, respectively - if ( w->inherits("KMultiTabBarButton") || w->inherits("Ideal::Button")) { + if ( ceData.widgetObjectTypes.contains("KMultiTabBarButton") || ceData.widgetObjectTypes.contains("Ideal::Button")) { p->setPen(cg.mid()); p->setBrush(cg.background()); p->drawRect(r); @@ -1380,7 +1375,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, } } else { - if (pb->isDefault()) { + if (elementFlags & CEF_IsDefault) { drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, r, cg, sf); drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, TQRect(x+1, y+1, sw-2, sh-2), cg, sf); } else { @@ -1508,15 +1503,12 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, /* Note: This is very poorly documented by TT. I'm disappointed. -clee */ case CE_HeaderLabel: { - const TQHeader *hw = dynamic_cast<const TQHeader *>(w); - int hs = o.headerSection(); const bool enabled = sf & Style_Enabled; bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags ); const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; - TQIconSet *is = hw->iconSet(hs); - if (is) { - TQPixmap pm = is->pixmap(TQIconSet::Small, sf & Style_Enabled ? TQIconSet::Normal : TQIconSet::Disabled); + if (!ceData.iconSet.isNull()) { + TQPixmap pm = ceData.iconSet.pixmap(TQIconSet::Small, sf & Style_Enabled ? TQIconSet::Normal : TQIconSet::Disabled); TQRect pr(0, 0, pm.width(), pm.height()); pr.moveCenter(r.center()); pr.setLeft(r.center().y() - (pm.height() - 1) / 2); @@ -1527,20 +1519,20 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, p->setPen( cg.dark()) ; TQPen savePen = p->pen(); p->setPen( cg.light() ); - p->drawText(pr_offset, text_flags, hw->label(hs)); + p->drawText(pr_offset, text_flags, ceData.textLabel); p->setPen(savePen); } - p->drawText(pr, text_flags, hw->label(hs)); + p->drawText(pr, text_flags, ceData.textLabel); } else { p->setPen( POPUPMENUITEM_TEXT_ETCH_CONDITIONS?cg.dark():cg.buttonText() ); TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height()); if HEADER_TEXT_ETCH_CONDITIONS { TQPen savePen = p->pen(); p->setPen( cg.light() ); - p->drawText(r_offset, text_flags, hw->label(hs)); + p->drawText(r_offset, text_flags, ceData.textLabel); p->setPen(savePen); } - p->drawText(r, text_flags, hw->label(hs)); + p->drawText(r, text_flags, ceData.textLabel); } break; } @@ -1962,7 +1954,6 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, case CC_ComboBox: { int x, y, x2, y2, sw, sh; - const TQComboBox *cb = dynamic_cast<const TQComboBox *>(w); r.rect(&x, &y, &sw, &sh); r.coords(&x, &y, &x2, &y2); @@ -2005,8 +1996,8 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, p->drawRect(hr); bool draw_skinny_frame = false; -// if (!cb) draw_skinny_frame = true; - if ((cb) && (cb->listBox() && cb->listBox()->isVisible())) draw_skinny_frame = true; +// if (!ceData.widgetObjectTypes.contains(TQCOMBOBOX_OBJECT_NAME_STRING)) draw_skinny_frame = true; + if (ceData.comboBoxListBoxFlags & CEF_IsVisible) draw_skinny_frame = true; if (draw_skinny_frame) { p->setPen(cg.mid()); p->drawRect(hr); @@ -2027,7 +2018,7 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, TQRect cr(sw - handle_offset-1, y+2, handle_width, sh - 4); TQRect pmr(0, 0, 7, 4); pmr.moveCenter(cr.center()); - if ((cb) && (cb->listBox() && cb->listBox()->isVisible())) { + if (ceData.comboBoxListBoxFlags & CEF_IsVisible) { pmr.moveBy(1, 1); } @@ -2042,11 +2033,9 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, #ifndef TQT_NO_TOOLBUTTON case CC_ToolButton: { - const TQToolButton *toolbutton = (const TQToolButton *) w; - TQColorGroup c = cg; - if ( toolbutton->backgroundMode() != TQt::PaletteButton ) - c.setBrush( TQColorGroup::Button, toolbutton->paletteBackgroundColor() ); + if ( ceData.backgroundMode != TQt::PaletteButton ) + c.setBrush( TQColorGroup::Button, ceData.paletteBgColor ); TQRect button, menuarea; button = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButton, o, w), ceData, elementFlags ); menuarea = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButtonMenu, o, w), ceData, elementFlags ); @@ -2062,11 +2051,10 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, if (sc & SC_ToolButton) { if (bflags & (Style_Down | Style_On | Style_Raised)) { drawPrimitive(TQStyle::PE_ButtonTool, p, ceData, elementFlags, button, c, bflags, o); - } else if ( toolbutton->parentWidget() && toolbutton->parentWidget()->backgroundPixmap() && ! toolbutton->parentWidget()->backgroundPixmap()->isNull() ) { - TQPixmap pixmap = - *(toolbutton->parentWidget()->backgroundPixmap()); + } else if ( ! ceData.parentWidgetData.bgPixmap.isNull() ) { + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; - p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); + p->drawTiledPixmap( r, pixmap, ceData.pos ); } } @@ -2076,8 +2064,8 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, drawPrimitive(TQStyle::PE_ArrowDown, p, ceData, elementFlags, menuarea, c, mflags, o); } - if (toolbutton->hasFocus() && !toolbutton->focusProxy()) { - TQRect fr = toolbutton->rect(); + if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) { + TQRect fr = ceData.rect; fr.addCoords(3, 3, -3, -3); drawPrimitive(TQStyle::PE_FocusRect, p, ceData, elementFlags, fr, c); } @@ -2087,20 +2075,17 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, #endif // TQT_NO_TOOLBUTTON case CC_Slider: { - const TQSlider* slider = (const TQSlider*)w; TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, o, w); TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, o, w); // Double-buffer slider for no flicker - TQPixmap pix(w->size()); + TQPixmap pix(ceData.rect.size()); TQPainter p2; p2.begin(&pix); - if ( slider->parentWidget() && - slider->parentWidget()->backgroundPixmap() && - !slider->parentWidget()->backgroundPixmap()->isNull() ) { - TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap()); - p2.drawTiledPixmap(r, pixmap, slider->pos()); + if ( !ceData.parentWidgetData.bgPixmap.isNull() ) { + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; + p2.drawTiledPixmap(r, pixmap, ceData.pos); } else pix.fill(cg.background()); @@ -2109,7 +2094,7 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc, drawKStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, sf, o, w ); // Draw the focus rect around the groove - if (slider->hasFocus()) + if (elementFlags & CEF_HasFocus) drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg); } @@ -2310,7 +2295,7 @@ int AsteroidStyle::pixelMetric(PixelMetric pm, TQStyleControlElementData ceData, } case PM_DefaultFrameWidth: { - if (w && w->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) { + if (ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) { return 3; } else { return KStyle::pixelMetric(pm, ceData, elementFlags, w); @@ -2448,7 +2433,7 @@ TQRect AsteroidStyle::querySubControlMetrics(TQ_ComplexControl cc, return TQRect(); } - TQRect r(w->rect()); + TQRect r(ceData.rect); switch (sc) { case SC_ComboBoxEditField: { @@ -2589,7 +2574,7 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct, sh = TQMAX(sh, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 2); } - sh = TQMAX(sh, w->fontMetrics().height() + 4); + sh = TQMAX(sh, TQFontMetrics(ceData.font).height() + 4); } if (!mi->text().isNull()) { @@ -2624,7 +2609,7 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct, case CT_Header: { // Fall through is intentional // const TQHeader *hw = dynamic_cast<const TQHeader *>(w); -// int sh = TQFontInfo(hw->font()).pixelSize() + 8; +// int sh = TQFontInfo(ceData.font).pixelSize() + 8; // int sw = 10; // return TQSize(sw, sh); } diff --git a/kstyles/highcolor/highcolor.cpp b/kstyles/highcolor/highcolor.cpp index 01da51717..e296c4196 100644 --- a/kstyles/highcolor/highcolor.cpp +++ b/kstyles/highcolor/highcolor.cpp @@ -1054,8 +1054,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe, // SLIDER GROOVE // ------------------------------------------------------------------- case KPE_SliderGroove: { - const TQSlider* slider = (const TQSlider*)widget; - bool horizontal = slider->orientation() == Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; int gcenter = (horizontal ? r.height() : r.width()) / 2; TQRect gr; @@ -1074,7 +1073,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe, p->drawLine(x+2, y, x2-2, y); p->drawLine(x, y+2, x, y2-2); p->fillRect(x+2,y+2,w-4, h-4, - slider->isEnabled() ? cg.dark() : cg.mid()); + (elementFlags & CEF_IsEnabled) ? cg.dark() : cg.mid()); p->setPen(cg.shadow()); p->drawRect(x+1, y+1, w-2, h-2); p->setPen(cg.light()); @@ -1088,8 +1087,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe, // SLIDER HANDLE // ------------------------------------------------------------------- case KPE_SliderHandle: { - const TQSlider* slider = (const TQSlider*)widget; - bool horizontal = slider->orientation() == Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; int x,y,w,h; r.rect(&x, &y, &w, &h); int x2 = x+w-1; @@ -1123,7 +1121,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe, p->drawLine(x+5, y+4, x+5, y2-4); p->drawLine(x+8, y+4, x+8, y2-4); p->drawLine(x+11,y+4, x+11, y2-4); - p->setPen(slider->isEnabled() ? cg.shadow(): cg.mid()); + p->setPen((elementFlags & CEF_IsEnabled) ? cg.shadow(): cg.mid()); p->drawLine(x+6, y+4, x+6, y2-4); p->drawLine(x+9, y+4, x+9, y2-4); p->drawLine(x+12,y+4, x+12, y2-4); @@ -1132,7 +1130,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe, p->drawLine(x+4, y+5, x2-4, y+5); p->drawLine(x+4, y+8, x2-4, y+8); p->drawLine(x+4, y+11, x2-4, y+11); - p->setPen(slider->isEnabled() ? cg.shadow() : cg.mid()); + p->setPen((elementFlags & CEF_IsEnabled) ? cg.shadow() : cg.mid()); p->drawLine(x+4, y+6, x2-4, y+6); p->drawLine(x+4, y+9, x2-4, y+9); p->drawLine(x+4, y+12, x2-4, y+12); @@ -1162,11 +1160,10 @@ void HighColorStyle::drawControl( TQ_ControlElement element, // ------------------------------------------------------------------- case CE_PushButton: { if ( type != HighColor ) { - TQPushButton *button = (TQPushButton*) widget; TQRect br = r; - bool btnDefault = button->isDefault(); + bool btnDefault = (elementFlags & CEF_IsDefault); - if ( btnDefault || button->autoDefault() ) { + if ( btnDefault || (elementFlags & CEF_AutoDefault) ) { // Compensate for default indicator static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); br.addCoords( di, di, -di, -di ); @@ -1187,8 +1184,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element, // PUSHBUTTON LABEL // ------------------------------------------------------------------- case CE_PushButtonLabel: { - const TQPushButton* button = (const TQPushButton*)widget; - bool active = button->isOn() || button->isDown(); + bool active = ((elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown)); int x, y, w, h; r.rect( &x, &y, &w, &h ); @@ -1200,7 +1196,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element, } // Does the button have a popup menu? - if ( button->isMenuButton() ) { + if ( elementFlags & CEF_IsMenuWidget ) { int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget ); drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect(x + w - dx - 2, y + 2, dx, h - 4), cg, flags, opt ); @@ -1208,19 +1204,19 @@ void HighColorStyle::drawControl( TQ_ControlElement element, } // Draw the icon if there is one - if ( button->iconSet() && !button->iconSet()->isNull() ) { + if ( !ceData.iconSet.isNull() ) { TQIconSet::Mode mode = TQIconSet::Disabled; TQIconSet::State state = TQIconSet::Off; - if (button->isEnabled()) - mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal; - if (button->isToggleButton() && button->isOn()) + if (elementFlags & CEF_IsEnabled) + mode = (elementFlags & CEF_HasFocus) ? TQIconSet::Active : TQIconSet::Normal; + if ((elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn)) state = TQIconSet::On; - TQPixmap pixmap = button->iconSet()->pixmap( TQIconSet::Small, mode, state ); + TQPixmap pixmap = ceData.iconSet.pixmap( TQIconSet::Small, mode, state ); // Center the iconset if there's no text or pixmap - if (button->text().isEmpty() && !button->pixmap()) + if (ceData.text.isEmpty() && ceData.fgPixmap.isNull()) p->drawPixmap( x + (w - pixmap.width()) / 2, y + (h - pixmap.height()) / 2, pixmap ); else @@ -1232,30 +1228,31 @@ void HighColorStyle::drawControl( TQ_ControlElement element, } // Make the label indicate if the button is a default button or not - if ( active || button->isDefault() ) { + if ( active || (elementFlags & CEF_IsDefault) ) { // Draw "fake" bold text - this enables the font metrics to remain // the same as computed in TQPushButton::sizeHint(), but gives // a reasonable bold effect. int i; // Text shadow - if (button->isEnabled()) // Don't draw double-shadow when disabled + if (elementFlags & CEF_IsEnabled) // Don't draw double-shadow when disabled for(i=0; i<2; i++) drawItem( p, TQRect(x+i+1, y+1, w, h), AlignCenter | ShowPrefix, - button->colorGroup(), button->isEnabled(), NULL, - button->text(), -1, - active ? &button->colorGroup().dark() : &button->colorGroup().mid() ); + ceData.colorGroup, (elementFlags & CEF_IsEnabled), NULL, + ceData.text, -1, + (active ? &ceData.colorGroup.dark() : &ceData.colorGroup.mid()) ); // Normal Text for(i=0; i<2; i++) drawItem( p, TQRect(x+i, y, w, h), AlignCenter | ShowPrefix, - button->colorGroup(), button->isEnabled(), i == 0 ? button->pixmap() : NULL, - button->text(), -1, - active ? &button->colorGroup().light() : &button->colorGroup().buttonText() ); - } else - drawItem( p, TQRect(x, y, w, h), AlignCenter | ShowPrefix, button->colorGroup(), - button->isEnabled(), button->pixmap(), button->text(), -1, - active ? &button->colorGroup().light() : &button->colorGroup().buttonText() ); + ceData.colorGroup, (elementFlags & CEF_IsEnabled), ((i == 0) ? (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap : NULL), + ceData.text, -1, + (active ? &ceData.colorGroup.light() : &ceData.colorGroup.buttonText()) ); + } else { + drawItem( p, TQRect(x, y, w, h), AlignCenter | ShowPrefix, ceData.colorGroup, + (elementFlags & CEF_IsEnabled), (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text, -1, + (active ? &ceData.colorGroup.light() : &ceData.colorGroup.buttonText()) ); + } // Draw a focus rect if the button has focus if ( flags & Style_HasFocus ) @@ -1334,7 +1331,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element, if ( !mi ) { // Don't leave blank holes if we set NoBackground for the TQPopupMenu. // This only happens when the popupMenu spans more than one column. - if (! (widget->erasePixmap() && !widget->erasePixmap()->isNull()) ) + if (! (!ceData.bgPixmap.isNull()) ) p->fillRect(r, cg.brush(TQColorGroup::Button) ); break; } @@ -1366,8 +1363,8 @@ void HighColorStyle::drawControl( TQ_ControlElement element, qDrawShadePanel( p, x, y, w, h, cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); // Draw the transparency pixmap - else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( x, y, *widget->erasePixmap(), x, y, w, h ); + else if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( x, y, ceData.bgPixmap, x, y, w, h ); // Draw a solid background else p->fillRect( r, cg.button() ); @@ -1609,7 +1606,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, ceData, elementFlags ); // Are we enabled? - if ( widget->isEnabled() ) + if ( elementFlags & CEF_IsEnabled ) flags |= Style_Enabled; // Are we "pushed" ? @@ -1628,13 +1625,13 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, SC_ComboBoxEditField, TQStyleOption::Default, widget), ceData, elementFlags ); // Draw the indent - if (cb->editable()) { + if ( elementFlags & CEF_IsEditable ) { p->setPen( cg.dark() ); p->drawLine( re.x(), re.y()-1, re.x()+re.width(), re.y()-1 ); p->drawLine( re.x()-1, re.y(), re.x()-1, re.y()+re.height() ); } - if ( cb->hasFocus() ) { + if ( elementFlags & CEF_HasFocus ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); } else { @@ -1642,7 +1639,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, p->setBackgroundColor( cg.button() ); } - if ( cb->hasFocus() && !cb->editable() ) { + if ( (elementFlags & CEF_HasFocus) && !(elementFlags & CEF_IsEditable) ) { // Draw the contents p->fillRect( re.x(), re.y(), re.width(), re.height(), cg.brush( TQColorGroup::Highlight ) ); @@ -1660,8 +1657,6 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, // TOOLBUTTON // ------------------------------------------------------------------- case CC_ToolButton: { - const TQToolButton *toolbutton = (const TQToolButton *) widget; - TQRect button, menuarea; button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget); menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget); @@ -1681,16 +1676,14 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); // Check whether to draw a background pixmap - else if ( toolbutton->parentWidget() && - toolbutton->parentWidget()->backgroundPixmap() && - !toolbutton->parentWidget()->backgroundPixmap()->isNull() ) + else if ( !ceData.parentWidgetData.bgPixmap.isNull() ) { - TQPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap()); - p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; + p->drawTiledPixmap( r, pixmap, ceData.pos ); } - else if (widget->parent()) + else if (!ceData.parentWidgetData.widgetObjectTypes.isEmpty()) { - if (widget->parent()->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) + if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) { TQToolBar* parent = (TQToolBar*)widget->parent(); TQRect pr = parent->rect(); @@ -1699,7 +1692,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, parent->orientation() == Qt::Vertical, r.x(), r.y(), pr.width()-2, pr.height()-2); } - else if (widget->parent()->inherits("QToolBarExtensionWidget")) + else if (ceData.parentWidgetData.widgetObjectTypes.contains("QToolBarExtensionWidget")) { TQWidget* parent = (TQWidget*)widget->parent(); TQToolBar* toolbar = (TQToolBar*)parent->parent(); @@ -1724,8 +1717,8 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control, drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); } - if (toolbutton->hasFocus() && !toolbutton->focusProxy()) { - TQRect fr = toolbutton->rect(); + if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) { + TQRect fr = ceData.rect; fr.addCoords(3, 3, -3, -3); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg); } @@ -1804,11 +1797,10 @@ TQRect HighColorStyle::subRect(SubRect r, const TQStyleControlElementData ceData // the Qt3 defaults to be similar to Qt 2's defaults. // ------------------------------------------------------------------- if (r == SR_PushButtonFocusRect ) { - const TQPushButton* button = (const TQPushButton*) widget; - TQRect wrect(widget->rect()); + TQRect wrect(ceData.rect); int dbw1 = 0, dbw2 = 0; - if (button->isDefault() || button->autoDefault()) { + if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) { dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget); dbw2 = dbw1 * 2; } @@ -1886,7 +1878,7 @@ int HighColorStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Co } break; default: - ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); break; } @@ -1905,7 +1897,6 @@ TQSize HighColorStyle::sizeFromContents( ContentsType contents, // PUSHBUTTON SIZE // ------------------------------------------------------------------ case CT_PushButton: { - const TQPushButton* button = (const TQPushButton*) widget; int w = contentSize.width(); int h = contentSize.height(); int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); @@ -1915,8 +1906,8 @@ TQSize HighColorStyle::sizeFromContents( ContentsType contents, h += bm + fw; // Ensure we stick to standard width and heights. - if ( button->isDefault() || button->autoDefault() ) { - if ( w < 80 && !button->text().isEmpty() ) + if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) { + if ( w < 80 && !ceData.text.isEmpty() ) w = 80; if ( type != HighColor ) { @@ -2043,7 +2034,7 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr // widgets that are on the toolbar. TQWidget *widget = TQT_TQWIDGET(object); TQWidget *parent = TQT_TQWIDGET(object->parent()); - int x_offset = widget->x(), y_offset = widget->y(); + int x_offset = ceData.rect.x(), y_offset = ceData.rect.y(); while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) { x_offset += parent->x(); @@ -2051,8 +2042,8 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr parent = TQT_TQWIDGET(parent->parent()); } - TQRect r = widget->rect(); - TQRect pr = parent->rect(); + TQRect r = ceData.rect; + TQRect pr = ceData.parentWidgetData.rect; bool horiz_grad = pr.width() < pr.height(); // Check if the parent is a QToolbar, and use its orientation, else guess. @@ -2077,7 +2068,7 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr if ( event->type() == TQEvent::Paint ) { TQWidget *widget = TQT_TQWIDGET(object); - TQRect wr = widget->rect(), tr = toolbar->rect(); + TQRect wr = ceData.rect, tr = ceData.parentWidgetData.rect; TQPainter p( widget ); renderGradient(&p, wr, toolbar->colorGroup().button(), toolbar->orientation() == Qt::Vertical, diff --git a/kstyles/highcontrast/highcontrast.cpp b/kstyles/highcontrast/highcontrast.cpp index 82734b7b3..5822452a5 100644 --- a/kstyles/highcontrast/highcontrast.cpp +++ b/kstyles/highcontrast/highcontrast.cpp @@ -724,10 +724,9 @@ void HighContrastStyle::drawKStylePrimitive (KStylePrimitive kpe, case KPE_SliderGroove: { setColorsText (p, cg, flags); TQRect r2 (r); - const TQSlider *slider = dynamic_cast<const TQSlider*>(widget); - if (slider != 0) + if (ceData.widgetObjectTypes.contains(TQSLIDER_OBJECT_NAME_STRING)) { - if (slider->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) { if (r2.height() > 5*basicLineWidth) { @@ -1565,12 +1564,12 @@ TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control, switch (subcontrol) { case SC_ComboBoxFrame: - return TQRect (0, 0, widget->width(), widget->height()); + return TQRect (0, 0, ceData.rect.width(), ceData.rect.height()); case SC_ComboBoxArrow: - return TQRect (widget->width() - arrow, 0, arrow, widget->height()); + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()); case SC_ComboBoxEditField: return TQRect (2*basicLineWidth, 2*basicLineWidth, - widget->width() - arrow - 3*basicLineWidth, widget->height() - 4*basicLineWidth); + ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth); default: break; } @@ -1581,17 +1580,17 @@ TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control, switch (subcontrol) { case SC_SpinWidgetFrame: - return TQRect (0, 0, widget->width(), widget->height()); + return TQRect (0, 0, ceData.rect.width(), ceData.rect.height()); case SC_SpinWidgetButtonField: - return TQRect (widget->width() - arrow, 0, arrow, widget->height()); + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()); case SC_SpinWidgetUp: - return TQRect (widget->width() - arrow, 0, arrow, widget->height()/2); + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()/2); case SC_SpinWidgetDown: - return TQRect (widget->width() - arrow, widget->height()/2, - arrow, widget->height()-widget->height()/2); + return TQRect (ceData.rect.width() - arrow, ceData.rect.height()/2, + arrow, ceData.rect.height()-ceData.rect.height()/2); case SC_SpinWidgetEditField: return TQRect (2*basicLineWidth, 2*basicLineWidth, - widget->width() - arrow - 3*basicLineWidth, widget->height() - 4*basicLineWidth); + ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth); default: break; } @@ -1616,7 +1615,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa return 2*basicLineWidth; case PM_ButtonDefaultIndicator: { - if ((widget != 0) && !widget->isEnabled()) + if ((widget != 0) && !(elementFlags & CEF_IsEnabled)) return 0; else return 2*basicLineWidth; @@ -1629,7 +1628,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa case PM_ScrollBarExtent: { int h = 0; if (widget != 0) - h = (2*widget->fontMetrics().lineSpacing())/3; + h = (2*TQFontMetrics(ceData.font).lineSpacing())/3; if (h > 9*basicLineWidth+4) return h; @@ -1638,7 +1637,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa } case PM_DefaultFrameWidth: { - if (widget && (widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))) + if (widget && (ceData.widgetObjectTypes.contains (TQLINEEDIT_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains (TQTEXTEDIT_OBJECT_NAME_STRING))) return 2*basicLineWidth; else return basicLineWidth; @@ -1651,7 +1650,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa case PM_MenuButtonIndicator: { // Arrow width int h = 0; if (widget != 0) - h = widget->fontMetrics().lineSpacing()/2; + h = TQFontMetrics(ceData.font).lineSpacing()/2; if (h > 3*basicLineWidth) return h; @@ -1667,7 +1666,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa case PM_IndicatorHeight: { int h = 0; if (widget != 0) - h = widget->fontMetrics().lineSpacing()-2*basicLineWidth; + h = TQFontMetrics(ceData.font).lineSpacing()-2*basicLineWidth; if (h > 6*basicLineWidth) return h; @@ -1681,7 +1680,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa case PM_DockWindowHandleExtent: { int w = 0; if (widget != 0) - w = widget->fontMetrics().lineSpacing()/4; + w = TQFontMetrics(ceData.font).lineSpacing()/4; if (w > 5*basicLineWidth) return w; else @@ -1843,7 +1842,7 @@ TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementD case SR_ProgressBarGroove: case SR_ProgressBarContents: case SR_ProgressBarLabel: - return widget->rect(); + return ceData.rect; default: return KStyle::subRect (subrect, ceData, elementFlags, widget); } @@ -1872,7 +1871,7 @@ int HighContrastStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, } break; default: - ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); break; } diff --git a/kstyles/keramik/keramik.cpp b/kstyles/keramik/keramik.cpp index 55534a03f..f619e0bfd 100644 --- a/kstyles/keramik/keramik.cpp +++ b/kstyles/keramik/keramik.cpp @@ -198,10 +198,9 @@ TQRect KeramikStyle::subRect(SubRect r, const TQStyleControlElementData ceData, { case SR_PushButtonFocusRect: { - const TQPushButton* button = (const TQPushButton*) widget; - TQRect wrect(widget->rect()); + TQRect wrect(ceData.rect); - if (button->isDefault() || button->autoDefault()) + if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) { return TQRect(wrect.x() + 6, wrect.y() + 5, wrect.width() - 12, wrect.height() - 10); } @@ -220,12 +219,10 @@ TQRect KeramikStyle::subRect(SubRect r, const TQStyleControlElementData ceData, case SR_CheckBoxFocusRect: { - const TQCheckBox* cb = static_cast<const TQCheckBox*>(widget); - //Only checkbox, no label - if (cb->text().isEmpty() && (cb->pixmap() == 0) ) + if (ceData.text.isEmpty() && (ceData.fgPixmap.isNull()) ) { - TQRect bounding = cb->rect(); + TQRect bounding = ceData.rect; TQSize checkDim = loader.size( keramik_checkbox_on); int cw = checkDim.width(); int ch = checkDim.height(); @@ -1357,26 +1354,29 @@ void KeramikStyle::drawKStylePrimitive( KStylePrimitive kpe, } } -bool KeramikStyle::isFormWidget(const TQWidget* widget) const +bool KeramikStyle::isFormWidget(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget* widget) const { - //Form widgets are in the KHTMLView, but that has 2 further inner levels - //of widgets - QClipperWidget, and outside of that, QViewportWidget - TQWidget* potentialClipPort = widget->parentWidget(); - if ( !potentialClipPort || potentialClipPort->isTopLevel() ) - return false; - - TQWidget* potentialViewPort = potentialClipPort->parentWidget(); - if (!potentialViewPort || potentialViewPort->isTopLevel() || - qstrcmp(potentialViewPort->name(), "qt_viewport") ) - return false; - - TQWidget* potentialKHTML = potentialViewPort->parentWidget(); - if (!potentialKHTML || potentialKHTML->isTopLevel() || - qstrcmp(potentialKHTML->className(), "KHTMLView") ) - return false; - - - return true; + if (widget) { + //Form widgets are in the KHTMLView, but that has 2 further inner levels + //of widgets - QClipperWidget, and outside of that, QViewportWidget + TQWidget* potentialClipPort = widget->parentWidget(); + if ((ceData.parentWidgetData.widgetObjectTypes.isEmpty()) && (ceData.parentWidgetFlags & CEF_IsTopLevel)) { + return false; + } + + TQWidget* potentialViewPort = potentialClipPort->parentWidget(); + if (!potentialViewPort || potentialViewPort->isTopLevel() || + qstrcmp(potentialViewPort->name(), "qt_viewport") ) + return false; + + TQWidget* potentialKHTML = potentialViewPort->parentWidget(); + if (!potentialKHTML || potentialKHTML->isTopLevel() || + qstrcmp(potentialKHTML->className(), "KHTMLView") ) + return false; + + + return true; + } } void KeramikStyle::drawControl( TQ_ControlElement element, @@ -1401,7 +1401,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element, { const TQPushButton* btn = static_cast< const TQPushButton* >( widget ); - if (isFormWidget(btn)) + if (isFormWidget(ceData, elementFlags, btn)) formMode = true; if ( btn->isFlat( ) ) @@ -1649,7 +1649,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element, { // Don't leave blank holes if we set NoBackground for the TQPopupMenu. // This only happens when the popupMenu spans more than one column. - if (! ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) ) + if (! ( !ceData.bgPixmap.isNull() ) ) p->fillRect( r, cg.background().light( 105 ) ); break; @@ -1670,15 +1670,15 @@ void KeramikStyle::drawControl( TQ_ControlElement element, if ( enabled ) Keramik::RowPainter( keramik_menuitem ).draw( p, main, cg.highlight(), cg.background() ); else { - if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( main.topLeft(), *widget->erasePixmap(), main ); + if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( main.topLeft(), ceData.bgPixmap, main ); else p->fillRect( main, cg.background().light( 105 ) ); p->drawWinFocusRect( r ); } } // Draw the transparency pixmap - else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( main.topLeft(), *widget->erasePixmap(), main ); + else if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( main.topLeft(), ceData.bgPixmap, main ); // Draw a solid background else p->fillRect( main, cg.background().light( 105 ) ); @@ -1853,11 +1853,10 @@ void KeramikStyle::drawControl( TQ_ControlElement element, break; } case CE_ProgressBarContents: { - const TQProgressBar* pb = (const TQProgressBar*)widget; TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget); - double progress = pb->progress(); + double progress = ceData.currentStep; bool reverse = TQApplication::reverseLayout(); - int steps = pb->totalSteps(); + int steps = ceData.totalSteps; if (!cr.isValid()) return; @@ -1908,6 +1907,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element, ////////////////////////////////////// if (animateProgressBar) { + const TQProgressBar* pb = (const TQProgressBar*)widget; int progAnimShift = progAnimWidgets[const_cast<TQProgressBar*>(pb)]; if (reverse) { @@ -1978,16 +1978,22 @@ void KeramikStyle::drawControlMask( TQ_ControlElement element, maskMode = false; } -bool KeramikStyle::isSizeConstrainedCombo(const TQComboBox* combo) const +bool KeramikStyle::isSizeConstrainedCombo(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQComboBox* combo) const { - if (combo->width() >= 80) + if (ceData.rect.width() >= 80) return false; - int suggestedWidth = combo->sizeHint().width(); - - if (combo->width() - suggestedWidth < -5) - return true; - return false; + if (combo) { + int suggestedWidth = combo->sizeHint().width(); + + if (ceData.rect.width() - suggestedWidth < -5) + return true; + + return false; + } + else { + return true; + } } void KeramikStyle::drawComplexControl( TQ_ComplexControl control, @@ -2010,10 +2016,10 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, case CC_ComboBox: { bool toolbarMode = false; - const TQComboBox* cb = static_cast< const TQComboBox* >( widget ); - bool compact = isSizeConstrainedCombo(cb); + const TQComboBox* cb = dynamic_cast< const TQComboBox* >( widget ); + bool compact = isSizeConstrainedCombo(ceData, elementFlags, cb); - if (isFormWidget(cb)) + if (isFormWidget(ceData, elementFlags, cb)) formMode = true; TQPixmap * buf = 0; @@ -2114,7 +2120,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, if ( controls & SC_ComboBoxEditField ) { - if ( cb->editable() ) + if ( elementFlags & CEF_IsEditable ) { TQRect er = visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags ); er.addCoords( -2, -2, 2, 2 ); @@ -2123,7 +2129,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( p2, er, cg.button(), Qt::black, false, pmodeFullBlend() ); } - else if ( cb->hasFocus() ) + else if ( elementFlags & CEF_HasFocus ) { TQRect re = TQStyle::visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, cb), ceData, elementFlags); if ( compact ) @@ -2133,7 +2139,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, Style_FocusAtBorder, TQStyleOption( cg.highlight() ) ); } // TQComboBox draws the text on its own and uses the painter's current colors - if ( cb->hasFocus() ) + if ( elementFlags & CEF_HasFocus ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); @@ -2280,7 +2286,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, if (active & SC_ToolButtonMenu) mflags |= Style_Down; - if (onToolbar && static_cast<TQToolBar*>(TQT_TQWIDGET(widget->parent()))->orientation() == Qt::Horizontal) + if (onToolbar && ceData.toolBarData.orientation == TQt::Horizontal) bflags |= Style_Horizontal; if (controls & SC_ToolButton) @@ -2297,11 +2303,9 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, } // Check whether to draw a background pixmap - else if ( toolbutton->parentWidget() && - toolbutton->parentWidget()->backgroundPixmap() && - !toolbutton->parentWidget()->backgroundPixmap()->isNull() ) + else if ( !ceData.parentWidgetData.bgPixmap.isNull() ) { - TQPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap()); + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); } else if (onToolbar) @@ -2314,8 +2318,8 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control, //(so if we're on an extender, we're not floating) TQWidget* parent = static_cast<TQWidget*> (TQT_TQWIDGET(widget->parent())); TQToolBar* toolbar = static_cast<TQToolBar*>(TQT_TQWIDGET(parent->parent())); - TQRect tr = toolbar->rect(); - bool horiz = toolbar->orientation() == Qt::Horizontal; + TQRect tr = ceData.parentWidgetData.rect; + bool horiz = ceData.toolBarData.orientation == TQt::Horizontal; //Calculate offset. We do this by translating our coordinates, //which are relative to the parent, to be relative to the toolbar. @@ -2507,8 +2511,7 @@ TQSize KeramikStyle::sizeFromContents( ContentsType contents, case CT_ComboBox: { int arrow = 11 + loader.size( keramik_ripple ).width(); - const TQComboBox *cb = static_cast<const TQComboBox*>( widget ); - return TQSize( contentSize.width() + arrow + (cb->editable() ? 26 : 22), + return TQSize( contentSize.width() + arrow + ((elementFlags & CEF_IsEditable) ? 26 : 22), contentSize.height() + 10 ); } @@ -2608,7 +2611,7 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control, { int arrow; bool compact = false; - if ( isSizeConstrainedCombo(static_cast<const TQComboBox*>(widget) ) ) //### constant + if ( isSizeConstrainedCombo(ceData, elementFlags, dynamic_cast<const TQComboBox*>(widget)) ) //### constant compact = true; if ( compact ) @@ -2715,10 +2718,9 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control, } case CC_Slider: { - const TQSlider* sl = static_cast< const TQSlider* >( widget ); - bool horizontal = sl->orientation() == Qt::Horizontal; - TQSlider::TickSetting ticks = sl->tickmarks(); - int pos = sl->sliderStart(); + bool horizontal = ceData.orientation == TQt::Horizontal; + TQSlider::TickSetting ticks = (TQSlider::TickSetting)ceData.tickMarkSetting; + int pos = ceData.startStep; int size = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget ); int handleSize = pixelMetric( PM_SliderThickness, ceData, elementFlags, widget ); int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); @@ -2726,9 +2728,9 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control, //Shrink the metrics if the widget is too small //to fit our normal values for them. if (horizontal) - handleSize = QMIN(handleSize, sl->height()); + handleSize = QMIN(handleSize, ceData.rect.height()); else - handleSize = QMIN(handleSize, sl->width()); + handleSize = QMIN(handleSize, ceData.rect.width()); size = QMIN(size, handleSize); @@ -2738,34 +2740,34 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control, if ( horizontal ) { if ( ticks == TQSlider::Both ) - return TQRect( 0, ( sl->height() - size ) / 2, sl->width(), size ); + return TQRect( 0, ( ceData.rect.height() - size ) / 2, ceData.rect.width(), size ); else if ( ticks == TQSlider::Above ) - return TQRect( 0, sl->height() - size - ( handleSize - size ) / 2, sl->width(), size ); - return TQRect( 0, ( handleSize - size ) / 2, sl->width(), size ); + return TQRect( 0, ceData.rect.height() - size - ( handleSize - size ) / 2, ceData.rect.width(), size ); + return TQRect( 0, ( handleSize - size ) / 2, ceData.rect.width(), size ); } else { if ( ticks == TQSlider::Both ) - return TQRect( ( sl->width() - size ) / 2, 0, size, sl->height() ); + return TQRect( ( ceData.rect.width() - size ) / 2, 0, size, ceData.rect.height() ); else if ( ticks == TQSlider::Above ) - return TQRect( sl->width() - size - ( handleSize - size ) / 2, 0, size, sl->height() ); - return TQRect( ( handleSize - size ) / 2, 0, size, sl->height() ); + return TQRect( ceData.rect.width() - size - ( handleSize - size ) / 2, 0, size, ceData.rect.height() ); + return TQRect( ( handleSize - size ) / 2, 0, size, ceData.rect.height() ); } case SC_SliderHandle: if ( horizontal ) { if ( ticks == TQSlider::Both ) - return TQRect( pos, ( sl->height() - handleSize ) / 2, len, handleSize ); + return TQRect( pos, ( ceData.rect.height() - handleSize ) / 2, len, handleSize ); else if ( ticks == TQSlider::Above ) - return TQRect( pos, sl->height() - handleSize, len, handleSize ); + return TQRect( pos, ceData.rect.height() - handleSize, len, handleSize ); return TQRect( pos, 0, len, handleSize ); } else { if ( ticks == TQSlider::Both ) - return TQRect( ( sl->width() - handleSize ) / 2, pos, handleSize, len ); + return TQRect( ( ceData.rect.width() - handleSize ) / 2, pos, handleSize, len ); else if ( ticks == TQSlider::Above ) - return TQRect( sl->width() - handleSize, pos, handleSize, len ); + return TQRect( ceData.rect.width() - handleSize, pos, handleSize, len ); return TQRect( 0, pos, handleSize, len ); } default: break; @@ -2925,6 +2927,9 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control return false; // Now draw the contents } +#if 0 // FIXME + // This does not work on modern systems + // Rather than resorting to hacks like this, which can stop working at any time, the required functionality should simply be added to TQt3! else if (event->type() == TQEvent::Paint && object->parent() && ::tqqt_cast<TQToolBar*>(object->parent()) && !::tqqt_cast<TQPopupMenu*>(object) ) { @@ -2958,6 +2963,7 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control return true; } +#endif // Track show events for progress bars if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) ) { @@ -2988,8 +2994,11 @@ int KeramikStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Cont ret = checkcol; } break; + case SH_ScrollBar_CombineAddLineRegionDrawingAreas: + ret = 1; + break; default: - ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); break; } diff --git a/kstyles/keramik/keramik.h b/kstyles/keramik/keramik.h index c9ec49639..53c06a3b4 100644 --- a/kstyles/keramik/keramik.h +++ b/kstyles/keramik/keramik.h @@ -146,8 +146,8 @@ private slots: private: - bool isSizeConstrainedCombo(const TQComboBox* combo) const; - bool isFormWidget (const TQWidget* widget) const; + bool isSizeConstrainedCombo(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQComboBox* widget) const; + bool isFormWidget (const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget* widget) const; ///Configuration settings bool animateProgressBar; diff --git a/kstyles/light/lightstyle-v2.cpp b/kstyles/light/lightstyle-v2.cpp index c96f636de..0a41317f4 100644 --- a/kstyles/light/lightstyle-v2.cpp +++ b/kstyles/light/lightstyle-v2.cpp @@ -804,7 +804,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, case CE_PopupMenuItem: { - if (! widget || data.isDefault()) + if (data.isDefault()) break; TQMenuItem *mi = data.menuItem(); @@ -813,8 +813,8 @@ void LightStyleV2::drawControl( TQ_ControlElement control, if ( mi && mi->isSeparator() ) { // draw separator (bg first, though) - if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); + if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( r.topLeft(), ceData.bgPixmap, r ); else p->fillRect(r, cg.brush(TQColorGroup::Button)); @@ -830,8 +830,8 @@ void LightStyleV2::drawControl( TQ_ControlElement control, if (flags & Style_Active) qDrawShadePanel(p, r, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); - else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); + else if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( r.topLeft(), ceData.bgPixmap, r ); else p->fillRect(r, cg.brush(TQColorGroup::Button)); @@ -1020,14 +1020,13 @@ void LightStyleV2::drawControlMask( TQ_ControlElement control, TQRect LightStyleV2::subRect(SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const { - TQRect rect, wrect(widget->rect()); + TQRect rect, wrect(ceData.rect); switch (subrect) { case SR_PushButtonFocusRect: { - const TQPushButton *button = (const TQPushButton *) widget; int dbw1 = 0, dbw2 = 0; - if (button->isDefault() || button->autoDefault()) { + if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) { dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget); dbw2 = dbw1 * 2; } @@ -1089,7 +1088,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, if ((controls & SC_ComboBoxEditField) && field.isValid()) { p->setPen(cg.dark()); - if (combobox->editable()) { + if (elementFlags & CEF_IsEditable) { field.addCoords(-1, -1, 1, 1); p->drawRect(field); } else @@ -1097,7 +1096,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, field.right() + 1, field.bottom()); if (flags & Style_HasFocus) { - if (! combobox->editable()) { + if (! (elementFlags & CEF_IsEditable)) { p->fillRect( field, cg.brush( TQColorGroup::Highlight ) ); TQRect fr = TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), @@ -1122,8 +1121,8 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetFrame, data, widget); - up = spinwidget->upRect(); - down = spinwidget->downRect(); + up = ceData.spinWidgetData.upRect; + down = ceData.spinWidgetData.downRect; if ((controls & SC_SpinWidgetFrame) && frame.isValid()) drawLightBevel(p, frame, cg, flags | Style_Sunken, @@ -1131,7 +1130,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, if ((controls & SC_SpinWidgetUp) && up.isValid()) { TQ_PrimitiveElement pe = PE_SpinWidgetUp; - if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) + if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetPlus; p->setPen(cg.dark()); @@ -1164,7 +1163,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, if ((controls & SC_SpinWidgetDown) && down.isValid()) { TQ_PrimitiveElement pe = PE_SpinWidgetDown; - if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) + if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetMinus; p->setPen(cg.dark()); @@ -1200,9 +1199,8 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, case CC_ScrollBar: { - const TQScrollBar *scrollbar = (const TQScrollBar *) widget; TQRect addline, subline, subline2, addpage, subpage, slider, first, last; - bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); + bool maxedOut = (ceData.minSteps == ceData.maxSteps); subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget); addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget); @@ -1213,7 +1211,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget); subline2 = addline; - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) subline2.moveBy(-addline.width(), 0); else subline2.moveBy(0, -addline.height()); @@ -1222,56 +1220,56 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if (subline2.isValid()) drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg, Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); } if ((controls & SC_ScrollBarAddLine) && addline.isValid()) drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg, Style_Enabled | ((active == SC_ScrollBarAddLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg, Style_Enabled | ((active == SC_ScrollBarSubPage) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg, ((maxedOut) ? Style_Default : Style_Enabled) | ((active == SC_ScrollBarAddPage) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarFirst) && first.isValid()) drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, Style_Enabled | ((active == SC_ScrollBarFirst) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarLast) && last.isValid()) drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, Style_Enabled | ((active == SC_ScrollBarLast) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarSlider) && slider.isValid()) { drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, Style_Enabled | ((active == SC_ScrollBarSlider) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); // ### perhaps this should not be able to accept focus if maxedOut? - if (scrollbar->hasFocus()) { + if (elementFlags & CEF_HasFocus) { TQRect fr(slider.x() + 2, slider.y() + 2, slider.width() - 5, slider.height() - 5); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default); @@ -1283,7 +1281,6 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, case CC_Slider: { - const TQSlider *slider = (const TQSlider *) widget; TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, data, widget), handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, @@ -1293,7 +1290,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control, if (flags & Style_HasFocus) drawPrimitive( PE_FocusRect, p, ceData, elementFlags, groove, cg ); - if (slider->orientation() == Qt::Horizontal) { + if (ceData.orientation == TQt::Horizontal) { int dh = (groove.height() - 5) / 2; groove.addCoords(0, dh, 0, -dh); } else { @@ -1344,18 +1341,17 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control, switch (control) { case CC_ScrollBar: { - const TQScrollBar *scrollbar = (const TQScrollBar *) widget; - int sliderstart = scrollbar->sliderStart(); + int sliderstart = ceData.startStep; int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget); - int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? - scrollbar->width() : scrollbar->height()) - (sbextent * 3); + int maxlen = ((ceData.orientation == TQt::Horizontal) ? + ceData.rect.width() : ceData.rect.height()) - (sbextent * 3); int sliderlen; // calculate slider length - if (scrollbar->maxValue() != scrollbar->minValue()) { - uint range = scrollbar->maxValue() - scrollbar->minValue(); - sliderlen = (scrollbar->pageStep() * maxlen) / - (range + scrollbar->pageStep()); + if (ceData.maxSteps != ceData.minSteps) { + uint range = ceData.maxSteps - ceData.minSteps; + sliderlen = (ceData.pageStep * maxlen) / + (range + ceData.pageStep); int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget ); if ( sliderlen < slidermin || range > INT_MAX / 2 ) @@ -1373,15 +1369,15 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control, case SC_ScrollBarAddLine: // bottom/right button - if (scrollbar->orientation() == Qt::Horizontal) - ret.setRect(scrollbar->width() - sbextent, 0, sbextent, sbextent); + if (ceData.orientation == TQt::Horizontal) + ret.setRect(ceData.rect.width() - sbextent, 0, sbextent, sbextent); else - ret.setRect(0, scrollbar->height() - sbextent, sbextent, sbextent); + ret.setRect(0, ceData.rect.height() - sbextent, sbextent, sbextent); break; case SC_ScrollBarSubPage: // between top/left button and slider - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent); else ret.setRect(0, sbextent, sbextent, sliderstart - sbextent); @@ -1389,7 +1385,7 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control, case SC_ScrollBarAddPage: // between bottom/right button and slider - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sliderstart + sliderlen, 0, maxlen - sliderstart - sliderlen + sbextent, sbextent); else @@ -1398,16 +1394,16 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control, break; case SC_ScrollBarGroove: - if (scrollbar->orientation() == Qt::Horizontal) - ret.setRect(sbextent, 0, scrollbar->width() - sbextent * 3, - scrollbar->height()); + if (ceData.orientation == TQt::Horizontal) + ret.setRect(sbextent, 0, ceData.rect.width() - sbextent * 3, + ceData.rect.height()); else - ret.setRect(0, sbextent, scrollbar->width(), - scrollbar->height() - sbextent * 3); + ret.setRect(0, sbextent, ceData.rect.width(), + ceData.rect.height() - sbextent * 3); break; case SC_ScrollBarSlider: - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sliderstart, 0, sliderlen, sbextent); else ret.setRect(0, sliderstart, sbextent, sliderlen); @@ -1541,7 +1537,7 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents, // only expand the button if we are displaying text... if ( ! button->text().isEmpty() ) { - if ( button->isDefault() || button->autoDefault() ) { + if ( (elementFlags & CEF_IsDefault) || button->autoDefault() ) { // default button minimum size if ( w < 80 ) w = 80; @@ -1562,7 +1558,7 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents, case CT_PopupMenuItem: { - if (! widget || data.isDefault()) + if (data.isDefault()) break; TQMenuItem *mi = data.menuItem(); @@ -1606,22 +1602,20 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents, } case CT_ProgressBar: { - const TQProgressBar* pb = static_cast<const TQProgressBar*>(widget); - //If we have to display the indicator, and we do it on RHS, give some more room //for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents //sizing in TQCommonStyle. - if (pb->percentageVisible() && - (pb->indicatorFollowsStyle() || ! pb->centerIndicator())) + if (ceData.percentageVisible && + ((elementFlags & CEF_IndicatorFollowsStyle) || ! (elementFlags & CEF_CenterIndicator))) { - int addw = pb->fontMetrics().width("100%") + 6; + int addw = TQFontMetrics(ceData.font).width("100%") + 6; return TQSize(contentsSize.width() + addw, contentsSize.height()); } else return contentsSize; //Otherwise leave unchanged - + break; - } + } default: ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget); diff --git a/kstyles/light/lightstyle-v3.cpp b/kstyles/light/lightstyle-v3.cpp index d14035c17..bf39f451a 100644 --- a/kstyles/light/lightstyle-v3.cpp +++ b/kstyles/light/lightstyle-v3.cpp @@ -926,7 +926,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, case CE_PopupMenuItem: { - if (! widget || data.isDefault()) + if (data.isDefault()) break; TQMenuItem *mi = data.menuItem(); @@ -934,8 +934,8 @@ void LightStyleV3::drawControl( TQ_ControlElement control, int maxpmw = data.maxIconWidth(); if ( mi && mi->isSeparator() ) { - if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); + if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( r.topLeft(), ceData.bgPixmap, r ); else p->fillRect(r, cg.brush(TQColorGroup::Button)); p->setPen( cg.mid() ); @@ -950,8 +950,8 @@ void LightStyleV3::drawControl( TQ_ControlElement control, if (flags & Style_Active) qDrawShadePanel(p, r, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); - else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) - p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); + else if ( !ceData.bgPixmap.isNull() ) + p->drawPixmap( r.topLeft(), ceData.bgPixmap, r ); else p->fillRect(r, cg.brush(TQColorGroup::Button)); @@ -1221,7 +1221,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, if ((controls & SC_ComboBoxEditField) && field.isValid()) { if (flags & Style_HasFocus) { - if (! combobox->editable()) { + if (! (elementFlags & CEF_IsEditable)) { TQRect fr = TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), ceData, elementFlags ); @@ -1250,15 +1250,15 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetFrame, data, widget); - up = spinwidget->upRect(); - down = spinwidget->downRect(); + up = ceData.spinWidgetData.upRect; + down = ceData.spinWidgetData.downRect; if ((controls & SC_SpinWidgetFrame) && frame.isValid()) drawPrimitive( PE_Panel, p, ceData, elementFlags, frame, cg, flags | Style_Sunken ); if ((controls & SC_SpinWidgetUp) && up.isValid()) { TQ_PrimitiveElement pe = PE_SpinWidgetUp; - if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) + if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetPlus; p->setPen( cg.background() ); @@ -1276,7 +1276,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, if ((controls & SC_SpinWidgetDown) && down.isValid()) { TQ_PrimitiveElement pe = PE_SpinWidgetDown; - if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) + if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetMinus; p->setPen( cg.background() ); @@ -1297,9 +1297,8 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, case CC_ScrollBar: { - const TQScrollBar *scrollbar = (const TQScrollBar *) widget; TQRect addline, subline, subline2, addpage, subpage, slider, first, last; - bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); + bool maxedOut = (ceData.minSteps == ceData.maxSteps); subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget); addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget); @@ -1310,7 +1309,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget); subline2 = addline; - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) subline2.moveBy(-addline.width(), 0); else subline2.moveBy(0, -addline.height()); @@ -1319,56 +1318,56 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if (subline2.isValid()) drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg, Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); } if ((controls & SC_ScrollBarAddLine) && addline.isValid()) drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg, Style_Enabled | ((active == SC_ScrollBarAddLine) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg, Style_Enabled | ((active == SC_ScrollBarSubPage) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg, ((maxedOut) ? Style_Default : Style_Enabled) | ((active == SC_ScrollBarAddPage) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarFirst) && first.isValid()) drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, Style_Enabled | ((active == SC_ScrollBarFirst) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarLast) && last.isValid()) drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, Style_Enabled | ((active == SC_ScrollBarLast) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarSlider) && slider.isValid()) { drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, Style_Enabled | ((active == SC_ScrollBarSlider) ? Style_Down : Style_Default) | - ((scrollbar->orientation() == Qt::Horizontal) ? + ((ceData.orientation == TQt::Horizontal) ? Style_Horizontal : 0)); // ### perhaps this should not be able to accept focus if maxedOut? - if (scrollbar->hasFocus()) { + if (elementFlags & CEF_HasFocus) { TQRect fr(slider.x() + 2, slider.y() + 2, slider.width() - 5, slider.height() - 5); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default); @@ -1425,7 +1424,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control, p->fillRect( handle, sliderColor ); p->setPen( cg.midlight() ); - if ( slider->orientation() == Qt::Horizontal ) + if ( ceData.orientation == TQt::Horizontal ) p->drawLine( handle.left() + handle.width() / 2, handle.top() + 1, handle.left() + handle.width() / 2, @@ -1473,15 +1472,15 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, switch ( sc ) { case SC_ComboBoxFrame: - ret = widget->rect(); + ret = ceData.rect; break; case SC_ComboBoxArrow: - ret.setRect( widget->width() - fw - sb, fw, - sb, widget->height() - fw*2 ); + ret.setRect( ceData.rect.width() - fw - sb, fw, + sb, ceData.rect.height() - fw*2 ); break; case SC_ComboBoxEditField: - ret.setRect( fw, fw, widget->width() - fw*2 - sb - 1, - widget->height() - fw*2 ); + ret.setRect( fw, fw, ceData.rect.width() - fw*2 - sb - 1, + ceData.rect.height() - fw*2 ); break; default: break; @@ -1492,18 +1491,17 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, case CC_ScrollBar: { - const TQScrollBar *scrollbar = (const TQScrollBar *) widget; - int sliderstart = scrollbar->sliderStart(); + int sliderstart = ceData.startStep; int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget); - int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? - scrollbar->width() : scrollbar->height()) - (sbextent * 3); + int maxlen = ((ceData.orientation == TQt::Horizontal) ? + ceData.rect.width() : ceData.rect.height()) - (sbextent * 3); int sliderlen; // calculate slider length - if (scrollbar->maxValue() != scrollbar->minValue()) { - uint range = scrollbar->maxValue() - scrollbar->minValue(); - sliderlen = (scrollbar->pageStep() * maxlen) / - (range + scrollbar->pageStep()); + if (ceData.maxSteps != ceData.minSteps) { + uint range = ceData.maxSteps - ceData.minSteps; + sliderlen = (ceData.pageStep * maxlen) / + (range + ceData.pageStep); int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget ); if ( sliderlen < slidermin || range > INT_MAX / 2 ) @@ -1521,15 +1519,15 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, case SC_ScrollBarAddLine: // bottom/right button - if (scrollbar->orientation() == Qt::Horizontal) - ret.setRect(scrollbar->width() - sbextent, 0, sbextent, sbextent); + if (ceData.orientation == TQt::Horizontal) + ret.setRect(ceData.rect.width() - sbextent, 0, sbextent, sbextent); else - ret.setRect(0, scrollbar->height() - sbextent, sbextent, sbextent); + ret.setRect(0, ceData.rect.height() - sbextent, sbextent, sbextent); break; case SC_ScrollBarSubPage: // between top/left button and slider - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent); else ret.setRect(0, sbextent, sbextent, sliderstart - sbextent); @@ -1537,7 +1535,7 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, case SC_ScrollBarAddPage: // between bottom/right button and slider - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sliderstart + sliderlen, 0, maxlen - sliderstart - sliderlen + sbextent, sbextent); else @@ -1546,14 +1544,14 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, break; case SC_ScrollBarGroove: - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sbextent, 0, maxlen, sbextent ); else ret.setRect(0, sbextent, sbextent, maxlen ); break; case SC_ScrollBarSlider: - if (scrollbar->orientation() == Qt::Horizontal) + if (ceData.orientation == TQt::Horizontal) ret.setRect(sliderstart, 0, sliderlen, sbextent); else ret.setRect(0, sliderstart, sbextent, sliderlen); @@ -1574,18 +1572,18 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control, switch ( sc ) { case SC_SliderGroove: - if ( slider->orientation() == Qt::Horizontal ) - ret.setRect( 0, tickOffset, slider->width(), thickness ); + if ( ceData.orientation == TQt::Horizontal ) + ret.setRect( 0, tickOffset, ceData.rect.width(), thickness ); else - ret.setRect( tickOffset, 0, thickness, slider->height() ); + ret.setRect( tickOffset, 0, thickness, ceData.rect.height() ); break; case SC_SliderHandle: { - int pos = slider->sliderStart(); + int pos = ceData.startStep; int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); - if ( slider->orientation() == Qt::Horizontal ) + if ( ceData.orientation == TQt::Horizontal ) ret.setRect( pos + 2, tickOffset + 2, len - 4, thickness - 4 ); else ret.setRect( tickOffset + 2, pos + 2, thickness - 4, len - 4 ); @@ -1697,10 +1695,9 @@ int LightStyleV3::pixelMetric( PixelMetric metric, TQStyleControlElementData ceD case PM_SliderControlThickness: { - const TQSlider * sl = (const TQSlider *) widget; - int space = (sl->orientation() == Qt::Horizontal) ? sl->height() - : sl->width(); - int ticks = sl->tickmarks(); + int space = (ceData.orientation == TQt::Horizontal) ? ceData.rect.height() + : ceData.rect.width(); + int ticks = ceData.tickMarkSetting; int n = 0; if ( ticks & TQSlider::Above ) n++; if ( ticks & TQSlider::Below ) n++; @@ -1789,7 +1786,7 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents, case CT_PopupMenuItem: { - if (! widget || data.isDefault()) + if (data.isDefault()) break; TQMenuItem *mi = data.menuItem(); @@ -1834,22 +1831,20 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents, case CT_ProgressBar: { - const TQProgressBar* pb = static_cast<const TQProgressBar*>(widget); - //If we have to display the indicator, and we do it on RHS, give some more room //for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents //sizing in TQCommonStyle. - if (pb->percentageVisible() && - (pb->indicatorFollowsStyle() || ! pb->centerIndicator())) + if (ceData.percentageVisible && + ((elementFlags & CEF_IndicatorFollowsStyle) || ! (elementFlags & CEF_CenterIndicator))) { - int addw = pb->fontMetrics().width("100%") + 6; + int addw = TQFontMetrics(ceData.font).width("100%") + 6; return TQSize(contentsSize.width() + addw, contentsSize.height()); } else return contentsSize; //Otherwise leave unchanged - + break; - } + } default: ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget); diff --git a/kstyles/plastik/plastik.cpp b/kstyles/plastik/plastik.cpp index 393780b50..2af00f723 100644 --- a/kstyles/plastik/plastik.cpp +++ b/kstyles/plastik/plastik.cpp @@ -1215,8 +1215,7 @@ void PlastikStyle::drawKStylePrimitive(KStylePrimitive kpe, // ------ switch( kpe ) { case KPE_SliderGroove: { - const TQSlider* slider = (const TQSlider*)widget; - bool horizontal = slider->orientation() == Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; if (horizontal) { int center = r.y()+r.height()/2; @@ -1233,8 +1232,7 @@ void PlastikStyle::drawKStylePrimitive(KStylePrimitive kpe, } case KPE_SliderHandle: { - const TQSlider* slider = (const TQSlider*)widget; - bool horizontal = slider->orientation() == Qt::Horizontal; + bool horizontal = ceData.orientation == TQt::Horizontal; const bool pressed = (flags&Style_Active); const WidgetState s = enabled?(pressed?IsPressed:IsEnabled):IsDisabled; @@ -2214,15 +2212,14 @@ void PlastikStyle::drawControl(TQ_ControlElement element, } case CE_ProgressBarContents: { - const TQProgressBar *pb = dynamic_cast<const TQProgressBar*>(widget); - int steps = pb->totalSteps(); + int steps = ceData.totalSteps; const TQColor bg = enabled?cg.base():cg.background(); // background const TQColor fg = enabled?cg.highlight():TQColor(cg.background().dark(110)); // foreground if( steps == 0 ) { // Busy indicator static const int barWidth = 10; - int progress = pb->progress() % (2*(r.width()-barWidth)); + int progress = ceData.currentStep % (2*(r.width()-barWidth)); if( progress < 0) progress = 0; if( progress > r.width()-barWidth ) @@ -2239,7 +2236,7 @@ void PlastikStyle::drawControl(TQ_ControlElement element, Round_UpperRight|Round_BottomRight| Round_UpperLeft|Round_BottomLeft|Is_Horizontal); } else { - double percent = static_cast<double>(pb->progress()) / static_cast<double>(steps); + double percent = static_cast<double>(ceData.currentStep) / static_cast<double>(steps); int w = static_cast<int>(r.width() * percent); // renderContour/renderSurface handle small sizes not very well, so set a minimal @@ -3196,11 +3193,11 @@ TQRect PlastikStyle::subRect(SubRect r, const TQStyleControlElementData ceData, // Don't use KStyles progressbar subrect // TODO: case SR_ProgressBarGroove: { - return TQRect(widget->rect()); + return TQRect(ceData.rect); } case SR_ProgressBarContents: case SR_ProgressBarLabel: { - TQRect rw = widget->rect(); + TQRect rw = ceData.rect; return TQRect(rw.left()+2, rw.top()+2, rw.width()-4, rw.height()-4 ); } |