summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/themes/metal.cpp253
-rw-r--r--examples/themes/metal.h24
-rw-r--r--examples/themes/wood.cpp404
-rw-r--r--examples/themes/wood.h44
4 files changed, 368 insertions, 357 deletions
diff --git a/examples/themes/metal.cpp b/examples/themes/metal.cpp
index 93522f194..8d6bdf593 100644
--- a/examples/themes/metal.cpp
+++ b/examples/themes/metal.cpp
@@ -41,113 +41,112 @@ MetalStyle::MetalStyle() : TQWindowsStyle() { }
/*!
Reimplementation from TQStyle
*/
-void MetalStyle::polish( TQApplication *app)
+void MetalStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, 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 );
+ 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::unPolish( TQApplication *app)
+void MetalStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *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( TQWidget* w)
+void MetalStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *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( TQWidget* w)
+void MetalStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *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));
+ }
+ }
}
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 +169,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,24 +184,24 @@ 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:
{
- const TQPushButton *btn;
- btn = (const TQPushButton*)widget;
int x1, y1, x2, y2;
r.coords( &x1, &y1, &x2, &y2 );
@@ -212,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,
@@ -232,23 +231,23 @@ 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,
+ 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;
- drawPrimitive( PE_ArrowDown, p,
+ drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
TQRect(x2 - dx, dx, y1, y2 - y1),
cg, flags, opt );
}
@@ -258,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 );
@@ -267,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--;
}
@@ -281,64 +278,62 @@ 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;
}
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,
- 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 );
- 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,
- cmb->isEnabled() ? Style_Enabled : Style_Default,
+ (elementFlags & CEF_IsEnabled) ? Style_Enabled : Style_Default,
opt );
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 +468,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 );
}
}
diff --git a/examples/themes/metal.h b/examples/themes/metal.h
index ac6fe84f6..d90cb36db 100644
--- a/examples/themes/metal.h
+++ b/examples/themes/metal.h
@@ -26,13 +26,15 @@ class MetalStyle : public TQWindowsStyle
{
public:
MetalStyle();
- void polish( TQApplication*);
- void unPolish( TQApplication*);
- void polish( TQWidget* );
- void unPolish( TQWidget* );
+ void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawPrimitive( PrimitiveElement pe,
TQPainter *p,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags = Style_Default,
@@ -40,22 +42,26 @@ public:
void drawControl( ControlElement element,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags how = Style_Default,
- const TQStyleOption& = TQStyleOption::Default ) const;
+ const TQStyleOption& = TQStyleOption::Default,
+ const TQWidget *widget = 0 ) const;
void drawComplexControl( ComplexControl cc,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags how = Style_Default,
SCFlags sub = SC_All,
SCFlags subActive = SC_None,
- const TQStyleOption& = TQStyleOption::Default ) const;
- int pixelMetric( PixelMetric, const TQWidget * ) const;
+ const TQStyleOption& = TQStyleOption::Default,
+ const TQWidget *widget = 0 ) const;
+ int pixelMetric( PixelMetric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget * = 0 ) const;
private:
diff --git a/examples/themes/wood.cpp b/examples/themes/wood.cpp
index 8b2830b32..cbd6aab6d 100644
--- a/examples/themes/wood.cpp
+++ b/examples/themes/wood.cpp
@@ -769,156 +769,154 @@ NorwegianWoodStyle::NorwegianWoodStyle() : TQWindowsStyle()
/*!
Reimplementation from TQStyle
*/
-void NorwegianWoodStyle::polish( TQApplication *app)
+void NorwegianWoodStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
-
- oldPalette = app->palette();
-
- // we simply create a nice TQColorGroup with a couple of fancy wood
- // pixmaps here and apply to it all widgets
-
- TQImage img(button_xpm);
- TQImage orig = img;
- orig.detach();
- TQPixmap button;
- button.convertFromImage(img);
-
-
- int i;
- for (i=0; i<img.numColors(); i++) {
- TQRgb rgb = img.color(i);
- TQColor c(rgb);
- rgb = c.dark(120).rgb();
- img.setColor(i,rgb);
- }
- TQPixmap mid;
- mid.convertFromImage(img);
-
- img = orig;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- TQRgb rgb = img.color(i);
- TQColor c(rgb);
- rgb = c.light().rgb();
- img.setColor(i,rgb);
- }
- TQPixmap light;
- light.convertFromImage(img);
-
- img = orig;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- TQRgb rgb = img.color(i);
- TQColor c(rgb);
- rgb = c.dark(180).rgb();
- img.setColor(i,rgb);
- }
- TQPixmap dark;
- dark.convertFromImage(img);
-
-
- TQImage bgimage(polish_xpm);
- TQPixmap background;
- background.convertFromImage(bgimage);
-
- img = bgimage;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- TQRgb rgb = img.color(i);
- TQColor c(rgb);
- rgb = c.dark(180).rgb();
- img.setColor(i,rgb);
- }
- sunkenDark = new TQPixmap;
- sunkenDark->convertFromImage(img);
-
-
- img = bgimage;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- TQRgb rgb = img.color(i);
- TQColor c(rgb);
- rgb = c.light(130).rgb();
- img.setColor(i,rgb);
- }
- sunkenLight= new TQPixmap;
- sunkenLight->convertFromImage(img);
-
-
-
- TQPalette op(TQColor(212,140,95));
- // 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,
- TQColor(236,182,120),
- TQBrush(op.active().background(), background)
- );
- 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,
- TQColor(236,182,120),
- TQBrush(op.disabled().background(), background)
- );
-
- app->setPalette(TQPalette(active, disabled, active), TRUE );
-
+ oldPalette = ceData.palette;
+
+ // we simply create a nice TQColorGroup with a couple of fancy wood
+ // pixmaps here and apply to it all widgets
+
+ TQImage img(button_xpm);
+ TQImage orig = img;
+ orig.detach();
+ TQPixmap button;
+ button.convertFromImage(img);
+
+
+ int i;
+ for (i=0; i<img.numColors(); i++) {
+ TQRgb rgb = img.color(i);
+ TQColor c(rgb);
+ rgb = c.dark(120).rgb();
+ img.setColor(i,rgb);
+ }
+ TQPixmap mid;
+ mid.convertFromImage(img);
+
+ img = orig;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ TQRgb rgb = img.color(i);
+ TQColor c(rgb);
+ rgb = c.light().rgb();
+ img.setColor(i,rgb);
+ }
+ TQPixmap light;
+ light.convertFromImage(img);
+
+ img = orig;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ TQRgb rgb = img.color(i);
+ TQColor c(rgb);
+ rgb = c.dark(180).rgb();
+ img.setColor(i,rgb);
+ }
+ TQPixmap dark;
+ dark.convertFromImage(img);
+
+
+ TQImage bgimage(polish_xpm);
+ TQPixmap background;
+ background.convertFromImage(bgimage);
+
+ img = bgimage;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ TQRgb rgb = img.color(i);
+ TQColor c(rgb);
+ rgb = c.dark(180).rgb();
+ img.setColor(i,rgb);
+ }
+ sunkenDark = new TQPixmap;
+ sunkenDark->convertFromImage(img);
+
+
+ img = bgimage;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ TQRgb rgb = img.color(i);
+ TQColor c(rgb);
+ rgb = c.light(130).rgb();
+ img.setColor(i,rgb);
+ }
+ sunkenLight= new TQPixmap;
+ sunkenLight->convertFromImage(img);
+
+
+
+ TQPalette op(TQColor(212,140,95));
+ // 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,
+ TQColor(236,182,120),
+ TQBrush(op.active().background(), background)
+ );
+ 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,
+ TQColor(236,182,120),
+ TQBrush(op.disabled().background(), background)
+ );
+
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, TQStyleApplicationActionRequestData(TQPalette(active, disabled, active), TRUE));
}
-void NorwegianWoodStyle::unPolish( TQApplication *app)
+void NorwegianWoodStyle::applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- app->setPalette(oldPalette, TRUE);
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, TQStyleApplicationActionRequestData(oldPalette, TRUE));
}
/*!
Reimplementation from TQStyle
*/
-void NorwegianWoodStyle::polish( TQWidget* w)
+void NorwegianWoodStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *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->isTopLevel() ) {
- if ( w->inherits("TQPushButton")
- || w->inherits("TQToolButton")
- || w->inherits("TQComboBox") ) {
- w->setAutoMask( TRUE );
- return;
+ // 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 ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( (ceData.widgetObjectTypes.contains("TQPushButton")) || (ceData.widgetObjectTypes.contains("TQToolButton")) || (ceData.widgetObjectTypes.contains("TQComboBox")) ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetAutoMask);
+ return;
+ }
+ if (!ceData.bgPixmap.isNull()) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, TQStyleWidgetActionRequestData(TQWidget::WindowOrigin));
+ }
}
- if ( w->backgroundPixmap() )
- w->setBackgroundOrigin( TQWidget::WindowOrigin );
- }
}
-void NorwegianWoodStyle::unPolish( TQWidget* w)
+void NorwegianWoodStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *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->isTopLevel() ) {
- if ( w->inherits("TQPushButton")
- || w->inherits("TQToolButton")
- || w->inherits("TQComboBox") ) {
- w->setAutoMask( FALSE );
- return;
+ // 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 ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( (ceData.widgetObjectTypes.contains("TQPushButton")) || (ceData.widgetObjectTypes.contains("TQToolButton")) || (ceData.widgetObjectTypes.contains("TQComboBox")) ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_UnSetAutoMask);
+ return;
+ }
+ if (!ceData.bgPixmap.isNull()) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, TQStyleWidgetActionRequestData(TQWidget::WidgetOrigin));
+ }
}
- if ( w->backgroundPixmap() )
- w->setBackgroundOrigin( TQWidget::WidgetOrigin );
- }
}
void NorwegianWoodStyle::drawPrimitive( PrimitiveElement pe,
TQPainter *p,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags, const TQStyleOption& opt ) const
@@ -970,45 +968,45 @@ void NorwegianWoodStyle::drawPrimitive( PrimitiveElement pe,
}
case PE_ScrollBarAddLine:
if ( flags & Style_Horizontal )
- drawSemicircleButton( p, r, PointRight, flags & Style_Down, cg );
+ drawSemicircleButton( p, ceData, elementFlags, r, PointRight, flags & Style_Down, cg );
else
- drawSemicircleButton( p, r, PointDown, flags & Style_Down, cg );
+ drawSemicircleButton( p, ceData, elementFlags, r, PointDown, flags & Style_Down, cg );
break;
case PE_ScrollBarSubLine:
if ( flags & Style_Horizontal )
- drawSemicircleButton( p, r, PointLeft, flags & Style_Down, cg );
+ drawSemicircleButton( p, ceData, elementFlags, r, PointLeft, flags & Style_Down, cg );
else
- drawSemicircleButton( p, r, PointUp, flags & Style_Down, cg );
+ drawSemicircleButton( p, ceData, elementFlags, r, PointUp, flags & Style_Down, cg );
break;
default:
- TQWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt );
+ TQWindowsStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
break;
}
}
void NorwegianWoodStyle::drawControl( ControlElement element,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
- SFlags how, const TQStyleOption& opt ) const
+ SFlags how, const TQStyleOption& opt,
+ const TQWidget *widget ) const
{
switch( element ) {
case CE_PushButton:
{
- const TQPushButton *btn;
- btn = ( const TQPushButton * )widget;
TQColorGroup myCg( cg );
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->isOn() || btn->isDown() )
+ if ( (elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown) )
flags |= Style_Sunken;
- if ( btn->isDefault() )
+ if ( elementFlags & CEF_IsDefault )
flags |= Style_Default;
- if ( ! btn->isFlat() && !(flags & Style_Down) )
+ if ( ! (elementFlags & CEF_IsFlat) && !(flags & Style_Down) )
flags |= Style_Raised;
int x1, y1, x2, y2;
@@ -1018,26 +1016,26 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
p->setBrush( TQBrush( cg.button(), NoBrush ) );
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 );
myCg.setBrush( TQColorGroup::Mid, fill );
- if ( btn->isDefault() ) {
+ if ( elementFlags & CEF_IsDefault ) {
x1 += 2;
y1 += 2;
x2 -= 2;
y2 -= 2;
}
- drawPrimitive( PE_ButtonCommand, p,
+ drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags,
TQRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1),
myCg, flags, opt );
- if ( btn->isDefault() ) {
+ if ( elementFlags & CEF_IsDefault ) {
TQPen pen( TQt::black, 4 );
pen.setCapStyle( TQt::RoundCap );
pen.setJoinStyle( TQt::RoundJoin );
@@ -1045,14 +1043,14 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
drawroundrect( p, x1 - 1, y1 - 1, x2 - x1 + 3, y2 - y1 + 3, 8 );
}
- if ( btn->isMenuButton() ) {
+ if ( elementFlags & CEF_IsMenuWidget ) {
int dx = ( y1 - y2 - 4 ) / 3;
// reset the flags
flags = Style_Default;
- if ( btn->isEnabled() )
+ if ( elementFlags & CEF_IsEnabled )
flags |= Style_Enabled;
- drawPrimitive( PE_ArrowDown, p,
+ drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
TQRect( x2 - dx, dx, y1, y2 - y1),
myCg, flags, opt );
}
@@ -1063,8 +1061,6 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
}
case CE_PushButtonLabel:
{
- const TQPushButton *btn;
- btn = (const TQPushButton*)widget;
int x, y, w, h;
r.rect( &x, &y, &w, &h );
@@ -1072,7 +1068,7 @@ void NorwegianWoodStyle::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 ( dx || dy )
p->translate( dx, dy );
@@ -1083,25 +1079,27 @@ void NorwegianWoodStyle::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, (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;
}
default:
- TQWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
+ TQWindowsStyle::drawControl( element, p, ceData, elementFlags, r, cg, how, opt, widget );
break;
}
}
void NorwegianWoodStyle::drawControlMask( ControlElement element,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
- const TQStyleOption& opt ) const
+ const TQStyleOption& opt,
+ const TQWidget *widget ) const
{
switch( element ) {
case CE_PushButton:
@@ -1113,37 +1111,36 @@ void NorwegianWoodStyle::drawControlMask( ControlElement element,
break;
}
default:
- TQWindowsStyle::drawControlMask( element, p, widget, r, opt );
+ TQWindowsStyle::drawControlMask( element, p, ceData, elementFlags, r, opt, widget );
break;
}
}
void NorwegianWoodStyle::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_ComboBox:
{
- const TQComboBox *cmb;
- cmb = (const TQComboBox*)widget;
-
int awh, ax, ay, sh, sy, dh, ew;
- get_combo_parameters( subRect(SR_PushButtonContents, widget),
+ get_combo_parameters( subRect(SR_PushButtonContents, ceData, elementFlags, widget),
ew, awh, ax, ay, sh, dh, sy );
- drawPrimitive( PE_ButtonCommand, p, r, cg, Style_Raised, opt );
+ drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, r, cg, Style_Raised, opt );
TQStyle *mstyle = TQStyleFactory::create( "Motif" );
if ( mstyle )
- mstyle->drawPrimitive( PE_ArrowDown, p,
+ mstyle->drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
TQRect(ax, ay, awh, awh), cg, how, opt );
else
- drawPrimitive( PE_ArrowDown, p,
+ drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
TQRect(ax, ay, awh, awh), cg, how, opt );
TQPen oldPen = p->pen();
@@ -1155,9 +1152,9 @@ void NorwegianWoodStyle::drawComplexControl( ComplexControl cc,
p->drawLine( ax + awh - 1, sy + 1, ax + awh - 1, sy + sh - 1 );
p->setPen( oldPen );
- if ( cmb->editable() ) {
- TQRect r( querySubControlMetrics(CC_ComboBox, widget,
- SC_ComboBoxEditField, opt) );
+ if ( elementFlags & CEF_IsEditable ) {
+ TQRect r( querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
+ SC_ComboBoxEditField, opt, widget) );
qDrawShadePanel( p, r, cg, TRUE, 1,
&cg.brush(TQColorGroup::Button) );
}
@@ -1165,17 +1162,19 @@ void NorwegianWoodStyle::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;
}
}
void NorwegianWoodStyle::drawComplexControlMask( ComplexControl control,
TQPainter *p,
- const TQWidget *widget,
+ const TQStyleControlElementData ceData,
+ const ControlElementFlags elementFlags,
const TQRect &r,
- const TQStyleOption& opt ) const
+ const TQStyleOption& opt,
+ const TQWidget *widget ) const
{
switch ( control ) {
case CC_ComboBox:
@@ -1187,15 +1186,17 @@ void NorwegianWoodStyle::drawComplexControlMask( ComplexControl control,
break;
}
default:
- TQWindowsStyle::drawComplexControlMask( control, p, widget, r, opt );
+ TQWindowsStyle::drawComplexControlMask( control, p, ceData, elementFlags, r, opt, widget );
break;
}
}
TQRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
SubControl sc,
- const TQStyleOption& opt ) const
+ const TQStyleOption& opt,
+ const TQWidget *widget ) const
{
TQRect rect;
switch ( control ) {
@@ -1204,62 +1205,58 @@ TQRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control,
switch( sc ) {
case SC_ComboBoxEditField:
{
- rect = subRect( SR_PushButtonContents, widget );
+ rect = subRect( SR_PushButtonContents, ceData, elementFlags, widget );
int ew = get_combo_extra_width( rect.height(), 0 );
rect.setRect( rect.x() + 1, rect.y() + 1,
rect.width() - 2 - ew, rect.height() - 2 );
break;
}
default:
- rect = TQWindowsStyle::querySubControlMetrics( control, widget,
- sc, opt );
+ rect = TQWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
+ sc, opt, widget );
break;
}
break;
}
case CC_ScrollBar:
{
- const TQScrollBar* sb;
- sb = (const TQScrollBar*)widget;
- bool horz = sb->orientation() == TQScrollBar::Horizontal;
+ bool horz = ceData.orientation == TQScrollBar::Horizontal;
int b = 2;
- int w = horz ? sb->height() : sb->width();
+ int w = horz ? ceData.rect.height() : ceData.rect.width();
switch ( sc ) {
case SC_ScrollBarAddLine:
rect.setRect( b, b, w - 2 * b, w - 2 * b );
if ( horz )
- rect.moveBy( sb->width() - w, 0 );
+ rect.moveBy( ceData.rect.width() - w, 0 );
else
- rect.moveBy( 0, sb->height() - w );
+ rect.moveBy( 0, ceData.rect.height() - w );
break;
case SC_ScrollBarSubLine:
rect.setRect( b, b, w - 2 * b, w - 2 * b );
break;
default:
- rect = TQWindowsStyle::querySubControlMetrics( control, widget,
- sc, opt );
+ rect = TQWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
+ sc, opt, widget );
break;
}
break;
}
default:
- rect = TQWindowsStyle::querySubControlMetrics( control, widget,
- sc, opt );
+ rect = TQWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
+ sc, opt, widget );
break;
}
return rect;
}
-TQRect NorwegianWoodStyle::subRect( SubRect sr, const TQWidget * widget ) const
+TQRect NorwegianWoodStyle::subRect( SubRect sr, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget * widget ) const
{
TQRect r;
switch ( sr ) {
case SR_PushButtonContents:
{
- const TQPushButton *btn;
- btn = (const TQPushButton*)widget;
- r = btn->rect();
+ r = ceData.rect;
int d = TQMIN( r.width(), r.height() ) / 2;
int b = buttonthickness( d );
@@ -1276,14 +1273,14 @@ TQRect NorwegianWoodStyle::subRect( SubRect sr, const TQWidget * widget ) const
}
case SR_ComboBoxFocusRect:
{
- r = subRect( SR_PushButtonContents, widget );
+ r = subRect( SR_PushButtonContents, ceData, elementFlags, widget );
int ew = get_combo_extra_width( r.height() );
r.setRect( r.x() + 1, r.y() + 1, r.width() - 2 - ew,
r.height() - 2 );
break;
}
default:
- r = TQWindowsStyle::subRect( sr, widget );
+ r = TQWindowsStyle::subRect( sr, ceData, elementFlags, widget );
break;
}
return r;
@@ -1358,11 +1355,12 @@ static void get_combo_parameters( const TQRect &r,
static inline int buttonthickness( int d )
{ return d > 20 ? 5 : ( d < 10 ? 2: 3 ); }
-void NorwegianWoodStyle::drawSemicircleButton( TQPainter *p, const TQRect &r,
+void NorwegianWoodStyle::drawSemicircleButton( TQPainter *p, TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags, const TQRect &r,
int dir, bool sunken,
const TQColorGroup &g ) const
{
- int b = pixelMetric( PM_ScrollBarExtent ) > 20 ? 3 : 2;
+ int b = pixelMetric( PM_ScrollBarExtent, ceData, elementFlags ) > 20 ? 3 : 2;
TQRegion extrn( r.x(), r.y(), r.width(), r.height(), TQRegion::Ellipse );
TQRegion intern( r.x()+b, r.y()+b, r.width()-2*b, r.height()-2*b, TQRegion::Ellipse );
diff --git a/examples/themes/wood.h b/examples/themes/wood.h
index dd2d10624..a572e24bb 100644
--- a/examples/themes/wood.h
+++ b/examples/themes/wood.h
@@ -26,13 +26,15 @@ class NorwegianWoodStyle : public TQWindowsStyle
{
public:
NorwegianWoodStyle();
- void polish( TQApplication*);
- void polish( TQWidget* );
- void unPolish( TQWidget* );
- void unPolish( TQApplication*);
+ void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
+ void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawPrimitive( PrimitiveElement pe,
TQPainter *p,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags = Style_Default,
@@ -40,44 +42,54 @@ public:
void drawControl( ControlElement element,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags how = 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,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
- const TQStyleOption& = TQStyleOption::Default ) const;
+ const TQStyleOption& = TQStyleOption::Default,
+ const TQWidget *widget = 0 ) const;
void drawComplexControl( ComplexControl cc,
TQPainter *p,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags how = Style_Default,
SCFlags sub = SC_All,
SCFlags subActive = 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,
+ const ControlElementFlags elementFlags,
const TQRect &r,
- const TQStyleOption& = TQStyleOption::Default ) const;
+ const TQStyleOption& = TQStyleOption::Default,
+ const TQWidget *widget = 0 ) const;
TQRect querySubControlMetrics( ComplexControl control,
- const TQWidget *widget,
+ TQStyleControlElementData ceData,
+ ControlElementFlags elementFlags,
SubControl sc,
- const TQStyleOption& = TQStyleOption::Default ) const;
+ const TQStyleOption& = TQStyleOption::Default,
+ const TQWidget *widget = 0 ) const;
- TQRect subRect( SubRect r, const TQWidget *widget ) const;
+ TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const;
private:
- void drawSemicircleButton(TQPainter *p, const TQRect &r, int dir,
+ void drawSemicircleButton(TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r, int dir,
bool sunken, const TQColorGroup &g ) const;
TQPalette oldPalette;
TQPixmap *sunkenDark;