Changeset 561 for trunk/src/gui/styles/qgtkstyle.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/styles/qgtkstyle.cpp
r2 r561 1 /******* 1 /**************************************************************************** 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 70 70 #include <qpixmapcache.h> 71 71 #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> 74 75 #include <private/qcleanlooksstyle_p.h> 75 76 76 77 77 78 QT_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;92 79 93 80 static const char * const dock_widget_close_xpm[] = … … 137 124 }; 138 125 139 140 class QGtkStyleFilter : public QObject141 {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 also155 // generate applicationPaletteChange events156 extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp157 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 QCleanlooksStylePrivate165 {166 Q_DECLARE_PUBLIC(QGtkStyle)167 public:168 QGtkStylePrivate()169 : QCleanlooksStylePrivate()170 {}171 QGtkStyleFilter filter;172 };173 174 126 static const int groupBoxBottomMargin = 2; // space below the groupbox 175 127 static const int groupBoxTitleMargin = 6; // space between contents and title 176 128 static 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 */ 134 QString QGtkStyle::getGConfString(const QString &value, const QString &fallback) 181 135 { 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 */ 143 bool QGtkStyle::getGConfBool(const QString &key, bool fallback) 144 { 145 return QGtkStylePrivate::getGConfBool(key, fallback); 190 146 } 191 147 … … 209 165 } 210 166 211 // Note this is different from uniqueName as used in QGtkPainter212 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 222 167 /*! 223 168 \class QGtkStyle … … 244 189 : QCleanlooksStyle(*new QGtkStylePrivate) 245 190 { 246 QGtk::initGtkWidgets(); 191 Q_D(QGtkStyle); 192 d->init(); 247 193 } 194 195 /*! 196 \internal 197 198 Constructs a QGtkStyle object. 199 */ 200 QGtkStyle::QGtkStyle(QGtkStylePrivate &dd) 201 : QCleanlooksStyle(dd) 202 { 203 Q_D(QGtkStyle); 204 d->init(); 205 } 206 248 207 249 208 /*! … … 259 218 QPalette QGtkStyle::standardPalette() const 260 219 { 220 Q_D(const QGtkStyle); 221 261 222 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(); 266 227 267 228 GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg; … … 293 254 294 255 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")); 296 257 GdkColor *gtkAltBase = NULL; 297 QGtk::gtk_widget_style_get(gtkTreeView, "odd-row-color", >kAltBase, NULL);258 d->gtk_widget_style_get(gtkTreeView, "odd-row-color", >kAltBase, NULL); 298 259 if (gtkAltBase) { 299 260 alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8); 300 QGtk::gdk_color_free(gtkAltBase);261 d->gdk_color_free(gtkAltBase); 301 262 } 302 263 palette.setColor(QPalette::AlternateBase, alternateRowColor); … … 318 279 palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight); 319 280 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()); 321 283 if (style) { 322 284 gdkText = style->fg[GTK_STATE_NORMAL]; … … 333 295 void QGtkStyle::polish(QPalette &palette) 334 296 { 297 Q_D(QGtkStyle); 298 335 299 // QCleanlooksStyle will alter the palette, hence we do 336 300 // not want to polish the palette unless we are using it as 337 301 // the fallback 338 if (! QGtk::isThemeAvailable())302 if (!d->isThemeAvailable()) 339 303 QCleanlooksStyle::polish(palette); 340 304 else … … 347 311 void QGtkStyle::polish(QApplication *app) 348 312 { 313 Q_D(QGtkStyle); 314 349 315 QCleanlooksStyle::polish(app); 350 316 // Custom fonts and palettes with QtConfig are intentionally 351 317 // not supported as these should be entirely determined by 352 318 // current Gtk settings 353 if (app->desktopSettingsAware() && QGtk::isThemeAvailable()) {319 if (app->desktopSettingsAware() && d->isThemeAvailable()) { 354 320 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; 362 328 } 363 329 } … … 369 335 void QGtkStyle::unpolish(QApplication *app) 370 336 { 337 Q_D(QGtkStyle); 338 371 339 QCleanlooksStyle::unpolish(app); 372 340 QPixmapCache::clear(); 373 341 374 if (app->desktopSettingsAware() && QGtk::isThemeAvailable()375 && ! QGtk::isKDE4Session()) {342 if (app->desktopSettingsAware() && d->isThemeAvailable() 343 && !d->isKDE4Session()) { 376 344 qt_filedialog_open_filename_hook = 0; 377 345 qt_filedialog_save_filename_hook = 0; … … 387 355 void QGtkStyle::polish(QWidget *widget) 388 356 { 357 Q_D(QGtkStyle); 358 389 359 QCleanlooksStyle::polish(widget); 390 if (! QGtk::isThemeAvailable())360 if (!d->isThemeAvailable()) 391 361 return; 392 362 if (qobject_cast<QAbstractButton*>(widget) … … 416 386 */ 417 387 int QGtkStyle::pixelMetric(PixelMetric metric, 418 419 388 const QStyleOption *option, 420 389 const QWidget *widget) const 421 390 { 422 if (!QGtk::isThemeAvailable()) 391 Q_D(const QGtkStyle); 392 393 if (!d->isThemeAvailable()) 423 394 return QCleanlooksStyle::pixelMetric(metric, option, widget); 424 395 … … 427 398 if (qobject_cast<const QFrame*>(widget)) { 428 399 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(), 430 401 "*.GtkScrolledWindow", 431 402 "*.GtkScrolledWindow", 432 Q_GTK_TYPE_WINDOW))403 d->gtk_window_get_type())) 433 404 return qMax(style->xthickness, style->ythickness); 434 405 } … … 451 422 452 423 case PM_ButtonShiftHorizontal: { 453 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));424 GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); 454 425 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); 456 427 return horizontal_shift; 457 428 } 458 429 459 430 case PM_ButtonShiftVertical: { 460 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));431 GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); 461 432 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); 463 434 return vertical_shift; 464 435 } … … 468 439 469 440 case PM_MenuPanelWidth: { 470 GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));441 GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); 471 442 guint horizontal_padding = 0; 472 443 // 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); 475 446 int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding); 476 447 return padding; … … 479 450 case PM_ButtonIconSize: { 480 451 int retVal = 24; 481 GtkSettings *settings = QGtk::gtk_settings_get_default();452 GtkSettings *settings = d->gtk_settings_get_default(); 482 453 gchararray icon_sizes; 483 454 g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL); … … 525 496 case PM_SliderThickness: 526 497 case PM_SliderControlThickness: { 527 GtkWidget *gtkScale = QGtk::gtkWidget(QLS("GtkHScale"));498 GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale")); 528 499 gint val; 529 QGtk::gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);500 d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL); 530 501 if (metric == PM_SliderControlThickness) 531 502 return val + 2*gtkScale->style->ythickness; … … 536 507 gint sliderLength; 537 508 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, 540 511 "trough-border", &trough_border, 541 512 "slider-width", &sliderLength, … … 549 520 case PM_SliderLength: 550 521 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); 552 523 return val; 553 524 … … 556 527 case PM_IndicatorWidth: 557 528 case PM_IndicatorHeight: { 558 GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));529 GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); 559 530 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); 561 532 return size + 2 * spacing; 562 533 } 563 534 564 535 case PM_MenuBarVMargin: { 565 GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));536 GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); 566 537 return qMax(0, gtkMenubar->style->ythickness); 567 538 } … … 569 540 { 570 541 gint spacing = 3; 571 GtkWidget *gtkScrollWindow = QGtk::gtkWidget(QLS("GtkScrolledWindow"));542 GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow")); 572 543 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); 574 545 return spacing; 575 546 } 576 547 case PM_SubMenuOverlap: { 577 548 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); 580 551 return offset; 581 552 } … … 592 563 QStyleHintReturn *returnData = 0) const 593 564 { 594 if (!QGtk::isThemeAvailable()) 565 Q_D(const QGtkStyle); 566 567 if (!d->isThemeAvailable()) 595 568 return QCleanlooksStyle::styleHint(hint, option, widget, returnData); 596 569 … … 600 573 int ret = QDialogButtonBox::GnomeLayout; 601 574 gboolean alternateOrder = 0; 602 GtkSettings *settings = QGtk::gtk_settings_get_default();575 GtkSettings *settings = d->gtk_settings_get_default(); 603 576 g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL); 604 577 … … 611 584 break; 612 585 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; 613 606 case SH_SpinControls_DisableOnBounds: 614 607 return int(true); … … 618 611 619 612 case SH_ComboBox_Popup: { 620 GtkWidget *gtkComboBox = QGtk::gtkWidget(QLS("GtkComboBox"));613 GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox")); 621 614 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); 623 616 return appears_as_list ? 0 : 1; 624 617 } … … 632 625 case SH_Menu_SubMenuPopupDelay: { 633 626 gint delay = 225; 634 GtkSettings *settings = QGtk::gtk_settings_get_default();627 GtkSettings *settings = d->gtk_settings_get_default(); 635 628 g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL); 636 629 return delay; … … 641 634 if (widget && widget->isWindow()) 642 635 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); 646 639 } 647 640 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; 648 655 } 649 656 … … 657 664 */ 658 665 void QGtkStyle::drawPrimitive(PrimitiveElement element, 659 660 666 const QStyleOption *option, 661 667 QPainter *painter, 662 668 const QWidget *widget) const 663 669 { 664 if (!QGtk::isThemeAvailable()) { 670 Q_D(const QGtkStyle); 671 672 if (!d->isThemeAvailable()) { 665 673 QCleanlooksStyle::drawPrimitive(element, option, painter, widget); 666 674 return; 667 675 } 668 676 669 GtkStyle* style = QGtk::gtkStyle();677 GtkStyle* style = d->gtkStyle(); 670 678 QGtkPainter gtkPainter(painter); 671 679 … … 675 683 QStyleOption copy = *option; 676 684 copy.state |= State_Raised; 677 drawPrimitive(PE_PanelMenu, ©, painter, widget);685 proxy()->drawPrimitive(PE_PanelMenu, ©, painter, widget); 678 686 break; 679 687 } … … 682 690 // thin rectangular images 683 691 const int pmSize = 64; 684 const int border = p ixelMetric(PM_DefaultFrameWidth, option, widget);692 const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); 685 693 const QString pmKey = QString(QLS("windowframe %0")).arg(option->state); 686 694 687 695 QPixmap pixmap; 688 QPixmapCache::find(pmKey, pixmap);689 696 QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); 690 697 691 698 // Only draw through style once 692 if ( pixmap.isNull()) {699 if (!QPixmapCache::find(pmKey, pixmap)) { 693 700 pixmap = QPixmap(pmSize, pmSize); 694 701 pixmap.fill(Qt::transparent); … … 703 710 shadow_type = GTK_SHADOW_OUT; 704 711 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()); 707 714 if (style) 708 gtkFramePainter.paintShadow( QGtk::gtkWidget(QLS("GtkFrame")), "viewport", pmRect,715 gtkFramePainter.paintShadow(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect, 709 716 option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, 710 717 shadow_type, style); … … 733 740 734 741 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()); 737 745 gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style); 738 746 } … … 747 755 } 748 756 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); 751 759 gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL, 752 760 shadow_type, gtkStatusbarFrame->style); … … 756 764 case PE_IndicatorHeaderArrow: 757 765 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")); 759 767 GtkStateType state = gtkPainter.gtkState(option); 760 768 style = gtkTreeHeader->style; … … 789 797 if (option->state & State_Children) { 790 798 QRect rect = option->rect; 791 rect = QRect(0, 0, 1 0, 10);799 rect = QRect(0, 0, 12, 12); 792 800 rect.moveCenter(option->rect.center()); 793 801 rect.translate(2, 0); 794 802 GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED; 795 803 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 802 806 GtkStateType state = GTK_STATE_NORMAL; 803 807 if (!(option->state & State_Enabled)) … … 805 809 else if (option->state & State_MouseOver) 806 810 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); 809 814 } 810 815 break; … … 833 838 { 834 839 const int margin = 6; 835 GtkWidget *gtkSeparator = QGtk::gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));840 GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem")); 836 841 if (option->state & State_Horizontal) { 837 842 const int offset = option->rect.width()/2; … … 853 858 854 859 case PE_IndicatorToolBarHandle: { 855 GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));860 GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); 856 861 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); 858 863 //Note when the toolbar is horizontal, the handle is vertical 859 864 painter->setClipRect(option->rect); … … 893 898 int bsx = 0, bsy = 0; 894 899 if (option->state & State_Sunken) { 895 bsx = p ixelMetric(PM_ButtonShiftHorizontal);896 bsy = p ixelMetric(PM_ButtonShiftVertical);900 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); 901 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); 897 902 } 898 903 QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy); … … 901 906 902 907 QColor arrowColor = option->palette.buttonText().color(); 903 GtkWidget *gtkArrow = QGtk::gtkWidget(QLS("GtkArrow"));908 GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow")); 904 909 GdkColor color = fromQColor(arrowColor); 905 QGtk::gtk_widget_modify_fg (gtkArrow, state, &color);910 d->gtk_widget_modify_fg (gtkArrow, state, &color); 906 911 gtkPainter.paintArrow(gtkArrow, "button", arrowRect, 907 912 type, state, shadow, FALSE, gtkArrow->style, 908 913 QString::number(arrowColor.rgba(), 16)); 909 914 // 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); 911 916 } 912 917 break; … … 917 922 918 923 case PE_PanelMenu: { 919 GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));924 GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); 920 925 gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons 921 926 gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString()); … … 929 934 // This is only used by floating tool bars 930 935 if (qobject_cast<const QToolBar *>(widget)) { 931 GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));936 GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); 932 937 gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect, 933 938 GTK_STATE_NORMAL, GTK_SHADOW_OUT, style); … … 938 943 939 944 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 946 947 947 948 gboolean interior_focus; 948 949 gint focus_line_width; 949 950 QRect rect = option->rect; 950 QGtk::gtk_widget_style_get(gtkEntry,951 d->gtk_widget_style_get(gtkEntry, 951 952 "interior-focus", &interior_focus, 952 953 "focus-line-width", &focus_line_width, NULL); 953 954 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 954 958 if (!interior_focus && option->state & State_HasFocus) 955 959 rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width); 956 960 961 if (option->state & State_HasFocus) 962 GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS); 957 963 gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ? 958 964 GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, 959 965 GTK_SHADOW_IN, gtkEntry->style, 960 966 option->state & State_HasFocus ? QLS("focus") : QString()); 961 962 967 if (!interior_focus && option->state & State_HasFocus) 963 968 gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ? 964 969 GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, 965 970 GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn")); 971 972 if (option->state & State_HasFocus) 973 GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS); 966 974 } 967 975 break; … … 969 977 case PE_PanelLineEdit: 970 978 if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) { 971 GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));979 GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); 972 980 if (panel->lineWidth > 0) 973 drawPrimitive(PE_FrameLineEdit, option, painter, widget);981 proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget); 974 982 uint resolve_mask = option->palette.resolve(); 975 983 QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness, … … 978 986 if (widget && widget->testAttribute(Qt::WA_SetPalette) && 979 987 resolve_mask & (1 << QPalette::Base)) // Palette overridden by user 980 painter->fillRect(textRect, option->palette.base() .color());988 painter->fillRect(textRect, option->palette.base()); 981 989 else 982 990 gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect, … … 987 995 case PE_FrameTabWidget: 988 996 if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) { 989 GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));997 GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); 990 998 style = gtkPainter.getStyle(gtkNotebook); 991 999 gtkPainter.setAlphaSupport(false); 992 1000 GtkShadowType shadow = GTK_SHADOW_OUT; 993 1001 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(); 1018 1017 } 1019 } 1018 gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, 1019 gapStart, gapSize, style); 1020 break; // done 1021 } 1022 1020 1023 // Note this is only the fallback option 1021 1024 gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style); … … 1023 1026 break; 1024 1027 1025 case PE_PanelButtonCommand: { 1028 case PE_PanelButtonCommand: 1029 case PE_PanelButtonTool: { 1026 1030 bool isDefault = false; 1031 bool isTool = (element == PE_PanelButtonTool); 1027 1032 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option)) 1028 1033 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; 1029 1041 1030 1042 GtkStateType state = gtkPainter.gtkState(option); 1031 1043 if (option->state & State_On || option->state & State_Sunken) 1032 1044 state = GTK_STATE_ACTIVE; 1033 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));1045 GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton")); 1034 1046 gint focusWidth, focusPad; 1035 1047 gboolean interiorFocus = false; 1036 QGtk::gtk_widget_style_get (gtkButton,1048 d->gtk_widget_style_get (gtkButton, 1037 1049 "focus-line-width", &focusWidth, 1038 1050 "focus-padding", &focusPad, … … 1049 1061 gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN, 1050 1062 style, isDefault ? QLS("d") : QString()); 1051 } else 1052 GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT); 1063 } 1053 1064 1054 1065 bool hasFocus = option->state & State_HasFocus; … … 1057 1068 key += QLS("def"); 1058 1069 GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS); 1059 1060 } else {1061 GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);1062 1070 } 1063 1071 … … 1070 1078 gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow, 1071 1079 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); 1072 1084 } 1073 1085 break; … … 1087 1099 shadow = GTK_SHADOW_OUT; 1088 1100 1089 GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));1101 GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); 1090 1102 gint spacing; 1091 QGtk::gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);1103 d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL); 1092 1104 QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); 1093 1105 gtkPainter.setClipRect(option->rect); 1094 1106 // ### Note: Ubuntulooks breaks when the proper widget is passed 1095 1107 // 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")); 1097 1109 gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, QLS("radiobutton")); 1098 1110 … … 1116 1128 int spacing; 1117 1129 1118 GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));1130 GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); 1119 1131 1120 1132 // Some styles such as aero-clone assume they can paint in the spacing area 1121 1133 gtkPainter.setClipRect(option->rect); 1122 1134 1123 QGtk::gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);1135 d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL); 1124 1136 1125 1137 QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); … … 1188 1200 QPainter *painter, const QWidget *widget) const 1189 1201 { 1190 if (!QGtk::isThemeAvailable()) { 1202 Q_D(const QGtkStyle); 1203 1204 if (!d->isThemeAvailable()) { 1191 1205 QCleanlooksStyle::drawComplexControl(control, option, painter, widget); 1192 1206 return; 1193 1207 } 1194 1208 1195 GtkStyle* style = QGtk::gtkStyle();1209 GtkStyle* style = d->gtkStyle(); 1196 1210 QGtkPainter gtkPainter(painter); 1197 1211 QColor button = option->palette.button().color(); … … 1242 1256 1243 1257 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); 1246 1260 // Draw title 1247 1261 1248 1262 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { 1249 1263 // Draw prelight background 1250 GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));1264 GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); 1251 1265 1252 1266 if (option->state & State_MouseOver) { … … 1258 1272 if (!groupBox->text.isEmpty()) { 1259 1273 int alignment = int(groupBox->textAlignment); 1260 if (! styleHint(QStyle::SH_UnderlineShortcut, option, widget))1274 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) 1261 1275 alignment |= Qt::TextHideMnemonic; 1262 1276 QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored … … 1283 1297 box.QStyleOption::operator=(*groupBox); 1284 1298 box.rect = checkBoxRect; 1285 drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);1299 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); 1286 1300 } 1287 1301 } … … 1306 1320 QColor buttonShadow = option->palette.dark().color(); 1307 1321 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); 1309 1323 QPixmap cache; 1310 1324 QString pixmapName; … … 1314 1328 bool reverse = (option->direction == Qt::RightToLeft); 1315 1329 QRect rect = option->rect; 1316 QRect arrowButtonRect = subControlRect(CC_ComboBox, &comboBoxCopy,1330 QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, 1317 1331 SC_ComboBoxArrow, widget); 1318 QRect editRect = subControlRect(CC_ComboBox, &comboBoxCopy,1332 QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, 1319 1333 SC_ComboBoxEditField, widget); 1320 1334 … … 1324 1338 1325 1339 // We use the gtk widget to position arrows and separators for us 1326 GtkWidget *gtkCombo = QGtk::gtkWidget(comboBoxPath);1340 GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); 1327 1341 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); 1330 1344 1331 1345 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); 1334 1348 if (gtkToggleButton && (appears_as_list || comboBox->editable)) { 1349 if (focus) 1350 GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); 1335 1351 // Draw the combo box as a line edit with a button next to it 1336 1352 if (comboBox->editable || appears_as_list) { 1337 1353 GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state; 1338 1354 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); 1341 1357 QRect frameRect = option->rect; 1342 1358 … … 1345 1361 else 1346 1362 frameRect.setRight(arrowButtonRect.left()); 1347 1348 // Required for inner blue highlight with clearlooks1349 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 }1357 1363 1358 1364 // Fill the line edit background … … 1362 1368 int yt = gtkEntry->style->ythickness; 1363 1369 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 1364 1374 if (widget && widget->testAttribute(Qt::WA_SetPalette) && 1365 1375 resolve_mask & (1 << QPalette::Base)) // Palette overridden by user … … 1368 1378 gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, 1369 1379 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)); 1371 1381 } 1372 1382 … … 1375 1385 QString::number(focus) + QString::number(comboBox->editable) + 1376 1386 QString::number(option->direction)); 1387 if (focus) 1388 GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS); 1377 1389 } 1378 1390 … … 1393 1405 shadow, gtkToggleButton->style, buttonPath + 1394 1406 QString::number(focus) + QString::number(option->direction)); 1395 1407 if (focus) 1408 GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); 1396 1409 } else { 1397 1410 // Draw combo box as a button 1398 1411 QRect buttonRect = option->rect; 1399 1412 1400 if (focus) {// Clearlooks actually check the widget for the default state1413 if (focus) // Clearlooks actually check the widget for the default state 1401 1414 GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); 1402 1403 } else {1404 GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);1405 }1406 1407 1415 gtkCachedPainter.paintBox(gtkToggleButton, "button", 1408 1416 buttonRect, state, 1409 1417 shadow, gtkToggleButton->style, 1410 1418 buttonPath + QString::number(focus)); 1419 if (focus) 1420 GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); 1421 1411 1422 // Draw the separator between label and arrows 1412 1423 QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator"); 1413 1424 1414 if (GtkWidget *gtkVSeparator = QGtk::gtkWidget(vSeparatorPath)) {1425 if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) { 1415 1426 QRect vLineRect(gtkVSeparator->allocation.x, 1416 1427 gtkVSeparator->allocation.y, … … 1424 1435 1425 1436 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); 1427 1438 int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0; 1428 1439 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))) 1430 1441 gtkCachedPainter.paintFocus(gtkToggleButton, "button", 1431 1442 option->rect.adjusted(xt, yt, -xt, -yt), … … 1448 1459 : ".GtkToggleButton.GtkHBox.GtkArrow"); 1449 1460 1450 GtkWidget *gtkArrow = QGtk::gtkWidget(arrowPath);1461 GtkWidget *gtkArrow = d->gtkWidget(arrowPath); 1451 1462 gfloat scale = 0.7; 1452 1463 gint minSize = 15; 1453 1464 QRect arrowWidgetRect; 1454 1465 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); 1458 1469 } 1459 1470 if (gtkArrow) { … … 1473 1484 if (sunken) { 1474 1485 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); 1478 1489 arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff); 1479 1490 } … … 1498 1509 = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { 1499 1510 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); 1502 1513 State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver); 1503 1514 … … 1528 1539 tool.rect = button; 1529 1540 tool.state = bflags; 1530 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);1541 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); 1531 1542 } 1532 1543 } … … 1539 1550 QStyleOptionFocusRect fr; 1540 1551 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); 1542 1553 fr.rect.adjust(1, 1, -1, -1); 1543 drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);1554 proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); 1544 1555 } 1545 1556 1546 1557 QStyleOptionToolButton label = *toolbutton; 1547 1558 label.state = bflags; 1548 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));1559 GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); 1549 1560 QPalette pal = toolbutton->palette; 1550 1561 if (option->state & State_Enabled && … … 1557 1568 label.rect = button.adjusted(style->xthickness, style->ythickness, 1558 1569 -style->xthickness - popupArrowSize, -style->ythickness); 1559 drawControl(CE_ToolButtonLabel, &label, painter, widget);1570 proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); 1560 1571 1561 1572 if (toolbutton->subControls & SC_ToolButtonMenu) { … … 1563 1574 tool.state = mflags; 1564 1575 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); 1568 1579 1569 1580 } else if (drawMenuArrow) { … … 1571 1582 QStyleOptionToolButton newBtn = *toolbutton; 1572 1583 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); 1574 1585 } 1575 1586 } … … 1581 1592 case CC_ScrollBar: 1582 1593 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")); 1585 1596 1586 1597 // Fill background in case the scrollbar is partially transparent … … 1588 1599 1589 1600 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); 1594 1605 bool horizontal = scrollBar->orientation == Qt::Horizontal; 1595 1606 GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar; … … 1599 1610 gboolean stepper_size = 14; 1600 1611 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), 1603 1614 "trough-border", &trough_border, 1604 1615 "trough-side-details", &trough_side_details, … … 1624 1635 else if (scrollBar->sliderPosition > scrollBar->minimum) 1625 1636 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); 1627 1638 1628 1639 if (horizontal) 1629 QGtk::gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));1640 d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment)); 1630 1641 else 1631 QGtk::gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));1642 d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment)); 1632 1643 1633 1644 if (scrollBar->subControls & SC_ScrollBarGroove) { … … 1726 1737 case CC_SpinBox: 1727 1738 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { 1728 GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));1739 GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); 1729 1740 bool isEnabled = (spinBox->state & State_Enabled); 1730 1741 bool hover = isEnabled && (spinBox->state & State_MouseOver); … … 1735 1746 1736 1747 //### 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); 1738 1749 upRect.setTop(option->rect.top()); 1739 1750 … … 1743 1754 upRect.setRight(option->rect.right()); 1744 1755 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); 1747 1758 downRect.setBottom(option->rect.bottom()); 1748 1759 … … 1774 1785 style = gtkPainter.getStyle(gtkSpinButton); 1775 1786 1776 if (option->state & State_HasFocus) 1787 1788 QString key; 1789 1790 if (option->state & State_HasFocus) { 1791 key += QLatin1Char('f'); 1777 1792 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 } 1785 1794 1786 1795 uint resolve_mask = option->palette.resolve(); … … 1815 1824 else 1816 1825 gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); 1826 1827 if (option->state & State_HasFocus) 1828 GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); 1817 1829 } 1818 1830 … … 1840 1852 1841 1853 } else { 1842 int size = spinboxArrowSize();1854 int size = d->getSpinboxArrowSize(); 1843 1855 int w = size / 2 - 1; 1844 1856 w -= w % 2 - 1; // force odd … … 1872 1884 case CC_Slider: 1873 1885 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); 1880 1892 1881 1893 bool horizontal = slider->orientation == Qt::Horizontal; … … 1897 1909 1898 1910 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, 1900 1912 slider->minimum, 1901 1913 slider->maximum, … … 1904 1916 slider->pageStep); 1905 1917 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); 1909 1921 outerSize++; 1910 1922 … … 1914 1926 -focusFrameMargin, -outerSize - focusFrameMargin); 1915 1927 1916 gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,1917 GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));1918 1919 1928 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; 1924 1937 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)); 1926 1949 gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state, 1927 1950 GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); 1928 1951 } 1929 1930 1952 } 1931 1953 1932 1954 if (option->subControls & SC_SliderTickmarks) { 1933 1955 painter->setPen(darkOutline); 1934 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);1935 int available = p ixelMetric(PM_SliderSpaceAvailable, slider, widget);1956 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 1957 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); 1936 1958 int interval = slider->tickInterval; 1937 1959 … … 1950 1972 1951 1973 int v = slider->minimum; 1952 int len = p ixelMetric(PM_SliderLength, slider, widget);1974 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 1953 1975 while (v <= slider->maximum + 1) { 1954 1976 if (v == slider->maximum + 1 && interval == 1) … … 2011 2033 fropt.rect.setRight(handle.right() + 3); 2012 2034 } 2013 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);2035 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); 2014 2036 } 2015 2037 gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style, … … 2040 2062 const QWidget *widget) const 2041 2063 { 2042 if (!QGtk::isThemeAvailable()) { 2064 Q_D(const QGtkStyle); 2065 2066 if (!d->isThemeAvailable()) { 2043 2067 QCleanlooksStyle::drawControl(element, option, painter, widget); 2044 2068 return; 2045 2069 } 2046 2070 2047 GtkStyle* style = QGtk::gtkStyle();2071 GtkStyle* style = d->gtkStyle(); 2048 2072 QGtkPainter gtkPainter(painter); 2049 2073 … … 2051 2075 case CE_ProgressBarLabel: 2052 2076 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { 2053 GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));2077 GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); 2054 2078 if (!gtkProgressBar) 2055 2079 return; … … 2070 2094 if (vertical) 2071 2095 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); 2074 2098 if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) 2075 2099 leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); … … 2101 2125 if (option->state & State_Sunken) 2102 2126 buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget), 2103 p ixelMetric(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)) 2106 2130 tf |= Qt::TextShowMnemonic; 2107 2131 else … … 2154 2178 ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); 2155 2179 2156 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));2180 GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); 2157 2181 QPalette pal = button->palette; 2158 2182 int labelState = GTK_STATE_INSENSITIVE; … … 2164 2188 QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); 2165 2189 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), 2167 2191 button->text, QPalette::ButtonText); 2168 2192 } … … 2175 2199 2176 2200 // Draw prelight background 2177 GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));2201 GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); 2178 2202 2179 2203 if (option->state & State_MouseOver) { … … 2185 2209 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator 2186 2210 : SE_CheckBoxIndicator, btn, widget); 2187 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,2211 proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, 2188 2212 &subopt, painter, widget); 2189 2213 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents … … 2199 2223 pal.setBrush(QPalette::WindowText, textColor); 2200 2224 subopt.palette = pal; 2201 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);2225 proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); 2202 2226 2203 2227 if (btn->state & State_HasFocus) { … … 2206 2230 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect 2207 2231 : SE_CheckBoxFocusRect, btn, widget); 2208 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);2232 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); 2209 2233 } 2210 2234 } … … 2215 2239 case CE_ComboBoxLabel: 2216 2240 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); 2219 2243 painter->save(); 2220 2244 painter->setClipRect(editRect); … … 2234 2258 painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); 2235 2259 2236 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);2260 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); 2237 2261 2238 2262 if (cb->direction == Qt::RightToLeft) … … 2243 2267 2244 2268 if (!cb->currentText.isEmpty() && !cb->editable) { 2245 GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox"));2269 GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); 2246 2270 QPalette pal = cb->palette; 2247 2271 int labelState = GTK_STATE_INSENSITIVE; … … 2256 2280 pal.setBrush(QPalette::ButtonText, textColor); 2257 2281 2258 drawItemText(painter, editRect.adjusted(1, 0, -1, 0),2282 proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), 2259 2283 visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), 2260 2284 pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText); … … 2302 2326 = painter->fontMetrics().elidedText(dwOpt->title, 2303 2327 Qt::ElideRight, titleRect.width()); 2304 drawItemText(painter,2328 proxy()->drawItemText(painter, 2305 2329 titleRect, 2306 2330 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, … … 2320 2344 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { 2321 2345 Q_UNUSED(header); 2322 GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));2346 GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); 2323 2347 // 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); 2325 2349 Q_ASSERT(column); 2326 2350 … … 2341 2365 2342 2366 case CE_SizeGrip: { 2343 GtkWidget *gtkStatusbar = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));2367 GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); 2344 2368 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, 2346 2370 GTK_SHADOW_OUT, QApplication::isRightToLeft() ? 2347 2371 GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST, … … 2353 2377 2354 2378 case CE_MenuBarEmptyArea: { 2355 GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));2379 GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); 2356 2380 GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency 2357 2381 painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); … … 2363 2387 QGtkPainter gtkMenuBarPainter(&pmPainter); 2364 2388 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); 2366 2390 gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect, 2367 2391 GTK_STATE_NORMAL, shadow_type, gtkMenubar->style); … … 2376 2400 2377 2401 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")); 2380 2404 2381 2405 style = gtkMenubarItem->style; … … 2392 2416 QGtkPainter menubarPainter(&pmPainter); 2393 2417 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); 2395 2419 GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency 2396 2420 painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); … … 2416 2440 if (act) { 2417 2441 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); 2419 2443 gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3), 2420 2444 GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style); … … 2423 2447 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 2424 2448 2425 if (! QCleanlooksStyle::styleHint(SH_UnderlineShortcut, mbi, widget))2449 if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) 2426 2450 alignment |= Qt::TextHideMnemonic; 2427 2451 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); 2429 2453 } 2430 2454 } … … 2433 2457 2434 2458 case CE_Splitter: { 2435 GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed2459 GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed 2436 2460 gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE, 2437 2461 !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, … … 2453 2477 rect.adjust(0, 0, 1, 0); 2454 2478 2455 GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));2479 GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); 2456 2480 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); 2458 2482 gtkPainter.paintBox( gtkToolbar, "toolbar", rect, 2459 2483 GTK_STATE_NORMAL, shadow_type, gtkToolbar->style); … … 2472 2496 const int windowsItemVMargin = 26; // menu item ver text margin 2473 2497 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")); 2477 2501 2478 2502 style = gtkPainter.getStyle(gtkMenuItem); … … 2481 2505 2482 2506 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { 2483 GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));2507 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); 2484 2508 painter->setPen(shadow.lighter(106)); 2485 2509 gboolean wide_separators = 0; 2486 2510 gint separator_height = 0; 2487 2511 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, 2490 2514 "wide-separators", &wide_separators, 2491 2515 "separator-height", &separator_height, … … 2507 2531 2508 2532 if (selected) { 2509 QRect rect = option->rect.adjusted(0, 0, -1, -1);2533 QRect rect = option->rect.adjusted(0, 0, 0, -1); 2510 2534 #ifndef QT_NO_COMBOBOX 2511 2535 if (qobject_cast<const QComboBox*>(widget)) … … 2521 2545 2522 2546 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); 2524 2548 2525 2549 int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize)); … … 2598 2622 2599 2623 QPixmap pixmap; 2600 int smallIconSize = p ixelMetric(PM_SmallIconSize, option, widget);2624 int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); 2601 2625 QSize iconSize(smallIconSize, smallIconSize); 2602 2626 … … 2614 2638 int pixh = pixmap.height(); 2615 2639 QRect pmr(0, 0, pixw, pixh); 2616 pmr.moveCenter(vCheckRect.center() );2640 pmr.moveCenter(vCheckRect.center() - QPoint(0, 1)); 2617 2641 painter->setPen(menuItem->palette.text().color()); 2618 2642 if (!ignoreCheckMark && checkable && checked) { … … 2626 2650 opt.state |= State_Sunken; 2627 2651 opt.rect = vCheckRect; 2628 drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);2652 proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); 2629 2653 } 2630 2654 painter->drawPixmap(pmr.topLeft(), pixmap); … … 2656 2680 int tab = menuitem->tabWidth; 2657 2681 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); 2660 2684 QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); 2661 2685 QString s = menuitem->text; … … 2666 2690 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; 2667 2691 2668 if (! styleHint(SH_UnderlineShortcut, menuitem, widget))2692 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) 2669 2693 text_flags |= Qt::TextHideMnemonic; 2670 2694 … … 2699 2723 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow 2700 2724 QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget), 2701 p ixelMetric(PM_ButtonShiftVertical, option, widget));2725 proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); 2702 2726 2703 2727 QFontMetrics fm(menuitem->font); 2704 2728 int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; 2705 2729 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 2709 2739 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; 2713 2743 int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim; 2714 2744 QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, … … 2726 2756 case CE_PushButton: 2727 2757 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); 2730 2760 QStyleOptionButton subopt = *btn; 2731 2761 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); 2732 2762 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); 2734 2764 int xt = interiorFocus ? gtkButton->style->xthickness : 0; 2735 2765 int yt = interiorFocus ? gtkButton->style->ythickness : 0; … … 2737 2767 if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus) 2738 2768 // 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); 2740 2770 else if (btn->state & State_HasFocus) 2741 2771 gtkPainter.paintFocus(gtkButton, "button", … … 2744 2774 gtkButton->style); 2745 2775 2746 drawControl(CE_PushButtonLabel, &subopt, painter, widget);2776 proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); 2747 2777 } 2748 2778 break; … … 2752 2782 case CE_TabBarTabShape: 2753 2783 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { 2754 GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));2784 GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); 2755 2785 style = gtkPainter.getStyle(gtkNotebook); 2756 2786 … … 2761 2791 state = GTK_STATE_NORMAL; 2762 2792 2763 bool first = tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab;2764 bool last = tab->position == QStyleOptionTab::End || tab->position == QStyleOptionTab::OnlyOneTab;2765 2793 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) { 2767 2800 bool tmp = first; 2768 2801 first = last; … … 2816 2849 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { 2817 2850 Q_UNUSED(bar); 2818 GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));2851 GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); 2819 2852 GtkStateType state = gtkPainter.gtkState(option); 2820 2853 gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style); … … 2826 2859 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { 2827 2860 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")); 2829 2862 style = gtkProgressBar->style; 2830 2863 gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style); … … 2848 2881 rect.translate(xt, -yt * 2); 2849 2882 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); 2852 2884 m.rotate(90.0); 2853 2885 painter->setTransform(m); … … 2875 2907 fakePos = maximum - 1; 2876 2908 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)); 2879 2911 2880 2912 QRect progressBar; … … 2916 2948 SubControl subControl, const QWidget *widget) const 2917 2949 { 2950 Q_D(const QGtkStyle); 2951 2918 2952 QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget); 2919 if (! QGtk::isThemeAvailable())2953 if (!d->isThemeAvailable()) 2920 2954 return QCleanlooksStyle::subControlRect(control, option, subControl, widget); 2921 2955 … … 2959 2993 QFontMetrics fontMetrics(font); 2960 2994 QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4); 2961 int indicatorWidth = p ixelMetric(PM_IndicatorWidth, option, widget);2962 int indicatorHeight = p ixelMetric(PM_IndicatorHeight, option, widget);2995 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); 2996 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); 2963 2997 2964 2998 if (subControl == SC_GroupBoxCheckBox) { … … 2983 3017 case CC_SpinBox: 2984 3018 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { 2985 GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));3019 GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); 2986 3020 int center = spinbox->rect.height() / 2; 2987 3021 int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0; … … 2991 3025 QSize bs; 2992 3026 bs.setHeight(qMax(8, spinbox->rect.height()/2 - y)); 2993 bs.setWidth( spinboxArrowSize());3027 bs.setWidth(d->getSpinboxArrowSize()); 2994 3028 int x, lx, rx; 2995 3029 x = spinbox->rect.width() - y - bs.width() + 2; … … 3037 3071 // We employ the gtk widget to position arrows and separators for us 3038 3072 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); 3041 3075 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); 3044 3078 QString arrowPath = comboBoxPath + QLS(".GtkToggleButton"); 3045 3079 … … 3047 3081 arrowPath += QLS(".GtkHBox.GtkArrow"); 3048 3082 3049 GtkWidget *arrowWidget = QGtk::gtkWidget(arrowPath);3083 GtkWidget *arrowWidget = d->gtkWidget(arrowPath); 3050 3084 if (!arrowWidget) 3051 3085 return QCleanlooksStyle::subControlRect(control, option, subControl, widget); 3052 3086 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, 3054 3089 arrowWidget->allocation.width, arrowWidget->allocation.height); 3055 3090 … … 3058 3093 case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos 3059 3094 rect = buttonRect; 3060 3061 3095 break; 3062 3096 … … 3092 3126 */ 3093 3127 QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, 3094 3095 3128 const QSize &size, const QWidget *widget) const 3096 3129 { 3130 Q_D(const QGtkStyle); 3097 3131 3098 3132 QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget); 3099 if (! QGtk::isThemeAvailable())3133 if (!d->isThemeAvailable()) 3100 3134 return newSize; 3101 3135 … … 3104 3138 case CT_ToolButton: 3105 3139 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); 3108 3142 if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { 3109 3143 QSize minSize(0, 25); … … 3112 3146 newSize = newSize.expandedTo(minSize); 3113 3147 } 3114 3148 3115 3149 if (toolbutton->features & QStyleOptionToolButton::HasMenu) 3116 3150 newSize += QSize(6, 0); … … 3123 3157 3124 3158 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { 3125 GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));3159 GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); 3126 3160 gboolean wide_separators; 3127 3161 gint separator_height; 3128 QGtk::gtk_widget_style_get(gtkMenuSeparator,3162 d->gtk_widget_style_get(gtkMenuSeparator, 3129 3163 "wide-separators", &wide_separators, 3130 3164 "separator-height", &separator_height, … … 3135 3169 } 3136 3170 3137 GtkWidget *gtkMenuItem = QGtk::gtkWidget(QLS("GtkMenu.GtkMenuItem"));3171 GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); 3138 3172 GtkStyle* style = gtkMenuItem->style; 3139 newSize += QSize(textMargin + style->xthickness - 2, style->ythickness - 4);3173 newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3); 3140 3174 3141 3175 // Cleanlooks assumes a check column of 20 pixels so we need to 3142 3176 // expand it a bit 3143 3177 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); 3145 3179 newSize.setHeight(qMax(newSize.height(), checkSize + 2)); 3146 3180 newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); … … 3157 3191 case CT_SpinBox: 3158 3192 // 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); 3160 3194 break; 3161 3195 3162 3196 case CT_PushButton: 3163 3197 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { 3164 GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));3198 GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); 3165 3199 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); 3168 3202 newSize = size; 3169 3203 newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness); 3170 3204 newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding)); 3171 3205 3172 GtkWidget *gtkButtonBox = QGtk::gtkWidget(QLS("GtkHButtonBox"));3206 GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox")); 3173 3207 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, 3175 3209 "child-min-height", &minHeight, NULL); 3176 3210 if (!btn->text.isEmpty() && newSize.width() < minWidth) … … 3183 3217 3184 3218 case CT_Slider: { 3185 GtkWidget *gtkSlider = QGtk::gtkWidget(QLS("GtkHScale"));3219 GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale")); 3186 3220 newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness); 3187 3221 } 3188 3222 break; 3189 3223 3190 case CT_MenuBarItem://cleanlooks adds 2 pixels3191 newSize = QWindowsStyle::sizeFromContents(type, option, size, widget) + QSize(0, 1);3192 break;3193 3194 3224 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); 3197 3227 } 3198 3228 break; … … 3204 3234 case CT_ComboBox: 3205 3235 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); 3208 3238 newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness); 3209 3239 3210 3240 if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget()))) 3211 newSize += QSize(0, 3);3241 newSize += QSize(0, 2); 3212 3242 } 3213 3243 break; … … 3222 3252 newSize += QSize(6, 0); 3223 3253 } 3224 newSize += QSize(1, 0);3254 newSize += QSize(1, 1); 3225 3255 break; 3226 3256 … … 3231 3261 return newSize; 3232 3262 } 3263 3233 3264 3234 3265 /*! \reimp */ … … 3236 3267 const QWidget *widget) const 3237 3268 { 3238 if (!QGtk::isThemeAvailable()) 3269 Q_D(const QGtkStyle); 3270 3271 if (!d->isThemeAvailable()) 3239 3272 return QCleanlooksStyle::standardPixmap(sp, option, widget); 3240 3273 … … 3264 3297 break; 3265 3298 3266 case SP_DialogDiscardButton: {3299 case SP_DialogDiscardButton: 3267 3300 return QGtkPainter::getIcon(GTK_STOCK_DELETE); 3268 } 3269 3270 case SP_DialogOkButton: { 3301 case SP_DialogOkButton: 3271 3302 return QGtkPainter::getIcon(GTK_STOCK_OK); 3272 } 3273 3274 case SP_DialogCancelButton: { 3303 case SP_DialogCancelButton: 3275 3304 return QGtkPainter::getIcon(GTK_STOCK_CANCEL); 3276 } 3277 3278 case SP_DialogYesButton: { 3305 case SP_DialogYesButton: 3279 3306 return QGtkPainter::getIcon(GTK_STOCK_YES); 3280 } 3281 3282 case SP_DialogNoButton: { 3307 case SP_DialogNoButton: 3283 3308 return QGtkPainter::getIcon(GTK_STOCK_NO); 3284 } 3285 3286 case SP_DialogOpenButton: { 3309 case SP_DialogOpenButton: 3287 3310 return QGtkPainter::getIcon(GTK_STOCK_OPEN); 3288 } 3289 3290 case SP_DialogCloseButton: { 3311 case SP_DialogCloseButton: 3291 3312 return QGtkPainter::getIcon(GTK_STOCK_CLOSE); 3292 } 3293 3294 case SP_DialogApplyButton: { 3313 case SP_DialogApplyButton: 3295 3314 return QGtkPainter::getIcon(GTK_STOCK_APPLY); 3296 } 3297 3298 case SP_DialogSaveButton: { 3315 case SP_DialogSaveButton: 3299 3316 return QGtkPainter::getIcon(GTK_STOCK_SAVE); 3300 } 3301 3302 case SP_MessageBoxWarning: { 3317 case SP_MessageBoxWarning: 3303 3318 return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); 3304 } 3305 3306 case SP_MessageBoxQuestion: { 3319 case SP_MessageBoxQuestion: 3307 3320 return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); 3308 } 3309 3310 case SP_MessageBoxInformation: { 3321 case SP_MessageBoxInformation: 3311 3322 return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); 3312 } 3313 3314 case SP_MessageBoxCritical: { 3323 case SP_MessageBoxCritical: 3315 3324 return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); 3316 }3317 3318 3325 default: 3319 3326 return QCleanlooksStyle::standardPixmap(sp, option, widget); 3320 3327 } 3321 3322 return QPixmap(); 3328 return pixmap; 3323 3329 } 3330 3331 /*! 3332 \internal 3333 */ 3334 QIcon 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 3324 3374 3325 3375 /*! \reimp */ 3326 3376 QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const 3327 3377 { 3378 Q_D(const QGtkStyle); 3379 3328 3380 QRect r = QCleanlooksStyle::subElementRect(element, option, widget); 3329 3381 switch (element) { … … 3332 3384 case SE_ProgressBarGroove: 3333 3385 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; 3334 3400 default: 3335 3401 break;
Note:
See TracChangeset
for help on using the changeset viewer.