summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2010-01-08 11:55:20 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2010-01-08 11:56:55 (GMT)
commitd40219cc9e0a5e078a9c9e874dc4d5f3efb98e3e (patch)
tree74e6b9f24d7e6fa1d4cc1868a504d3c802bf1de5 /src
parent2530a32d5e02f2cde0cdf3d6d4e42a0079d669fd (diff)
downloadQt-d40219cc9e0a5e078a9c9e874dc4d5f3efb98e3e.zip
Qt-d40219cc9e0a5e078a9c9e874dc4d5f3efb98e3e.tar.gz
Qt-d40219cc9e0a5e078a9c9e874dc4d5f3efb98e3e.tar.bz2
Fixes: Fix spinbox with NoButton style in QGtkStyle
Task: QTBUG-6952 RevBy: ogoffart Details: We simply need to handle this case explicitly to draw like a GtkEntry.
Diffstat (limited to 'src')
-rw-r--r--src/gui/styles/qgtkstyle.cpp97
1 files changed, 53 insertions, 44 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 920a0f7..abb9e1e 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -1736,7 +1736,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
+
+ GtkWidget *gtkSpinButton = d->gtkWidget(
+ spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ?
+ QLS("GtkEntry") :
+ QLS("GtkSpinButton"));
bool isEnabled = (spinBox->state & State_Enabled);
bool hover = isEnabled && (spinBox->state & State_MouseOver);
bool sunken = (spinBox->state & State_Sunken);
@@ -1744,32 +1748,35 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
bool reverse = (spinBox->direction == Qt::RightToLeft);
- //### Move this to subControlRect
- QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
- upRect.setTop(option->rect.top());
+ QRect editArea = option->rect;
+ QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
+ QRect upRect, downRect, buttonRect;
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
+ downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
- if (reverse)
- upRect.setLeft(option->rect.left());
- else
- upRect.setRight(option->rect.right());
+ //### Move this to subControlRect
+ upRect.setTop(option->rect.top());
- QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
- QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
- downRect.setBottom(option->rect.bottom());
+ if (reverse)
+ upRect.setLeft(option->rect.left());
+ else
+ upRect.setRight(option->rect.right());
- if (reverse)
- downRect.setLeft(option->rect.left());
- else
- downRect.setRight(option->rect.right());
+ downRect.setBottom(option->rect.bottom());
- QRect buttonRect = upRect | downRect;
- QRect editArea = option->rect;
+ if (reverse)
+ downRect.setLeft(option->rect.left());
+ else
+ downRect.setRight(option->rect.right());
- if (reverse)
- editArea.setLeft(upRect.right());
- else
- editArea.setRight(upRect.left());
+ buttonRect = upRect | downRect;
+ if (reverse)
+ editArea.setLeft(upRect.right());
+ else
+ editArea.setRight(upRect.left());
+ }
if (spinBox->frame) {
GtkShadowType shadow = GTK_SHADOW_OUT;
GtkStateType state = gtkPainter.gtkState(option);
@@ -1803,29 +1810,31 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key);
- gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
-
- upRect.setSize(downRect.size());
- if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
-
- if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
+
+ upRect.setSize(downRect.size());
+ if (!(option->state & State_Enabled))
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ else if (upIsActive && sunken)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ else if (upIsActive && hover)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ else
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+
+ if (!(option->state & State_Enabled))
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ else if (downIsActive && sunken)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ else if (downIsActive && hover)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ else
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
- if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ }
}
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
@@ -1850,7 +1859,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
}
- } else {
+ } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
int size = d->getSpinboxArrowSize();
int w = size / 2 - 1;
w -= w % 2 - 1; // force odd