diff options
Diffstat (limited to 'examples/themes/metal.cpp')
-rw-r--r-- | examples/themes/metal.cpp | 215 |
1 files changed, 95 insertions, 120 deletions
diff --git a/examples/themes/metal.cpp b/examples/themes/metal.cpp index a84547518..8d6bdf593 100644 --- a/examples/themes/metal.cpp +++ b/examples/themes/metal.cpp @@ -41,121 +41,104 @@ MetalStyle::MetalStyle() : TQWindowsStyle() { } /*! Reimplementation from TQStyle */ -void MetalStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) +void MetalStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQApplication")) { - TQApplication *app = reinterpret_cast<TQApplication*>(ptr); - - oldPalette = app->palette(); - - // we simply create a nice TQColorGroup with a couple of fancy - // pixmaps here and apply to it all widgets - - TQFont f("times", app->font().pointSize() ); - f.setBold( TRUE ); - f.setItalic( TRUE ); - app->setFont( f, TRUE, "TQMenuBar"); - app->setFont( f, TRUE, "TQPopupMenu"); - - - - // TQPixmap button( stonedark_xpm ); - - TQColor gold("#B9B9A5A54040"); //same as topgrad below - TQPixmap button( 1, 1 ); button.fill( gold ); - - TQPixmap background(marble_xpm); - TQPixmap dark( 1, 1 ); dark.fill( red.dark() ); - TQPixmap mid( stone1_xpm ); - TQPixmap light( stone1_xpm );//1, 1 ); light.fill( green ); - - TQPalette op = app->palette(); - - TQColor backCol( 227,227,227 ); - - // TQPalette op(white); - TQColorGroup active (op.active().foreground(), - TQBrush(op.active().button(),button), - TQBrush(op.active().light(), light), - TQBrush(op.active().dark(), dark), - TQBrush(op.active().mid(), mid), - op.active().text(), - TQt::white, - op.active().base(),// TQColor(236,182,120), - TQBrush(backCol, background) - ); - active.setColor( TQColorGroup::ButtonText, TQt::white ); - active.setColor( TQColorGroup::Shadow, TQt::black ); - TQColorGroup disabled (op.disabled().foreground(), - TQBrush(op.disabled().button(),button), - TQBrush(op.disabled().light(), light), - op.disabled().dark(), - TQBrush(op.disabled().mid(), mid), - op.disabled().text(), - TQt::white, - op.disabled().base(),// TQColor(236,182,120), - TQBrush(backCol, background) - ); - - TQPalette newPalette( active, disabled, active ); - app->setPalette( newPalette, TRUE ); - } + oldPalette = ceData.palette; + + // we simply create a nice TQColorGroup with a couple of fancy + // pixmaps here and apply to it all widgets + + TQFont f("times", ceData.font.pointSize() ); + f.setBold( TRUE ); + f.setItalic( TRUE ); + applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, TQStyleApplicationActionRequestData(f, TRUE, "TQMenuBar")); + applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, TQStyleApplicationActionRequestData(f, TRUE, "TQPopupMenu")); + + // TQPixmap button( stonedark_xpm ); + + TQColor gold("#B9B9A5A54040"); //same as topgrad below + TQPixmap button( 1, 1 ); button.fill( gold ); + + TQPixmap background(marble_xpm); + TQPixmap dark( 1, 1 ); dark.fill( red.dark() ); + TQPixmap mid( stone1_xpm ); + TQPixmap light( stone1_xpm );//1, 1 ); light.fill( green ); + + TQPalette op = ceData.palette; + + TQColor backCol( 227,227,227 ); + + // TQPalette op(white); + TQColorGroup active (op.active().foreground(), + TQBrush(op.active().button(),button), + TQBrush(op.active().light(), light), + TQBrush(op.active().dark(), dark), + TQBrush(op.active().mid(), mid), + op.active().text(), + TQt::white, + op.active().base(),// TQColor(236,182,120), + TQBrush(backCol, background) + ); + active.setColor( TQColorGroup::ButtonText, TQt::white ); + active.setColor( TQColorGroup::Shadow, TQt::black ); + TQColorGroup disabled (op.disabled().foreground(), + TQBrush(op.disabled().button(),button), + TQBrush(op.disabled().light(), light), + op.disabled().dark(), + TQBrush(op.disabled().mid(), mid), + op.disabled().text(), + TQt::white, + op.disabled().base(),// TQColor(236,182,120), + TQBrush(backCol, background) + ); + + TQPalette newPalette( active, disabled, active ); + applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, TQStyleApplicationActionRequestData(newPalette, TRUE)); } /*! Reimplementation from TQStyle */ -void MetalStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) +void MetalStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQApplication")) { - TQApplication *app = reinterpret_cast<TQApplication*>(ptr); - - app->setPalette(oldPalette, TRUE); - app->setFont( app->font(), TRUE ); - } + applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, TQStyleApplicationActionRequestData(oldPalette, TRUE)); + applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, TQStyleApplicationActionRequestData(ceData.font, TRUE)); } /*! Reimplementation from TQStyle */ -void MetalStyle::polish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) +void MetalStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQWidget")) { - TQWidget *w = reinterpret_cast<TQWidget*>(ptr); + // the polish function sets some widgets to transparent mode and + // some to translate background mode in order to get the full + // benefit from the nice pixmaps in the color group. - // the polish function sets some widgets to transparent mode and - // some to translate background mode in order to get the full - // benefit from the nice pixmaps in the color group. - - if (w->inherits("TQPushButton")){ - w->setBackgroundMode( TQWidget::NoBackground ); - return; - } - - if ( !w->isTopLevel() ) { - if ( w->backgroundPixmap() ) { - w->setBackgroundOrigin( TQWidget::WindowOrigin ); - } + if (ceData.widgetObjectTypes.contains("TQPushButton")) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::NoBackground)); + return; + } + + if ( !(elementFlags & CEF_IsTopLevel) ) { + if ( !ceData.bgPixmap.isNull() ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, TQStyleWidgetActionRequestData(TQWidget::WindowOrigin)); } } } -void MetalStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) +void MetalStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQWidget")) { - TQWidget *w = reinterpret_cast<TQWidget*>(ptr); - - // the polish function sets some widgets to transparent mode and - // some to translate background mode in order to get the full - // benefit from the nice pixmaps in the color group. - - if (w->inherits("TQPushButton")){ - w->setBackgroundMode( TQWidget::PaletteButton ); - return; - } - if ( !w->isTopLevel() ) { - if ( w->backgroundPixmap() ) - w->setBackgroundOrigin( TQWidget::WidgetOrigin ); + // the polish function sets some widgets to transparent mode and + // some to translate background mode in order to get the full + // benefit from the nice pixmaps in the color group. + + if (ceData.widgetObjectTypes.contains("TQPushButton")) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::PaletteButton)); + return; + } + if ( !(elementFlags & CEF_IsTopLevel) ) { + if ( !ceData.bgPixmap.isNull() ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, TQStyleWidgetActionRequestData(TQWidget::WidgetOrigin)); } } } @@ -219,8 +202,6 @@ void MetalStyle::drawControl( ControlElement element, switch( element ) { case CE_PushButton: { - const TQPushButton *btn; - btn = (const TQPushButton*)widget; int x1, y1, x2, y2; r.coords( &x1, &y1, &x2, &y2 ); @@ -230,14 +211,14 @@ void MetalStyle::drawControl( ControlElement element, TQBrush fill; - if ( btn->isDown() ) + if ( elementFlags & CEF_IsDown ) fill = cg.brush( TQColorGroup::Mid ); - else if ( btn->isOn() ) + else if ( elementFlags & CEF_IsOn ) fill = TQBrush( cg.mid(), Dense4Pattern ); else fill = cg.brush( TQColorGroup::Button ); - if ( btn->isDefault() ) { + if ( elementFlags & CEF_IsDefault ) { TQPointArray a; a.setPoints( 9, x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, @@ -250,19 +231,19 @@ void MetalStyle::drawControl( ControlElement element, y2 -= 2; } SFlags flags = Style_Default; - if ( btn->isOn() ) + if ( elementFlags & CEF_IsOn ) flags |= Style_On; - if ( btn->isDown() ) + if ( elementFlags & CEF_IsDown ) flags |= Style_Down; - if ( !btn->isFlat() && !btn->isDown() ) + if ( !(elementFlags & CEF_IsFlat) && !(elementFlags & CEF_IsDown) ) flags |= Style_Raised; drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, TQRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1), cg, flags, opt ); - if ( btn->isMenuButton() ) { + if ( (elementFlags & CEF_IsMenuWidget) ) { flags = Style_Default; - if ( btn->isEnabled() ) + if ( elementFlags & CEF_IsEnabled ) flags |= Style_Enabled; int dx = ( y1 - y2 - 4 ) / 3; @@ -276,8 +257,6 @@ void MetalStyle::drawControl( ControlElement element, } case CE_PushButtonLabel: { - const TQPushButton *btn; - btn = (const TQPushButton*)widget; int x, y, w, h; r.rect( &x, &y, &w, &h ); @@ -285,9 +264,9 @@ void MetalStyle::drawControl( ControlElement element, r.coords( &x1, &y1, &x2, &y2 ); int dx = 0; int dy = 0; - if ( btn->isMenuButton() ) + if ( (elementFlags & CEF_IsMenuWidget) ) dx = ( y2 - y1 ) / 3; - if ( btn->isOn() || btn->isDown() ) { + if ( (elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown) ) { dx--; dy--; } @@ -299,9 +278,9 @@ void MetalStyle::drawControl( ControlElement element, h -= 4; drawItem( p, TQRect( x, y, w, h ), AlignCenter|ShowPrefix, - cg, btn->isEnabled(), - btn->pixmap(), btn->text(), -1, - (btn->isDown() || btn->isOn())? &cg.brightText() : &cg.buttonText() ); + cg, (elementFlags & CEF_IsEnabled), + (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text, -1, + ((elementFlags & CEF_IsDown) || (elementFlags & CEF_IsOn))? &cg.brightText() : &cg.buttonText() ); if ( dx || dy ) p->translate( -dx, -dy ); break; @@ -326,7 +305,6 @@ void MetalStyle::drawComplexControl( ComplexControl cc, switch ( cc ) { case CC_Slider: { - const TQSlider *slider = ( const TQSlider* ) widget; TQRect handle = querySubControlMetrics( CC_Slider, ceData, elementFlags, SC_SliderHandle, opt, widget); if ( sub & SC_SliderGroove ) @@ -335,16 +313,13 @@ void MetalStyle::drawComplexControl( ComplexControl cc, if ( (sub & SC_SliderHandle) && handle.isValid() ) drawMetalButton( p, handle.x(), handle.y(), handle.width(), handle.height(), FALSE, - slider->orientation() == TQSlider::Horizontal); + ceData.orientation == TQSlider::Horizontal); break; } case CC_ComboBox: { - // not exactly correct... - const TQComboBox *cmb = ( const TQComboBox* ) widget; - qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), cg, TRUE, - cmb->isEnabled() ? &cg.brush( TQColorGroup::Base ) : + (elementFlags & CEF_IsEnabled) ? &cg.brush( TQColorGroup::Base ) : &cg.brush( TQColorGroup::Background ) ); drawMetalButton( p, r.x() + r.width() - 2 - 16, r.y() + 2, 16, r.height() - 4, how & Style_Sunken, TRUE ); @@ -352,7 +327,7 @@ void MetalStyle::drawComplexControl( ComplexControl cc, TQRect( r.x() + r.width() - 2 - 16 + 2, r.y() + 2 + 2, 16 - 4, r.height() - 4 -4 ), cg, - cmb->isEnabled() ? Style_Enabled : Style_Default, + (elementFlags & CEF_IsEnabled) ? Style_Enabled : Style_Default, opt ); break; } |