Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    1 /*******    *********************************************************************
     1/****************************************************************************
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7070#include <qpixmapcache.h>
    7171#undef signals // Collides with GTK stymbols
    72 #include "qgtkpainter_p.h"
    73 
     72#include <private/qgtkpainter_p.h>
     73#include <private/qstylehelper_p.h>
     74#include <private/qgtkstyle_p.h>
    7475#include <private/qcleanlooksstyle_p.h>
    7576
    7677
    7778QT_BEGIN_NAMESPACE
    78 
    79 typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
    80                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
    81 typedef QString (*_qt_filedialog_open_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
    82                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
    83 typedef QString (*_qt_filedialog_save_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
    84                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
    85 typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
    86                                                           QFileDialog::Options options);
    87 
    88 extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
    89 extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
    90 extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
    91 extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
    9279
    9380static const char * const dock_widget_close_xpm[] =
     
    137124    };
    138125
    139 
    140 class QGtkStyleFilter : public QObject
    141 {
    142 public:
    143     QGtkStyleFilter() {
    144         qApp->installEventFilter(this);
    145     }
    146 
    147 private:
    148     bool eventFilter(QObject *obj, QEvent *e);
    149 };
    150 
    151 bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
    152 {
    153     if (e->type() == QEvent::ApplicationPaletteChange) {
    154         // Only do this the first time since this will also
    155         // generate applicationPaletteChange events
    156         extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp
    157         if (!qt_app_palettes_hash() ||  qt_app_palettes_hash()->isEmpty()) {
    158             QGtk::applyCustomPaletteHash();
    159         }
    160     }
    161     return QObject::eventFilter(obj, e);
    162 }
    163 
    164 class QGtkStylePrivate : public QCleanlooksStylePrivate
    165 {
    166     Q_DECLARE_PUBLIC(QGtkStyle)
    167 public:
    168     QGtkStylePrivate()
    169             : QCleanlooksStylePrivate()
    170     {}
    171     QGtkStyleFilter filter;
    172 };
    173 
    174126static const int groupBoxBottomMargin    =  2;  // space below the groupbox
    175127static const int groupBoxTitleMargin     =  6;  // space between contents and title
    176128static const int groupBoxTopMargin       =  2;
    177 static bool UsePixmapCache = true;
    178 
    179 // Get size of the arrow controls in a GtkSpinButton
    180 static int spinboxArrowSize()
     129
     130/*!
     131  Returns the configuration string for \a value.
     132  Returns \a fallback if \a value is not found.
     133 */
     134QString QGtkStyle::getGConfString(const QString &value, const QString &fallback)
    181135{
    182     const int MIN_ARROW_WIDTH = 6;
    183     GtkWidget *spinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
    184     GtkStyle *style = spinButton->style;
    185     gint size = QGtk::pango_font_description_get_size (style->font_desc);
    186     gint arrow_size;
    187     arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
    188     arrow_size += arrow_size%2 + 1;
    189     return arrow_size;
     136    return QGtkStylePrivate::getGConfString(value, fallback);
     137}
     138
     139/*!
     140  Returns the configuration boolean for \a key.
     141  Returns \a fallback if \a key is not found.
     142 */
     143bool QGtkStyle::getGConfBool(const QString &key, bool fallback)
     144{
     145    return QGtkStylePrivate::getGConfBool(key, fallback);
    190146}
    191147
     
    209165}
    210166
    211 // Note this is different from uniqueName as used in QGtkPainter
    212 static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
    213 {
    214     QString tmp;
    215     const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
    216     tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state),
    217                 option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0),
    218                 option->palette.cacheKey(), size.width(), size.height());
    219     return tmp;
    220 }
    221 
    222167/*!
    223168    \class QGtkStyle
     
    244189    : QCleanlooksStyle(*new QGtkStylePrivate)
    245190{
    246     QGtk::initGtkWidgets();
     191    Q_D(QGtkStyle);
     192    d->init();
    247193}
     194
     195/*!
     196    \internal
     197
     198    Constructs a QGtkStyle object.
     199*/
     200QGtkStyle::QGtkStyle(QGtkStylePrivate &dd)
     201     : QCleanlooksStyle(dd)
     202{
     203    Q_D(QGtkStyle);
     204    d->init();
     205}
     206
    248207
    249208/*!
     
    259218QPalette QGtkStyle::standardPalette() const
    260219{
     220    Q_D(const QGtkStyle);
     221
    261222    QPalette palette = QCleanlooksStyle::standardPalette();
    262     if (QGtk::isThemeAvailable()) {
    263         GtkStyle *style = QGtk::gtkStyle();
    264         GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
    265         GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
     223    if (d->isThemeAvailable()) {
     224        GtkStyle *style = d->gtkStyle();
     225        GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
     226        GtkWidget *gtkEntry = d->getTextColorWidget();
    266227
    267228        GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg;
     
    293254
    294255        QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
    295         GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));
     256        GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
    296257        GdkColor *gtkAltBase = NULL;
    297         QGtk::gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
     258        d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
    298259        if (gtkAltBase) {
    299260            alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8);
    300             QGtk::gdk_color_free(gtkAltBase);
     261            d->gdk_color_free(gtkAltBase);
    301262        }
    302263        palette.setColor(QPalette::AlternateBase, alternateRowColor);
     
    318279        palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
    319280        palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
    320         style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", Q_GTK_TYPE_WINDOW);
     281        style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
     282                d->gtk_window_get_type());
    321283        if (style) {
    322284            gdkText = style->fg[GTK_STATE_NORMAL];
     
    333295void QGtkStyle::polish(QPalette &palette)
    334296{
     297    Q_D(QGtkStyle);
     298
    335299    // QCleanlooksStyle will alter the palette, hence we do
    336300    // not want to polish the palette unless we are using it as
    337301    // the fallback
    338     if (!QGtk::isThemeAvailable())
     302    if (!d->isThemeAvailable())
    339303        QCleanlooksStyle::polish(palette);
    340304    else
     
    347311void QGtkStyle::polish(QApplication *app)
    348312{
     313    Q_D(QGtkStyle);
     314
    349315    QCleanlooksStyle::polish(app);
    350316    // Custom fonts and palettes with QtConfig are intentionally
    351317    // not supported as these should be entirely determined by
    352318    // current Gtk settings
    353     if (app->desktopSettingsAware() && QGtk::isThemeAvailable()) {
     319    if (app->desktopSettingsAware() && d->isThemeAvailable()) {
    354320        QApplicationPrivate::setSystemPalette(standardPalette());
    355         QApplicationPrivate::setSystemFont(QGtk::getThemeFont());
    356         QGtk::applyCustomPaletteHash();
    357         if (!QGtk::isKDE4Session()) {
    358             qt_filedialog_open_filename_hook = &QGtk::openFilename;
    359             qt_filedialog_save_filename_hook = &QGtk::saveFilename;
    360             qt_filedialog_open_filenames_hook = &QGtk::openFilenames;
    361             qt_filedialog_existing_directory_hook = &QGtk::openDirectory;
     321        QApplicationPrivate::setSystemFont(d->getThemeFont());
     322        d->applyCustomPaletteHash();
     323        if (!d->isKDE4Session()) {
     324            qt_filedialog_open_filename_hook = &QGtkStylePrivate::openFilename;
     325            qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename;
     326            qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames;
     327            qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory;
    362328        }
    363329    }
     
    369335void QGtkStyle::unpolish(QApplication *app)
    370336{
     337    Q_D(QGtkStyle);
     338
    371339    QCleanlooksStyle::unpolish(app);
    372340    QPixmapCache::clear();
    373341
    374     if (app->desktopSettingsAware() && QGtk::isThemeAvailable()
    375         && !QGtk::isKDE4Session()) {
     342    if (app->desktopSettingsAware() && d->isThemeAvailable()
     343        && !d->isKDE4Session()) {
    376344        qt_filedialog_open_filename_hook = 0;
    377345        qt_filedialog_save_filename_hook = 0;
     
    387355void QGtkStyle::polish(QWidget *widget)
    388356{
     357    Q_D(QGtkStyle);
     358
    389359    QCleanlooksStyle::polish(widget);
    390     if (!QGtk::isThemeAvailable())
     360    if (!d->isThemeAvailable())
    391361        return;
    392362    if (qobject_cast<QAbstractButton*>(widget)
     
    416386*/
    417387int QGtkStyle::pixelMetric(PixelMetric metric,
    418 
    419388                           const QStyleOption *option,
    420389                           const QWidget *widget) const
    421390{
    422     if (!QGtk::isThemeAvailable())
     391    Q_D(const QGtkStyle);
     392
     393    if (!d->isThemeAvailable())
    423394        return QCleanlooksStyle::pixelMetric(metric, option, widget);
    424395
     
    427398        if (qobject_cast<const QFrame*>(widget)) {
    428399            if (GtkStyle *style =
    429                 QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
     400                d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
    430401                                                "*.GtkScrolledWindow",
    431402                                                "*.GtkScrolledWindow",
    432                                                 Q_GTK_TYPE_WINDOW))
     403                                                d->gtk_window_get_type()))
    433404                return qMax(style->xthickness, style->ythickness);
    434405        }
     
    451422
    452423    case PM_ButtonShiftHorizontal: {
    453         GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     424        GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
    454425        guint horizontal_shift;
    455         QGtk::gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
     426        d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
    456427        return horizontal_shift;
    457428    }
    458429
    459430    case PM_ButtonShiftVertical: {
    460         GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     431        GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
    461432        guint vertical_shift;
    462         QGtk::gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
     433        d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
    463434        return vertical_shift;
    464435    }
     
    468439
    469440    case PM_MenuPanelWidth: {
    470         GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
     441        GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
    471442        guint horizontal_padding = 0;
    472443        // horizontal-padding is used by Maemo to get thicker borders
    473         if (!QGtk::gtk_check_version(2, 10, 0))
    474             QGtk::gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
     444        if (!d->gtk_check_version(2, 10, 0))
     445            d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
    475446        int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
    476447        return padding;
     
    479450    case PM_ButtonIconSize: {
    480451        int retVal = 24;
    481         GtkSettings *settings = QGtk::gtk_settings_get_default();
     452        GtkSettings *settings = d->gtk_settings_get_default();
    482453        gchararray icon_sizes;
    483454        g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL);
     
    525496    case PM_SliderThickness:
    526497    case PM_SliderControlThickness: {
    527         GtkWidget *gtkScale = QGtk::gtkWidget(QLS("GtkHScale"));
     498        GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale"));
    528499        gint val;
    529         QGtk::gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
     500        d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
    530501        if (metric == PM_SliderControlThickness)
    531502            return val + 2*gtkScale->style->ythickness;
     
    536507        gint sliderLength;
    537508        gint trough_border;
    538         GtkWidget *hScrollbar = QGtk::gtkWidget(QLS("GtkHScrollbar"));
    539         QGtk::gtk_widget_style_get(hScrollbar,
     509        GtkWidget *hScrollbar = d->gtkWidget(QLS("GtkHScrollbar"));
     510        d->gtk_widget_style_get(hScrollbar,
    540511                               "trough-border",   &trough_border,
    541512                               "slider-width",    &sliderLength,
     
    549520    case PM_SliderLength:
    550521        gint val;
    551         QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL);
     522        d->gtk_widget_style_get(d->gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL);
    552523        return val;
    553524
     
    556527    case PM_IndicatorWidth:
    557528    case PM_IndicatorHeight: {
    558         GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
     529        GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
    559530        gint size, spacing;
    560         QGtk::gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
     531        d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
    561532        return size + 2 * spacing;
    562533    }
    563534
    564535    case PM_MenuBarVMargin: {
    565         GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
     536        GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
    566537        return  qMax(0, gtkMenubar->style->ythickness);
    567538    }
     
    569540    {
    570541        gint spacing = 3;
    571         GtkWidget *gtkScrollWindow = QGtk::gtkWidget(QLS("GtkScrolledWindow"));
     542        GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow"));
    572543        Q_ASSERT(gtkScrollWindow);
    573         QGtk::gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
     544        d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
    574545        return spacing;
    575546    }
    576547    case PM_SubMenuOverlap: {
    577548        gint offset = 0;
    578         GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
    579         QGtk::gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
     549        GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
     550        d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
    580551        return offset;
    581552    }
     
    592563                         QStyleHintReturn *returnData = 0) const
    593564{
    594     if (!QGtk::isThemeAvailable())
     565    Q_D(const QGtkStyle);
     566
     567    if (!d->isThemeAvailable())
    595568        return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
    596569
     
    600573        int ret = QDialogButtonBox::GnomeLayout;
    601574        gboolean alternateOrder = 0;
    602         GtkSettings *settings = QGtk::gtk_settings_get_default();
     575        GtkSettings *settings = d->gtk_settings_get_default();
    603576        g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
    604577
     
    611584    break;
    612585
     586    case SH_ToolButtonStyle:
     587    {
     588        if (d->isKDE4Session())
     589            return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
     590        GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
     591        GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
     592        g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
     593        switch (toolbar_style) {
     594        case GTK_TOOLBAR_TEXT:
     595            return Qt::ToolButtonTextOnly;
     596        case GTK_TOOLBAR_BOTH:
     597            return Qt::ToolButtonTextUnderIcon;
     598        case GTK_TOOLBAR_BOTH_HORIZ:
     599            return Qt::ToolButtonTextBesideIcon;
     600        case GTK_TOOLBAR_ICONS:
     601        default:
     602            return Qt::ToolButtonIconOnly;
     603        }
     604    }
     605    break;
    613606    case SH_SpinControls_DisableOnBounds:
    614607        return int(true);
     
    618611
    619612    case SH_ComboBox_Popup: {
    620         GtkWidget *gtkComboBox = QGtk::gtkWidget(QLS("GtkComboBox"));
     613        GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox"));
    621614        gboolean appears_as_list;
    622         QGtk::gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
     615        d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
    623616        return appears_as_list ? 0 : 1;
    624617    }
     
    632625    case SH_Menu_SubMenuPopupDelay: {
    633626        gint delay = 225;
    634         GtkSettings *settings = QGtk::gtk_settings_get_default();
     627        GtkSettings *settings = d->gtk_settings_get_default();
    635628        g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
    636629        return delay;
     
    641634        if (widget && widget->isWindow())
    642635            scrollbars_within_bevel = true;
    643         else if (!QGtk::gtk_check_version(2, 12, 0)) {
    644             GtkWidget *gtkScrollWindow = QGtk::gtkWidget(QLS("GtkScrolledWindow"));
    645             QGtk::gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
     636        else if (!d->gtk_check_version(2, 12, 0)) {
     637            GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow"));
     638            d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
    646639        }
    647640        return !scrollbars_within_bevel;
     641    }
     642
     643    case SH_DialogButtonBox_ButtonsHaveIcons: {
     644        static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
     645        return buttonsHaveIcons;
     646    }
     647
     648    case SH_UnderlineShortcut: {
     649        gboolean underlineShortcut = true;
     650        if (!d->gtk_check_version(2, 12, 0)) {
     651            GtkSettings *settings = d->gtk_settings_get_default();
     652            g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL);
     653        }
     654        return underlineShortcut;
    648655    }
    649656
     
    657664*/
    658665void QGtkStyle::drawPrimitive(PrimitiveElement element,
    659 
    660666                              const QStyleOption *option,
    661667                              QPainter *painter,
    662668                              const QWidget *widget) const
    663669{
    664     if (!QGtk::isThemeAvailable()) {
     670    Q_D(const QGtkStyle);
     671
     672    if (!d->isThemeAvailable()) {
    665673        QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
    666674        return;
    667675    }
    668676
    669     GtkStyle* style = QGtk::gtkStyle();
     677    GtkStyle* style = d->gtkStyle();
    670678    QGtkPainter gtkPainter(painter);
    671679
     
    675683            QStyleOption copy = *option;
    676684            copy.state |= State_Raised;
    677             drawPrimitive(PE_PanelMenu, &copy, painter, widget);
     685            proxy()->drawPrimitive(PE_PanelMenu, &copy, painter, widget);
    678686            break;
    679687        }
     
    682690        // thin rectangular images
    683691        const int pmSize = 64;
    684         const int border = pixelMetric(PM_DefaultFrameWidth, option, widget);
     692        const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
    685693        const QString pmKey = QString(QLS("windowframe %0")).arg(option->state);
    686694
    687695        QPixmap pixmap;
    688         QPixmapCache::find(pmKey, pixmap);
    689696        QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
    690697
    691698        // Only draw through style once
    692         if (pixmap.isNull()) {
     699        if (!QPixmapCache::find(pmKey, pixmap)) {
    693700            pixmap = QPixmap(pmSize, pmSize);
    694701            pixmap.fill(Qt::transparent);
     
    703710                shadow_type = GTK_SHADOW_OUT;
    704711
    705             GtkStyle *style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
    706                                      "*.GtkScrolledWindow", "*.GtkScrolledWindow", Q_GTK_TYPE_WINDOW);
     712            GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
     713                                     "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
    707714            if (style)
    708                 gtkFramePainter.paintShadow(QGtk::gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
     715                gtkFramePainter.paintShadow(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
    709716                                         option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
    710717                                         shadow_type, style);
     
    733740
    734741    case PE_PanelTipLabel: {
    735         GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
    736         style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", Q_GTK_TYPE_WINDOW);
     742        GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
     743        style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
     744                d->gtk_window_get_type());
    737745        gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
    738746    }
     
    747755        }
    748756        GtkShadowType shadow_type;
    749         GtkWidget *gtkStatusbarFrame = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
    750         QGtk::gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
     757        GtkWidget *gtkStatusbarFrame = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
     758        d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
    751759        gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
    752760                               shadow_type, gtkStatusbarFrame->style);
     
    756764    case PE_IndicatorHeaderArrow:
    757765        if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
    758             GtkWidget *gtkTreeHeader = QGtk::gtkWidget(QLS("GtkTreeView.GtkButton"));
     766            GtkWidget *gtkTreeHeader = d->gtkWidget(QLS("GtkTreeView.GtkButton"));
    759767            GtkStateType state = gtkPainter.gtkState(option);
    760768            style = gtkTreeHeader->style;
     
    789797        if (option->state & State_Children) {
    790798            QRect rect = option->rect;
    791             rect = QRect(0, 0, 10, 10);
     799            rect = QRect(0, 0, 12, 12);
    792800            rect.moveCenter(option->rect.center());
    793801            rect.translate(2, 0);
    794802            GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
    795803            GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
    796             GtkWidget *gtkExpander = QGtk::gtkWidget(QLS("GtkExpander"));
    797             guint expanderSize;
    798             QGtk::gtk_widget_style_get(gtkExpander, "expander-size", &expanderSize, NULL);
    799             // Note CleanIce will crash unless a GtkExpander is provided
    800             // but providing the expander will enforce the expander-size, which we
    801             // don't neccessarily have room for
     804            GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
     805
    802806            GtkStateType state = GTK_STATE_NORMAL;
    803807            if (!(option->state & State_Enabled))
     
    805809            else if (option->state & State_MouseOver)
    806810                state = GTK_STATE_PRELIGHT;
    807             gtkPainter.paintExpander(expanderSize <= 10 ? gtkExpander : NULL, "expander", rect, state,
    808                                      option->state & State_Open ? openState : closedState , gtkExpander->style);
     811
     812            gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
     813                                     option->state & State_Open ? openState : closedState , gtkTreeView->style);
    809814        }
    810815        break;
     
    833838        {
    834839            const int margin = 6;
    835             GtkWidget *gtkSeparator = QGtk::gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));
     840            GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));
    836841            if (option->state & State_Horizontal) {
    837842                const int offset = option->rect.width()/2;
     
    853858
    854859    case PE_IndicatorToolBarHandle: {
    855         GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));
     860        GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
    856861        GtkShadowType shadow_type;
    857         QGtk::gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
     862        d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
    858863        //Note when the toolbar is horizontal, the handle is vertical
    859864        painter->setClipRect(option->rect);
     
    893898        int bsx = 0, bsy = 0;
    894899        if (option->state & State_Sunken) {
    895             bsx = pixelMetric(PM_ButtonShiftHorizontal);
    896             bsy = pixelMetric(PM_ButtonShiftVertical);
     900            bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
     901            bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
    897902        }
    898903        QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
     
    901906
    902907        QColor arrowColor = option->palette.buttonText().color();
    903         GtkWidget *gtkArrow = QGtk::gtkWidget(QLS("GtkArrow"));
     908        GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow"));
    904909        GdkColor color = fromQColor(arrowColor);
    905         QGtk::gtk_widget_modify_fg (gtkArrow, state, &color);
     910        d->gtk_widget_modify_fg (gtkArrow, state, &color);
    906911        gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
    907912                              type, state, shadow, FALSE, gtkArrow->style,
    908913                              QString::number(arrowColor.rgba(), 16));
    909914        // Passing NULL will revert the color change
    910         QGtk::gtk_widget_modify_fg (gtkArrow, state, NULL);
     915        d->gtk_widget_modify_fg (gtkArrow, state, NULL);
    911916    }
    912917    break;
     
    917922
    918923    case PE_PanelMenu: {
    919             GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
     924            GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
    920925            gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
    921926            gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
     
    929934        // This is only used by floating tool bars
    930935        if (qobject_cast<const QToolBar *>(widget)) {
    931             GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
     936            GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
    932937            gtkPainter.paintBox( gtkMenubar, "toolbar",  option->rect,
    933938                                 GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
     
    938943
    939944    case PE_FrameLineEdit: {
    940         GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
    941 
    942         if (option->state & State_HasFocus)
    943             GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    944         else
    945             GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
     945        GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
     946
    946947
    947948        gboolean interior_focus;
    948949        gint focus_line_width;
    949950        QRect rect = option->rect;
    950         QGtk::gtk_widget_style_get(gtkEntry,
     951        d->gtk_widget_style_get(gtkEntry,
    951952                               "interior-focus", &interior_focus,
    952953                               "focus-line-width", &focus_line_width, NULL);
    953954
     955        // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack
     956        g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
     957
    954958        if (!interior_focus && option->state & State_HasFocus)
    955959            rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
    956960
     961        if (option->state & State_HasFocus)
     962            GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    957963        gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
    958964                               GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
    959965                               GTK_SHADOW_IN, gtkEntry->style,
    960966                               option->state & State_HasFocus ? QLS("focus") : QString());
    961 
    962967        if (!interior_focus && option->state & State_HasFocus)
    963968            gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
    964969                                   GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
    965970                                   GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
     971
     972        if (option->state & State_HasFocus)
     973            GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    966974    }
    967975    break;
     
    969977    case PE_PanelLineEdit:
    970978        if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
    971             GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
     979            GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
    972980            if (panel->lineWidth > 0)
    973                 drawPrimitive(PE_FrameLineEdit, option, painter, widget);
     981                proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
    974982            uint resolve_mask = option->palette.resolve();
    975983            QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness,
     
    978986            if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
    979987                resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
    980                 painter->fillRect(textRect, option->palette.base().color());
     988                painter->fillRect(textRect, option->palette.base());
    981989            else
    982990                gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
     
    987995    case PE_FrameTabWidget:
    988996        if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
    989             GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));
     997            GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
    990998            style = gtkPainter.getStyle(gtkNotebook);
    991999            gtkPainter.setAlphaSupport(false);
    9921000            GtkShadowType shadow = GTK_SHADOW_OUT;
    9931001            GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
    994             if (const QTabWidget *tabwidget = qobject_cast<const QTabWidget*>(widget)) {
    995                 // We should introduce QStyleOptionTabWidgetFrameV2 to obtain this information
    996                 // No gap if we do not show the actual tabs
    997                 QTabBar *tabBar = tabwidget->findChild<QTabBar*>();
    998                 if (tabwidget->count() > 0 && tabBar->isVisible()) {
    999                     QRect tabRect = tabBar->tabRect(tabBar->currentIndex());
    1000                     int begin = 0, size = 0;
    1001                     GtkPositionType frameType = GTK_POS_TOP;
    1002                     QTabBar::Shape shape = frame->shape;
    1003                     if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
    1004                         begin = option->direction == Qt::LeftToRight ?
    1005                                 frame->leftCornerWidgetSize.width() + tabRect.left() :
    1006                                 frame->rect.width() - frame->tabBarSize.width() + tabRect.left()
    1007                                 - frame->rightCornerWidgetSize.width();
    1008                         size = tabRect.width();
    1009                         frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
    1010                     } else {
    1011                         begin = frame->leftCornerWidgetSize.height() + tabRect.top();
    1012                         size = tabRect.height();
    1013                         frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
    1014                     }
    1015                     gtkPainter.paintBoxGap(gtkNotebook, "notebook",  option->rect, state, shadow, frameType,
    1016                                             begin, size, style);
    1017                     break; // done
     1002            bool reverse = (option->direction == Qt::RightToLeft);
     1003            QGtkStylePrivate::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
     1004            if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
     1005                GtkPositionType frameType = GTK_POS_TOP;
     1006                QTabBar::Shape shape = frame->shape;
     1007                int gapStart = 0;
     1008                int gapSize = 0;
     1009                if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
     1010                    frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
     1011                    gapStart = tabframe->selectedTabRect.left();
     1012                    gapSize = tabframe->selectedTabRect.width();
     1013                } else {
     1014                    frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
     1015                    gapStart = tabframe->selectedTabRect.y();
     1016                    gapSize = tabframe->selectedTabRect.height();
    10181017                }
    1019             }
     1018                gtkPainter.paintBoxGap(gtkNotebook, "notebook",  option->rect, state, shadow, frameType,
     1019                                        gapStart, gapSize, style);
     1020                break; // done
     1021            }
     1022
    10201023            // Note this is only the fallback option
    10211024            gtkPainter.paintBox(gtkNotebook, "notebook",  option->rect, state, shadow, style);
     
    10231026        break;
    10241027
    1025     case PE_PanelButtonCommand: {
     1028    case PE_PanelButtonCommand:
     1029    case PE_PanelButtonTool: {
    10261030        bool isDefault = false;
     1031        bool isTool = (element == PE_PanelButtonTool);
    10271032        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
    10281033            isDefault = btn->features & QStyleOptionButton::DefaultButton;
     1034
     1035        // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
     1036        if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
     1037            break;
     1038        // don't draw a frame for dock widget buttons, unless we are hovering
     1039        if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
     1040            break;
    10291041
    10301042        GtkStateType state = gtkPainter.gtkState(option);
    10311043        if (option->state & State_On || option->state & State_Sunken)
    10321044            state = GTK_STATE_ACTIVE;
    1033         GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     1045        GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton"));
    10341046        gint focusWidth, focusPad;
    10351047        gboolean interiorFocus = false;
    1036         QGtk::gtk_widget_style_get (gtkButton,
     1048        d->gtk_widget_style_get (gtkButton,
    10371049                                "focus-line-width", &focusWidth,
    10381050                                "focus-padding", &focusPad,
     
    10491061            gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
    10501062                                style, isDefault ? QLS("d") : QString());
    1051         } else
    1052             GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
     1063        }
    10531064
    10541065        bool hasFocus = option->state & State_HasFocus;
     
    10571068            key += QLS("def");
    10581069            GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
    1059 
    1060         } else {
    1061             GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
    10621070        }
    10631071
     
    10701078        gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
    10711079                            style, key);
     1080        if (isDefault)
     1081            GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
     1082        if (hasFocus)
     1083            GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
    10721084    }
    10731085    break;
     
    10871099            shadow = GTK_SHADOW_OUT;
    10881100
    1089         GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));
     1101        GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
    10901102        gint spacing;
    1091         QGtk::gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
     1103        d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
    10921104        QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
    10931105        gtkPainter.setClipRect(option->rect);
    10941106        // ### Note: Ubuntulooks breaks when the proper widget is passed
    10951107        //           Murrine engine requires a widget not to get RGBA check - warnings
    1096         GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
     1108        GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
    10971109        gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, QLS("radiobutton"));
    10981110
     
    11161128        int spacing;
    11171129
    1118         GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
     1130        GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
    11191131
    11201132        // Some styles such as aero-clone assume they can paint in the spacing area
    11211133        gtkPainter.setClipRect(option->rect);
    11221134
    1123         QGtk::gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
     1135        d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
    11241136
    11251137        QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
     
    11881200                                   QPainter *painter, const QWidget *widget) const
    11891201{
    1190     if (!QGtk::isThemeAvailable()) {
     1202    Q_D(const QGtkStyle);
     1203
     1204    if (!d->isThemeAvailable()) {
    11911205        QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
    11921206        return;
    11931207    }
    11941208
    1195     GtkStyle* style = QGtk::gtkStyle();
     1209    GtkStyle* style = d->gtkStyle();
    11961210    QGtkPainter gtkPainter(painter);
    11971211    QColor button = option->palette.button().color();
     
    12421256
    12431257        if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
    1244             QRect textRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
    1245             QRect checkBoxRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
     1258            QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
     1259            QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
    12461260            // Draw title
    12471261
    12481262            if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
    12491263                // Draw prelight background
    1250                 GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
     1264                GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
    12511265
    12521266                if (option->state & State_MouseOver) {
     
    12581272                if (!groupBox->text.isEmpty()) {
    12591273                    int alignment = int(groupBox->textAlignment);
    1260                     if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
     1274                    if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
    12611275                        alignment |= Qt::TextHideMnemonic;
    12621276                    QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored
     
    12831297                box.QStyleOption::operator=(*groupBox);
    12841298                box.rect = checkBoxRect;
    1285                 drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
     1299                proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
    12861300            }
    12871301        }
     
    13061320            QColor buttonShadow = option->palette.dark().color();
    13071321            GtkStateType state = gtkPainter.gtkState(option);
    1308             int appears_as_list = !styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
     1322            int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
    13091323            QPixmap cache;
    13101324            QString pixmapName;
     
    13141328            bool reverse = (option->direction == Qt::RightToLeft);
    13151329            QRect rect = option->rect;
    1316             QRect arrowButtonRect = subControlRect(CC_ComboBox, &comboBoxCopy,
     1330            QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
    13171331                                                   SC_ComboBoxArrow, widget);
    1318             QRect editRect = subControlRect(CC_ComboBox, &comboBoxCopy,
     1332            QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
    13191333                                            SC_ComboBoxEditField, widget);
    13201334
     
    13241338
    13251339            // We use the gtk widget to position arrows and separators for us
    1326             GtkWidget *gtkCombo = QGtk::gtkWidget(comboBoxPath);
     1340            GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
    13271341            GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
    1328             QGtk::gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
    1329             QGtk::gtk_widget_size_allocate(gtkCombo, &geometry);
     1342            d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
     1343            d->gtk_widget_size_allocate(gtkCombo, &geometry);
    13301344
    13311345            QString buttonPath = comboBoxPath + QLS(".GtkToggleButton");
    1332             GtkWidget *gtkToggleButton = QGtk::gtkWidget(buttonPath);
    1333             QGtk::gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
     1346            GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
     1347            d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
    13341348            if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
     1349                if (focus)
     1350                    GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    13351351                // Draw the combo box as a line edit with a button next to it
    13361352                if (comboBox->editable || appears_as_list) {
    13371353                    GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
    13381354                    QString entryPath = QLS(comboBox->editable ? "GtkComboBoxEntry.GtkEntry" : "GtkComboBox.GtkFrame");
    1339                     GtkWidget *gtkEntry = QGtk::gtkWidget(entryPath);
    1340                     QGtk::gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
     1355                    GtkWidget *gtkEntry = d->gtkWidget(entryPath);
     1356                    d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
    13411357                    QRect frameRect = option->rect;
    13421358
     
    13451361                    else
    13461362                        frameRect.setRight(arrowButtonRect.left());
    1347 
    1348                     // Required for inner blue highlight with clearlooks
    1349                     if (focus) {
    1350                         GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    1351                         GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    1352 
    1353                     } else {
    1354                         GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    1355                         GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    1356                     }
    13571363
    13581364                    // Fill the line edit background
     
    13621368                    int yt = gtkEntry->style->ythickness;
    13631369                    QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
     1370                    // Required for inner blue highlight with clearlooks
     1371                    if (focus)
     1372                        GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
     1373
    13641374                    if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
    13651375                        resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
     
    13681378                        gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
    13691379                                                option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
    1370                                                 GTK_SHADOW_NONE, style, entryPath + QString::number(focus));
     1380                                                GTK_SHADOW_NONE, gtkCombo->style, entryPath + QString::number(focus));
    13711381                    }
    13721382
     
    13751385                                           QString::number(focus) + QString::number(comboBox->editable) +
    13761386                                           QString::number(option->direction));
     1387                    if (focus)
     1388                        GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
    13771389                }
    13781390
     
    13931405                                     shadow, gtkToggleButton->style, buttonPath +
    13941406                                     QString::number(focus) + QString::number(option->direction));
    1395 
     1407                if (focus)
     1408                    GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    13961409            } else {
    13971410                // Draw combo box as a button
    13981411                QRect buttonRect = option->rect;
    13991412
    1400                 if (focus) { // Clearlooks actually check the widget for the default state
     1413                if (focus) // Clearlooks actually check the widget for the default state
    14011414                    GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    1402 
    1403                 } else {
    1404                     GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
    1405                 }
    1406 
    14071415                gtkCachedPainter.paintBox(gtkToggleButton, "button",
    14081416                                    buttonRect, state,
    14091417                                    shadow, gtkToggleButton->style,
    14101418                                    buttonPath + QString::number(focus));
     1419                if (focus)
     1420                    GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
     1421
    14111422                // Draw the separator between label and arrows
    14121423                QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator");
    14131424
    1414                 if (GtkWidget *gtkVSeparator = QGtk::gtkWidget(vSeparatorPath)) {
     1425                if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
    14151426                    QRect vLineRect(gtkVSeparator->allocation.x,
    14161427                                    gtkVSeparator->allocation.y,
     
    14241435
    14251436                    gint interiorFocus = true;
    1426                     QGtk::gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
     1437                    d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
    14271438                    int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
    14281439                    int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
    1429                     if ((focus && (option->state & State_KeyboardFocusChange)))
     1440                    if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
    14301441                        gtkCachedPainter.paintFocus(gtkToggleButton, "button",
    14311442                                              option->rect.adjusted(xt, yt, -xt, -yt),
     
    14481459                                                    : ".GtkToggleButton.GtkHBox.GtkArrow");
    14491460
    1450                 GtkWidget *gtkArrow = QGtk::gtkWidget(arrowPath);
     1461                GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
    14511462                gfloat scale = 0.7;
    14521463                gint minSize = 15;
    14531464                QRect arrowWidgetRect;
    14541465
    1455                 if (gtkArrow && !QGtk::gtk_check_version(2, 12, 0)) {
    1456                     QGtk::gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
    1457                     QGtk::gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
     1466                if (gtkArrow && !d->gtk_check_version(2, 12, 0)) {
     1467                    d->gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
     1468                    d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
    14581469                }
    14591470                if (gtkArrow) {
     
    14731484                if (sunken) {
    14741485                    int xoff, yoff;
    1475                     GtkWidget *gtkButton = QGtk::gtkWidget(comboBoxPath + QLS(".GtkToggleButton"));
    1476                     QGtk::gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
    1477                     QGtk::gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
     1486                    GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton"));
     1487                    d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
     1488                    d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
    14781489                    arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
    14791490                }
     
    14981509                = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
    14991510            QRect button, menuarea;
    1500             button = subControlRect(control, toolbutton, SC_ToolButton, widget);
    1501             menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
     1511            button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
     1512            menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
    15021513            State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver);
    15031514
     
    15281539                    tool.rect = button;
    15291540                    tool.state = bflags;
    1530                     drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
     1541                    proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
    15311542                }
    15321543            }
     
    15391550                QStyleOptionFocusRect fr;
    15401551                fr.QStyleOption::operator=(*toolbutton);
    1541                 fr.rect = subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
     1552                fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
    15421553                fr.rect.adjust(1, 1, -1, -1);
    1543                 drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
     1554                proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
    15441555            }
    15451556
    15461557            QStyleOptionToolButton label = *toolbutton;
    15471558            label.state = bflags;
    1548             GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     1559            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
    15491560            QPalette pal = toolbutton->palette;
    15501561            if (option->state & State_Enabled &&
     
    15571568            label.rect = button.adjusted(style->xthickness, style->ythickness,
    15581569                                        -style->xthickness - popupArrowSize, -style->ythickness);
    1559             drawControl(CE_ToolButtonLabel, &label, painter, widget);
     1570            proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
    15601571
    15611572            if (toolbutton->subControls & SC_ToolButtonMenu) {
     
    15631574                tool.state = mflags;
    15641575                if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise))
    1565                     drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
    1566 
    1567                 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
     1576                    proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
     1577
     1578                proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
    15681579
    15691580            } else if (drawMenuArrow) {
     
    15711582                QStyleOptionToolButton newBtn = *toolbutton;
    15721583                newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize);
    1573                 drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
     1584                proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
    15741585            }
    15751586        }
     
    15811592    case CC_ScrollBar:
    15821593        if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    1583             GtkWidget *gtkHScrollBar = QGtk::gtkWidget(QLS("GtkHScrollbar"));
    1584             GtkWidget *gtkVScrollBar = QGtk::gtkWidget(QLS("GtkVScrollbar"));
     1594            GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar"));
     1595            GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar"));
    15851596
    15861597            // Fill background in case the scrollbar is partially transparent
     
    15881599
    15891600            QRect rect = scrollBar->rect;
    1590             QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
    1591             QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
    1592             QRect scrollBarSlider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
    1593             QRect grooveRect = subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
     1601            QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
     1602            QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
     1603            QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
     1604            QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
    15941605            bool horizontal = scrollBar->orientation == Qt::Horizontal;
    15951606            GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
     
    15991610            gboolean stepper_size = 14;
    16001611            gint trough_border = 1;
    1601             if (!QGtk::gtk_check_version(2, 10, 0)) {
    1602                 QGtk::gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
     1612            if (!d->gtk_check_version(2, 10, 0)) {
     1613                d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
    16031614                                           "trough-border",   &trough_border,
    16041615                                           "trough-side-details",   &trough_side_details,
     
    16241635            else if (scrollBar->sliderPosition > scrollBar->minimum)
    16251636                fakePos = maximum - 1;
    1626             GtkObject *adjustment =  QGtk::gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
     1637            GtkObject *adjustment =  d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
    16271638
    16281639            if (horizontal)
    1629                 QGtk::gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
     1640                d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
    16301641            else
    1631                 QGtk::gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
     1642                d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
    16321643
    16331644            if (scrollBar->subControls & SC_ScrollBarGroove) {
     
    17261737    case CC_SpinBox:
    17271738        if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
    1728             GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
     1739            GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
    17291740            bool isEnabled = (spinBox->state & State_Enabled);
    17301741            bool hover = isEnabled && (spinBox->state & State_MouseOver);
     
    17351746
    17361747            //### Move this to subControlRect
    1737             QRect upRect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
     1748            QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
    17381749            upRect.setTop(option->rect.top());
    17391750
     
    17431754                upRect.setRight(option->rect.right());
    17441755
    1745             QRect editRect = subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
    1746             QRect downRect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
     1756            QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
     1757            QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
    17471758            downRect.setBottom(option->rect.bottom());
    17481759
     
    17741785                style = gtkPainter.getStyle(gtkSpinButton);
    17751786
    1776                 if (option->state & State_HasFocus)
     1787
     1788                QString key;
     1789
     1790                if (option->state & State_HasFocus) {
     1791                    key += QLatin1Char('f');
    17771792                    GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
    1778                 else
    1779                     GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
    1780 
    1781                 QString key;
    1782 
    1783                 if (option->state & State_HasFocus)
    1784                     key = QLS("f");
     1793                }
    17851794
    17861795                uint resolve_mask = option->palette.resolve();
     
    18151824                else
    18161825                    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);
    18171829            }
    18181830
     
    18401852
    18411853            } else {
    1842                 int size = spinboxArrowSize();
     1854                int size = d->getSpinboxArrowSize();
    18431855                int w = size / 2 - 1;
    18441856                w -= w % 2 - 1; // force odd
     
    18721884    case CC_Slider:
    18731885        if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
    1874             GtkWidget *hScaleWidget = QGtk::gtkWidget(QLS("GtkHScale"));
    1875             GtkWidget *vScaleWidget = QGtk::gtkWidget(QLS("GtkVScale"));
    1876 
    1877             QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget);
    1878             QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget);
    1879             QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
     1886            GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale"));
     1887            GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale"));
     1888
     1889            QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
     1890            QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
     1891            QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
    18801892
    18811893            bool horizontal = slider->orientation == Qt::Horizontal;
     
    18971909
    18981910            if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
    1899                 GtkObject *adjustment =  QGtk::gtk_adjustment_new(slider->sliderPosition,
     1911                GtkObject *adjustment =  d->gtk_adjustment_new(slider->sliderPosition,
    19001912                                         slider->minimum,
    19011913                                         slider->maximum,
     
    19041916                                         slider->pageStep);
    19051917                int outerSize;
    1906                 QGtk::gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
    1907                 QGtk::gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
    1908                 QGtk::gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
     1918                d->gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
     1919                d->gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
     1920                d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
    19091921                outerSize++;
    19101922
     
    19141926                                   -focusFrameMargin, -outerSize - focusFrameMargin);
    19151927
    1916                 gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
    1917                                      GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
    1918 
    19191928                gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
    1920                 if (!QGtk::gtk_check_version(2, 10, 0))
    1921                     QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details",   &trough_side_details, NULL);
    1922 
    1923                 if (trough_side_details && horizontal) { //### Vertical sliders look broken with this for some reason
     1929                if (!d->gtk_check_version(2, 10, 0))
     1930                    d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details",   &trough_side_details, NULL);
     1931
     1932                if (!trough_side_details) {
     1933                    gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
     1934                                         GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
     1935                } else {
     1936                    QRect upperGroove = grooveRect;
    19241937                    QRect lowerGroove = grooveRect;
    1925                     lowerGroove.setRight(handle.center().x());
     1938
     1939                    if (horizontal) {
     1940                        upperGroove.setLeft(handle.center().x());
     1941                        lowerGroove.setRight(handle.center().x());
     1942                    } else {
     1943                        upperGroove.setBottom(handle.center().y());
     1944                        lowerGroove.setTop(handle.center().y());
     1945                    }
     1946
     1947                    gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
     1948                                         GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
    19261949                    gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
    19271950                                         GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
    19281951                }
    1929 
    19301952            }
    19311953
    19321954            if (option->subControls & SC_SliderTickmarks) {
    19331955                painter->setPen(darkOutline);
    1934                 int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
    1935                 int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget);
     1956                int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
     1957                int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
    19361958                int interval = slider->tickInterval;
    19371959
     
    19501972
    19511973                int v = slider->minimum;
    1952                 int len = pixelMetric(PM_SliderLength, slider, widget);
     1974                int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
    19531975                while (v <= slider->maximum + 1) {
    19541976                    if (v == slider->maximum + 1 && interval == 1)
     
    20112033                        fropt.rect.setRight(handle.right() + 3);
    20122034                    }
    2013                     drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
     2035                    proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
    20142036                }
    20152037                gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
     
    20402062                            const QWidget *widget) const
    20412063{
    2042     if (!QGtk::isThemeAvailable()) {
     2064    Q_D(const QGtkStyle);
     2065
     2066    if (!d->isThemeAvailable()) {
    20432067        QCleanlooksStyle::drawControl(element, option, painter, widget);
    20442068        return;
    20452069    }
    20462070
    2047     GtkStyle* style = QGtk::gtkStyle();
     2071    GtkStyle* style = d->gtkStyle();
    20482072    QGtkPainter gtkPainter(painter);
    20492073
     
    20512075    case CE_ProgressBarLabel:
    20522076        if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
    2053             GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));
     2077            GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
    20542078            if (!gtkProgressBar)
    20552079                return;
     
    20702094            if (vertical)
    20712095                rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
    2072             const int progressIndicatorPos = static_cast<int>((bar->progress - qint64(bar->minimum)) /
    2073                                        qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width());
     2096            const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
     2097                                              qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
    20742098            if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
    20752099                leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
     
    21012125            if (option->state & State_Sunken)
    21022126                buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
    2103                                      pixelMetric(PM_ButtonShiftVertical, option, widget));
    2104 
    2105             if (styleHint(SH_UnderlineShortcut, button, widget))
     2127                                     proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
     2128
     2129            if (proxy()->styleHint(SH_UnderlineShortcut, button, widget))
    21062130                tf |= Qt::TextShowMnemonic;
    21072131            else
     
    21542178                ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
    21552179
    2156             GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     2180            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
    21572181            QPalette pal = button->palette;
    21582182            int labelState = GTK_STATE_INSENSITIVE;
     
    21642188            QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
    21652189            pal.setBrush(QPalette::ButtonText, textColor);
    2166             drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
     2190            proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
    21672191                         button->text, QPalette::ButtonText);
    21682192        }
     
    21752199
    21762200            // Draw prelight background
    2177             GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));
     2201            GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
    21782202
    21792203            if (option->state & State_MouseOver) {
     
    21852209            subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
    21862210                                         : SE_CheckBoxIndicator, btn, widget);
    2187             drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
     2211            proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
    21882212                          &subopt, painter, widget);
    21892213            subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
     
    21992223            pal.setBrush(QPalette::WindowText, textColor);
    22002224            subopt.palette = pal;
    2201             drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
     2225            proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
    22022226
    22032227            if (btn->state & State_HasFocus) {
     
    22062230                fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
    22072231                                            : SE_CheckBoxFocusRect, btn, widget);
    2208                 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
     2232                proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
    22092233            }
    22102234        }
     
    22152239    case CE_ComboBoxLabel:
    22162240        if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
    2217             QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
    2218             bool appearsAsList = !styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
     2241            QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
     2242            bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
    22192243            painter->save();
    22202244            painter->setClipRect(editRect);
     
    22342258                    painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
    22352259
    2236                 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
     2260                proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
    22372261
    22382262                if (cb->direction == Qt::RightToLeft)
     
    22432267
    22442268            if (!cb->currentText.isEmpty() && !cb->editable) {
    2245                 GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox"));
     2269                GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
    22462270                QPalette pal = cb->palette;
    22472271                int labelState = GTK_STATE_INSENSITIVE;
     
    22562280                pal.setBrush(QPalette::ButtonText, textColor);
    22572281
    2258                 drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
     2282                proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
    22592283                             visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
    22602284                             pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText);
     
    23022326                    = painter->fontMetrics().elidedText(dwOpt->title,
    23032327                                            Qt::ElideRight, titleRect.width());
    2304                 drawItemText(painter,
     2328                proxy()->drawItemText(painter,
    23052329                             titleRect,
    23062330                             Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
     
    23202344        if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
    23212345            Q_UNUSED(header);
    2322             GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));
     2346            GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
    23232347            // Get the middle column
    2324             GtkTreeViewColumn *column = QGtk::gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
     2348            GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
    23252349            Q_ASSERT(column);
    23262350
     
    23412365
    23422366    case CE_SizeGrip: {
    2343         GtkWidget *gtkStatusbar = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
     2367        GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
    23442368        QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
    2345         gtkPainter.paintResizeGrip( gtkStatusbar, "window", gripRect, GTK_STATE_NORMAL,
     2369        gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
    23462370                                    GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
    23472371                                        GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
     
    23532377
    23542378    case CE_MenuBarEmptyArea: {
    2355         GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
     2379        GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
    23562380        GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
    23572381        painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
     
    23632387            QGtkPainter gtkMenuBarPainter(&pmPainter);
    23642388            GtkShadowType shadow_type;
    2365             QGtk::gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
     2389            d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
    23662390            gtkMenuBarPainter.paintBox( gtkMenubar, "menubar",  menuBarRect,
    23672391                                        GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
     
    23762400
    23772401        if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
    2378             GtkWidget *gtkMenubarItem = QGtk::gtkWidget(QLS("GtkMenuBar.GtkMenuItem"));
    2379             GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
     2402            GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem"));
     2403            GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
    23802404
    23812405            style = gtkMenubarItem->style;
     
    23922416                QGtkPainter menubarPainter(&pmPainter);
    23932417                GtkShadowType shadow_type;
    2394                 QGtk::gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
     2418                d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
    23952419                GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
    23962420                painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
     
    24162440            if (act) {
    24172441                GtkShadowType shadowType = GTK_SHADOW_NONE;
    2418                 QGtk::gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
     2442                d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
    24192443                gtkPainter.paintBox(gtkMenubarItem, "menuitem",  option->rect.adjusted(0, 0, 0, 3),
    24202444                                    GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style);
     
    24232447                uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
    24242448
    2425                 if (!QCleanlooksStyle::styleHint(SH_UnderlineShortcut, mbi, widget))
     2449                if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
    24262450                    alignment |= Qt::TextHideMnemonic;
    24272451
    2428                 drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
     2452                proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
    24292453            }
    24302454        }
     
    24332457
    24342458    case CE_Splitter: {
    2435         GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
     2459        GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
    24362460        gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
    24372461                                !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
     
    24532477                rect.adjust(0, 0, 1, 0);
    24542478
    2455             GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));
     2479            GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
    24562480            GtkShadowType shadow_type = GTK_SHADOW_NONE;
    2457             QGtk::gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
     2481            d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
    24582482            gtkPainter.paintBox( gtkToolbar, "toolbar",  rect,
    24592483                                 GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
     
    24722496            const int windowsItemVMargin      = 26; // menu item ver text margin
    24732497            const int windowsRightBorder      = 15; // right border on windows
    2474             GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
    2475             GtkWidget *gtkMenuItem = menuItem->checked ? QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
    2476                                      QGtk::gtkWidget(QLS("GtkMenu.GtkMenuItem"));
     2498            GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
     2499            GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
     2500                                     d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
    24772501
    24782502            style = gtkPainter.getStyle(gtkMenuItem);
     
    24812505
    24822506            if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
    2483                 GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
     2507                GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
    24842508                painter->setPen(shadow.lighter(106));
    24852509                gboolean wide_separators = 0;
    24862510                gint     separator_height = 0;
    24872511                guint    horizontal_padding = 3;
    2488                 if (!QGtk::gtk_check_version(2, 10, 0)) {
    2489                     QGtk::gtk_widget_style_get(gtkMenuSeparator,
     2512                if (!d->gtk_check_version(2, 10, 0)) {
     2513                    d->gtk_widget_style_get(gtkMenuSeparator,
    24902514                                           "wide-separators",    &wide_separators,
    24912515                                           "separator-height",   &separator_height,
     
    25072531
    25082532            if (selected) {
    2509                 QRect rect = option->rect.adjusted(0, 0, -1, -1);
     2533                QRect rect = option->rect.adjusted(0, 0, 0, -1);
    25102534#ifndef QT_NO_COMBOBOX
    25112535                if (qobject_cast<const QComboBox*>(widget))
     
    25212545
    25222546            gint checkSize;
    2523             QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
     2547            d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
    25242548
    25252549            int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
     
    25982622
    25992623                QPixmap pixmap;
    2600                 int smallIconSize = pixelMetric(PM_SmallIconSize, option, widget);
     2624                int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
    26012625                QSize iconSize(smallIconSize, smallIconSize);
    26022626
     
    26142638                int pixh = pixmap.height();
    26152639                QRect pmr(0, 0, pixw, pixh);
    2616                 pmr.moveCenter(vCheckRect.center());
     2640                pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
    26172641                painter->setPen(menuItem->palette.text().color());
    26182642                if (!ignoreCheckMark && checkable && checked) {
     
    26262650                    opt.state |= State_Sunken;
    26272651                    opt.rect = vCheckRect;
    2628                     drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
     2652                    proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
    26292653                }
    26302654                painter->drawPixmap(pmr.topLeft(), pixmap);
     
    26562680            int tab = menuitem->tabWidth;
    26572681            int xm = windowsItemFrame + checkcol + windowsItemHMargin;
    2658             int xpos = menuitem->rect.x() + xm;
    2659             QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
     2682            int xpos = menuitem->rect.x() + xm + 1;
     2683            QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
    26602684            QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
    26612685            QString s = menuitem->text;
     
    26662690                int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
    26672691
    2668                 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
     2692                if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
    26692693                    text_flags |= Qt::TextHideMnemonic;
    26702694
     
    26992723            if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
    27002724                QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
    2701                                    pixelMetric(PM_ButtonShiftVertical, option, widget));
     2725                                   proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
    27022726
    27032727                QFontMetrics fm(menuitem->font);
    27042728                int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
    27052729                gfloat arrow_scaling = 0.8;
    2706 
    2707                 // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
    2708                 // though the current documentation states otherwise
     2730                int extra = 0;
     2731                if (!d->gtk_check_version(2, 16, 0)) {
     2732                    // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
     2733                    // though the current documentation states otherwise
     2734                    d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
     2735                    // in versions < 2.16 ythickness was previously subtracted from the arrow_size
     2736                    extra = 2 * gtkMenuItem->style->ythickness;
     2737                }
     2738
    27092739                int horizontal_padding;
    2710                 QGtk::gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
    2711 
    2712                 const int dim = static_cast<int>(arrow_size * arrow_scaling);
     2740                d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
     2741
     2742                const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
    27132743                int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
    27142744                QRect  vSubMenuRect = visualRect(option->direction, menuItem->rect,
     
    27262756    case CE_PushButton:
    27272757        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
    2728             GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
    2729             drawControl(CE_PushButtonBevel, btn, painter, widget);
     2758            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
     2759            proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
    27302760            QStyleOptionButton subopt = *btn;
    27312761            subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
    27322762            gint interiorFocus = true;
    2733             QGtk::gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
     2763            d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
    27342764            int xt = interiorFocus ? gtkButton->style->xthickness : 0;
    27352765            int yt = interiorFocus ? gtkButton->style->ythickness : 0;
     
    27372767            if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
    27382768                // The normal button focus rect does not work well for flat buttons in Clearlooks
    2739                 drawPrimitive(PE_FrameFocusRect, option, painter, widget);
     2769                proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
    27402770            else if (btn->state & State_HasFocus)
    27412771                gtkPainter.paintFocus(gtkButton, "button",
     
    27442774                                      gtkButton->style);
    27452775
    2746             drawControl(CE_PushButtonLabel, &subopt, painter, widget);
     2776            proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
    27472777        }
    27482778        break;
     
    27522782    case CE_TabBarTabShape:
    27532783        if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
    2754             GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));
     2784            GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
    27552785            style = gtkPainter.getStyle(gtkNotebook);
    27562786
     
    27612791                state = GTK_STATE_NORMAL;
    27622792
    2763             bool first = tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab;
    2764             bool last = tab->position == QStyleOptionTab::End || tab->position == QStyleOptionTab::OnlyOneTab;
    27652793            bool selected = (tab->state & State_Selected);
    2766             if (option->direction == Qt::RightToLeft) {
     2794            bool first = false, last = false;
     2795            if (widget) {
     2796                // This is most accurate and avoids resizing tabs while moving
     2797                first = tab->rect.left() == widget->rect().left();
     2798                last = tab->rect.right() == widget->rect().right();
     2799            } else if (option->direction == Qt::RightToLeft) {
    27672800                bool tmp = first;
    27682801                first = last;
     
    28162849        if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
    28172850            Q_UNUSED(bar);
    2818             GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));
     2851            GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
    28192852            GtkStateType state = gtkPainter.gtkState(option);
    28202853            gtkPainter.paintBox( gtkProgressBar, "trough",  option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
     
    28262859        if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
    28272860            GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
    2828             GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));
     2861            GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
    28292862            style = gtkProgressBar->style;
    28302863            gtkPainter.paintBox( gtkProgressBar, "trough",  option->rect, state, GTK_SHADOW_IN, style);
     
    28482881                rect.translate(xt, -yt * 2);
    28492882                rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height
    2850                 QTransform m;
    2851                 m.translate(rect.height(), 0);
     2883                QTransform m = QTransform::fromTranslate(rect.height(), 0);
    28522884                m.rotate(90.0);
    28532885                painter->setTransform(m);
     
    28752907                fakePos = maximum - 1;
    28762908
    2877             GtkObject *adjustment =  QGtk::gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
    2878             QGtk::gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
     2909            GtkObject *adjustment =  d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
     2910            d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
    28792911
    28802912            QRect progressBar;
     
    29162948                                SubControl subControl, const QWidget *widget) const
    29172949{
     2950    Q_D(const QGtkStyle);
     2951
    29182952    QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
    2919     if (!QGtk::isThemeAvailable())
     2953    if (!d->isThemeAvailable())
    29202954        return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
    29212955
     
    29592993                QFontMetrics fontMetrics(font);
    29602994                QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4);
    2961                 int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget);
    2962                 int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget);
     2995                int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
     2996                int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
    29632997
    29642998                if (subControl == SC_GroupBoxCheckBox) {
     
    29833017    case CC_SpinBox:
    29843018        if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
    2985             GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
     3019            GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
    29863020            int center = spinbox->rect.height() / 2;
    29873021            int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
     
    29913025            QSize bs;
    29923026            bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
    2993             bs.setWidth(spinboxArrowSize());
     3027            bs.setWidth(d->getSpinboxArrowSize());
    29943028            int x, lx, rx;
    29953029            x = spinbox->rect.width() - y - bs.width() + 2;
     
    30373071            // We employ the gtk widget to position arrows and separators for us
    30383072            QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox");
    3039             GtkWidget *gtkCombo = QGtk::gtkWidget(comboBoxPath);
    3040             QGtk::gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
     3073            GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
     3074            d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
    30413075            GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
    3042             QGtk::gtk_widget_size_allocate(gtkCombo, &geometry);
    3043             int appears_as_list = !styleHint(QStyle::SH_ComboBox_Popup, option, widget);
     3076            d->gtk_widget_size_allocate(gtkCombo, &geometry);
     3077            int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
    30443078            QString arrowPath = comboBoxPath + QLS(".GtkToggleButton");
    30453079
     
    30473081                arrowPath += QLS(".GtkHBox.GtkArrow");
    30483082
    3049             GtkWidget *arrowWidget = QGtk::gtkWidget(arrowPath);
     3083            GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
    30503084            if (!arrowWidget)
    30513085                return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
    30523086
    3053             QRect buttonRect(arrowWidget->allocation.x, arrowWidget->allocation.y,
     3087            QRect buttonRect(option->rect.left() + arrowWidget->allocation.x,
     3088                             option->rect.top() + arrowWidget->allocation.y,
    30543089                             arrowWidget->allocation.width, arrowWidget->allocation.height);
    30553090
     
    30583093            case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos
    30593094                rect = buttonRect;
    3060 
    30613095                break;
    30623096
     
    30923126*/
    30933127QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
    3094 
    30953128                                  const QSize &size, const QWidget *widget) const
    30963129{
     3130    Q_D(const QGtkStyle);
    30973131
    30983132    QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget);
    3099     if (!QGtk::isThemeAvailable())
     3133    if (!d->isThemeAvailable())
    31003134        return newSize;
    31013135
     
    31043138    case CT_ToolButton:
    31053139        if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
    3106             GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
    3107             newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness);
     3140            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
     3141            newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
    31083142            if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
    31093143                QSize minSize(0, 25);
     
    31123146                newSize = newSize.expandedTo(minSize);
    31133147            }
    3114            
     3148
    31153149            if (toolbutton->features & QStyleOptionToolButton::HasMenu)
    31163150                newSize += QSize(6, 0);
     
    31233157
    31243158            if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
    3125                 GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
     3159                GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
    31263160                gboolean wide_separators;
    31273161                gint     separator_height;
    3128                 QGtk::gtk_widget_style_get(gtkMenuSeparator,
     3162                d->gtk_widget_style_get(gtkMenuSeparator,
    31293163                                       "wide-separators",    &wide_separators,
    31303164                                       "separator-height",   &separator_height,
     
    31353169            }
    31363170
    3137             GtkWidget *gtkMenuItem = QGtk::gtkWidget(QLS("GtkMenu.GtkMenuItem"));
     3171            GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
    31383172            GtkStyle* style = gtkMenuItem->style;
    3139             newSize += QSize(textMargin + style->xthickness - 2, style->ythickness - 4);
     3173            newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3);
    31403174
    31413175            // Cleanlooks assumes a check column of 20 pixels so we need to
    31423176            // expand it a bit
    31433177            gint checkSize;
    3144             QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
     3178            d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
    31453179            newSize.setHeight(qMax(newSize.height(), checkSize + 2));
    31463180            newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
     
    31573191    case CT_SpinBox:
    31583192        // QSpinBox does some nasty things that depends on CT_LineEdit
    3159         newSize = size + QSize(0, -QGtk::gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2 + 2);
     3193        newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2);
    31603194        break;
    31613195
    31623196    case CT_PushButton:
    31633197        if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
    3164             GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
     3198            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
    31653199            gint focusPadding, focusWidth;
    3166             QGtk::gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
    3167             QGtk::gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
     3200            d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
     3201            d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
    31683202            newSize = size;
    31693203            newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
    31703204            newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
    31713205
    3172             GtkWidget *gtkButtonBox = QGtk::gtkWidget(QLS("GtkHButtonBox"));
     3206            GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox"));
    31733207            gint minWidth = 85, minHeight = 0;
    3174             QGtk::gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
     3208            d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
    31753209                                   "child-min-height", &minHeight, NULL);
    31763210            if (!btn->text.isEmpty() && newSize.width() < minWidth)
     
    31833217
    31843218    case CT_Slider: {
    3185         GtkWidget *gtkSlider = QGtk::gtkWidget(QLS("GtkHScale"));
     3219        GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale"));
    31863220        newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
    31873221    }
    31883222    break;
    31893223
    3190     case CT_MenuBarItem://cleanlooks adds 2 pixels
    3191         newSize = QWindowsStyle::sizeFromContents(type, option, size, widget) + QSize(0, 1);
    3192         break;
    3193 
    31943224    case CT_LineEdit: {
    3195         GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
    3196         newSize = size + QSize(2*gtkEntry->style->xthickness, 2*gtkEntry->style->ythickness);
     3225        GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
     3226        newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
    31973227    }
    31983228    break;
     
    32043234    case CT_ComboBox:
    32053235        if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
    3206             GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox"));
    3207             QRect arrowButtonRect = subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
     3236            GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
     3237            QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
    32083238            newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
    32093239
    32103240            if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
    3211                 newSize += QSize(0, 3);
     3241                newSize += QSize(0, 2);
    32123242        }
    32133243        break;
     
    32223252                newSize += QSize(6, 0);
    32233253        }
    3224         newSize += QSize(1, 0);
     3254        newSize += QSize(1, 1);
    32253255        break;
    32263256
     
    32313261    return newSize;
    32323262}
     3263
    32333264
    32343265/*! \reimp */
     
    32363267                                  const QWidget *widget) const
    32373268{
    3238     if (!QGtk::isThemeAvailable())
     3269    Q_D(const QGtkStyle);
     3270
     3271    if (!d->isThemeAvailable())
    32393272        return QCleanlooksStyle::standardPixmap(sp, option, widget);
    32403273
     
    32643297    break;
    32653298
    3266     case SP_DialogDiscardButton: {
     3299    case SP_DialogDiscardButton:
    32673300        return QGtkPainter::getIcon(GTK_STOCK_DELETE);
    3268     }
    3269 
    3270     case SP_DialogOkButton: {
     3301    case SP_DialogOkButton:
    32713302        return QGtkPainter::getIcon(GTK_STOCK_OK);
    3272     }
    3273 
    3274     case SP_DialogCancelButton: {
     3303    case SP_DialogCancelButton:
    32753304        return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
    3276     }
    3277 
    3278     case SP_DialogYesButton: {
     3305    case SP_DialogYesButton:
    32793306        return QGtkPainter::getIcon(GTK_STOCK_YES);
    3280     }
    3281 
    3282     case SP_DialogNoButton: {
     3307    case SP_DialogNoButton:
    32833308        return QGtkPainter::getIcon(GTK_STOCK_NO);
    3284     }
    3285 
    3286     case SP_DialogOpenButton: {
     3309    case SP_DialogOpenButton:
    32873310        return QGtkPainter::getIcon(GTK_STOCK_OPEN);
    3288     }
    3289 
    3290     case SP_DialogCloseButton: {
     3311    case SP_DialogCloseButton:
    32913312        return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
    3292     }
    3293 
    3294     case SP_DialogApplyButton: {
     3313    case SP_DialogApplyButton:
    32953314        return QGtkPainter::getIcon(GTK_STOCK_APPLY);
    3296     }
    3297 
    3298     case SP_DialogSaveButton: {
     3315    case SP_DialogSaveButton:
    32993316        return QGtkPainter::getIcon(GTK_STOCK_SAVE);
    3300     }
    3301 
    3302     case SP_MessageBoxWarning: {
     3317    case SP_MessageBoxWarning:
    33033318        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
    3304     }
    3305 
    3306     case SP_MessageBoxQuestion: {
     3319    case SP_MessageBoxQuestion:
    33073320        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
    3308     }
    3309 
    3310     case SP_MessageBoxInformation: {
     3321    case SP_MessageBoxInformation:
    33113322        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
    3312     }
    3313 
    3314     case SP_MessageBoxCritical: {
     3323    case SP_MessageBoxCritical:
    33153324        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
    3316     }
    3317 
    33183325    default:
    33193326        return QCleanlooksStyle::standardPixmap(sp, option, widget);
    33203327    }
    3321 
    3322     return QPixmap();
     3328    return pixmap;
    33233329}
     3330
     3331/*!
     3332    \internal
     3333*/
     3334QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
     3335                                                  const QStyleOption *option,
     3336                                                  const QWidget *widget) const
     3337{
     3338    Q_D(const QGtkStyle);
     3339
     3340    if (!d->isThemeAvailable())
     3341        return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
     3342    switch (standardIcon) {
     3343    case SP_DialogDiscardButton:
     3344        return QGtkPainter::getIcon(GTK_STOCK_DELETE);
     3345    case SP_DialogOkButton:
     3346        return QGtkPainter::getIcon(GTK_STOCK_OK);
     3347    case SP_DialogCancelButton:
     3348        return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
     3349    case SP_DialogYesButton:
     3350        return QGtkPainter::getIcon(GTK_STOCK_YES);
     3351    case SP_DialogNoButton:
     3352        return QGtkPainter::getIcon(GTK_STOCK_NO);
     3353    case SP_DialogOpenButton:
     3354        return QGtkPainter::getIcon(GTK_STOCK_OPEN);
     3355    case SP_DialogCloseButton:
     3356        return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
     3357    case SP_DialogApplyButton:
     3358        return QGtkPainter::getIcon(GTK_STOCK_APPLY);
     3359    case SP_DialogSaveButton:
     3360        return QGtkPainter::getIcon(GTK_STOCK_SAVE);
     3361    case SP_MessageBoxWarning:
     3362        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
     3363    case SP_MessageBoxQuestion:
     3364        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
     3365    case SP_MessageBoxInformation:
     3366        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
     3367    case SP_MessageBoxCritical:
     3368        return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
     3369    default:
     3370        return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
     3371    }
     3372}
     3373
    33243374
    33253375/*! \reimp */
    33263376QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
    33273377{
     3378    Q_D(const QGtkStyle);
     3379
    33283380    QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
    33293381    switch (element) {
     
    33323384    case SE_ProgressBarGroove:
    33333385        return option->rect;
     3386    case SE_PushButtonContents:
     3387        if (!d->gtk_check_version(2, 10, 0)) {
     3388            GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
     3389            GtkBorder *border = 0;
     3390            d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
     3391            if (border) {
     3392                r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
     3393                d->gtk_border_free(border);
     3394            } else {
     3395                r = option->rect.adjusted(1, 1, -1, -1);
     3396            }
     3397            r = visualRect(option->direction, option->rect, r);
     3398        }
     3399        break;
    33343400    default:
    33353401        break;
Note: See TracChangeset for help on using the changeset viewer.