diff options
author | Timothy Pearson <[email protected]> | 2012-08-09 15:32:33 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-08-09 15:32:33 -0500 |
commit | 6df11f9b12f7d5b8f52c8f6b52faa8fdac13ddfa (patch) | |
tree | c9503d63a3812acc90c4341ee214ced8ed608811 /examples/themes/metal.cpp | |
parent | b6053b1b40b51e3d9b1b679a8a1751e5472e06e2 (diff) | |
download | tqt3-6df11f9b12f7d5b8f52c8f6b52faa8fdac13ddfa.tar.gz tqt3-6df11f9b12f7d5b8f52c8f6b52faa8fdac13ddfa.zip |
Automated update from Qt3
Diffstat (limited to 'examples/themes/metal.cpp')
-rw-r--r-- | examples/themes/metal.cpp | 228 |
1 files changed, 124 insertions, 104 deletions
diff --git a/examples/themes/metal.cpp b/examples/themes/metal.cpp index 93522f194..a84547518 100644 --- a/examples/themes/metal.cpp +++ b/examples/themes/metal.cpp @@ -41,113 +41,129 @@ MetalStyle::MetalStyle() : TQWindowsStyle() { } /*! Reimplementation from TQStyle */ -void MetalStyle::polish( TQApplication *app) +void MetalStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags, void *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 ); + 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 ); + } } /*! Reimplementation from TQStyle */ -void MetalStyle::unPolish( TQApplication *app) +void MetalStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) { - app->setPalette(oldPalette, TRUE); - app->setFont( app->font(), TRUE ); + if (ceData.widgetObjectTypes.contains("TQApplication")) { + TQApplication *app = reinterpret_cast<TQApplication*>(ptr); + + app->setPalette(oldPalette, TRUE); + app->setFont( app->font(), TRUE ); + } } /*! Reimplementation from TQStyle */ -void MetalStyle::polish( TQWidget* w) +void MetalStyle::polish( TQStyleControlElementData ceData, ControlElementFlags, 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::NoBackground ); - return; - } - - if ( !w->isTopLevel() ) { - if ( w->backgroundPixmap() ) - w->setBackgroundOrigin( TQWidget::WindowOrigin ); - } + // 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 ); + } + } + } } -void MetalStyle::unPolish( TQWidget* w) +void MetalStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags, 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 (w->inherits("TQPushButton")){ + w->setBackgroundMode( TQWidget::PaletteButton ); + return; + } + if ( !w->isTopLevel() ) { + if ( w->backgroundPixmap() ) + w->setBackgroundOrigin( TQWidget::WidgetOrigin ); + } + } } void MetalStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt ) const @@ -170,13 +186,13 @@ void MetalStyle::drawPrimitive( PrimitiveElement pe, drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), flags & Style_Down, !( flags & Style_Horizontal ) ); drawPrimitive( (flags & Style_Horizontal) ? PE_ArrowRight :PE_ArrowDown, - p, r, cg, flags, opt ); + p, ceData, elementFlags, r, cg, flags, opt ); break; case PE_ScrollBarSubLine: drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), flags & Style_Down, !( flags & Style_Horizontal ) ); drawPrimitive( (flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp, - p, r, cg, flags, opt ); + p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -185,18 +201,20 @@ void MetalStyle::drawPrimitive( PrimitiveElement pe, flags & Style_Horizontal ); break; default: - TQWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt ); + TQWindowsStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; } } void MetalStyle::drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch( element ) { case CE_PushButton: @@ -238,7 +256,7 @@ void MetalStyle::drawControl( ControlElement element, flags |= Style_Down; if ( !btn->isFlat() && !btn->isDown() ) flags |= Style_Raised; - drawPrimitive( PE_ButtonCommand, p, + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, TQRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1), cg, flags, opt ); @@ -248,7 +266,7 @@ void MetalStyle::drawControl( ControlElement element, flags |= Style_Enabled; int dx = ( y1 - y2 - 4 ) / 3; - drawPrimitive( PE_ArrowDown, p, + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect(x2 - dx, dx, y1, y2 - y1), cg, flags, opt ); } @@ -289,29 +307,31 @@ void MetalStyle::drawControl( ControlElement element, break; } default: - TQWindowsStyle::drawControl( element, p, widget, r, cg, how, opt ); + TQWindowsStyle::drawControl( element, p, ceData, elementFlags, r, cg, how, opt, widget ); break; } } void MetalStyle::drawComplexControl( ComplexControl cc, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch ( cc ) { case CC_Slider: { const TQSlider *slider = ( const TQSlider* ) widget; - TQRect handle = querySubControlMetrics( CC_Slider, widget, - SC_SliderHandle, opt); + TQRect handle = querySubControlMetrics( CC_Slider, ceData, elementFlags, + SC_SliderHandle, opt, widget); if ( sub & SC_SliderGroove ) - TQWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, - SC_SliderGroove, subActive, opt ); + TQWindowsStyle::drawComplexControl( cc, p, ceData, elementFlags, r, cg, how, + SC_SliderGroove, subActive, opt, widget ); if ( (sub & SC_SliderHandle) && handle.isValid() ) drawMetalButton( p, handle.x(), handle.y(), handle.width(), handle.height(), FALSE, @@ -328,7 +348,7 @@ void MetalStyle::drawComplexControl( ComplexControl cc, &cg.brush( TQColorGroup::Background ) ); drawMetalButton( p, r.x() + r.width() - 2 - 16, r.y() + 2, 16, r.height() - 4, how & Style_Sunken, TRUE ); - drawPrimitive( PE_ArrowDown, p, + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect( r.x() + r.width() - 2 - 16 + 2, r.y() + 2 + 2, 16 - 4, r.height() - 4 -4 ), cg, @@ -337,8 +357,8 @@ void MetalStyle::drawComplexControl( ComplexControl cc, break; } default: - TQWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, sub, subActive, - opt ); + TQWindowsStyle::drawComplexControl( cc, p, ceData, elementFlags, r, cg, how, sub, subActive, + opt, widget ); break; } } @@ -473,13 +493,13 @@ void MetalStyle::drawMetalGradient( TQPainter *p, int x, int y, int w, int h, -int MetalStyle::pixelMetric( PixelMetric metric, const TQWidget *w ) const +int MetalStyle::pixelMetric( PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *w ) const { switch ( metric ) { case PM_MenuBarFrameWidth: return 2; default: - return TQWindowsStyle::pixelMetric( metric, w ); + return TQWindowsStyle::pixelMetric( metric, ceData, elementFlags, w ); } } |