1375 resolve_mask & (1 << QPalette::Base)) // Palette overridden by user |
1375 resolve_mask & (1 << QPalette::Base)) // Palette overridden by user |
1376 p->fillRect(contentRect, option->palette.base().color()); |
1376 p->fillRect(contentRect, option->palette.base().color()); |
1377 else { |
1377 else { |
1378 gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, |
1378 gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, |
1379 option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, |
1379 option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, |
1380 GTK_SHADOW_NONE, gtkCombo->style, entryPath + QString::number(focus)); |
1380 GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus)); |
1381 } |
1381 } |
1382 |
1382 |
1383 gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, |
1383 gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, |
1384 GTK_SHADOW_IN, gtkEntry->style, entryPath + |
1384 GTK_SHADOW_IN, gtkEntry->style, entryPath + |
1385 QString::number(focus) + QString::number(comboBox->editable) + |
1385 QString::number(focus) + QString::number(comboBox->editable) + |
1734 #endif //QT_NO_SCROLLBAR |
1734 #endif //QT_NO_SCROLLBAR |
1735 #ifndef QT_NO_SPINBOX |
1735 #ifndef QT_NO_SPINBOX |
1736 |
1736 |
1737 case CC_SpinBox: |
1737 case CC_SpinBox: |
1738 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
1738 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
1739 GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); |
1739 |
|
1740 GtkWidget *gtkSpinButton = d->gtkWidget( |
|
1741 spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ? |
|
1742 QLS("GtkEntry") : |
|
1743 QLS("GtkSpinButton")); |
1740 bool isEnabled = (spinBox->state & State_Enabled); |
1744 bool isEnabled = (spinBox->state & State_Enabled); |
1741 bool hover = isEnabled && (spinBox->state & State_MouseOver); |
1745 bool hover = isEnabled && (spinBox->state & State_MouseOver); |
1742 bool sunken = (spinBox->state & State_Sunken); |
1746 bool sunken = (spinBox->state & State_Sunken); |
1743 bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); |
1747 bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); |
1744 bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); |
1748 bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); |
1745 bool reverse = (spinBox->direction == Qt::RightToLeft); |
1749 bool reverse = (spinBox->direction == Qt::RightToLeft); |
1746 |
1750 |
1747 //### Move this to subControlRect |
1751 QRect editArea = option->rect; |
1748 QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); |
|
1749 upRect.setTop(option->rect.top()); |
|
1750 |
|
1751 if (reverse) |
|
1752 upRect.setLeft(option->rect.left()); |
|
1753 else |
|
1754 upRect.setRight(option->rect.right()); |
|
1755 |
|
1756 QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); |
1752 QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); |
1757 QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); |
1753 QRect upRect, downRect, buttonRect; |
1758 downRect.setBottom(option->rect.bottom()); |
1754 if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { |
1759 |
1755 upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); |
1760 if (reverse) |
1756 downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); |
1761 downRect.setLeft(option->rect.left()); |
1757 |
1762 else |
1758 //### Move this to subControlRect |
1763 downRect.setRight(option->rect.right()); |
1759 upRect.setTop(option->rect.top()); |
1764 |
1760 |
1765 QRect buttonRect = upRect | downRect; |
1761 if (reverse) |
1766 QRect editArea = option->rect; |
1762 upRect.setLeft(option->rect.left()); |
1767 |
1763 else |
1768 if (reverse) |
1764 upRect.setRight(option->rect.right()); |
1769 editArea.setLeft(upRect.right()); |
1765 |
1770 else |
1766 downRect.setBottom(option->rect.bottom()); |
1771 editArea.setRight(upRect.left()); |
1767 |
1772 |
1768 if (reverse) |
|
1769 downRect.setLeft(option->rect.left()); |
|
1770 else |
|
1771 downRect.setRight(option->rect.right()); |
|
1772 |
|
1773 buttonRect = upRect | downRect; |
|
1774 |
|
1775 if (reverse) |
|
1776 editArea.setLeft(upRect.right()); |
|
1777 else |
|
1778 editArea.setRight(upRect.left()); |
|
1779 } |
1773 if (spinBox->frame) { |
1780 if (spinBox->frame) { |
1774 GtkShadowType shadow = GTK_SHADOW_OUT; |
1781 GtkShadowType shadow = GTK_SHADOW_OUT; |
1775 GtkStateType state = gtkPainter.gtkState(option); |
1782 GtkStateType state = gtkPainter.gtkState(option); |
1776 |
1783 |
1777 if (!(option->state & State_Enabled)) |
1784 if (!(option->state & State_Enabled)) |
1801 -style->xthickness, -style->ythickness), |
1808 -style->xthickness, -style->ythickness), |
1802 option->state & State_Enabled ? |
1809 option->state & State_Enabled ? |
1803 GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key); |
1810 GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key); |
1804 |
1811 |
1805 gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key); |
1812 gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key); |
1806 gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); |
1813 if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { |
1807 |
1814 gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); |
1808 upRect.setSize(downRect.size()); |
1815 |
1809 if (!(option->state & State_Enabled)) |
1816 upRect.setSize(downRect.size()); |
1810 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
1817 if (!(option->state & State_Enabled)) |
1811 else if (upIsActive && sunken) |
1818 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
1812 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
1819 else if (upIsActive && sunken) |
1813 else if (upIsActive && hover) |
1820 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
1814 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
1821 else if (upIsActive && hover) |
1815 else |
1822 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
1816 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
1823 else |
1817 |
1824 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
1818 if (!(option->state & State_Enabled)) |
1825 |
1819 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
1826 if (!(option->state & State_Enabled)) |
1820 else if (downIsActive && sunken) |
1827 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
1821 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
1828 else if (downIsActive && sunken) |
1822 else if (downIsActive && hover) |
1829 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
1823 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
1830 else if (downIsActive && hover) |
1824 else |
1831 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
1825 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
1832 else |
1826 |
1833 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
1827 if (option->state & State_HasFocus) |
1834 |
1828 GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); |
1835 if (option->state & State_HasFocus) |
|
1836 GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); |
|
1837 } |
1829 } |
1838 } |
1830 |
1839 |
1831 if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { |
1840 if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { |
1832 int centerX = upRect.center().x(); |
1841 int centerX = upRect.center().x(); |
1833 int centerY = upRect.center().y(); |
1842 int centerY = upRect.center().y(); |
2507 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
2515 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
2508 painter->setPen(shadow.lighter(106)); |
2516 painter->setPen(shadow.lighter(106)); |
2509 gboolean wide_separators = 0; |
2517 gboolean wide_separators = 0; |
2510 gint separator_height = 0; |
2518 gint separator_height = 0; |
2511 guint horizontal_padding = 3; |
2519 guint horizontal_padding = 3; |
|
2520 QRect separatorRect = option->rect; |
2512 if (!d->gtk_check_version(2, 10, 0)) { |
2521 if (!d->gtk_check_version(2, 10, 0)) { |
2513 d->gtk_widget_style_get(gtkMenuSeparator, |
2522 d->gtk_widget_style_get(gtkMenuSeparator, |
2514 "wide-separators", &wide_separators, |
2523 "wide-separators", &wide_separators, |
2515 "separator-height", &separator_height, |
2524 "separator-height", &separator_height, |
2516 "horizontal-padding", &horizontal_padding, |
2525 "horizontal-padding", &horizontal_padding, |
2517 NULL); |
2526 NULL); |
2518 } |
2527 } |
|
2528 separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness); |
|
2529 separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness)); |
|
2530 separatorRect.moveCenter(option->rect.center()); |
2519 if (wide_separators) |
2531 if (wide_separators) |
2520 gtkPainter.paintBox( gtkMenuSeparator, "hseparator", |
2532 gtkPainter.paintBox( gtkMenuSeparator, "hseparator", |
2521 option->rect.adjusted(0, 0, 0, -1), GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenu->style); |
2533 separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style); |
2522 else |
2534 else |
2523 gtkPainter.paintHline( gtkMenuSeparator, "hseparator", |
2535 gtkPainter.paintHline( gtkMenuSeparator, "hseparator", |
2524 menuItem->rect, GTK_STATE_NORMAL, gtkMenu->style, |
2536 separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style, |
2525 option->rect.left() + horizontal_padding, option->rect.width() - 2*horizontal_padding, 2); |
2537 0, option->rect.right() - 1, 1); |
2526 painter->restore(); |
2538 painter->restore(); |
2527 break; |
2539 break; |
2528 } |
2540 } |
2529 |
2541 |
2530 bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; |
2542 bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; |
2531 |
2543 |
2532 if (selected) { |
2544 if (selected) { |
2533 QRect rect = option->rect.adjusted(0, 0, 0, -1); |
2545 QRect rect = option->rect; |
2534 #ifndef QT_NO_COMBOBOX |
2546 #ifndef QT_NO_COMBOBOX |
2535 if (qobject_cast<const QComboBox*>(widget)) |
2547 if (qobject_cast<const QComboBox*>(widget)) |
2536 rect = option->rect; |
2548 rect = option->rect; |
2537 #endif |
2549 #endif |
2538 gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style); |
2550 gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style); |
2678 int x, y, w, h; |
2690 int x, y, w, h; |
2679 menuitem->rect.getRect(&x, &y, &w, &h); |
2691 menuitem->rect.getRect(&x, &y, &w, &h); |
2680 int tab = menuitem->tabWidth; |
2692 int tab = menuitem->tabWidth; |
2681 int xm = windowsItemFrame + checkcol + windowsItemHMargin; |
2693 int xm = windowsItemFrame + checkcol + windowsItemHMargin; |
2682 int xpos = menuitem->rect.x() + xm + 1; |
2694 int xpos = menuitem->rect.x() + xm + 1; |
2683 QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); |
2695 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); |
2684 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); |
2696 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); |
2685 QString s = menuitem->text; |
2697 QString s = menuitem->text; |
2686 |
2698 |
2687 if (!s.isEmpty()) { // Draw text |
2699 if (!s.isEmpty()) { // Draw text |
2688 p->save(); |
2700 p->save(); |
3148 |
3160 |
3149 if (toolbutton->features & QStyleOptionToolButton::HasMenu) |
3161 if (toolbutton->features & QStyleOptionToolButton::HasMenu) |
3150 newSize += QSize(6, 0); |
3162 newSize += QSize(6, 0); |
3151 } |
3163 } |
3152 break; |
3164 break; |
3153 |
|
3154 case CT_MenuItem: |
3165 case CT_MenuItem: |
3155 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
3166 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
3156 int textMargin = 8; |
3167 int textMargin = 8; |
3157 |
3168 |
3158 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
3169 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
3159 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
3170 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
3160 gboolean wide_separators; |
3171 GtkRequisition sizeReq = {0, 0}; |
3161 gint separator_height; |
3172 d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); |
3162 d->gtk_widget_style_get(gtkMenuSeparator, |
3173 newSize = QSize(size.width(), sizeReq.height); |
3163 "wide-separators", &wide_separators, |
|
3164 "separator-height", &separator_height, |
|
3165 NULL); |
|
3166 newSize = QSize(size.width(), wide_separators ? separator_height - 1 : 7 ); |
|
3167 |
|
3168 break; |
3174 break; |
3169 } |
3175 } |
3170 |
3176 |
3171 GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); |
3177 GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); |
3172 GtkStyle* style = gtkMenuItem->style; |
3178 GtkStyle* style = gtkMenuItem->style; |
3173 newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3); |
3179 |
|
3180 // Note we get the perfect height for the default font since we |
|
3181 // set a fake text label on the gtkMenuItem |
|
3182 // But if custom fonts are used on the widget we need a minimum size |
|
3183 GtkRequisition sizeReq = {0, 0}; |
|
3184 d->gtk_widget_size_request(gtkMenuItem, &sizeReq); |
|
3185 newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); |
|
3186 newSize += QSize(textMargin + style->xthickness - 1, 0); |
3174 |
3187 |
3175 // Cleanlooks assumes a check column of 20 pixels so we need to |
3188 // Cleanlooks assumes a check column of 20 pixels so we need to |
3176 // expand it a bit |
3189 // expand it a bit |
3177 gint checkSize; |
3190 gint checkSize; |
3178 d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); |
3191 d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); |
3179 newSize.setHeight(qMax(newSize.height(), checkSize + 2)); |
|
3180 newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); |
3192 newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); |
3181 } |
3193 } |
3182 |
|
3183 break; |
|
3184 |
|
3185 case CT_Menu: |
|
3186 // This is evil, but QMenu adds 1 pixel too much |
|
3187 newSize -= QSize(0, 1); |
|
3188 |
3194 |
3189 break; |
3195 break; |
3190 |
3196 |
3191 case CT_SpinBox: |
3197 case CT_SpinBox: |
3192 // QSpinBox does some nasty things that depends on CT_LineEdit |
3198 // QSpinBox does some nasty things that depends on CT_LineEdit |