diff options
author | Timothy Pearson <[email protected]> | 2012-10-31 12:39:27 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-10-31 12:39:27 -0500 |
commit | a5ced706e9295f4f3c1e95c829750dff0d808935 (patch) | |
tree | cd1851fcfaa1639c8ab9fc3b8ee166b13a745257 /src/styles/qsgistyle.cpp | |
parent | 69429dcfc35d449c78b346bdce536f17d926c755 (diff) | |
download | qt3-a5ced706e9295f4f3c1e95c829750dff0d808935.tar.gz qt3-a5ced706e9295f4f3c1e95c829750dff0d808935.zip |
Add new style hints for enhanced third party style compatibility
Diffstat (limited to 'src/styles/qsgistyle.cpp')
-rw-r--r-- | src/styles/qsgistyle.cpp | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index b65100c..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; } @@ -881,7 +889,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, } break; - case PE_MenuItemIndicatorCheck: + case PE_MenuItemIndicatorFrame: { int x, y, w, h; r.rect(&x, &y, &w, &h); @@ -895,6 +903,32 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, 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 ); } @@ -1012,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 ) @@ -1041,7 +1074,8 @@ void QSGIStyle::drawControl( ControlElement element, } else { if ( checkable ) { if ( mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, w, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } } } @@ -1477,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 |