diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-10-31 12:39:27 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-10-31 12:39:27 -0500 |
commit | a5ced706e9295f4f3c1e95c829750dff0d808935 (patch) | |
tree | cd1851fcfaa1639c8ab9fc3b8ee166b13a745257 /src/styles/qcompactstyle.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/qcompactstyle.cpp')
-rw-r--r-- | src/styles/qcompactstyle.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/styles/qcompactstyle.cpp b/src/styles/qcompactstyle.cpp index 5b83f0e..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,7 +195,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont return; if ( mi->isChecked() ) { - drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } else if ( !act ) { p->fillRect(x, y, checkcol , h, g.brush( QColorGroup::Button )); @@ -208,7 +214,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont int pixh = pixmap.height(); if ( act && !dis ) { if ( !mi->isChecked() ) - drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, itemg, flags, opt ); } QRect cr( x, y, checkcol, h ); QRect pmr( 0, 0, pixw, pixh ); @@ -221,7 +227,7 @@ void QCompactStyle::drawControl( ControlElement element, QPainter *p, QStyleCont p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill); } else if ( checkable ) { // just "checking"... if ( mi->isChecked() ) { - drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), itemg, flags, opt ); + drawPrimitive( PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, itemg, flags, opt ); } } @@ -322,21 +328,27 @@ void QCompactStyle::drawPrimitive( PrimitiveElement pe, switch (pe) { case PE_MenuItemIndicatorFrame: { + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + if ( act && !dis ) { - qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) ); } else { - qDrawShadePanel( p, x, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); + qDrawShadePanel( p, x, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Midlight ) ); } } break; case PE_MenuItemIndicatorIconFrame: { - qDrawShadePanel( p, x, y, w, h, cg, FALSE, 1, &cg.brush( QColorGroup::Button ) ); + 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 mw = w + motifItemFrame; + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + int mw = checkcol + motifItemFrame; int mh = h - 2*motifItemFrame; SFlags cflags = Style_Default; @@ -355,4 +367,29 @@ void QCompactStyle::drawPrimitive( PrimitiveElement pe, } } +/*! \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 |