Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qgtkstyle.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    11071107        //           Murrine engine requires a widget not to get RGBA check - warnings
    11081108        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);
    11111117    }
    11121118    break;
     
    11291135
    11301136        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        }
    11311142
    11321143        // Some styles such as aero-clone assume they can paint in the spacing area
     
    11381149
    11391150        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
    11411155    }
    11421156    break;
     
    13781392                        gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
    13791393                                                option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
    1380                                                 GTK_SHADOW_NONE, gtkCombo->style, entryPath + QString::number(focus));
     1394                                                GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus));
    13811395                    }
    13821396
     
    17371751    case CC_SpinBox:
    17381752        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"));
    17401758            bool isEnabled = (spinBox->state & State_Enabled);
    17411759            bool hover = isEnabled && (spinBox->state & State_MouseOver);
     
    17451763            bool reverse = (spinBox->direction == Qt::RightToLeft);
    17461764
    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;
    17561766            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            }
    17731794            if (spinBox->frame) {
    17741795                GtkShadowType shadow = GTK_SHADOW_OUT;
     
    18041825
    18051826                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                }
    18291852            }
    18301853
     
    18511874                }
    18521875
    1853             } else {
     1876            } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
    18541877                int size = d->getSpinboxArrowSize();
    18551878                int w = size / 2 - 1;
     
    24962519            const int windowsItemVMargin      = 26; // menu item ver text margin
    24972520            const int windowsRightBorder      = 15; // right border on windows
    2498             GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
    24992521            GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
    25002522                                     d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
     
    25102532                gint     separator_height = 0;
    25112533                guint    horizontal_padding = 3;
     2534                QRect separatorRect = option->rect;
    25122535                if (!d->gtk_check_version(2, 10, 0)) {
    25132536                    d->gtk_widget_style_get(gtkMenuSeparator,
     
    25172540                                           NULL);
    25182541                }
     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());
    25192545                if (wide_separators)
    2520                     gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
    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);
    25222548                else
    25232549                    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);
    25262552                painter->restore();
    25272553                break;
     
    25312557
    25322558            if (selected) {
    2533                 QRect rect = option->rect.adjusted(0, 0, 0, -1);
     2559                QRect rect = option->rect;
    25342560#ifndef QT_NO_COMBOBOX
    25352561                if (qobject_cast<const QComboBox*>(widget))
     
    25572583            if (!ignoreCheckMark) {
    25582584                // 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);
    25602586                checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
    25612587
     
    26812707            int xm = windowsItemFrame + checkcol + windowsItemHMargin;
    26822708            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);
    26842710            QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
    26852711            QString s = menuitem->text;
     
    31513177        }
    31523178        break;
    3153 
    31543179    case CT_MenuItem:
    31553180        if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
     
    31583183            if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
    31593184                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);
    31683188                break;
    31693189            }
    31703190
    3171             GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
     3191            GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem"));
    31723192            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);
    31743201
    31753202            // Cleanlooks assumes a check column of 20 pixels so we need to
    31763203            // expand it a bit
    31773204            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);
    31803206            newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
    31813207        }
    3182 
    3183         break;
    3184 
    3185     case CT_Menu:
    3186         // This is evil, but QMenu adds 1 pixel too much
    3187         newSize -= QSize(0, 1);
    31883208
    31893209        break;
Note: See TracChangeset for help on using the changeset viewer.