summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2009-10-07 14:15:43 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2009-10-07 14:21:08 (GMT)
commitdbaa856d4d20840394baf8f4c9abf78051a6693a (patch)
treecaa532e34392d6179bb3583f7a3f6f15cb56264f /src/gui/styles
parente4606e2d6491bd7020e8bfb12665c3addc24b7e3 (diff)
downloadQt-dbaa856d4d20840394baf8f4c9abf78051a6693a.zip
Qt-dbaa856d4d20840394baf8f4c9abf78051a6693a.tar.gz
Qt-dbaa856d4d20840394baf8f4c9abf78051a6693a.tar.bz2
Fix split tool button drawing on Vista when not in a tool bar
When a tool button is not in a tool bar on XP and Vista it will get a slightly different appearance from normal tool buttons. I resolved this by drawing a normal tool button with a divider line on top if the autoraise property is not set on the button. (which is by default enabled only for buttons in a tool bar). Task-number: QTBUG-5061 Reviewed-by: prasanth
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 2f00f07..b5dc647 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -2841,8 +2841,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
State bflags = toolbutton->state & ~State_Sunken;
State mflags = bflags;
-
- if (bflags & State_AutoRaise) {
+ bool autoRaise = flags & State_AutoRaise;
+ if (autoRaise) {
if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
bflags &= ~State_Raised;
}
@@ -2861,8 +2861,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
QStyleOption tool(0);
tool.palette = toolbutton->palette;
if (toolbutton->subControls & SC_ToolButton) {
- if (flags & (State_Sunken | State_On | State_Raised) || !(flags & State_AutoRaise)) {
- if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) {
+ if (flags & (State_Sunken | State_On | State_Raised) || !autoRaise) {
+ if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup && autoRaise) {
XPThemeData theme(widget, p, QLatin1String("TOOLBAR"));
theme.partId = TP_SPLITBUTTON;
theme.rect = button;
@@ -2881,13 +2881,12 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
theme.stateId = stateId;
d->drawBackground(theme);
} else {
- tool.rect = button;
+ tool.rect = option->rect;
tool.state = bflags;
- if (widget && !qobject_cast<QToolBar*>(widget->parentWidget())
- && !(bflags & State_AutoRaise))
- proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget);
- else
+ if (autoRaise) // for tool bars
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
+ else
+ proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget);
}
}
}
@@ -2904,13 +2903,40 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
QStyleOptionToolButton label = *toolbutton;
label.state = bflags;
int fw = 2;
+ if (!autoRaise)
+ label.state &= ~State_Sunken;
label.rect = button.adjusted(fw, fw, -fw, -fw);
proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
if (toolbutton->subControls & SC_ToolButtonMenu) {
tool.rect = menuarea;
tool.state = mflags;
- proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
+ if (autoRaise) {
+ proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
+ } else {
+ tool.state = mflags;
+ menuarea.adjust(-2, 0, 0, 0);
+ // Draw menu button
+ if ((bflags & State_Sunken) != (mflags & State_Sunken)){
+ p->save();
+ p->setClipRect(menuarea);
+ tool.rect = option->rect;
+ proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0);
+ p->restore();
+ }
+ // Draw arrow
+ p->save();
+ p->setPen(option->palette.dark());
+ p->drawLine(menuarea.left(), menuarea.top() + 3,
+ menuarea.left(), menuarea.bottom() - 3);
+ p->setPen(option->palette.light());
+ p->drawLine(menuarea.left() - 1, menuarea.top() + 3,
+ menuarea.left() - 1, menuarea.bottom() - 3);
+
+ tool.rect = menuarea.adjusted(2, 3, -2, -1);
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
+ p->restore();
+ }
} else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
QRect ir = toolbutton->rect;