summaryrefslogtreecommitdiffstats
path: root/src/styles/qwindowsstyle.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-10-31 12:39:27 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-10-31 12:39:27 -0500
commita5ced706e9295f4f3c1e95c829750dff0d808935 (patch)
treecd1851fcfaa1639c8ab9fc3b8ee166b13a745257 /src/styles/qwindowsstyle.cpp
parent69429dcfc35d449c78b346bdce536f17d926c755 (diff)
downloadqt3-a5ced706e9295f4f3c1e95c829750dff0d808935.tar.gz
qt3-a5ced706e9295f4f3c1e95c829750dff0d808935.zip
Add new style hints for enhanced third party style compatibility
Diffstat (limited to 'src/styles/qwindowsstyle.cpp')
-rw-r--r--src/styles/qwindowsstyle.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp
index 578b32f..f93e31a 100644
--- a/src/styles/qwindowsstyle.cpp
+++ b/src/styles/qwindowsstyle.cpp
@@ -575,12 +575,13 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
{
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, w, h ), r );
+ QRect vrect = visualRect( QRect( x, y, checkcol, h ), r );
int xvis = vrect.x();
if ( act && !dis ) {
- qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
+ qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
}
else {
QBrush fill( cg.light(), Dense4Pattern );
@@ -589,7 +590,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
// a consistent look
QPoint origin = p->brushOrigin();
p->setBrushOrigin( xvis, y );
- qDrawShadePanel( p, xvis, y, w, h, cg, TRUE, 1, &fill );
+ qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1, &fill );
// restore the previous brush origin
p->setBrushOrigin( origin );
}
@@ -600,8 +601,9 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
{
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, w, h ), r );
+ 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 ) );
@@ -612,6 +614,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
{
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;
@@ -621,7 +624,7 @@ void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
if (act)
cflags |= Style_On;
- drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, w - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags);
+ drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( QRect(xp, y + windowsItemFrame, checkcol - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags);
}
break;
@@ -866,7 +869,7 @@ void QWindowsStyle::drawControl( ControlElement element,
QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r );
int xvis = vrect.x();
if ( mi->isChecked() ) {
- drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags);
+ drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt);
} else if (! act)
p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button ));
@@ -882,7 +885,7 @@ void QWindowsStyle::drawControl( ControlElement element,
int pixw = pixmap.width();
int pixh = pixmap.height();
if ( act && !dis && !mi->isChecked() )
- drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags);
+ drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt);
QRect pmr( 0, 0, pixw, pixh );
pmr.moveCenter( vrect.center() );
p->setPen( cg.text() );
@@ -895,7 +898,7 @@ void QWindowsStyle::drawControl( ControlElement element,
p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill);
} else if ( checkable ) { // just "checking"...
if ( mi->isChecked() ) {
- drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, QRect(x, y, checkcol, h), cg, flags);
+ drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt);
}
}
@@ -1073,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;
@@ -1996,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;