Darrell Anderson 12 years ago
commit ac2895edc0

@ -41,113 +41,112 @@ MetalStyle::MetalStyle() : QWindowsStyle() { }
/*!
Reimplementation from QStyle
*/
void MetalStyle::polish( QApplication *app)
void MetalStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *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::unPolish( QApplication *app)
void MetalStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *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( QWidget* w)
void MetalStyle::polish( QStyleControlElementData 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("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( QWidget* w)
void MetalStyle::unPolish( QStyleControlElementData 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("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));
}
}
}
void MetalStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags, const QStyleOption& 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:
QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt );
QWindowsStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
break;
}
}
void MetalStyle::drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
switch( element ) {
case CE_PushButton:
{
const QPushButton *btn;
btn = (const QPushButton*)widget;
int x1, y1, x2, y2;
r.coords( &x1, &y1, &x2, &y2 );
@ -212,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,
@ -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,
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;
drawPrimitive( PE_ArrowDown, p,
drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
QRect(x2 - dx, dx, y1, y2 - y1),
cg, flags, opt );
}
@ -258,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 );
@ -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, 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;
}
default:
QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
QWindowsStyle::drawControl( element, p, ceData, elementFlags, r, cg, how, opt, widget );
break;
}
}
void MetalStyle::drawComplexControl( ComplexControl cc,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how,
SCFlags sub,
SCFlags subActive,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
switch ( cc ) {
case CC_Slider:
{
const QSlider *slider = ( const QSlider* ) widget;
QRect handle = querySubControlMetrics( CC_Slider, widget,
SC_SliderHandle, opt);
QRect handle = querySubControlMetrics( CC_Slider, ceData, elementFlags,
SC_SliderHandle, opt, widget);
if ( sub & SC_SliderGroove )
QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how,
SC_SliderGroove, subActive, opt );
QWindowsStyle::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() == 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 );
drawPrimitive( PE_ArrowDown, p,
drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
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;
}
default:
QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how, sub, subActive,
opt );
QWindowsStyle::drawComplexControl( cc, p, ceData, elementFlags, r, cg, how, sub, subActive,
opt, widget );
break;
}
}
@ -473,13 +468,13 @@ void MetalStyle::drawMetalGradient( QPainter *p, int x, int y, int w, int h,
int MetalStyle::pixelMetric( PixelMetric metric, const QWidget *w ) const
int MetalStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *w ) const
{
switch ( metric ) {
case PM_MenuBarFrameWidth:
return 2;
default:
return QWindowsStyle::pixelMetric( metric, w );
return QWindowsStyle::pixelMetric( metric, ceData, elementFlags, w );
}
}

@ -26,13 +26,15 @@ class MetalStyle : public QWindowsStyle
{
public:
MetalStyle();
void polish( QApplication*);
void unPolish( QApplication*);
void polish( QWidget* );
void unPolish( QWidget* );
void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawPrimitive( PrimitiveElement pe,
QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags = Style_Default,
@ -40,22 +42,26 @@ public:
void drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how = Style_Default,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
void drawComplexControl( ComplexControl cc,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how = Style_Default,
SCFlags sub = SC_All,
SCFlags subActive = SC_None,
const QStyleOption& = QStyleOption::Default ) const;
int pixelMetric( PixelMetric, const QWidget * ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
int pixelMetric( PixelMetric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget * = 0 ) const;
private:

@ -769,156 +769,154 @@ NorwegianWoodStyle::NorwegianWoodStyle() : QWindowsStyle()
/*!
Reimplementation from QStyle
*/
void NorwegianWoodStyle::polish( QApplication *app)
void NorwegianWoodStyle::applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *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::unPolish( QApplication *app)
void NorwegianWoodStyle::applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{
app->setPalette(oldPalette, TRUE);
applicationActionRequest(ceData, elementFlags, ptr, AAR_SetPalette, QStyleApplicationActionRequestData(oldPalette, TRUE));
}
/*!
Reimplementation from QStyle
*/
void NorwegianWoodStyle::polish( QWidget* w)
void NorwegianWoodStyle::polish( QStyleControlElementData 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("QPushButton")
|| w->inherits("QToolButton")
|| w->inherits("QComboBox") ) {
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("QPushButton")) || (ceData.widgetObjectTypes.contains("QToolButton")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) {
widgetActionRequest(ceData, elementFlags, ptr, WAR_SetAutoMask);
return;
}
if (!ceData.bgPixmap.isNull()) {
widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WindowOrigin));
}
}
if ( w->backgroundPixmap() )
w->setBackgroundOrigin( QWidget::WindowOrigin );
}
}
void NorwegianWoodStyle::unPolish( QWidget* w)
void NorwegianWoodStyle::unPolish( QStyleControlElementData 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("QPushButton")
|| w->inherits("QToolButton")
|| w->inherits("QComboBox") ) {
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("QPushButton")) || (ceData.widgetObjectTypes.contains("QToolButton")) || (ceData.widgetObjectTypes.contains("QComboBox")) ) {
widgetActionRequest(ceData, elementFlags, ptr, WAR_UnSetAutoMask);
return;
}
if (!ceData.bgPixmap.isNull()) {
widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundOrigin, QStyleWidgetActionRequestData(QWidget::WidgetOrigin));
}
}
if ( w->backgroundPixmap() )
w->setBackgroundOrigin( QWidget::WidgetOrigin );
}
}
void NorwegianWoodStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags, const QStyleOption& 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:
QWindowsStyle::drawPrimitive( pe, p, r, cg, flags, opt );
QWindowsStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
break;
}
}
void NorwegianWoodStyle::drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how, const QStyleOption& opt ) const
SFlags how, const QStyleOption& opt,
const QWidget *widget ) const
{
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;
@ -1018,26 +1016,26 @@ 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;
y2 -= 2;
}
drawPrimitive( PE_ButtonCommand, p,
drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags,
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 );
@ -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,
QRect( x2 - dx, dx, y1, y2 - y1),
myCg, flags, opt );
}
@ -1063,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 );
@ -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, 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 );
break;
}
default:
QWindowsStyle::drawControl( element, p, widget, r, cg, how, opt );
QWindowsStyle::drawControl( element, p, ceData, elementFlags, r, cg, how, opt, widget );
break;
}
}
void NorwegianWoodStyle::drawControlMask( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
switch( element ) {
case CE_PushButton:
@ -1113,37 +1111,36 @@ void NorwegianWoodStyle::drawControlMask( ControlElement element,
break;
}
default:
QWindowsStyle::drawControlMask( element, p, widget, r, opt );
QWindowsStyle::drawControlMask( element, p, ceData, elementFlags, r, opt, widget );
break;
}
}
void NorwegianWoodStyle::drawComplexControl( ComplexControl cc,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how,
SCFlags sub,
SCFlags subActive,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
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, 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 );
QStyle *mstyle = QStyleFactory::create( "Motif" );
if ( mstyle )
mstyle->drawPrimitive( PE_ArrowDown, p,
mstyle->drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
QRect(ax, ay, awh, awh), cg, how, opt );
else
drawPrimitive( PE_ArrowDown, p,
drawPrimitive( PE_ArrowDown, p, ceData, elementFlags,
QRect(ax, ay, awh, awh), cg, how, opt );
QPen 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() ) {
QRect r( querySubControlMetrics(CC_ComboBox, widget,
SC_ComboBoxEditField, opt) );
if ( elementFlags & CEF_IsEditable ) {
QRect r( querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
SC_ComboBoxEditField, opt, widget) );
qDrawShadePanel( p, r, cg, TRUE, 1,
&cg.brush(QColorGroup::Button) );
}
@ -1165,17 +1162,19 @@ void NorwegianWoodStyle::drawComplexControl( ComplexControl cc,
break;
}
default:
QWindowsStyle::drawComplexControl( cc, p, widget, r, cg, how,
sub, subActive, opt );
QWindowsStyle::drawComplexControl( cc, p, ceData, elementFlags, r, cg, how,
sub, subActive, opt, widget );
break;
}
}
void NorwegianWoodStyle::drawComplexControlMask( ComplexControl control,
QPainter *p,
const QWidget *widget,
const QStyleControlElementData ceData,
const ControlElementFlags elementFlags,
const QRect &r,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
switch ( control ) {
case CC_ComboBox:
@ -1187,15 +1186,17 @@ void NorwegianWoodStyle::drawComplexControlMask( ComplexControl control,
break;
}
default:
QWindowsStyle::drawComplexControlMask( control, p, widget, r, opt );
QWindowsStyle::drawComplexControlMask( control, p, ceData, elementFlags, r, opt, widget );
break;
}
}
QRect NorwegianWoodStyle::querySubControlMetrics( ComplexControl control,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
SubControl sc,
const QStyleOption& opt ) const
const QStyleOption& opt,
const QWidget *widget ) const
{
QRect rect;
switch ( control ) {
@ -1204,62 +1205,58 @@ QRect 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 = QWindowsStyle::querySubControlMetrics( control, widget,
sc, opt );
rect = QWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
sc, opt, widget );
break;
}
break;
}
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 );
break;
default:
rect = QWindowsStyle::querySubControlMetrics( control, widget,
sc, opt );
rect = QWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
sc, opt, widget );
break;
}
break;
}
default:
rect = QWindowsStyle::querySubControlMetrics( control, widget,
sc, opt );
rect = QWindowsStyle::querySubControlMetrics( control, ceData, elementFlags,
sc, opt, widget );
break;
}
return rect;
}
QRect NorwegianWoodStyle::subRect( SubRect sr, const QWidget * widget ) const
QRect NorwegianWoodStyle::subRect( SubRect sr, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget * widget ) const
{
QRect r;
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 );
@ -1276,14 +1273,14 @@ QRect NorwegianWoodStyle::subRect( SubRect sr, const QWidget * 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 = QWindowsStyle::subRect( sr, widget );
r = QWindowsStyle::subRect( sr, ceData, elementFlags, widget );
break;
}
return r;
@ -1358,11 +1355,12 @@ static void get_combo_parameters( const QRect &r,
static inline int buttonthickness( int d )
{ return d > 20 ? 5 : ( d < 10 ? 2: 3 ); }
void NorwegianWoodStyle::drawSemicircleButton( QPainter *p, const QRect &r,
void NorwegianWoodStyle::drawSemicircleButton( QPainter *p, QStyleControlElementData ceData,
ControlElementFlags elementFlags, const QRect &r,
int dir, bool sunken,
const QColorGroup &g ) const
{
int b = pixelMetric( PM_ScrollBarExtent ) > 20 ? 3 : 2;
int b = pixelMetric( PM_ScrollBarExtent, ceData, elementFlags ) > 20 ? 3 : 2;
QRegion extrn( r.x(), r.y(), r.width(), r.height(), QRegion::Ellipse );
QRegion intern( r.x()+b, r.y()+b, r.width()-2*b, r.height()-2*b, QRegion::Ellipse );

@ -26,13 +26,15 @@ class NorwegianWoodStyle : public QWindowsStyle
{
public:
NorwegianWoodStyle();
void polish( QApplication*);
void polish( QWidget* );
void unPolish( QWidget* );
void unPolish( QApplication*);
void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void applicationUnPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void drawPrimitive( PrimitiveElement pe,
QPainter *p,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags flags = Style_Default,
@ -40,44 +42,54 @@ public:
void drawControl( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how = Style_Default,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
void drawControlMask( ControlElement element,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
void drawComplexControl( ComplexControl cc,
QPainter *p,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
const QRect &r,
const QColorGroup &cg,
SFlags how = Style_Default,
SCFlags sub = SC_All,
SCFlags subActive = SC_None,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
void drawComplexControlMask( ComplexControl control,
QPainter *p,
const QWidget *widget,
const QStyleControlElementData ceData,
const ControlElementFlags elementFlags,
const QRect &r,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
QRect querySubControlMetrics( ComplexControl control,
const QWidget *widget,
QStyleControlElementData ceData,
ControlElementFlags elementFlags,
SubControl sc,
const QStyleOption& = QStyleOption::Default ) const;
const QStyleOption& = QStyleOption::Default,
const QWidget *widget = 0 ) const;
QRect subRect( SubRect r, const QWidget *widget ) const;
QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const;
private:
void drawSemicircleButton(QPainter *p, const QRect &r, int dir,
void drawSemicircleButton(QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, int dir,
bool sunken, const QColorGroup &g ) const;
QPalette oldPalette;
QPixmap *sunkenDark;

@ -403,6 +403,7 @@ QStyle::QStyle()
m_eventHandlerInstallationHook = NULL;
m_eventHandlerRemovalHook = NULL;
m_widgetActionRequestHook = NULL;
m_applicationActionRequestHook = NULL;
conditionalAcceleratorsEnabled = false;
d = new QStylePrivate;
}
@ -526,8 +527,7 @@ void QStyle::unPolish( QStyleControlElementData ceData, ControlElementFlags, voi
\sa unPolish()
*/
void QStyle::polish( QApplication *app ) {
QStyleControlElementData ceData;
ceData.widgetObjectTypes = getObjectTypeListForObject(app);
QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption());
applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app);
}
@ -539,8 +539,7 @@ void QStyle::polish( QApplication *app ) {
\sa polish()
*/
void QStyle::unPolish( QApplication *app ) {
QStyleControlElementData ceData;
ceData.widgetObjectTypes = getObjectTypeListForObject(app);
QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption());
applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app);
}
@ -2217,6 +2216,12 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
else if (request == WAR_DisableMouseTracking) {
widget->setMouseTracking(FALSE);
}
else if (request == WAR_SetAutoMask) {
widget->setAutoMask(TRUE);
}
else if (request == WAR_UnSetAutoMask) {
widget->setAutoMask(FALSE);
}
else if (request == WAR_SetCheckable) {
QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget);
if (pm) {
@ -2253,6 +2258,9 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
else if (request == WAR_SetBackgroundMode) {
widget->setBackgroundMode((Qt::BackgroundMode)requestData.metric1);
}
else if (request == WAR_SetBackgroundOrigin) {
widget->setBackgroundOrigin((QWidget::BackgroundOrigin)requestData.metric1);
}
else if (request == WAR_SetFont) {
widget->setFont(requestData.font);
}
@ -2289,11 +2297,45 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen
return true;
}
void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) {
// RAJA FIXME
// Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the QWindowsStyle::styleHint overridden method
// Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint
/*!
\fn void QStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook );
Sets a callback function \a hook which will be called whenever a new application action request
is made via the QStyle::installObjectEventHandler method. The callback function must
use this definition: bool callbackFunction( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler ).
\sa void QStyle::installObjectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QStyle* handler )
*/
void QStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ) {
m_applicationActionRequestHook = hook;
}
/*!
\fn bool applicationActionRequestHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request );
Handles application action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing.
*/
bool QStyle::applicationActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData ) {
bool cbret = false;
if (m_applicationActionRequestHook) {
cbret = (*m_applicationActionRequestHook)(ceData, elementFlags, source, request, requestData);
}
if (!cbret) {
if (ceData.widgetObjectTypes.contains("QApplication")) {
QApplication* application = reinterpret_cast<QApplication*>(source);
if (request == AAR_SetPalette) {
application->setPalette(requestData.palette, requestData.bool1, requestData.cstr);
}
else if (request == AAR_SetFont) {
application->setFont(requestData.font, requestData.bool1, requestData.cstr);
}
return true;
}
}
return true;
}
void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) {
if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) {
QWidget *widget = dynamic_cast<QWidget*>(o);
if (widget) {
@ -2337,12 +2379,16 @@ QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(int param1, int par
metric2 = param2;
}
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param) {
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPalette param, bool informWidgets, const char* className) {
palette = param;
bool1 = informWidgets;
cstr = className;
}
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param) {
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QFont param, bool informWidgets, const char* className) {
font = param;
bool1 = informWidgets;
cstr = className;
}
QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QRect param) {

@ -257,18 +257,24 @@ class Q_EXPORT QStyleWidgetActionRequestData {
public:
QStyleWidgetActionRequestData();
QStyleWidgetActionRequestData(int metric1, int metric2=0);
QStyleWidgetActionRequestData(QPalette palette);
QStyleWidgetActionRequestData(QFont font);
QStyleWidgetActionRequestData(QPalette palette, bool informWidgets = FALSE, const char* className = 0);
QStyleWidgetActionRequestData(QFont font, bool informWidgets = FALSE, const char* className = 0);
QStyleWidgetActionRequestData(QRect rect);
~QStyleWidgetActionRequestData();
public:
bool bool1;
bool bool2;
int metric1;
int metric2;
QPalette palette;
QFont font;
QRect rect;
const char * cstr;
QString string;
};
typedef QStyleWidgetActionRequestData QStyleApplicationActionRequestData;
class Q_EXPORT QStyle: public QObject
{
Q_OBJECT
@ -1077,6 +1083,8 @@ public:
WAR_RepaintRect,
WAR_EnableMouseTracking,
WAR_DisableMouseTracking,
WAR_SetAutoMask,
WAR_UnSetAutoMask,
WAR_SetCheckable,
WAR_UnSetCheckable,
WAR_FrameSetStyle,
@ -1084,6 +1092,7 @@ public:
WAR_SetLayoutMargin,
WAR_SetPalette,
WAR_SetBackgroundMode,
WAR_SetBackgroundOrigin,
WAR_SetFont,
WAR_RepaintAllAccelerators
};
@ -1092,6 +1101,15 @@ public:
void setWidgetActionRequestHook( WidgetActionRequestHook );
virtual bool widgetActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData = QStyleWidgetActionRequestData() );
enum ApplicationActionRequest {
AAR_SetPalette,
AAR_SetFont
};
typedef bool (*ApplicationActionRequestHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData);
void setApplicationActionRequestHook( ApplicationActionRequestHook );
virtual bool applicationActionRequest( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, QStyleApplicationActionRequestData requestData = QStyleApplicationActionRequestData() );
// Old 2.x QStyle API
#ifndef QT_NO_COMPAT
@ -1131,6 +1149,7 @@ private:
EventHandlerInstallationHook m_eventHandlerInstallationHook;
EventHandlerRemovalHook m_eventHandlerRemovalHook;
WidgetActionRequestHook m_widgetActionRequestHook;
ApplicationActionRequestHook m_applicationActionRequestHook;
ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap;
ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap;
ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap;
@ -1141,6 +1160,7 @@ inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a
// inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; }
Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields=true);
Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object);

@ -556,6 +556,18 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid
return ceData;
}
QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption&, bool) {
QStyleControlElementData ceData;
if (app) {
ceData.widgetObjectTypes = getObjectTypeListForObject(app);
ceData.palette = app->palette();
ceData.font = app->font();
}
return ceData;
}
/*! \reimp */
void QCommonStyle::drawPrimitive( PrimitiveElement pe,
QPainter *p,

Loading…
Cancel
Save