Changeset 651 for trunk/src/gui/styles/qgtkstyle.cpp
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/styles/qgtkstyle.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 1107 1107 // Murrine engine requires a widget not to get RGBA check - warnings 1108 1108 GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); 1109 gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, QLS("radiobutton")); 1110 1109 QString key(QLS("radiobutton")); 1110 if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag 1111 key += QLatin1Char('f'); 1112 GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); 1113 } 1114 gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key); 1115 if (option->state & State_HasFocus) 1116 GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); 1111 1117 } 1112 1118 break; … … 1129 1135 1130 1136 GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); 1137 QString key(QLS("checkbutton")); 1138 if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag 1139 key += QLatin1Char('f'); 1140 GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); 1141 } 1131 1142 1132 1143 // Some styles such as aero-clone assume they can paint in the spacing area … … 1138 1149 1139 1150 gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style, 1140 QLS("checkbutton")); 1151 key); 1152 if (option->state & State_HasFocus) 1153 GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); 1154 1141 1155 } 1142 1156 break; … … 1378 1392 gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, 1379 1393 option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, 1380 GTK_SHADOW_NONE, gtk Combo->style, entryPath + QString::number(focus));1394 GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus)); 1381 1395 } 1382 1396 … … 1737 1751 case CC_SpinBox: 1738 1752 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { 1739 GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); 1753 1754 GtkWidget *gtkSpinButton = d->gtkWidget( 1755 spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ? 1756 QLS("GtkEntry") : 1757 QLS("GtkSpinButton")); 1740 1758 bool isEnabled = (spinBox->state & State_Enabled); 1741 1759 bool hover = isEnabled && (spinBox->state & State_MouseOver); … … 1745 1763 bool reverse = (spinBox->direction == Qt::RightToLeft); 1746 1764 1747 //### Move this to subControlRect 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 1765 QRect editArea = option->rect; 1756 1766 QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); 1757 QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); 1758 downRect.setBottom(option->rect.bottom()); 1759 1760 if (reverse) 1761 downRect.setLeft(option->rect.left()); 1762 else 1763 downRect.setRight(option->rect.right()); 1764 1765 QRect buttonRect = upRect | downRect; 1766 QRect editArea = option->rect; 1767 1768 if (reverse) 1769 editArea.setLeft(upRect.right()); 1770 else 1771 editArea.setRight(upRect.left()); 1772 1767 QRect upRect, downRect, buttonRect; 1768 if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { 1769 upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); 1770 downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); 1771 1772 //### Move this to subControlRect 1773 upRect.setTop(option->rect.top()); 1774 1775 if (reverse) 1776 upRect.setLeft(option->rect.left()); 1777 else 1778 upRect.setRight(option->rect.right()); 1779 1780 downRect.setBottom(option->rect.bottom()); 1781 1782 if (reverse) 1783 downRect.setLeft(option->rect.left()); 1784 else 1785 downRect.setRight(option->rect.right()); 1786 1787 buttonRect = upRect | downRect; 1788 1789 if (reverse) 1790 editArea.setLeft(upRect.right()); 1791 else 1792 editArea.setRight(upRect.left()); 1793 } 1773 1794 if (spinBox->frame) { 1774 1795 GtkShadowType shadow = GTK_SHADOW_OUT; … … 1804 1825 1805 1826 gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key); 1806 gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); 1807 1808 upRect.setSize(downRect.size()); 1809 if (!(option->state & State_Enabled)) 1810 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); 1811 else if (upIsActive && sunken) 1812 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); 1813 else if (upIsActive && hover) 1814 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); 1815 else 1816 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); 1817 1818 if (!(option->state & State_Enabled)) 1819 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); 1820 else if (downIsActive && sunken) 1821 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); 1822 else if (downIsActive && hover) 1823 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); 1824 else 1825 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); 1826 1827 if (option->state & State_HasFocus) 1828 GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); 1827 if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { 1828 gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); 1829 1830 upRect.setSize(downRect.size()); 1831 if (!(option->state & State_Enabled)) 1832 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); 1833 else if (upIsActive && sunken) 1834 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); 1835 else if (upIsActive && hover) 1836 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); 1837 else 1838 gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); 1839 1840 if (!(option->state & State_Enabled)) 1841 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); 1842 else if (downIsActive && sunken) 1843 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); 1844 else if (downIsActive && hover) 1845 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); 1846 else 1847 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); 1848 1849 if (option->state & State_HasFocus) 1850 GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); 1851 } 1829 1852 } 1830 1853 … … 1851 1874 } 1852 1875 1853 } else {1876 } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) { 1854 1877 int size = d->getSpinboxArrowSize(); 1855 1878 int w = size / 2 - 1; … … 2496 2519 const int windowsItemVMargin = 26; // menu item ver text margin 2497 2520 const int windowsRightBorder = 15; // right border on windows 2498 GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));2499 2521 GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) : 2500 2522 d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); … … 2510 2532 gint separator_height = 0; 2511 2533 guint horizontal_padding = 3; 2534 QRect separatorRect = option->rect; 2512 2535 if (!d->gtk_check_version(2, 10, 0)) { 2513 2536 d->gtk_widget_style_get(gtkMenuSeparator, … … 2517 2540 NULL); 2518 2541 } 2542 separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness); 2543 separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness)); 2544 separatorRect.moveCenter(option->rect.center()); 2519 2545 if (wide_separators) 2520 2521 option->rect.adjusted(0, 0, 0, -1), GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenu->style);2546 gtkPainter.paintBox( gtkMenuSeparator, "hseparator", 2547 separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style); 2522 2548 else 2523 2549 gtkPainter.paintHline( gtkMenuSeparator, "hseparator", 2524 menuItem->rect, GTK_STATE_NORMAL, gtkMenu->style,2525 option->rect.left() + horizontal_padding, option->rect.width() - 2*horizontal_padding, 2);2550 separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style, 2551 0, option->rect.right() - 1, 1); 2526 2552 painter->restore(); 2527 2553 break; … … 2531 2557 2532 2558 if (selected) { 2533 QRect rect = option->rect .adjusted(0, 0, 0, -1);2559 QRect rect = option->rect; 2534 2560 #ifndef QT_NO_COMBOBOX 2535 2561 if (qobject_cast<const QComboBox*>(widget)) … … 2557 2583 if (!ignoreCheckMark) { 2558 2584 // Check 2559 QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 , checkSize, checkSize);2585 QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize); 2560 2586 checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); 2561 2587 … … 2681 2707 int xm = windowsItemFrame + checkcol + windowsItemHMargin; 2682 2708 int xpos = menuitem->rect.x() + xm + 1; 2683 QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);2709 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); 2684 2710 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); 2685 2711 QString s = menuitem->text; … … 3151 3177 } 3152 3178 break; 3153 3154 3179 case CT_MenuItem: 3155 3180 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { … … 3158 3183 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { 3159 3184 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); 3160 gboolean wide_separators; 3161 gint separator_height; 3162 d->gtk_widget_style_get(gtkMenuSeparator, 3163 "wide-separators", &wide_separators, 3164 "separator-height", &separator_height, 3165 NULL); 3166 newSize = QSize(size.width(), wide_separators ? separator_height - 1 : 7 ); 3167 3185 GtkRequisition sizeReq = {0, 0}; 3186 d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); 3187 newSize = QSize(size.width(), sizeReq.height); 3168 3188 break; 3169 3189 } 3170 3190 3171 GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.Gtk MenuItem"));3191 GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); 3172 3192 GtkStyle* style = gtkMenuItem->style; 3173 newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3); 3193 3194 // Note we get the perfect height for the default font since we 3195 // set a fake text label on the gtkMenuItem 3196 // But if custom fonts are used on the widget we need a minimum size 3197 GtkRequisition sizeReq = {0, 0}; 3198 d->gtk_widget_size_request(gtkMenuItem, &sizeReq); 3199 newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); 3200 newSize += QSize(textMargin + style->xthickness - 1, 0); 3174 3201 3175 3202 // Cleanlooks assumes a check column of 20 pixels so we need to 3176 3203 // expand it a bit 3177 3204 gint checkSize; 3178 d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); 3179 newSize.setHeight(qMax(newSize.height(), checkSize + 2)); 3205 d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); 3180 3206 newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); 3181 3207 } 3182 3183 break;3184 3185 case CT_Menu:3186 // This is evil, but QMenu adds 1 pixel too much3187 newSize -= QSize(0, 1);3188 3208 3189 3209 break;
Note:
See TracChangeset
for help on using the changeset viewer.