diff options
author | François Andriot <francois.andriot@free.fr> | 2016-03-26 23:56:30 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2016-03-27 00:06:43 +0100 |
commit | d4a24866b531801cace227c1d09fda763cbca8ac (patch) | |
tree | 1bf3f3d9c7d137c70ecbee0e73b7838b4ee18dc6 /src | |
parent | 3ae9f9432e0df88db99fc7aaadaea3b35bda1f9a (diff) | |
download | tde-style-ia-ora-d4a24866b531801cace227c1d09fda763cbca8ac.tar.gz tde-style-ia-ora-d4a24866b531801cace227c1d09fda763cbca8ac.zip |
Update to new style API
Signed-off-by: François Andriot <francois.andriot@free.fr>
Diffstat (limited to 'src')
-rw-r--r-- | src/widget/Makefile.am | 2 | ||||
-rw-r--r-- | src/widget/ia_ora.cpp | 663 | ||||
-rw-r--r-- | src/widget/ia_ora.h | 76 |
3 files changed, 400 insertions, 341 deletions
diff --git a/src/widget/Makefile.am b/src/widget/Makefile.am index ca6c057..aa2cc82 100644 --- a/src/widget/Makefile.am +++ b/src/widget/Makefile.am @@ -21,6 +21,6 @@ BUILT_SOURCES = ia_ora.moc CLEANFILES = $(BUILT_SOURCES) ia_oradata_DATA = ia_ora.themerc -ia_oradatadir = $(kde_datadir)/kstyle/themes +ia_oradatadir = $(kde_datadir)/tdestyle/themes EXTRA_DIST = ia_ora.cpp ia_ora.h $(ia_oradata_DATA) diff --git a/src/widget/ia_ora.cpp b/src/widget/ia_ora.cpp index 3cc1b09..8ae0735 100644 --- a/src/widget/ia_ora.cpp +++ b/src/widget/ia_ora.cpp @@ -288,7 +288,7 @@ void MandrivaStyle::getShade (const TQColorGroup &cg, int shadenr, TQColor &res) res = cdata->shades[shadenr]; } -void MandrivaStyle::updateHoverControl(const TQPoint &pos) +void MandrivaStyle::updateHoverControl(const TQPoint &pos, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags) { TQRegion repaint; enum Hover oldControl = hoverControl; @@ -299,12 +299,12 @@ void MandrivaStyle::updateHoverControl(const TQPoint &pos) if (hoverWidget->inherits("TQScrollBar")) { - TQRect subline(querySubControlMetrics(CC_ScrollBar, hoverWidget, - SC_ScrollBarSubLine)), - addline(querySubControlMetrics(CC_ScrollBar, hoverWidget, - SC_ScrollBarAddLine)), - slider(querySubControlMetrics(CC_ScrollBar, hoverWidget, - SC_ScrollBarSlider)); + TQRect subline(querySubControlMetrics(CC_ScrollBar, ceData, elementFlags, + SC_ScrollBarSubLine, hoverWidget)), + addline(querySubControlMetrics(CC_ScrollBar, ceData, elementFlags, + SC_ScrollBarAddLine, hoverWidget)), + slider(querySubControlMetrics(CC_ScrollBar, ceData, elementFlags, + SC_ScrollBarSlider, hoverWidget)); if (subline.contains(pos)) hoverControl = HoverScrollBarSubLine; else if (addline.contains(pos)) @@ -329,10 +329,10 @@ void MandrivaStyle::updateHoverControl(const TQPoint &pos) if (!cb->editable()) return; - TQRect comboArrow(querySubControlMetrics(CC_ComboBox, hoverWidget, - SC_ComboBoxArrow)), - comboEditField(querySubControlMetrics(CC_ComboBox, hoverWidget, - SC_ComboBoxEditField)); + TQRect comboArrow(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, + SC_ComboBoxArrow, hoverWidget)), + comboEditField(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, hoverWidget)); if (comboArrow.contains(pos)) hoverControl = HoverComboBoxArrow; @@ -351,111 +351,124 @@ void MandrivaStyle::updateHoverControl(const TQPoint &pos) hoverWidget->repaint(repaint, false); } -void MandrivaStyle::polish(TQApplication* app) +void MandrivaStyle::applicationPolish(const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr) { - if (!qstrcmp(app->argv()[0], "kicker")) - kickerMode = true; + if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) { + TQApplication *app = reinterpret_cast<TQApplication*>(ptr); + if (!qstrcmp(app->argv()[0], "kicker")) { + kickerMode = true; + } + } } -void MandrivaStyle::polish(TQWidget* widget) +void MandrivaStyle::polish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) { - // Put in order of highest occurance to maximize hit rate - if ( widget->inherits( "TQComboBox" ) - || widget->inherits("TQScrollBar") - || widget->inherits("TQHeader") - || widget->inherits( "TQSlider" ) - || widget->inherits( "TQCheckBox" ) - || widget->inherits("TQSplitterHandle")) - { - widget->installEventFilter(this); - if (widget->inherits( "TQScrollBar" ) || widget->inherits( "TQComboBox" )) - widget->setMouseTracking( true ); - } - else if (widget->inherits("TQMenuBar") - || widget->inherits("TQPopupMenu") ) - { - widget->setBackgroundMode(TQWidget::NoBackground); - } - else if (widget->inherits("TQPushButton") ) - { - widget->installEventFilter(this); - widget->setBackgroundMode( TQWidget::PaletteBackground ); - } - else if ( widget->inherits( "TDEToolBarSeparator" ) || widget->inherits( "TQToolBarSeparator" ) ) - { - widget->setBackgroundMode( TQWidget::PaletteBackground ); - } - else if (widget->inherits("TQToolBarExtensionWidget")) - { - widget->installEventFilter(this); - } - else if ( widget->parentWidget() && - ( ( widget->inherits( "TQListBox" ) && widget->parentWidget()->inherits( "TQComboBox" ) ) - || widget->inherits( "TDECompletionBox" ) ) ) - { - TQListBox* listbox = (TQListBox*) widget; - listbox->setLineWidth( 1 ); - listbox->setBackgroundMode( NoBackground ); - widget->installEventFilter( this ); - } - else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) - { - widget->setBackgroundMode( NoBackground ); // We paint the whole background. - widget->installEventFilter(this); - } - TDEStyle::polish( widget ); + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); + + // Put in order of highest occurance to maximize hit rate + if ( widget->inherits( "TQComboBox" ) + || widget->inherits( "TQScrollBar" ) + || widget->inherits( "TQHeader" ) + || widget->inherits( "TQSlider" ) + || widget->inherits( "TQCheckBox" ) + || widget->inherits("TQSplitterHandle") ) + { + widget->installEventFilter(this); + if (widget->inherits( "TQScrollBar" ) || widget->inherits( "TQComboBox" )) + widget->setMouseTracking( true ); + } + else if (widget->inherits("TQMenuBar") + || widget->inherits("TQPopupMenu") ) + { + widget->setBackgroundMode(TQWidget::NoBackground); + } + else if (widget->inherits("TQPushButton") ) + { + widget->installEventFilter(this); + widget->setBackgroundMode( TQWidget::PaletteBackground ); + } + else if ( widget->inherits( "TDEToolBarSeparator" ) || widget->inherits( "TQToolBarSeparator" ) ) + { + widget->setBackgroundMode( TQWidget::PaletteBackground ); + } + else if (widget->inherits("TQToolBarExtensionWidget")) + { + widget->installEventFilter(this); + } + else if ( widget->parentWidget() && + ( ( widget->inherits( "TQListBox" ) && widget->parentWidget()->inherits( "TQComboBox" ) ) + || widget->inherits( "TDECompletionBox" ) ) ) + { + TQListBox* listbox = (TQListBox*) widget; + listbox->setLineWidth( 1 ); + listbox->setBackgroundMode( NoBackground ); + widget->installEventFilter( this ); + } + else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) + { + widget->setBackgroundMode( NoBackground ); // We paint the whole background. + widget->installEventFilter(this); + } + } + + TDEStyle::polish( ceData, elementFlags, ptr ); } -void MandrivaStyle::unPolish(TQWidget* widget) +void MandrivaStyle::unPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) { - TQFont f = TQApplication::font(); - TQApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes - - if ( widget->inherits( "TQComboBox" ) - || widget->inherits("TQScrollBar") - || widget->inherits("TQHeader") - || widget->inherits( "TQSlider" ) - || widget->inherits( "TQCheckBox" ) - || widget->inherits("TQSplitterHandle")) - { - widget->removeEventFilter(this); - } - else if ( widget->inherits("TQMenuBar") - || widget->inherits("TQPopupMenu")) - { - widget->setBackgroundMode(TQWidget::PaletteBackground); - } - else if ( widget->inherits("TQPushButton") ) - { - widget->removeEventFilter(this); - } - else if (widget->inherits("TQToolBarExtensionWidget")) - { - widget->removeEventFilter(this); - } - else if ( widget->parentWidget() && - ( ( widget->inherits( "TQListBox" ) && widget->parentWidget()->inherits( "TQComboBox" ) ) - || widget->inherits( "TDECompletionBox" ) ) ) - { - TQListBox* listbox = (TQListBox*) widget; - listbox->setLineWidth( 1 ); - listbox->setBackgroundMode( PaletteBackground ); - widget->removeEventFilter( this ); - widget->clearMask(); - } - //For toolbar internal separators, return to button, too (can't use tqt_cast here since don't have access to the class) - else if ( widget->inherits( "TDEToolBarSeparator" ) || widget->inherits( "TQToolBarSeparator" ) ) - { - widget->setBackgroundMode( TQWidget::PaletteBackground ); - } - else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) - { - widget->setBackgroundMode( PaletteBackground ); - widget->removeEventFilter(this); - } - - TDEStyle::unPolish( widget ); + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); + + TQFont f = TQApplication::font(); + TQApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes + + if ( widget->inherits( "TQComboBox" ) + || widget->inherits("TQScrollBar") + || widget->inherits("TQHeader") + || widget->inherits( "TQSlider" ) + || widget->inherits( "TQCheckBox" ) + || widget->inherits("TQSplitterHandle")) + { + widget->removeEventFilter(this); + } + else if ( widget->inherits("TQMenuBar") + || widget->inherits("TQPopupMenu")) + { + widget->setBackgroundMode(TQWidget::PaletteBackground); + } + else if ( widget->inherits("TQPushButton") ) + { + widget->removeEventFilter(this); + } + else if (widget->inherits("TQToolBarExtensionWidget")) + { + widget->removeEventFilter(this); + } + else if ( widget->parentWidget() && + ( ( widget->inherits( "TQListBox" ) && widget->parentWidget()->inherits( "TQComboBox" ) ) + || widget->inherits( "TDECompletionBox" ) ) ) + { + TQListBox* listbox = (TQListBox*) widget; + listbox->setLineWidth( 1 ); + listbox->setBackgroundMode( PaletteBackground ); + widget->removeEventFilter( this ); + widget->clearMask(); + } + //For toolbar internal separators, return to button, too (can't use tqt_cast here since don't have access to the class) + else if ( widget->inherits( "TDEToolBarSeparator" ) || widget->inherits( "TQToolBarSeparator" ) ) + { + widget->setBackgroundMode( TQWidget::PaletteBackground ); + } + else if ( !qstrcmp( widget->name(), kdeToolbarWidget) ) + { + widget->setBackgroundMode( PaletteBackground ); + widget->removeEventFilter(this); + } + } + + TDEStyle::unPolish( ceData, elementFlags, ptr ); } /* reimp. */ @@ -629,16 +642,17 @@ void MandrivaStyle::drawFrame( const MandrivaColorData *cdata, const TQColorGrou // This function draws primitive elements as well as their masks. void MandrivaStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt ) const { - int x, y, xw, yh; + int x, y, xw; x= r.x(); y= r.y(); xw = r.x()+r.width()-1; - yh = r.y()+r.height()-1; bool down = flags & Style_Down; bool on = flags & Style_On; const MandrivaColorData *cdata = lookupData(cg); @@ -685,7 +699,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, int y = r.y(); int x2 = r.x() + r.width() - 1; int y2 = r.y() + r.height() - 1; - int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth) + int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags) : opt.lineWidth(); //FIXME @@ -765,7 +779,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, case PE_PanelPopup: case PE_WindowFrame: { - int lw = /*opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth) + int lw = /*opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags) : opt.lineWidth()*/1; if (lw == 1 || lw == 2) { @@ -798,7 +812,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, p->setPen(oldPen); } else - TDEStyle::drawPrimitive(pe, p, r, cg, flags, opt); + TDEStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); break; } case PE_GroupBoxFrame: @@ -810,7 +824,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, } #if 0 case PE_PanelGroupBox: - drawPrimitive( PE_GroupBoxFrame, p, r, cg, flags, opt ); + drawPrimitive( PE_GroupBoxFrame, p, ceData, elementFlags, r, cg, flags, opt ); break; #endif case PE_Separator: @@ -821,9 +835,9 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, case PE_HeaderArrow: { if ( flags & Style_Up ) - drawPrimitive( PE_ArrowUp, p, r, cg, Style_Enabled ); + drawPrimitive( PE_ArrowUp, p, ceData, elementFlags, r, cg, Style_Enabled ); else - drawPrimitive( PE_ArrowDown, p, r, cg, Style_Enabled ); + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, r, cg, Style_Enabled ); break; } case PE_HeaderSection: @@ -903,7 +917,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, if(!item) return; int x = r.x(), y = r.y(), w = r.width(), h = r.width(); - drawPrimitive(PE_Indicator, p, TQRect(x-2, y-2 , w+3, h+3 ) , cg, flags ); + drawPrimitive(PE_Indicator, p, ceData, elementFlags, TQRect(x-2, y-2 , w+3, h+3 ) , cg, flags ); break; } //case PE_IndicatorMask: @@ -1283,7 +1297,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, } // draw the arrow - drawPrimitive( arrow, p, r, cg, flags ); + drawPrimitive( arrow, p, ceData, elementFlags, r, cg, flags ); break; } @@ -1371,7 +1385,7 @@ void MandrivaStyle::drawPrimitive( PrimitiveElement pe, drawMandrivaArrow( a, p, r, cg, flags, opt ); } else - TDEStyle::drawPrimitive( pe, p, r, cg, flags, opt ); + TDEStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); } } //switch } @@ -1391,11 +1405,13 @@ void MandrivaStyle::drawMandrivaArrow( TQPointArray a, TQPainter *p, void MandrivaStyle::drawTDEStylePrimitive( TDEStylePrimitive pe, TQPainter* p, - const TQWidget* widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - const TQStyleOption &opt ) const + const TQStyleOption &opt, + const TQWidget* widget) const { const MandrivaColorData *cdata = lookupData(cg); switch(pe) @@ -1589,31 +1605,33 @@ void MandrivaStyle::drawTDEStylePrimitive( TDEStylePrimitive pe, break; } default: - TDEStyle::drawTDEStylePrimitive( pe, p, widget, r, cg, flags, opt); + TDEStyle::drawTDEStylePrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt, widget); } } void MandrivaStyle::drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { const MandrivaColorData *cdata = lookupData(cg); switch (element) { case CE_CheckBox: { - drawPrimitive (PE_Indicator, p, r, cg, flags); + drawPrimitive (PE_Indicator, p, ceData, elementFlags, r, cg, flags); break; } //progressbar case CE_ProgressBarContents: { const TQProgressBar* pb = (const TQProgressBar*)widget; - TQRect backend = subRect(SR_ProgressBarContents, widget); + TQRect backend = subRect(SR_ProgressBarContents, ceData, elementFlags, widget); double progress = pb->progress(); bool reverse = TQApplication::reverseLayout(); int steps = pb->totalSteps(); @@ -1625,7 +1643,7 @@ void MandrivaStyle::drawControl( ControlElement element, p->fillRect(backend , cg.background() ); //draw border - drawPrimitive( PE_PanelLineEdit, p, r, cg ); + drawPrimitive( PE_PanelLineEdit, p, ceData, elementFlags, r, cg ); TQRect cr(backend); cr.addCoords( 1, 1, -2, -2 ); @@ -1749,7 +1767,7 @@ void MandrivaStyle::drawControl( ControlElement element, case CE_ProgressBarLabel: { const TQProgressBar * pb = (const TQProgressBar *) widget; - const int unit_width = pixelMetric( PM_ProgressBarChunkWidth, pb ); + const int unit_width = pixelMetric( PM_ProgressBarChunkWidth, ceData, elementFlags, pb ); int u = r.width() / unit_width; int p_v = pb->progress(); int t_s = pb->totalSteps(); @@ -1795,7 +1813,7 @@ void MandrivaStyle::drawControl( ControlElement element, } case CE_ToolButtonLabel: { - TDEStyle::drawControl(element, p, widget, r, cg, flags, opt); + TDEStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); break; } @@ -1908,9 +1926,7 @@ void MandrivaStyle::drawControl( ControlElement element, //CHECK case CE_MenuBarItem: { - TQMenuBar *mb = (TQMenuBar*)widget; TQMenuItem *mi = opt.menuItem(); - TQRect pr = mb->rect(); bool active = flags & Style_Active; bool focused = flags & Style_HasFocus; @@ -1969,7 +1985,7 @@ void MandrivaStyle::drawControl( ControlElement element, bool enabled = mi->isEnabled(); bool checkable = popupmenu->isCheckable(); bool active = flags & Style_Active; - bool etchtext = styleHint( SH_EtchDisabledText ); + bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags ); bool reverse = TQApplication::reverseLayout(); int x, y, w, h; r.rect( &x, &y, &w, &h ); @@ -2044,7 +2060,7 @@ void MandrivaStyle::drawControl( ControlElement element, // Draw the checkmark SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; - drawPrimitive( PE_CheckMark, p, TQRect( cx + itemFrame, y + itemFrame, + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( cx + itemFrame, y + itemFrame, checkcol - itemFrame*2, h - itemFrame*2), cg, cflags ); } else @@ -2070,7 +2086,7 @@ void MandrivaStyle::drawControl( ControlElement element, // Draw the checkmark SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; - drawPrimitive( PE_CheckMark, p, TQRect( cx + itemFrame, y + itemFrame, + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( cx + itemFrame, y + itemFrame, checkcol - itemFrame*2, h - itemFrame*2), cg, cflags ); } @@ -2186,7 +2202,7 @@ void MandrivaStyle::drawControl( ControlElement element, if ( mi->popup() ) { PrimitiveElement arrow = reverse ? PE_ArrowLeft : PE_ArrowRight; - int dim = pixelMetric(PM_MenuButtonIndicator)- itemFrame; + int dim = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags)- itemFrame; TQRect vr = visualRect( TQRect( x + w - arrowHMargin - itemFrame - dim, y + h / 2 - dim / 2, dim, dim), r ); @@ -2199,10 +2215,10 @@ void MandrivaStyle::drawControl( ControlElement element, TQColorGroup g2( cg.highlightedText ()/*white*/, cg.highlight(), /*white*/cg.highlightedText (), /*white*/cg.highlightedText (), enabled ? cg.highlightedText () : discol, /*discol*/cg.highlightedText (), cg.highlightedText () ); - drawPrimitive( arrow, p, vr, g2, Style_Enabled ); + drawPrimitive( arrow, p, ceData, elementFlags, vr, g2, Style_Enabled ); } else - drawPrimitive( arrow, p, vr, cg, + drawPrimitive( arrow, p, ceData, elementFlags, vr, cg, enabled ? Style_Enabled : Style_Default ); } break; @@ -2217,16 +2233,16 @@ void MandrivaStyle::drawControl( ControlElement element, // Shift button contents if pushed. if ( active ) { - x += pixelMetric(PM_ButtonShiftHorizontal, widget); - y += pixelMetric(PM_ButtonShiftVertical, widget); + x += pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget); + y += pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget); flags |= Style_Sunken; } // Does the button have a popup menu? if ( button->isMenuButton() ) { - int dx = pixelMetric( PM_MenuButtonIndicator, widget ); - drawPrimitive( PE_ArrowDown, p, TQRect(x + w - dx - 2, y + 2, dx, h - 4), + 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 ); w -= dx; } @@ -2290,8 +2306,8 @@ void MandrivaStyle::drawControl( ControlElement element, } // Draw a focus rect if the button has focus if ( flags & Style_HasFocus ) - drawPrimitive( PE_FocusRect, p, - TQStyle::visualRect(subRect(SR_PushButtonFocusRect, widget), widget), + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, + TQStyle::visualRect(subRect(SR_PushButtonFocusRect, ceData, elementFlags, widget), widget), cg, flags ); break; } @@ -2303,19 +2319,21 @@ void MandrivaStyle::drawControl( ControlElement element, if (isFormWidget(btn)) formMode = true; - drawPrimitive( btn->isDefault( ) ? PE_ButtonDefault : PE_ButtonCommand, p, r, cg, flags ); + drawPrimitive( btn->isDefault( ) ? PE_ButtonDefault : PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags ); } break; default: - TDEStyle::drawControl(element, p, widget, r, cg, flags, opt); + TDEStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); } } void MandrivaStyle::drawControlMask( ControlElement element, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch (element) { @@ -2326,16 +2344,18 @@ void MandrivaStyle::drawControlMask( ControlElement element, break; } default: - TDEStyle::drawControlMask(element, p, widget, r, opt); + TDEStyle::drawControlMask(element, p, ceData, elementFlags, r, opt, widget); } } void MandrivaStyle::drawComboboxArrow( TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &ar, const TQColorGroup &cg, SFlags flags, - SCFlags active)const + SCFlags active, + const TQWidget *widget)const { const TQComboBox * cb = (const TQComboBox *) widget; bool editableCombo = cb->editable(); @@ -2357,8 +2377,8 @@ void MandrivaStyle::drawComboboxArrow( TQPainter *p, a.setPoints(TQCOORDARRLEN(c_arrow), c_arrow); if ( flags & Style_Down ) - p->translate( pixelMetric( PM_ButtonShiftHorizontal ), - pixelMetric( PM_ButtonShiftVertical ) ); + p->translate( pixelMetric( PM_ButtonShiftHorizontal, ceData, elementFlags ), + pixelMetric( PM_ButtonShiftVertical, ceData, elementFlags ) ); if ( flags & Style_Enabled ) { @@ -2397,13 +2417,15 @@ void MandrivaStyle::drawComboboxArrow( TQPainter *p, void MandrivaStyle::drawComplexControl( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, SCFlags controls, SCFlags active, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { const MandrivaColorData *cdata = lookupData(cg); switch(control) @@ -2411,7 +2433,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, case CC_SpinWidget: { const TQSpinWidget* sw = static_cast< const TQSpinWidget* >( widget ); - TQRect br = visualRect( querySubControlMetrics( CC_SpinWidget, widget, SC_SpinWidgetButtonField ), widget ); + TQRect br = visualRect( querySubControlMetrics( CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetButtonField, opt, widget ), widget ); //FIXME p->fillRect( r, widget->isEnabled() ? cg.base() : cg.background() ); @@ -2420,17 +2442,17 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, if ( controls & SC_SpinWidgetUp) { TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled(); - drawPrimitive( PE_SpinWidgetUp,p, TQRect(br.x()+1 , br.y()+1 , br.width()-2 , br.height() / 2 ), ucg, flags, opt); + drawPrimitive( PE_SpinWidgetUp,p, ceData, elementFlags, TQRect(br.x()+1, br.y()+1 , br.width()-2 , br.height() / 2 ), ucg, flags, opt); } if ( controls & SC_SpinWidgetDown) { TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled(); - drawPrimitive( PE_SpinWidgetDown,p, TQRect( br.x()+1 , br.y() + br.height() / 2 , br.width()-2, br.height()/ 2 -1 ), dcg, flags, opt); + drawPrimitive( PE_SpinWidgetDown,p, ceData, elementFlags, TQRect( br.x()+1 , br.y() + br.height() / 2 , br.width()-2, br.height()/ 2 -1 ), dcg, flags, opt); } } if ( controls & SC_SpinWidgetFrame ) - drawPrimitive( PE_PanelLineEdit, p, r, cg ); + drawPrimitive( PE_PanelLineEdit, p, ceData, elementFlags, r, cg ); break; } @@ -2439,8 +2461,8 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, const TQToolButton *tb = (const TQToolButton *) widget; TQRect button, menuarea; - button = querySubControlMetrics(control, widget, SC_ToolButton, opt); - menuarea = querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt); + button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget); + menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget); SFlags bflags = flags, mflags = flags; @@ -2460,7 +2482,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, // If we're pressed, on, or raised... if (bflags & (Style_Down | Style_On | Style_Raised) || widget==hoverWidget ) { - drawPrimitive(PE_ButtonTool, p, button, cg, bflags, opt); + drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); } else if (tb->parentWidget() && tb->parentWidget()->backgroundPixmap() && @@ -2475,16 +2497,16 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, if (controls & SC_ToolButtonMenu) { if (mflags & (Style_Down | Style_On | Style_Raised)) - drawPrimitive(PE_ButtonDropDown, p, menuarea, cg, mflags, opt); + drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); - drawPrimitive(PE_ArrowDown, p, menuarea, cg, mflags, opt); + drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); } if (tb->hasFocus() && !tb->focusProxy()) { TQRect fr = tb->rect(); fr.addCoords(2, 2, -2, -2); - drawPrimitive(PE_FocusRect, p, fr, cg); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg); } // Set the color for the ToolButton menu indicator @@ -2500,14 +2522,14 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); scrollmin = ( scrollbar->minValue() == scrollbar->value() ); scrollmax = (( scrollbar->maxValue() == scrollbar->value() )|| maxedOut); - subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt); - addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt); - subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt); - addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt); - slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt); + subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, opt, widget); + addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, opt, widget); + subpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget); + addpage = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget); + slider = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSlider, opt, widget); - first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt); - last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt); + first = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarFirst, opt, widget); + last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, opt, widget); if ((controls & SC_ScrollBarSubLine) && subline.isValid()) { @@ -2518,7 +2540,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, flags |= Style_Horizontal; if (hoverWidget == widget && hoverControl == HoverScrollBarSubLine) flags |= Style_MouseOver; - drawPrimitive(PE_ScrollBarSubLine, p, subline, cg, flags); + drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, flags); } if ((controls & SC_ScrollBarAddLine) && addline.isValid()) { @@ -2529,29 +2551,29 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, flags |= Style_Horizontal; if (hoverWidget == widget && hoverControl == HoverScrollBarAddLine) flags |= Style_MouseOver; - drawPrimitive(PE_ScrollBarAddLine, p, addline, cg, flags); + drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg, flags); } if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) - drawPrimitive(PE_ScrollBarSubPage, p, subpage, cg, + drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg, Style_Enabled | ((active == SC_ScrollBarSubPage) ? Style_Down : Style_Default) | ((scrollbar->orientation() == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) - drawPrimitive(PE_ScrollBarAddPage, p, addpage, cg, + drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg, ((maxedOut) ? Style_Default : Style_Enabled) | ((active == SC_ScrollBarAddPage) ? Style_Down : Style_Default) | ((scrollbar->orientation() == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarFirst) && first.isValid()) - drawPrimitive(PE_ScrollBarFirst, p, first, cg, + drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, Style_Enabled | ((active == SC_ScrollBarFirst) ? Style_Down : Style_Default) | ((scrollbar->orientation() == TQt::Horizontal) ? Style_Horizontal : 0)); if ((controls & SC_ScrollBarLast) && last.isValid()) - drawPrimitive(PE_ScrollBarLast, p, last, cg, + drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, Style_Enabled | ((active == SC_ScrollBarLast) ? Style_Down : Style_Default) | ((scrollbar->orientation() == TQt::Horizontal) ? @@ -2565,14 +2587,14 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, flags |= Style_Horizontal; if (hoverWidget == widget && hoverControl == HoverScrollBarSlider) flags |= Style_MouseOver; - drawPrimitive(PE_ScrollBarSlider, p, slider, cg, flags); + drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, flags); // ### perhaps this should not be able to accept focus if maxedOut? if (scrollbar->hasFocus()) { TQRect fr(slider.x() + 2, slider.y() + 2, slider.width() - 5, slider.height() - 5); - drawPrimitive(PE_FocusRect, p, fr, cg, Style_Default); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default); } } break; @@ -2601,9 +2623,9 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, if( (controls & SC_ComboBoxEditField )) { - TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, widget, SC_ComboBoxEditField), widget ); + TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, opt, widget), widget ); - drawPrimitive( PE_PanelLineEdit, p, ar, cg ); + drawPrimitive( PE_PanelLineEdit, p, ceData, elementFlags, ar, cg ); } //if ( controls & SC_ComboBoxListBoxPopup ) //{ @@ -2611,7 +2633,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, //} if( (controls & SC_ComboBoxArrow )) { - TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, widget, SC_ComboBoxArrow), widget ); + TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, opt, widget), widget ); bool mouseOver = (flags & Style_MouseOver) && (hoverControl == HoverComboBoxArrow); if ( sunken ) renderGradient(p, TQRect(ar.x()+1, ar.y()+1, ar.width()-1, ar.height()-2), cdata->shades[2], cdata->shades[0], false); @@ -2649,7 +2671,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, else p->drawLine( ar.x(), ar.y()+1, ar.x(), ar.height()-2 ); - drawComboboxArrow( p,widget,ar,cg,flags,active); + drawComboboxArrow( p,ceData,elementFlags,ar,cg,flags,active,widget); } } else @@ -2657,7 +2679,7 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, TQPen oldPen = p->pen(); // Get the button bounding box - TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, widget, SC_ComboBoxArrow), widget ); + TQRect ar = TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, opt, widget), widget ); drawButton( cdata,r,p,cg,flags | (sunken ? Style_Down : Style_Default)); //test reverse ! @@ -2676,22 +2698,24 @@ void MandrivaStyle::drawComplexControl( ComplexControl control, p->drawLine( ar.x()-2,ar.y()+5,ar.x()-2,ar.height()-6); } - drawComboboxArrow( p,widget,ar,cg,flags,active); + drawComboboxArrow( p,ceData,elementFlags,ar,cg,flags,active,widget); p->setPen( oldPen );// restore pen } break; } default: - TDEStyle::drawComplexControl(control, p, widget, - r, cg, flags, controls, active, opt); + TDEStyle::drawComplexControl(control, p, ceData, elementFlags, + r, cg, flags, controls, active, opt, widget); } } TQRect MandrivaStyle::querySubControlMetrics( ComplexControl control, - const TQWidget* widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, SubControl subcontrol, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget* widget ) const { switch (control) { @@ -2702,7 +2726,7 @@ TQRect MandrivaStyle::querySubControlMetrics( ComplexControl control, case SC_SpinWidgetButtonField: return TQRect( widget->width() -14 , 0, 14, widget->height() ); default: - return TDEStyle::querySubControlMetrics( control, widget, subcontrol, opt ); + return TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ); } } //TODO verify it. @@ -2729,7 +2753,7 @@ TQRect MandrivaStyle::querySubControlMetrics( ComplexControl control, return TQRect( 5, 1, widget->width() - arrow-12, widget->height() - 2); } default: - return TDEStyle::querySubControlMetrics( control, widget, subcontrol, opt ); + return TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ); } break; } @@ -2739,8 +2763,8 @@ TQRect MandrivaStyle::querySubControlMetrics( ComplexControl control, bool horizontal = sl->orientation() == Horizontal; TQSlider::TickSetting ticks = sl->tickmarks(); int pos = sl->sliderStart(); - int handleSize = pixelMetric( PM_SliderThickness, widget ); - int len = pixelMetric( PM_SliderLength, widget ); + int handleSize = pixelMetric( PM_SliderThickness, ceData, elementFlags, widget ); + int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); switch ( subcontrol ) { case SC_SliderHandle: @@ -2768,14 +2792,16 @@ TQRect MandrivaStyle::querySubControlMetrics( ComplexControl control, default: break; } - return TDEStyle::querySubControlMetrics( control, widget, subcontrol, opt ); + return TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ); } void MandrivaStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { //TODO verify //#if 0 @@ -2796,14 +2822,14 @@ void MandrivaStyle::drawComplexControlMask( ComplexControl control, } default: - TDEStyle::drawComplexControlMask(control, p, widget, r, opt); + TDEStyle::drawComplexControlMask(control, p, ceData, elementFlags, r, opt, widget); } //#endif - //TDEStyle::drawComplexControlMask(control, p, widget, r, opt); + //TDEStyle::drawComplexControlMask(control, p, ceData, elementFlags, r, opt, widget); } -int MandrivaStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const +int MandrivaStyle::pixelMetric(PixelMetric m, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget) const { switch(m) { @@ -2841,15 +2867,17 @@ int MandrivaStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const case PM_TabBarTabShiftVertical: return 0; default: - return TDEStyle::pixelMetric(m, widget); + return TDEStyle::pixelMetric(m, ceData, elementFlags, widget); } } TQSize MandrivaStyle::sizeFromContents( ContentsType contents, - const TQWidget* widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQSize &contentSize, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget* widget ) const { switch (contents) { @@ -2876,7 +2904,7 @@ TQSize MandrivaStyle::sizeFromContents( ContentsType contents, } else { - return TDEStyle::sizeFromContents( contents, widget, contentSize, opt ); + return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget ); } } case CT_ComboBox: @@ -2898,8 +2926,8 @@ TQSize MandrivaStyle::sizeFromContents( ContentsType contents, const TQPushButton* button = (const TQPushButton*) widget; int w = contentSize.width(); int h = contentSize.height(); - int bm = pixelMetric( PM_ButtonMargin, widget ); - int fw = pixelMetric( PM_DefaultFrameWidth, widget ) * 2; + int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ) * 2; w += bm + fw + 6; // ### Add 6 to make way for bold font. h += bm + fw; @@ -2981,122 +3009,129 @@ TQSize MandrivaStyle::sizeFromContents( ContentsType contents, } default: - return TDEStyle::sizeFromContents( contents, widget, contentSize, opt ); + return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget ); } } //Why ? why create virtual function ? // Fix TQt's wacky image alignment TQPixmap MandrivaStyle::stylePixmap(StylePixmap stylepixmap, - const TQWidget* widget, - const TQStyleOption& opt) const + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQStyleOption& opt, + const TQWidget* widget) const { - return TDEStyle::stylePixmap(stylepixmap, widget, opt); + return TDEStyle::stylePixmap(stylepixmap, ceData, elementFlags, opt, widget); } -bool MandrivaStyle::eventFilter( TQObject *object, TQEvent *event ) +bool MandrivaStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *ev ) { - if (TDEStyle::eventFilter( object, event )) - return true; - TQToolBar* toolbar; - //Hover highlight on buttons and combos - if ( object->inherits("TQPushButton") - || object->inherits("TQComboBox") - || object->inherits("TQScrollBar") - || object->inherits("TQHeader") - || object->inherits("TQSlider") - || object->inherits("TQCheckBox") - || object->inherits("TQSplitterHandle")) - { - if ( (event->type() == TQEvent::Enter) && static_cast<TQWidget*>(object)->isEnabled()) - { - TQWidget* button = static_cast<TQWidget*>(object); - hoverWidget = button; - button->repaint( false ); - } - else if ( (event->type() == TQEvent::Leave) && (object == hoverWidget) ) - { - TQWidget* button = static_cast<TQWidget*>(object); - hoverWidget = 0; - hoverControl = HoverNone; - button->repaint( false ); - } - if ((object->inherits("TQScrollBar") || object->inherits("TQComboBox")) - && event->type() == TQEvent::MouseMove) - { - TQWidget *button = static_cast<TQWidget*>(object); - TQMouseEvent *e = static_cast<TQMouseEvent*>(event); - // updateHoverControl will trigger a repainting if necessary - updateHoverControl(e->pos()); - } - - } - else if (object->inherits("TQListBox")) - { - if ( event->type() == TQEvent::Show || event->type() == TQEvent::Hide) - { - TQWidget *w = static_cast<TQWidget*>(object); - if (w->parentWidget() && w->parentWidget()->inherits("TQComboBox")) - w->parentWidget()->repaint(false); - } - } - else if ( object->parent() && !qstrcmp( object->name(), kdeToolbarWidget ) ) - { - // Draw a gradient background for custom widgets in the toolbar - // that have specified a "tde toolbar widget" name. - - if (event->type() == TQEvent::Paint ) - { - // Find the top-level toolbar of this widget, since it may be nested in other - // widgets that are on the toolbar. - TQWidget *widget = static_cast<TQWidget*>(object); - TQWidget *parent = static_cast<TQWidget*>(object->parent()); - int x_offset = widget->x(), y_offset = widget->y(); - while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) - { - x_offset += parent->x(); - y_offset += parent->y(); - parent = static_cast<TQWidget*>(parent->parent()); - } - - TQRect r = widget->rect(); - TQRect pr = parent->rect(); - bool horiz_grad = pr.width() < pr.height(); - - // Check if the parent is a TQToolbar, and use its orientation, else guess. - TQToolBar* tb = dynamic_cast<TQToolBar*>(parent); - if (tb) horiz_grad = tb->orientation() == TQt::Vertical; - - TQPainter p( widget ); - renderGradient(&p, r, parent->colorGroup().background(),parent->colorGroup().background(), horiz_grad);/*, - x_offset, y_offset, pr.width(), pr.height());*/ - //FIXME: check this code later - return false; // Now draw the contents - } - } - else if ( object->parent() && - (toolbar = dynamic_cast<TQToolBar*>(object->parent())) ) - { - - // We need to override the paint event to draw a - // gradient on a TQToolBarExtensionWidget. - if ( event->type() == TQEvent::Paint ) - { - TQWidget *widget = static_cast<TQWidget*>(object); - TQRect wr = widget->rect(), tr = toolbar->rect(); - TQPainter p( widget ); - renderGradient(&p, wr, toolbar->colorGroup().background(),toolbar->colorGroup().background(), - toolbar->orientation() == TQt::Vertical);/*, - wr.x(), wr.y(), tr.width() - 2, tr.height() - 2);*/ - //FIXME: check this code later - p.setPen( toolbar->colorGroup().dark() ); - if ( toolbar->orientation() == TQt::Horizontal ) - p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 ); - else - p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 ); - return true; - } - } + if (TDEStyle::objectEventHandler(ceData, elementFlags, source, ev)) { + return true; + } + + if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) { + TQObject* obj = reinterpret_cast<TQObject*>(source); + + TQToolBar* toolbar; + //Hover highlight on buttons and combos + if ( obj->inherits("TQPushButton") + || obj->inherits("TQComboBox") + || obj->inherits("TQScrollBar") + || obj->inherits("TQHeader") + || obj->inherits("TQSlider") + || obj->inherits("TQCheckBox") + || obj->inherits("TQSplitterHandle")) + { + if ( (ev->type() == TQEvent::Enter) && static_cast<TQWidget*>(obj)->isEnabled()) + { + TQWidget* button = static_cast<TQWidget*>(obj); + hoverWidget = button; + button->repaint( false ); + } + else if ( (ev->type() == TQEvent::Leave) && (obj == hoverWidget) ) + { + TQWidget* button = static_cast<TQWidget*>(obj); + hoverWidget = 0; + hoverControl = HoverNone; + button->repaint( false ); + } + if ((obj->inherits("TQScrollBar") || obj->inherits("TQComboBox")) + && ev->type() == TQEvent::MouseMove) + { + TQMouseEvent *e = static_cast<TQMouseEvent*>(ev); + // updateHoverControl will trigger a repainting if necessary + updateHoverControl(e->pos(), ceData, elementFlags); + } + + } + else if (obj->inherits("TQListBox")) + { + if ( ev->type() == TQEvent::Show || ev->type() == TQEvent::Hide) + { + TQWidget *w = static_cast<TQWidget*>(obj); + if (w->parentWidget() && w->parentWidget()->inherits("TQComboBox")) + w->parentWidget()->repaint(false); + } + } + else if ( obj->parent() && !qstrcmp( obj->name(), kdeToolbarWidget ) ) + { + // Draw a gradient background for custom widgets in the toolbar + // that have specified a "tde toolbar widget" name. + + if (ev->type() == TQEvent::Paint ) + { + // Find the top-level toolbar of this widget, since it may be nested in other + // widgets that are on the toolbar. + TQWidget *widget = static_cast<TQWidget*>(obj); + TQWidget *parent = static_cast<TQWidget*>(obj->parent()); + int x_offset = widget->x(), y_offset = widget->y(); + while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) + { + x_offset += parent->x(); + y_offset += parent->y(); + parent = static_cast<TQWidget*>(parent->parent()); + } + + TQRect r = widget->rect(); + TQRect pr = parent->rect(); + bool horiz_grad = pr.width() < pr.height(); + + // Check if the parent is a TQToolbar, and use its orientation, else guess. + TQToolBar* tb = dynamic_cast<TQToolBar*>(parent); + if (tb) horiz_grad = tb->orientation() == TQt::Vertical; + + TQPainter p( widget ); + renderGradient(&p, r, parent->colorGroup().background(),parent->colorGroup().background(), horiz_grad);/*, + x_offset, y_offset, pr.width(), pr.height());*/ + //FIXME: check this code later + return false; // Now draw the contents + } + } + else if ( obj->parent() && + (toolbar = dynamic_cast<TQToolBar*>(obj->parent())) ) + { + + // We need to override the paint event to draw a + // gradient on a TQToolBarExtensionWidget. + if ( ev->type() == TQEvent::Paint ) + { + TQWidget *widget = static_cast<TQWidget*>(obj); + TQRect wr = widget->rect(); + TQPainter p( widget ); + renderGradient(&p, wr, toolbar->colorGroup().background(),toolbar->colorGroup().background(), + toolbar->orientation() == TQt::Vertical);/*, + wr.x(), wr.y(), tr.width() - 2, tr.height() - 2);*/ + //FIXME: check this code later + p.setPen( toolbar->colorGroup().dark() ); + if ( toolbar->orientation() == TQt::Horizontal ) + p.drawLine( wr.width()-1, 0, wr.width()-1, wr.height()-1 ); + else + p.drawLine( 0, wr.height()-1, wr.width()-1, wr.height()-1 ); + return true; + } + } + } return false; } @@ -3331,7 +3366,7 @@ void MandrivaStyle::drawButton( const MandrivaColorData *cdata, const TQRect & r } -TQRect MandrivaStyle::subRect(SubRect r, const TQWidget *widget) const +TQRect MandrivaStyle::subRect(SubRect r, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const { switch ( r ) { @@ -3353,10 +3388,10 @@ TQRect MandrivaStyle::subRect(SubRect r, const TQWidget *widget) const } case SR_ComboBoxFocusRect: { - return querySubControlMetrics( CC_ComboBox, widget, SC_ComboBoxEditField ); + return querySubControlMetrics( CC_ComboBox, ceData, elementFlags , SC_ComboBoxEditField, TQStyleOption::Default, widget ); } default: - return TDEStyle::subRect( r, widget ); + return TDEStyle::subRect( r, ceData, elementFlags, widget ); } } diff --git a/src/widget/ia_ora.h b/src/widget/ia_ora.h index aaac040..68b05fb 100644 --- a/src/widget/ia_ora.h +++ b/src/widget/ia_ora.h @@ -51,22 +51,26 @@ public: MandrivaStyle(); virtual ~MandrivaStyle(); - void polish( TQWidget* widget ); - void unPolish( TQWidget* widget ); - void polish( TQApplication *app ); + void polish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); + void unPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); + void applicationPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup &cg, const TQPopupMenu* popup ) const; void drawTDEStylePrimitive( TDEStylePrimitive kpe, TQPainter* p, - const TQWidget* widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget* widget = 0 ) const; void drawPrimitive( PrimitiveElement pe, TQPainter* p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, @@ -74,54 +78,72 @@ public: void drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; void drawControlMask( ControlElement element, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; void drawComplexControl( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, SCFlags controls = SC_All, SCFlags active = SC_None, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default , + const TQWidget *widget = 0 ) const; void drawComplexControlMask( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; int pixelMetric( PixelMetric m, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; TQSize sizeFromContents( ContentsType contents, - const TQWidget *widget, - const TQSize &contentSize, - const TQStyleOption& opt ) const; + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentSize, + const TQStyleOption& opt, + const TQWidget *widget = 0 ) const; TQRect subRect( SubRect r, - const TQWidget *widget ) const; + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQWidget *widget ) const; // Fix TQt3's wacky image positions TQPixmap stylePixmap( StylePixmap stylepixmap, - const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; TQRect querySubControlMetrics( ComplexControl control, - const TQWidget* widget, - SubControl subcontrol, - const TQStyleOption& opt = TQStyleOption::Default ) const; + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl subcontrol, + const TQStyleOption& opt = TQStyleOption::Default, + const TQWidget* widget = 0 ) const; protected: enum Hover @@ -141,7 +163,7 @@ protected: }; - bool eventFilter( TQObject *object, TQEvent *event ); + virtual bool objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); void renderGradient(TQPainter* p, const TQRect& r, @@ -225,11 +247,13 @@ private: bool active) const; void drawComboboxArrow( TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - SCFlags active)const; + SCFlags active, + const TQWidget *widget)const; void drawMandrivaArrow( TQPointArray a, TQPainter *p, const TQRect &r, @@ -243,7 +267,7 @@ private: bool isFormWidget(const TQWidget* widget) const; bool excludeColor(const TQColor &col, bool active) const; void getShade (const TQColorGroup &cg, int shadenr, TQColor &res) const; - void updateHoverControl(const TQPoint &pos); + void updateHoverControl(const TQPoint &pos, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags); TQIntCache<MandrivaColorData> m_dataCache; static const double shading[8]; mutable bool formMode; |