diff options
Diffstat (limited to 'src/styles')
-rw-r--r-- | src/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/styles/qcompactstyle.cpp | 111 | ||||
-rw-r--r-- | src/styles/qcompactstyle.h | 11 | ||||
-rw-r--r-- | src/styles/qmotifplusstyle.cpp | 81 | ||||
-rw-r--r-- | src/styles/qmotifstyle.cpp | 90 | ||||
-rw-r--r-- | src/styles/qsgistyle.cpp | 98 | ||||
-rw-r--r-- | src/styles/qsgistyle.h | 2 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 118 |
8 files changed, 423 insertions, 91 deletions
diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 2614bbf..3a1a8d8 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -2870,6 +2870,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co case PM_TabBarScrollButtonWidth: ret = 16; break; + case PM_ArrowSize: + ret = 7; + break; default: ret = 0; break; diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp index 7c7e0f5..63c5be5 100644 --- a/src/styles/qcompactstyle.cpp +++ b/src/styles/qcompactstyle.cpp @@ -67,6 +67,12 @@ int QCompactStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceD case PM_MaximumDragDistance: ret = -1; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 0; + break; default: ret = QWindowsStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -189,13 +195,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont return; if ( mi->isChecked() ) { - if ( act && !dis ) { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Button ) ); - } else { - qDrawShadePanel( p, x, y, checkcol, h, - g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); - } + drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } else if ( !act ) { p->fillRect(x, y, checkcol , h, g.brush( QColorGroup::Button )); @@ -214,7 +214,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont int pixh = pixmap.height(); if ( act && !dis ) { if ( !mi->isChecked() ) - qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) ); + drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } QRect cr( x, y, checkcol, h ); QRect pmr( 0, 0, pixw, pixh ); @@ -226,18 +226,8 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont g.brush( QColorGroup::Button ); p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); } else if ( checkable ) { // just "checking"... - int mw = checkcol + motifItemFrame; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, - mw, mh), itemg, cflags, opt ); + drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, itemg, flags, opt ); } } @@ -319,4 +309,87 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont } } +/*! \reimp */ +void QCompactStyle::drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + switch (pe) { + case PE_MenuItemIndicatorFrame: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + if ( act && !dis ) { + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } else { + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + } + } + break; + case PE_MenuItemIndicatorIconFrame: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + qDrawShadePanel( p, x, y, checkcol, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + case PE_MenuItemIndicatorCheck: + { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int mw = checkcol + motifItemFrame; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) { + cflags |= Style_Enabled; + } + if (act) { + cflags |= Style_On; + } + + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, QRect(x + motifItemFrame + 2, y + motifItemFrame, mw, mh), cg, cflags, opt ); + } + break; + default: + break; + } +} + +/*! \reimp */ +int QCompactStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks + + ret = maxpmw; + } + break; + default: + ret = QWindowsStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif diff --git a/src/styles/qcompactstyle.h b/src/styles/qcompactstyle.h index 2f9748b..6002055 100644 --- a/src/styles/qcompactstyle.h +++ b/src/styles/qcompactstyle.h @@ -60,9 +60,20 @@ public: int pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget = 0 ); + void drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags = Style_Default, + const QStyleOption& = QStyleOption::Default ) const; + void drawControl( ControlElement element, QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default, const QWidget *w = 0 ); + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + private: // Disabled copy constructor and operator= #if defined(Q_DISABLE_COPY) QCompactStyle( const QCompactStyle & ); diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 72e28a8..113716c 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -263,6 +263,13 @@ int QMotifPlusStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ce ret = 11; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 2; + break; + default: ret = QMotifStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -282,6 +289,9 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch (pe) { case PE_HeaderSection: @@ -638,6 +648,47 @@ void QMotifPlusStyle::drawPrimitive( PrimitiveElement pe, break; } + case PE_PanelScrollBar: + { + drawMotifPlusShade(p, r, cg, TRUE, FALSE, &cg.brush(QColorGroup::Mid)); + break; + } + + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); + + qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + break; + } + default: QMotifStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); break; @@ -795,8 +846,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( x+2, y+2, checkcol, h-2 ), r ); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, vrect.x(), y+2, checkcol, h-2*2, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(vrect, @@ -828,13 +878,7 @@ void QMotifPlusStyle::drawControl( ControlElement element, } else if (checkable) { if (mi->isChecked()) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, vrect, cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1147,8 +1191,12 @@ void QMotifPlusStyle::drawComplexControl(ComplexControl control, if (controls == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - drawMotifPlusShade(p, widget->rect(), cg, TRUE, FALSE, - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((maxedOut) ? Style_Default : Style_Enabled) | + ((active == SC_ScrollBarLast) ? + Style_Down : Style_Default) | + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); if ((controls & SC_ScrollBarSubLine) && subline.isValid()) drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, @@ -1559,6 +1607,17 @@ int QMotifPlusStyle::styleHint(StyleHint hint, case SH_PopupMenu_MouseTracking: ret = 1; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if (checkable) + maxpmw = QMAX(maxpmw, 15); + + ret = maxpmw; + break; + } default: ret = QMotifStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index e91e0d0..826cd16 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -211,6 +211,9 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch( pe ) { #ifndef QT_NO_LISTVIEW case PE_CheckListExclusiveIndicator: { @@ -761,6 +764,52 @@ void QMotifStyle::drawPrimitive( PrimitiveElement pe, r.height() - 4, cg.brush(QColorGroup::Highlight)); break; + case PE_PanelScrollBar: + qDrawShadePanel(p, r, cg, TRUE, + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags), + &cg.brush(QColorGroup::Mid)); + break; + + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + break; + } + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x+motifItemFrame, y+motifItemFrame, checkcol, h-2*motifItemFrame ), r ); + int xvis = vrect.x(); + int mw = checkcol; + int mh = h - 2*motifItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, QRect(xvis, y+motifItemFrame, mw, mh), cg, cflags); + break; + } + default: QCommonStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -1050,8 +1099,7 @@ void QMotifStyle::drawControl( ControlElement element, int xvis = vrect.x(); if ( mi->isChecked() ) { if ( mi->iconSet() ) { - qDrawShadePanel( p, xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else if ( !act ) { p->fillRect(xvis, y+motifItemFrame, checkcol, h-2*motifItemFrame, @@ -1076,18 +1124,8 @@ void QMotifStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else if ( checkable ) { // just "checking"... - int mw = checkcol; - int mh = h - 2*motifItemFrame; if ( mi->isChecked() ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - QRect(xvis, y+motifItemFrame, mw, mh), - cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1339,9 +1377,10 @@ void QMotifStyle::drawComplexControl( ComplexControl control, if (sub == (SC_ScrollBarAddLine | SC_ScrollBarSubLine | SC_ScrollBarAddPage | SC_ScrollBarSubPage | SC_ScrollBarFirst | SC_ScrollBarLast | SC_ScrollBarSlider)) - qDrawShadePanel(p, ceData.rect, cg, TRUE, - pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget), - &cg.brush(QColorGroup::Mid)); + drawPrimitive(PE_PanelScrollBar, p, ceData, elementFlags, ceData.rect, cg, + ((ceData.orientation == Qt::Horizontal) ? + Style_Horizontal : Style_Default)); + QCommonStyle::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget); break; @@ -1538,6 +1577,13 @@ int QMotifStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceDat ret = 13; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = motifItemFrame; + break; + default: ret = QCommonStyle::pixelMetric( metric, ceData, elementFlags, widget ); break; @@ -2346,6 +2392,18 @@ int QMotifStyle::styleHint(StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + maxpmw = QMAX( maxpmw, motifCheckMarkSpace ); + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index a66fcda..eb59d11 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -398,6 +398,14 @@ int QSGIStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, case PM_SplitterWidth: return QMAX( 10, QApplication::globalStrut().width() ); + case PM_MenuIndicatorFrameHBorder: + return (sgiItemFrame+2); + case PM_MenuIndicatorFrameVBorder: + return (sgiItemFrame+4); + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return sgiItemFrame; + default: break; } @@ -567,6 +575,9 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags ); bool hot = ( flags & Style_MouseOver ) && ( flags & Style_Enabled ); + bool dis = ! (flags & Style_Enabled); + bool act = flags & Style_Active; + switch ( pe ) { case PE_ButtonCommand: { @@ -878,6 +889,51 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect(&x, &y, &w, &h); + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, pixelMetric(PM_IndicatorWidth, ceData, elementFlags), pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); + er.addCoords( 1, 1, -1, -1 ); + er.addCoords( 0, 1, 1, 1 ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + } + break; + default: QMotifStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; @@ -990,8 +1046,7 @@ void QSGIStyle::drawControl( ControlElement element, if ( mi->isChecked() ) { if ( mi->iconSet() ) { - drawPanel( p, x+sgiItemFrame, y+sgiItemFrame, checkcol, h-2*sgiItemFrame, - cg, TRUE, 1, &cg.brush( QColorGroup::Light ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } else { if ( !act ) @@ -1018,20 +1073,9 @@ void QSGIStyle::drawControl( ControlElement element, p->drawPixmap( pmr.topLeft(), pixmap ); } else { if ( checkable ) { - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - if ( mi->isChecked() ) { - QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, - pixelMetric(PM_IndicatorWidth, ceData, elementFlags), - pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); - er.addCoords( 1, 1, -1, -1 ); - drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); - er.addCoords( 0, 1, 1, 1 ); - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } } @@ -1467,4 +1511,28 @@ QRect QSGIStyle::querySubControlMetrics( ComplexControl control, return QMotifStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); } +/*! \reimp */ +int QSGIStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &opt, QStyleHintReturn *returnData, const QWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) + maxpmw = QMAX( maxpmw, sgiCheckMarkSpace ); + ret = maxpmw; + } + break; + default: + ret = QMotifStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + #endif // QT_NO_STYLE_SGI diff --git a/src/styles/qsgistyle.h b/src/styles/qsgistyle.h index 0afacd6..17bdb05 100644 --- a/src/styles/qsgistyle.h +++ b/src/styles/qsgistyle.h @@ -124,6 +124,8 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; + int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget *) const; + bool objectEventHandler( QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, QEvent *e ); private: diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 4bdb421..f93e31a 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -225,6 +225,9 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, SFlags flags, const QStyleOption& opt ) const { + bool dis = !(flags & Style_Enabled); + bool act = flags & Style_Active; + QRect rr( r ); switch (pe) { case PE_ButtonCommand: @@ -568,6 +571,63 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe, } break; + case PE_MenuItemIndicatorFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); + int xvis = vrect.x(); + + if ( act && !dis ) { + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + } + else { + QBrush fill( cg.light(), Dense4Pattern ); + // set the brush origin for the hash pattern to the x/y coordinate + // of the menu item's checkmark... this way, the check marks have + // a consistent look + QPoint origin = p->brushOrigin(); + p->setBrushOrigin( xvis, y ); + qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill ); + // restore the previous brush origin + p->setBrushOrigin( origin ); + } + } + break; + + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + QRect vrect = visualRect( QRect( x, y, checkcol, h ), r ); + int xvis = vrect.x(); + + qDrawShadePanel( p, xvis, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + } + break; + + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int xp = x + windowsItemFrame; + + SFlags cflags = Style_Default; + if (! dis) + cflags |= Style_Enabled; + if (act) + cflags |= Style_On; + + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, checkcol - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); + } + break; + default: if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) { QPointArray a; @@ -809,21 +869,7 @@ void QWindowsStyle::drawControl( ControlElement element, QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r ); int xvis = vrect.x(); if ( mi->isChecked() ) { - if ( act && !dis ) - qDrawShadePanel( p, xvis, y, checkcol, h, - cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); - else { - QBrush fill( cg.light(), Dense4Pattern ); - // set the brush origin for the hash pattern to the x/y coordinate - // of the menu item's checkmark... this way, the check marks have - // a consistent look - QPoint origin = p->brushOrigin(); - p->setBrushOrigin( xvis, y ); - qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, - &fill ); - // restore the previous brush origin - p->setBrushOrigin( origin ); - } + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); } else if (! act) p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button )); @@ -839,8 +885,7 @@ void QWindowsStyle::drawControl( ControlElement element, int pixw = pixmap.width(); int pixh = pixmap.height(); if ( act && !dis && !mi->isChecked() ) - qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1, - &cg.brush( QColorGroup::Button ) ); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); QRect pmr( 0, 0, pixw, pixh ); pmr.moveCenter( vrect.center() ); p->setPen( cg.text() ); @@ -851,20 +896,9 @@ void QWindowsStyle::drawControl( ControlElement element, cg.brush( QColorGroup::Button )); int xp = xpos + checkcol + 1; p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill); - } else if ( checkable ) { // just "checking"... + } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - int xp = xpos + windowsItemFrame; - - SFlags cflags = Style_Default; - if (! dis) - cflags |= Style_Enabled; - if (act) - cflags |= Style_On; - - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, - visualRect( QRect(xp, y + windowsItemFrame, - checkcol - 2*windowsItemFrame, - h - 2*windowsItemFrame), r ), cg, cflags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -1042,6 +1076,13 @@ int QWindowsStyle::pixelMetric(PixelMetric metric, QStyleControlElementData ceDa ret = QMAX( 6, QApplication::globalStrut().width() ); break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = windowsItemFrame; + break; + default: ret = QCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -1965,6 +2006,23 @@ int QWindowsStyle::styleHint( StyleHint hint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = opt.maxIconWidth(); + bool checkable = ( elementFlags & CEF_IsCheckable ); + + if ( checkable ) { + // space for the checkmarks + if (use2000style) + maxpmw = QMAX( maxpmw, 20 ); + else + maxpmw = QMAX( maxpmw, 12 ); + } + + ret = maxpmw; + break; + } + default: ret = QCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; |