summaryrefslogtreecommitdiffstats
path: root/examples/themes
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-08-09 16:41:42 -0500
committerTimothy Pearson <[email protected]>2012-08-09 16:41:42 -0500
commit403cd53c4e6f6b35bf9881c44efb9f41f5c65b57 (patch)
tree4faf9f3cd1f22f3c41bc5581db938c79b88b99a9 /examples/themes
parentd24053184c51974368634902f1c0e862c811098b (diff)
downloadqt3-403cd53c4e6f6b35bf9881c44efb9f41f5c65b57.tar.gz
qt3-403cd53c4e6f6b35bf9881c44efb9f41f5c65b57.zip
Extend style API further and clean up example themes
Diffstat (limited to 'examples/themes')
-rw-r--r--examples/themes/metal.cpp215
-rw-r--r--examples/themes/wood.cpp310
2 files changed, 236 insertions, 289 deletions
diff --git a/examples/themes/metal.cpp b/examples/themes/metal.cpp
index e772d22..636e562 100644
--- a/examples/themes/metal.cpp
+++ b/examples/themes/metal.cpp
@@ -41,121 +41,104 @@ MetalStyle::MetalStyle() : QWindowsStyle() { }
/*!
Reimplementation from QStyle
*/
-void MetalStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void MetalStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QApplication")) {
- QApplication *app = reinterpret_cast<QApplication*>(ptr);
-
- oldPalette = app->palette();
-
- // we simply create a nice QColorGroup with a couple of fancy
- // pixmaps here and apply to it all widgets
-
- QFont f("times", app->font().pointSize() );
- f.setBold( TRUE );
- f.setItalic( TRUE );
- app->setFont( f, TRUE, "QMenuBar");
- app->setFont( f, TRUE, "QPopupMenu");
-
-
-
- // QPixmap button( stonedark_xpm );
-
- QColor gold("#B9B9A5A54040"); //same as topgrad below
- QPixmap button( 1, 1 ); button.fill( gold );
-
- QPixmap background(marble_xpm);
- QPixmap dark( 1, 1 ); dark.fill( red.dark() );
- QPixmap mid( stone1_xpm );
- QPixmap light( stone1_xpm );//1, 1 ); light.fill( green );
-
- QPalette op = app->palette();
-
- QColor backCol( 227,227,227 );
-
- // QPalette op(white);
- QColorGroup active (op.active().foreground(),
- QBrush(op.active().button(),button),
- QBrush(op.active().light(), light),
- QBrush(op.active().dark(), dark),
- QBrush(op.active().mid(), mid),
- op.active().text(),
- Qt::white,
- op.active().base(),// QColor(236,182,120),
- QBrush(backCol, background)
- );
- active.setColor( QColorGroup::ButtonText, Qt::white );
- active.setColor( QColorGroup::Shadow, Qt::black );
- QColorGroup disabled (op.disabled().foreground(),
- QBrush(op.disabled().button(),button),
- QBrush(op.disabled().light(), light),
- op.disabled().dark(),
- QBrush(op.disabled().mid(), mid),
- op.disabled().text(),
- Qt::white,
- op.disabled().base(),// QColor(236,182,120),
- QBrush(backCol, background)
- );
-
- QPalette newPalette( active, disabled, active );
- app->setPalette( newPalette, TRUE );
- }
+ oldPalette = ceData.palette;
+
+ // we simply create a nice QColorGroup with a couple of fancy
+ // pixmaps here and apply to it all widgets
+
+ QFont f("times", ceData.font.pointSize() );
+ f.setBold( TRUE );
+ f.setItalic( TRUE );
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, QStyleApplicationActionRequestData(f, TRUE, "QMenuBar"));
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, QStyleApplicationActionRequestData(f, TRUE, "QPopupMenu"));
+
+ // QPixmap button( stonedark_xpm );
+
+ QColor gold("#B9B9A5A54040"); //same as topgrad below
+ QPixmap button( 1, 1 ); button.fill( gold );
+
+ QPixmap background(marble_xpm);
+ QPixmap dark( 1, 1 ); dark.fill( red.dark() );
+ QPixmap mid( stone1_xpm );
+ QPixmap light( stone1_xpm );//1, 1 ); light.fill( green );
+
+ QPalette op = ceData.palette;
+
+ QColor backCol( 227,227,227 );
+
+ // QPalette op(white);
+ QColorGroup active (op.active().foreground(),
+ QBrush(op.active().button(),button),
+ QBrush(op.active().light(), light),
+ QBrush(op.active().dark(), dark),
+ QBrush(op.active().mid(), mid),
+ op.active().text(),
+ Qt::white,
+ op.active().base(),// QColor(236,182,120),
+ QBrush(backCol, background)
+ );
+ active.setColor( QColorGroup::ButtonText, Qt::white );
+ active.setColor( QColorGroup::Shadow, Qt::black );
+ QColorGroup disabled (op.disabled().foreground(),
+ QBrush(op.disabled().button(),button),
+ QBrush(op.disabled().light(), light),
+ op.disabled().dark(),
+ QBrush(op.disabled().mid(), mid),
+ op.disabled().text(),
+ Qt::white,
+ op.disabled().base(),// QColor(236,182,120),
+ QBrush(backCol, background)
+ );
+
+ QPalette newPalette( active, disabled, active );
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(newPalette, TRUE));
}
/*!
Reimplementation from QStyle
*/
-void MetalStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void MetalStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QApplication")) {
- QApplication *app = reinterpret_cast<QApplication*>(ptr);
-
- app->setPalette(oldPalette, TRUE);
- app->setFont( app->font(), TRUE );
- }
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(oldPalette, TRUE));
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetFont, QStyleApplicationActionRequestData(ceData.font, TRUE));
}
/*!
Reimplementation from QStyle
*/
-void MetalStyle::polish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void MetalStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QWidget")) {
- QWidget *w = reinterpret_cast<QWidget*>(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("QPushButton")){
- w->setBackgroundMode( QWidget::NoBackground );
- return;
- }
-
- if ( !w->isTopLevel() ) {
- if ( w->backgroundPixmap() ) {
- w->setBackgroundOrigin( QWidget::WindowOrigin );
- }
+ if (ceData.widgetObjectTypes.contains("QPushButton")) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::NoBackground));
+ return;
+ }
+
+ if ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( !ceData.bgPixmap.isNull() ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WindowOrigin));
}
}
}
-void MetalStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void MetalStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QWidget")) {
- QWidget *w = reinterpret_cast<QWidget*>(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("QPushButton")){
- w->setBackgroundMode( QWidget::PaletteButton );
- return;
- }
- if ( !w->isTopLevel() ) {
- if ( w->backgroundPixmap() )
- w->setBackgroundOrigin( QWidget::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("QPushButton")) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, QStyleWidgetActionRequestData(QWidget::PaletteButton));
+ return;
+ }
+ if ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( !ceData.bgPixmap.isNull() ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WidgetOrigin));
}
}
}
@@ -219,8 +202,6 @@ void MetalStyle::drawControl( ControlElement element,
switch( element ) {
case CE_PushButton:
{
- const QPushButton *btn;
- btn = (const QPushButton*)widget;
int x1, y1, x2, y2;
r.coords( &x1, &y1, &x2, &y2 );
@@ -230,14 +211,14 @@ void MetalStyle::drawControl( ControlElement element,
QBrush fill;
- if ( btn->isDown() )
+ if ( elementFlags & CEF_IsDown )
fill = cg.brush( QColorGroup::Mid );
- else if ( btn->isOn() )
+ else if ( elementFlags & CEF_IsOn )
fill = QBrush( cg.mid(), Dense4Pattern );
else
fill = cg.brush( QColorGroup::Button );
- if ( btn->isDefault() ) {
+ if ( elementFlags & CEF_IsDefault ) {
QPointArray 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,
QRect( 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 QPushButton *btn;
- btn = (const QPushButton*)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, QRect( 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 QSlider *slider = ( const QSlider* ) widget;
QRect 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() == QSlider::Horizontal);
+ ceData.orientation == QSlider::Horizontal);
break;
}
case CC_ComboBox:
{
- // not exactly correct...
- const QComboBox *cmb = ( const QComboBox* ) widget;
-
qDrawWinPanel( p, r.x(), r.y(), r.width(), r.height(), cg, TRUE,
- cmb->isEnabled() ? &cg.brush( QColorGroup::Base ) :
+ (elementFlags & CEF_IsEnabled) ? &cg.brush( QColorGroup::Base ) :
&cg.brush( QColorGroup::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,
QRect( 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;
}
diff --git a/examples/themes/wood.cpp b/examples/themes/wood.cpp
index f5fa72a..085fdea 100644
--- a/examples/themes/wood.cpp
+++ b/examples/themes/wood.cpp
@@ -769,163 +769,146 @@ NorwegianWoodStyle::NorwegianWoodStyle() : QWindowsStyle()
/*!
Reimplementation from QStyle
*/
-void NorwegianWoodStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void NorwegianWoodStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QApplication")) {
- QApplication *app = reinterpret_cast<QApplication*>(ptr);
-
- oldPalette = app->palette();
-
- // we simply create a nice QColorGroup with a couple of fancy wood
- // pixmaps here and apply to it all widgets
-
- QImage img(button_xpm);
- QImage orig = img;
- orig.detach();
- QPixmap button;
- button.convertFromImage(img);
-
-
- int i;
- for (i=0; i<img.numColors(); i++) {
- QRgb rgb = img.color(i);
- QColor c(rgb);
- rgb = c.dark(120).rgb();
- img.setColor(i,rgb);
- }
- QPixmap mid;
- mid.convertFromImage(img);
-
- img = orig;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- QRgb rgb = img.color(i);
- QColor c(rgb);
- rgb = c.light().rgb();
- img.setColor(i,rgb);
- }
- QPixmap light;
- light.convertFromImage(img);
-
- img = orig;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- QRgb rgb = img.color(i);
- QColor c(rgb);
- rgb = c.dark(180).rgb();
- img.setColor(i,rgb);
- }
- QPixmap dark;
- dark.convertFromImage(img);
-
-
- QImage bgimage(polish_xpm);
- QPixmap background;
- background.convertFromImage(bgimage);
-
- img = bgimage;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- QRgb rgb = img.color(i);
- QColor c(rgb);
- rgb = c.dark(180).rgb();
- img.setColor(i,rgb);
- }
- sunkenDark = new QPixmap;
- sunkenDark->convertFromImage(img);
-
-
- img = bgimage;
- img.detach();
- for (i=0; i<img.numColors(); i++) {
- QRgb rgb = img.color(i);
- QColor c(rgb);
- rgb = c.light(130).rgb();
- img.setColor(i,rgb);
- }
- sunkenLight= new QPixmap;
- sunkenLight->convertFromImage(img);
-
-
-
- QPalette op(QColor(212,140,95));
- // QPalette op(white);
- QColorGroup active (op.active().foreground(),
- QBrush(op.active().button(),button),
- QBrush(op.active().light(), light),
- QBrush(op.active().dark(), dark),
- QBrush(op.active().mid(), mid),
- op.active().text(),
- Qt::white,
- QColor(236,182,120),
- QBrush(op.active().background(), background)
- );
- QColorGroup disabled (op.disabled().foreground(),
- QBrush(op.disabled().button(),button),
- QBrush(op.disabled().light(), light),
- op.disabled().dark(),
- QBrush(op.disabled().mid(), mid),
- op.disabled().text(),
- Qt::white,
- QColor(236,182,120),
- QBrush(op.disabled().background(), background)
- );
-
- app->setPalette(QPalette(active, disabled, active), TRUE );
+ oldPalette = ceData.palette;
+
+ // we simply create a nice QColorGroup with a couple of fancy wood
+ // pixmaps here and apply to it all widgets
+
+ QImage img(button_xpm);
+ QImage orig = img;
+ orig.detach();
+ QPixmap button;
+ button.convertFromImage(img);
+
+
+ int i;
+ for (i=0; i<img.numColors(); i++) {
+ QRgb rgb = img.color(i);
+ QColor c(rgb);
+ rgb = c.dark(120).rgb();
+ img.setColor(i,rgb);
+ }
+ QPixmap mid;
+ mid.convertFromImage(img);
+
+ img = orig;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ QRgb rgb = img.color(i);
+ QColor c(rgb);
+ rgb = c.light().rgb();
+ img.setColor(i,rgb);
+ }
+ QPixmap light;
+ light.convertFromImage(img);
+
+ img = orig;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ QRgb rgb = img.color(i);
+ QColor c(rgb);
+ rgb = c.dark(180).rgb();
+ img.setColor(i,rgb);
}
+ QPixmap dark;
+ dark.convertFromImage(img);
+
+
+ QImage bgimage(polish_xpm);
+ QPixmap background;
+ background.convertFromImage(bgimage);
+
+ img = bgimage;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ QRgb rgb = img.color(i);
+ QColor c(rgb);
+ rgb = c.dark(180).rgb();
+ img.setColor(i,rgb);
+ }
+ sunkenDark = new QPixmap;
+ sunkenDark->convertFromImage(img);
+
+
+ img = bgimage;
+ img.detach();
+ for (i=0; i<img.numColors(); i++) {
+ QRgb rgb = img.color(i);
+ QColor c(rgb);
+ rgb = c.light(130).rgb();
+ img.setColor(i,rgb);
+ }
+ sunkenLight= new QPixmap;
+ sunkenLight->convertFromImage(img);
+
+
+
+ QPalette op(QColor(212,140,95));
+ // QPalette op(white);
+ QColorGroup active (op.active().foreground(),
+ QBrush(op.active().button(),button),
+ QBrush(op.active().light(), light),
+ QBrush(op.active().dark(), dark),
+ QBrush(op.active().mid(), mid),
+ op.active().text(),
+ Qt::white,
+ QColor(236,182,120),
+ QBrush(op.active().background(), background)
+ );
+ QColorGroup disabled (op.disabled().foreground(),
+ QBrush(op.disabled().button(),button),
+ QBrush(op.disabled().light(), light),
+ op.disabled().dark(),
+ QBrush(op.disabled().mid(), mid),
+ op.disabled().text(),
+ Qt::white,
+ QColor(236,182,120),
+ QBrush(op.disabled().background(), background)
+ );
+
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(QPalette(active, disabled, active), TRUE));
}
-void NorwegianWoodStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void NorwegianWoodStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QApplication")) {
- QApplication *app = reinterpret_cast<QApplication*>(ptr);
-
- app->setPalette(oldPalette, TRUE);
- }
+ applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(oldPalette, TRUE));
}
/*!
Reimplementation from QStyle
*/
-void NorwegianWoodStyle::polish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void NorwegianWoodStyle::polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QWidget")) {
- QWidget *w = reinterpret_cast<QWidget*>(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->isTopLevel() ) {
- if ( w->inherits("QPushButton")
- || w->inherits("QToolButton")
- || w->inherits("QComboBox") ) {
- w->setAutoMask( TRUE );
+ if ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( (ceData.widgetObjectTypes.contains("QPushButton")) || (ceData.widgetObjectTypes.contains("QToolButton")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetAutoMask);
return;
- }
- if ( w->backgroundPixmap() )
- w->setBackgroundOrigin( QWidget::WindowOrigin );
+ }
+ if (!ceData.bgPixmap.isNull()) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WindowOrigin));
}
}
}
-void NorwegianWoodStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, void *ptr )
+void NorwegianWoodStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
- if (ceData.widgetObjectTypes.contains("QWidget")) {
- QWidget *w = reinterpret_cast<QWidget*>(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->isTopLevel() ) {
- if ( w->inherits("QPushButton")
- || w->inherits("QToolButton")
- || w->inherits("QComboBox") ) {
- w->setAutoMask( FALSE );
+ if ( !(elementFlags & CEF_IsTopLevel) ) {
+ if ( (ceData.widgetObjectTypes.contains("QPushButton")) || (ceData.widgetObjectTypes.contains("QToolButton")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_UnSetAutoMask);
return;
- }
- if ( w->backgroundPixmap() )
- w->setBackgroundOrigin( QWidget::WidgetOrigin );
+ }
+ if (!ceData.bgPixmap.isNull()) {
+ widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WidgetOrigin));
}
}
}
@@ -1013,19 +996,17 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
switch( element ) {
case CE_PushButton:
{
- const QPushButton *btn;
- btn = ( const QPushButton * )widget;
QColorGroup 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;
@@ -1035,15 +1016,15 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
p->setBrush( QBrush( cg.button(), NoBrush ) );
QBrush fill;
- if ( btn->isDown() )
+ if ( elementFlags & CEF_IsDown )
fill = cg.brush( QColorGroup::Mid );
- else if ( btn->isOn() )
+ else if ( elementFlags & CEF_IsOn )
fill = QBrush( cg.mid(), Dense4Pattern );
else
fill = cg.brush( QColorGroup::Button );
myCg.setBrush( QColorGroup::Mid, fill );
- if ( btn->isDefault() ) {
+ if ( elementFlags & CEF_IsDefault ) {
x1 += 2;
y1 += 2;
x2 -= 2;
@@ -1054,7 +1035,7 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
QRect( x1, y1, x2 - x1 + 1, y2 - y1 + 1),
myCg, flags, opt );
- if ( btn->isDefault() ) {
+ if ( elementFlags & CEF_IsDefault ) {
QPen pen( Qt::black, 4 );
pen.setCapStyle( Qt::RoundCap );
pen.setJoinStyle( Qt::RoundJoin );
@@ -1062,12 +1043,12 @@ 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, ceData, elementFlags,
QRect( x2 - dx, dx, y1, y2 - y1),
@@ -1080,8 +1061,6 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
}
case CE_PushButtonLabel:
{
- const QPushButton *btn;
- btn = (const QPushButton*)widget;
int x, y, w, h;
r.rect( &x, &y, &w, &h );
@@ -1089,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 );
@@ -1100,9 +1079,9 @@ void NorwegianWoodStyle::drawControl( ControlElement element,
h -= 4;
drawItem( p, QRect( 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 );
@@ -1152,9 +1131,6 @@ void NorwegianWoodStyle::drawComplexControl( ComplexControl cc,
switch( cc ) {
case CC_ComboBox:
{
- const QComboBox *cmb;
- cmb = (const QComboBox*)widget;
-
int awh, ax, ay, sh, sy, dh, ew;
get_combo_parameters( subRect(SR_PushButtonContents, ceData, elementFlags, widget),
ew, awh, ax, ay, sh, dh, sy );
@@ -1176,7 +1152,7 @@ void NorwegianWoodStyle::drawComplexControl( ComplexControl cc,
p->drawLine( ax + awh - 1, sy + 1, ax + awh - 1, sy + sh - 1 );
p->setPen( oldPen );
- if ( cmb->editable() ) {
+ if ( elementFlags & CEF_IsEditable ) {
QRect r( querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
SC_ComboBoxEditField, opt, widget) );
qDrawShadePanel( p, r, cg, TRUE, 1,
@@ -1244,19 +1220,17 @@ QRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control,
}
case CC_ScrollBar:
{
- const QScrollBar* sb;
- sb = (const QScrollBar*)widget;
- bool horz = sb->orientation() == QScrollBar::Horizontal;
+ bool horz = ceData.orientation == QScrollBar::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 );
@@ -1282,9 +1256,7 @@ QRect NorwegianWoodStyle::subRect( SubRect sr, const QStyleControlElementData ce
switch ( sr ) {
case SR_PushButtonContents:
{
- const QPushButton *btn;
- btn = (const QPushButton*)widget;
- r = btn->rect();
+ r = ceData.rect;
int d = QMIN( r.width(), r.height() ) / 2;
int b = buttonthickness( d );