diff options
author | David Boddie <dboddie@trolltech.com> | 2009-11-19 13:53:04 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-11-19 13:53:04 (GMT) |
commit | 4e53466f63bf05e90a69f80fda8580dabc1e9ed0 (patch) | |
tree | 0978f427af78291d8dd16004cc4ca33dbe1af433 /src/gui/styles/qgtkstyle.cpp | |
parent | 5bd71902f97ba75dc93ccf709dbfdd2ffeb361b2 (diff) | |
parent | fbbdf8698fb0444d5170b7d0a14e870ea789398f (diff) | |
download | Qt-4e53466f63bf05e90a69f80fda8580dabc1e9ed0.zip Qt-4e53466f63bf05e90a69f80fda8580dabc1e9ed0.tar.gz Qt-4e53466f63bf05e90a69f80fda8580dabc1e9ed0.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'src/gui/styles/qgtkstyle.cpp')
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 70b7aa3..5566cc6 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -2521,7 +2521,7 @@ void QGtkStyle::drawControl(ControlElement element, bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; if (selected) { - QRect rect = option->rect.adjusted(0, 0, -1, -1); + QRect rect = option->rect.adjusted(0, 0, 0, -1); #ifndef QT_NO_COMBOBOX if (qobject_cast<const QComboBox*>(widget)) rect = option->rect; @@ -2628,7 +2628,7 @@ void QGtkStyle::drawControl(ControlElement element, int pixw = pixmap.width(); int pixh = pixmap.height(); QRect pmr(0, 0, pixw, pixh); - pmr.moveCenter(vCheckRect.center()); + pmr.moveCenter(vCheckRect.center() - QPoint(0, 1)); painter->setPen(menuItem->palette.text().color()); if (!ignoreCheckMark && checkable && checked) { QStyleOption opt = *option; @@ -2670,8 +2670,8 @@ void QGtkStyle::drawControl(ControlElement element, menuitem->rect.getRect(&x, &y, &w, &h); int tab = menuitem->tabWidth; int xm = windowsItemFrame + checkcol + windowsItemHMargin; - int xpos = menuitem->rect.x() + xm; - QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); + int xpos = menuitem->rect.x() + xm + 1; + QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); QString s = menuitem->text; @@ -2718,13 +2718,19 @@ void QGtkStyle::drawControl(ControlElement element, QFontMetrics fm(menuitem->font); int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; gfloat arrow_scaling = 0.8; + int extra = 0; + if (!d->gtk_check_version(2, 16, 0)) { + // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c) + // though the current documentation states otherwise + d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL); + // in versions < 2.16 ythickness was previously subtracted from the arrow_size + extra = 2 * gtkMenuItem->style->ythickness; + } - // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c) - // though the current documentation states otherwise int horizontal_padding; d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL); - const int dim = static_cast<int>(arrow_size * arrow_scaling); + const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra; int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim; QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, QRect(xpos, menuItem->rect.top() + @@ -3123,7 +3129,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); - newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness); + newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness); if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { QSize minSize(0, 25); if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly) @@ -3155,7 +3161,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); GtkStyle* style = gtkMenuItem->style; - newSize += QSize(textMargin + style->xthickness - 2, style->ythickness - 4); + newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3); // Cleanlooks assumes a check column of 20 pixels so we need to // expand it a bit @@ -3175,7 +3181,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_SpinBox: // QSpinBox does some nasty things that depends on CT_LineEdit - newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2 + 2); + newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2); break; case CT_PushButton: @@ -3206,13 +3212,9 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, } break; - case CT_MenuBarItem://cleanlooks adds 2 pixels - newSize = QWindowsStyle::sizeFromContents(type, option, size, widget) + QSize(0, 1); - break; - case CT_LineEdit: { GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); - newSize = size + QSize(2*gtkEntry->style->xthickness, 2*gtkEntry->style->ythickness); + newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness); } break; @@ -3227,7 +3229,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness); if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget()))) - newSize += QSize(0, 3); + newSize += QSize(0, 2); } break; @@ -3240,7 +3242,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, if (!tab->icon.isNull()) newSize += QSize(6, 0); } - newSize += QSize(1, 0); + newSize += QSize(1, 1); break; default: |