Qt 4.8
qgtkstyle.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include "qgtkstyle.h"
42 
43 #if !defined(QT_NO_STYLE_GTK)
44 
45 #include <private/qapplication_p.h>
46 #include <QtCore/QLibrary>
47 #include <QtCore/QSettings>
48 #include <QtGui/QDialogButtonBox>
49 #include <QtGui/QStatusBar>
50 #include <QtGui/QLineEdit>
51 #include <QtGui/QWidget>
52 #include <QtGui/QListView>
53 #include <QtGui/QApplication>
54 #include <QtGui/QStyleOption>
55 #include <QtGui/QPushButton>
56 #include <QtGui/QPainter>
57 #include <QtGui/QMainWindow>
58 #include <QtGui/QToolBar>
59 #include <QtGui/QHeaderView>
60 #include <QtGui/QMenuBar>
61 #include <QtGui/QComboBox>
62 #include <QtGui/QSpinBox>
63 #include <QtGui/QScrollBar>
64 #include <QtGui/QAbstractButton>
65 #include <QtGui/QToolButton>
66 #include <QtGui/QGroupBox>
67 #include <QtGui/QRadioButton>
68 #include <QtGui/QCheckBox>
69 #include <QtGui/QTreeView>
70 #include <QtGui/QStyledItemDelegate>
71 #include <qpixmapcache.h>
72 #undef signals // Collides with GTK stymbols
73 #include <private/qgtkpainter_p.h>
74 #include <private/qstylehelper_p.h>
75 #include <private/qgtkstyle_p.h>
76 #include <private/qcleanlooksstyle_p.h>
77 
78 
80 
81 static const char * const dock_widget_close_xpm[] =
82  {
83  "11 13 5 1",
84  " c None",
85  ". c #D5CFCB",
86  "+ c #6C6A67",
87  "@ c #6C6A67",
88  "$ c #B5B0AC",
89  " ",
90  " @@@@@@@@@ ",
91  "@+ +@",
92  "@ +@ @+ @",
93  "@ @@@ @@@ @",
94  "@ @@@@@ @",
95  "@ @@@ @",
96  "@ @@@@@ @",
97  "@ @@@ @@@ @",
98  "@ +@ @+ @",
99  "@+ +@",
100  " @@@@@@@@@ ",
101  " "
102  };
103 
104 static const char * const dock_widget_restore_xpm[] =
105  {
106  "11 13 5 1",
107  " c None",
108  ". c #D5CFCB",
109  "+ c #6C6A67",
110  "@ c #6C6A67",
111  "# c #6C6A67",
112  " ",
113  " @@@@@@@@@ ",
114  "@+ +@",
115  "@ #@@@# @",
116  "@ @ @ @",
117  "@ #@@@# @ @",
118  "@ @ @ @ @",
119  "@ @ @@@ @",
120  "@ @ @ @",
121  "@ #@@@@ @",
122  "@+ +@",
123  " @@@@@@@@@ ",
124  " "
125  };
126 
127 static const int groupBoxBottomMargin = 2; // space below the groupbox
128 static const int groupBoxTitleMargin = 6; // space between contents and title
129 static const int groupBoxTopMargin = 2;
130 
136 {
137  return QGtkStylePrivate::getGConfString(value, fallback);
138 }
139 
145 {
146  return QGtkStylePrivate::getGConfBool(key, fallback);
147 }
148 
149 static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
150 {
151  const int maxFactor = 100;
152  QColor tmp = colorA;
153  tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
154  tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
155  tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
156  return tmp;
157 }
158 
159 static GdkColor fromQColor(const QColor &color)
160 {
161  GdkColor retval;
162  retval.red = color.red() * 255;
163  retval.green = color.green() * 255;
164  retval.blue = color.blue() * 255;
165  return retval;
166 }
167 
194 {
195  Q_D(QGtkStyle);
196  d->init();
197 }
198 
208  : QCleanlooksStyle(dd)
209 {
210  Q_D(QGtkStyle);
211  d->init();
212 }
213 
214 
219 {
220 }
221 
226 {
227  Q_D(const QGtkStyle);
228 
230  if (d->isThemeAvailable()) {
231  GtkStyle *style = d->gtkStyle();
232  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
233  GtkWidget *gtkEntry = d->getTextColorWidget();
234  GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg;
235  QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt;
236  gdkBg = style->bg[GTK_STATE_NORMAL];
237  gdkForeground = gtkButton->style->fg[GTK_STATE_NORMAL];
238 
239  // Our base and selected color is primarily used for text
240  // so we assume a gtkEntry will have the most correct value
241  gdkBase = gtkEntry->style->base[GTK_STATE_NORMAL];
242  gdkText = gtkEntry->style->text[GTK_STATE_NORMAL];
243  gdkSbg = gtkEntry->style->base[GTK_STATE_SELECTED];
244  gdkSfg = gtkEntry->style->text[GTK_STATE_SELECTED];
245 
246  // The ACTIVE base color is really used for inactive windows
247  gdkaSbg = gtkEntry->style->base[GTK_STATE_ACTIVE];
248  gdkaSfg = gtkEntry->style->text[GTK_STATE_ACTIVE];
249 
250  bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
251  text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
252  fg = QColor(gdkForeground.red>>8, gdkForeground.green>>8, gdkForeground.blue>>8);
253  base = QColor(gdkBase.red>>8, gdkBase.green>>8, gdkBase.blue>>8);
254  highlight = QColor(gdkSbg.red>>8, gdkSbg.green>>8, gdkSbg.blue>>8);
255  highlightText = QColor(gdkSfg.red>>8, gdkSfg.green>>8, gdkSfg.blue>>8);
256  inactiveHighlight = QColor(gdkaSbg.red>>8, gdkaSbg.green>>8, gdkaSbg.blue>>8);
257  inactiveHighlightedTExt = QColor(gdkaSfg.red>>8, gdkaSfg.green>>8, gdkaSfg.blue>>8);
258 
259  palette.setColor(QPalette::HighlightedText, highlightText);
260 
261 
262  palette.setColor(QPalette::Light, bg.lighter(125));
263  palette.setColor(QPalette::Shadow, bg.darker(130));
264  palette.setColor(QPalette::Dark, bg.darker(120));
265  palette.setColor(QPalette::Text, text);
266  palette.setColor(QPalette::WindowText, fg);
267  palette.setColor(QPalette::ButtonText, fg);
268  palette.setColor(QPalette::Base, base);
269 
270  QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
271  GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
272  GdkColor *gtkAltBase = NULL;
273  d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
274  if (gtkAltBase) {
275  alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8);
276  d->gdk_color_free(gtkAltBase);
277  }
278  palette.setColor(QPalette::AlternateBase, alternateRowColor);
279 
280  palette.setColor(QPalette::Window, bg);
281  palette.setColor(QPalette::Button, bg);
282  palette.setColor(QPalette::Background, bg);
283  QColor disabled((fg.red() + bg.red()) / 2,
284  (fg.green() + bg.green())/ 2,
285  (fg.blue() + bg.blue()) / 2);
286  palette.setColor(QPalette::Disabled, QPalette::Text, disabled);
290  palette.setColor(QPalette::Highlight, highlight);
291  // calculate disabled colors by removing saturation
292  highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha());
293  highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
294  palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
295  palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
296 
297  palette.setColor(QPalette::Inactive, QPalette::HighlightedText, inactiveHighlightedTExt);
298  palette.setColor(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
299 
300  style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
301  d->gtk_window_get_type());
302  if (style) {
303  gdkText = style->fg[GTK_STATE_NORMAL];
304  text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
305  palette.setColor(QPalette::ToolTipText, text);
306  }
307  }
308  return palette;
309 }
310 
315 {
316  Q_D(QGtkStyle);
317 
318  // QCleanlooksStyle will alter the palette, hence we do
319  // not want to polish the palette unless we are using it as
320  // the fallback
321  if (!d->isThemeAvailable())
322  QCleanlooksStyle::polish(palette);
323  else
324  palette = palette.resolve(standardPalette());
325 }
326 
331 {
332  Q_D(QGtkStyle);
333 
335  // Custom fonts and palettes with QtConfig are intentionally
336  // not supported as these should be entirely determined by
337  // current Gtk settings
338  if (app->desktopSettingsAware() && d->isThemeAvailable()) {
340  QApplicationPrivate::setSystemFont(d->getThemeFont());
341  d->applyCustomPaletteHash();
342  if (!d->isKDE4Session()) {
347  qApp->installEventFilter(&d->filter);
348  }
349  }
350 }
351 
356 {
357  Q_D(QGtkStyle);
358 
361 
362  if (app->desktopSettingsAware() && d->isThemeAvailable()
363  && !d->isKDE4Session()) {
368  qApp->removeEventFilter(&d->filter);
369  }
370 }
371 
377 {
378  Q_D(QGtkStyle);
379 
380  QCleanlooksStyle::polish(widget);
381  if (!d->isThemeAvailable())
382  return;
383  if (qobject_cast<QAbstractButton*>(widget)
385  || qobject_cast<QComboBox*>(widget)
387  || qobject_cast<QScrollBar*>(widget)
389  || qobject_cast<QAbstractSpinBox*>(widget)
391  || qobject_cast<QHeaderView*>(widget))
392  widget->setAttribute(Qt::WA_Hover);
393  else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
394  tree->viewport()->setAttribute(Qt::WA_Hover);
395 }
396 
401 {
403 }
404 
409  const QStyleOption *option,
410  const QWidget *widget) const
411 {
412  Q_D(const QGtkStyle);
413 
414  if (!d->isThemeAvailable())
415  return QCleanlooksStyle::pixelMetric(metric, option, widget);
416 
417  switch (metric) {
419  if (qobject_cast<const QFrame*>(widget)) {
420  if (GtkStyle *style =
421  d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
422  "*.GtkScrolledWindow",
423  "*.GtkScrolledWindow",
424  d->gtk_window_get_type()))
425  return qMax(style->xthickness, style->ythickness);
426  }
427  return 2;
428 
430  return 20;
431 
433  return 1;
434 
436  return 11;
437 
439  return 1;
440 
442  return 0;
443 
445  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
446  guint horizontal_shift;
447  d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
448  return horizontal_shift;
449  }
450 
451  case PM_ButtonShiftVertical: {
452  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
453  guint vertical_shift;
454  d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
455  return vertical_shift;
456  }
457 
459  return 0;
460 
461  case PM_MenuPanelWidth: {
462  GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
463  guint horizontal_padding = 0;
464  // horizontal-padding is used by Maemo to get thicker borders
465  if (!d->gtk_check_version(2, 10, 0))
466  d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
467  int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
468  return padding;
469  }
470 
471  case PM_ButtonIconSize: {
472  int retVal = 24;
473  GtkSettings *settings = d->gtk_settings_get_default();
474  gchararray icon_sizes;
475  g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL);
476  QStringList values = QString(QLS(icon_sizes)).split(QLatin1Char(':'));
477  g_free(icon_sizes);
478  QChar splitChar(QLatin1Char(','));
479  foreach (const QString &value, values) {
480  if (value.startsWith(QLS("gtk-button="))) {
481  QString iconSize = value.right(value.size() - 11);
482 
483  if (iconSize.contains(splitChar))
484  retVal = iconSize.split(splitChar)[0].toInt();
485  break;
486  }
487  }
488  return retVal;
489  }
490 
491  case PM_MenuVMargin:
492 
493  case PM_MenuHMargin:
494  return 0;
495 
497  return 0;
498 
500  return 5;
501 
502  case PM_TabBarTabVSpace:
503  return 12;
504 
505  case PM_TabBarTabHSpace:
506  return 14;
507 
509  return 2;
510 
512  return 9;
513 
514  case PM_SplitterWidth:
515  return 6;
516 
517  case PM_SliderThickness:
519  GtkWidget *gtkScale = d->gtkWidget("GtkHScale");
520  gint val;
521  d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
522  if (metric == PM_SliderControlThickness)
523  return val + 2*gtkScale->style->ythickness;
524  return val;
525  }
526 
527  case PM_ScrollBarExtent: {
528  gint sliderLength;
529  gint trough_border;
530  GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar");
531  d->gtk_widget_style_get(hScrollbar,
532  "trough-border", &trough_border,
533  "slider-width", &sliderLength,
534  NULL);
535  return sliderLength + trough_border*2;
536  }
537 
539  return 34;
540 
541  case PM_SliderLength:
542  gint val;
543  d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL);
544  return val;
545 
548  case PM_IndicatorWidth:
549  case PM_IndicatorHeight: {
550  GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
551  gint size, spacing;
552  d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
553  return size + 2 * spacing;
554  }
555 
556  case PM_MenuBarVMargin: {
557  GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
558  return qMax(0, gtkMenubar->style->ythickness);
559  }
561  {
562  gint spacing = 3;
563  GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
564  Q_ASSERT(gtkScrollWindow);
565  d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
566  return spacing;
567  }
568  case PM_SubMenuOverlap: {
569  gint offset = 0;
570  GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
571  d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
572  return offset;
573  }
574  default:
575  return QCleanlooksStyle::pixelMetric(metric, option, widget);
576  }
577 }
578 
582 int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
583 
584  QStyleHintReturn *returnData = 0) const
585 {
586  Q_D(const QGtkStyle);
587 
588  if (!d->isThemeAvailable())
589  return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
590 
591  switch (hint) {
592 
593  case SH_DialogButtonLayout: {
595  gboolean alternateOrder = 0;
596  GtkSettings *settings = d->gtk_settings_get_default();
597  g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
598 
599  if (alternateOrder)
601 
602  return ret;
603  }
604 
605  break;
606 
607  case SH_ToolButtonStyle:
608  {
609  if (d->isKDE4Session())
610  return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
611  GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
612  GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
613  g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
614  switch (toolbar_style) {
615  case GTK_TOOLBAR_TEXT:
616  return Qt::ToolButtonTextOnly;
617  case GTK_TOOLBAR_BOTH:
619  case GTK_TOOLBAR_BOTH_HORIZ:
621  case GTK_TOOLBAR_ICONS:
622  default:
623  return Qt::ToolButtonIconOnly;
624  }
625  }
626  break;
628  return int(true);
629 
631  return int(false);
632 
633  case SH_ComboBox_Popup: {
634  GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox");
635  gboolean appears_as_list;
636  d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
637  return appears_as_list ? 0 : 1;
638  }
639 
641  return int(false);
642 
643  case SH_EtchDisabledText:
644  return int(false);
645 
647  gint delay = 225;
648  GtkSettings *settings = d->gtk_settings_get_default();
649  g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
650  return delay;
651  }
652 
654  gboolean scrollbars_within_bevel = false;
655  if (widget && widget->isWindow())
656  scrollbars_within_bevel = true;
657  else if (!d->gtk_check_version(2, 12, 0)) {
658  GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
659  d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
660  }
661  return !scrollbars_within_bevel;
662  }
663 
665  static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
666  return buttonsHaveIcons;
667  }
668 
669  case SH_UnderlineShortcut: {
670  gboolean underlineShortcut = true;
671  if (!d->gtk_check_version(2, 12, 0)) {
672  GtkSettings *settings = d->gtk_settings_get_default();
673  g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL);
674  }
675  return underlineShortcut;
676  }
677 
678  default:
679  return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
680  }
681 }
682 
687  const QStyleOption *option,
688  QPainter *painter,
689  const QWidget *widget) const
690 {
691  Q_D(const QGtkStyle);
692 
693  if (!d->isThemeAvailable()) {
694  QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
695  return;
696  }
697 
698  GtkStyle* style = d->gtkStyle();
699  QGtkPainter gtkPainter(painter);
700 
701  switch (element) {
702  case PE_Frame: {
703  if (widget && widget->inherits("QComboBoxPrivateContainer")){
704  QStyleOption copy = *option;
705  copy.state |= State_Raised;
706  proxy()->drawPrimitive(PE_PanelMenu, &copy, painter, widget);
707  break;
708  }
709  // Drawing the entire itemview frame is very expensive, especially on the native X11 engine
710  // Instead we cheat a bit and draw a border image without the center part, hence only scaling
711  // thin rectangular images
712  const int pmSize = 64;
713  const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
714  const QString pmKey = QLatin1Literal("windowframe") % HexString<uint>(option->state);
715 
716  QPixmap pixmap;
717  QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
718 
719  // Only draw through style once
720  if (!QPixmapCache::find(pmKey, pixmap)) {
721  pixmap = QPixmap(pmSize, pmSize);
722  pixmap.fill(Qt::transparent);
723  QPainter pmPainter(&pixmap);
724  QGtkPainter gtkFramePainter(&pmPainter);
725  gtkFramePainter.setUsePixmapCache(false); // Don't cache twice
726 
727  GtkShadowType shadow_type = GTK_SHADOW_NONE;
728  if (option->state & State_Sunken)
729  shadow_type = GTK_SHADOW_IN;
730  else if (option->state & State_Raised)
731  shadow_type = GTK_SHADOW_OUT;
732 
733  GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
734  "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
735  if (style)
736  gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
737  option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
738  shadow_type, style);
739  QPixmapCache::insert(pmKey, pixmap);
740  }
741 
742  QRect rect = option->rect;
743  const int rw = rect.width() - border;
744  const int rh = rect.height() - border;
745  const int pw = pmRect.width() - border;
746  const int ph = pmRect.height() - border;
747 
748  // Sidelines
749  painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph));
750  painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0));
751  painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border));
752  painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border));
753 
754  // Corners
755  painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph));
756  painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph));
757  painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0));
758  painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0));
759  }
760  break;
761 
762  case PE_PanelTipLabel: {
763  GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
764  style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
765  d->gtk_window_get_type());
766  gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
767  }
768  break;
769 
770  case PE_PanelStatusBar: {
771  if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
772  option->palette.resolve() & (1 << QPalette::Window)) {
773  // Respect custom palette
774  painter->fillRect(option->rect, option->palette.window());
775  break;
776  }
777  GtkShadowType shadow_type;
778  GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
779  d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
780  gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
781  shadow_type, gtkStatusbarFrame->style);
782  }
783  break;
784 
786  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
787  GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
788  GtkStateType state = gtkPainter.gtkState(option);
789  style = gtkTreeHeader->style;
790  GtkArrowType type = GTK_ARROW_UP;
791  QImage arrow;
792  // This sorting indicator inversion is intentional, and follows the GNOME HIG.
793  // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
794  if (header->sortIndicator & QStyleOptionHeader::SortUp)
795  type = GTK_ARROW_UP;
796  else if (header->sortIndicator & QStyleOptionHeader::SortDown)
797  type = GTK_ARROW_DOWN;
798 
799  gtkPainter.paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
800  GTK_SHADOW_NONE, FALSE, style);
801  }
802  break;
803 
804  case PE_FrameFocusRect:
805  if (!widget || qobject_cast<const QAbstractItemView*>(widget))
806  QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
807  else {
808  // ### this mess should move to subcontrolrect
809  QRect frameRect = option->rect.adjusted(1, 1, -1, -2);
810 
811  if (qobject_cast<const QTabBar*>(widget)) {
812  GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
813  style = gtkPainter.getStyle(gtkNotebook);
814  gtkPainter.paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
815  } else {
816  gtkPainter.paintFocus(NULL, "tab", frameRect, GTK_STATE_ACTIVE, style);
817  }
818  }
819  break;
820 
821  case PE_IndicatorBranch:
822  if (option->state & State_Children) {
823  QRect rect = option->rect;
824  rect = QRect(0, 0, 12, 12);
825  rect.moveCenter(option->rect.center());
826  rect.translate(2, 0);
827  GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
828  GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
829  GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
830 
831  GtkStateType state = GTK_STATE_NORMAL;
832  if (!(option->state & State_Enabled))
833  state = GTK_STATE_INSENSITIVE;
834  else if (option->state & State_MouseOver)
835  state = GTK_STATE_PRELIGHT;
836 
837  gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
838  option->state & State_Open ? openState : closedState , gtkTreeView->style);
839  }
840  break;
841 
842  case PE_PanelItemViewRow:
843  // This primitive is only used to draw selection behind selected expander arrows.
844  // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate
845  // The reason for this is that a lot of code that relies on custom item delegates will look odd having
846  // a gradient on the branch but a flat shaded color on the item itself.
847  QCommonStyle::drawPrimitive(element, option, painter, widget);
848  if (!option->state & State_Selected) {
849  break;
850  } else {
851  if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) {
852  if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate()))
853  break;
854  }
855  } // fall through
856 
858  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
859  uint resolve_mask = vopt->palette.resolve();
860  if (vopt->backgroundBrush.style() != Qt::NoBrush
861  || (resolve_mask & (1 << QPalette::Base)))
862  {
863  QPointF oldBO = painter->brushOrigin();
864  painter->setBrushOrigin(vopt->rect.topLeft());
865  painter->fillRect(vopt->rect, vopt->backgroundBrush);
866  painter->setBrushOrigin(oldBO);
867  if (!(option->state & State_Selected))
868  break;
869  }
870  if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
871  const char *detail = "cell_even_ruled";
872  if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate)
873  detail = "cell_odd_ruled";
874  bool isActive = option->state & State_Active;
875  QString key;
876  if (isActive ) {
877  // Required for active/non-active window appearance
878  key = QLS("a");
879  GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
880  }
881  bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled));
882  gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
883  option->state & State_Selected ? GTK_STATE_SELECTED :
884  isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
885  GTK_SHADOW_OUT, gtkTreeView->style, key);
886  if (isActive )
887  GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
888  }
889  }
890  break;
892  {
893  const int margin = 6;
894  GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem");
895  if (option->state & State_Horizontal) {
896  const int offset = option->rect.width()/2;
897  QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
898  painter->setPen(QPen(option->palette.background().color().darker(110)));
899  gtkPainter.paintVline( gtkSeparator, "vseparator",
900  rect, GTK_STATE_NORMAL, gtkSeparator->style,
901  0, rect.height(), 0);
902  } else { //Draw vertical separator
903  const int offset = option->rect.height()/2;
904  QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
905  painter->setPen(QPen(option->palette.background().color().darker(110)));
906  gtkPainter.paintHline( gtkSeparator, "hseparator",
907  rect, GTK_STATE_NORMAL, gtkSeparator->style,
908  0, rect.width(), 0);
909  }
910  }
911  break;
912 
914  GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
915  GtkShadowType shadow_type;
916  d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
917  //Note when the toolbar is horizontal, the handle is vertical
918  painter->setClipRect(option->rect);
919  gtkPainter.paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
920  GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
921  GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, gtkToolbar->style);
922  }
923  break;
924 
925  case PE_IndicatorArrowUp:
928  case PE_IndicatorArrowRight: {
929 
930 
931  GtkArrowType type = GTK_ARROW_UP;
932 
933  switch (element) {
934 
936  type = GTK_ARROW_DOWN;
937  break;
938 
940  type = GTK_ARROW_LEFT;
941  break;
942 
944  type = GTK_ARROW_RIGHT;
945  break;
946 
947  default:
948  break;
949  }
950  int size = qMin(option->rect.height(), option->rect.width());
951  int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions
952  int bsx = 0, bsy = 0;
953  if (option->state & State_Sunken) {
956  }
957  QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
958  GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
959  GtkStateType state = gtkPainter.gtkState(option);
960 
961  QColor arrowColor = option->palette.buttonText().color();
962  GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
963  GdkColor color = fromQColor(arrowColor);
964  d->gtk_widget_modify_fg (gtkArrow, state, &color);
965  gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
966  type, state, shadow, FALSE, gtkArrow->style,
967  QString::number(arrowColor.rgba(), 16));
968  // Passing NULL will revert the color change
969  d->gtk_widget_modify_fg (gtkArrow, state, NULL);
970  }
971  break;
972 
973  case PE_FrameGroupBox:
974  // Do nothing here, the GNOME groupboxes are flat
975  break;
976 
977  case PE_PanelMenu: {
978  GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
979  gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
980  gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
981  }
982  break;
983 
984  case PE_FrameMenu:
985  //This is actually done by PE_Widget due to a clipping issue
986  //Otherwise Menu items will not be able to span the entire menu width
987 
988  // This is only used by floating tool bars
989  if (qobject_cast<const QToolBar *>(widget)) {
990  GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
991  gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
992  GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
993  gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
994  GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
995  }
996  break;
997 
998  case PE_FrameLineEdit: {
999  GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
1000 
1001 
1002  gboolean interior_focus;
1003  gint focus_line_width;
1004  QRect rect = option->rect;
1005  d->gtk_widget_style_get(gtkEntry,
1006  "interior-focus", &interior_focus,
1007  "focus-line-width", &focus_line_width, NULL);
1008 
1009  // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack
1010  g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
1011 
1012  if (!interior_focus && option->state & State_HasFocus)
1013  rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
1014 
1015  if (option->state & State_HasFocus)
1016  GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
1017  gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
1018  GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
1019  GTK_SHADOW_IN, gtkEntry->style,
1020  option->state & State_HasFocus ? QLS("focus") : QString());
1021  if (!interior_focus && option->state & State_HasFocus)
1022  gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
1023  GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
1024  GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
1025 
1026  if (option->state & State_HasFocus)
1027  GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
1028  }
1029  break;
1030 
1031  case PE_PanelLineEdit:
1032  if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
1033  GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
1034  if (panel->lineWidth > 0)
1035  proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
1036  uint resolve_mask = option->palette.resolve();
1037  QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness,
1038  -gtkEntry->style->xthickness, -gtkEntry->style->ythickness);
1039 
1040  if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
1041  resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
1042  painter->fillRect(textRect, option->palette.base());
1043  else
1044  gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
1045  option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
1046  }
1047  break;
1048 
1049  case PE_FrameTabWidget:
1050  if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
1051  GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
1052  style = gtkPainter.getStyle(gtkNotebook);
1053  gtkPainter.setAlphaSupport(false);
1054  GtkShadowType shadow = GTK_SHADOW_OUT;
1055  GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
1056  bool reverse = (option->direction == Qt::RightToLeft);
1057  QGtkStylePrivate::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
1058  if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
1059  GtkPositionType frameType = GTK_POS_TOP;
1060  QTabBar::Shape shape = frame->shape;
1061  int gapStart = 0;
1062  int gapSize = 0;
1063  if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
1064  frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
1065  gapStart = tabframe->selectedTabRect.left();
1066  gapSize = tabframe->selectedTabRect.width();
1067  } else {
1068  frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
1069  gapStart = tabframe->selectedTabRect.y();
1070  gapSize = tabframe->selectedTabRect.height();
1071  }
1072  gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
1073  gapStart, gapSize, style);
1074  break; // done
1075  }
1076 
1077  // Note this is only the fallback option
1078  gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
1079  }
1080  break;
1081 
1082  case PE_PanelButtonCommand:
1083  case PE_PanelButtonTool: {
1084  bool isDefault = false;
1085  bool isTool = (element == PE_PanelButtonTool);
1086  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
1087  isDefault = btn->features & QStyleOptionButton::DefaultButton;
1088 
1089  // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
1090  if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
1091  break;
1092  // don't draw a frame for dock widget buttons, unless we are hovering
1093  if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
1094  break;
1095 
1096  GtkStateType state = gtkPainter.gtkState(option);
1097  if (option->state & State_On || option->state & State_Sunken)
1098  state = GTK_STATE_ACTIVE;
1099  GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
1100  gint focusWidth, focusPad;
1101  gboolean interiorFocus = false;
1102  d->gtk_widget_style_get (gtkButton,
1103  "focus-line-width", &focusWidth,
1104  "focus-padding", &focusPad,
1105  "interior-focus", &interiorFocus, NULL);
1106 
1107  style = gtkButton->style;
1108 
1109  QRect buttonRect = option->rect;
1110 
1111  QString key;
1112  if (isDefault) {
1113  key += QLS("def");
1114  GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
1115  gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
1116  style, isDefault ? QLS("d") : QString());
1117  }
1118 
1119  bool hasFocus = option->state & State_HasFocus;
1120 
1121  if (hasFocus) {
1122  key += QLS("def");
1123  GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
1124  }
1125 
1126  if (!interiorFocus)
1127  buttonRect = buttonRect.adjusted(focusWidth, focusWidth, -focusWidth, -focusWidth);
1128 
1129  GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
1130  GTK_SHADOW_IN : GTK_SHADOW_OUT;
1131 
1132  gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
1133  style, key);
1134  if (isDefault)
1135  GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
1136  if (hasFocus)
1137  GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
1138  }
1139  break;
1140 
1141  case PE_IndicatorRadioButton: {
1142  GtkShadowType shadow = GTK_SHADOW_OUT;
1143  GtkStateType state = gtkPainter.gtkState(option);
1144 
1145  if (option->state & State_Sunken)
1146  state = GTK_STATE_ACTIVE;
1147 
1148  if (option->state & State_NoChange)
1149  shadow = GTK_SHADOW_ETCHED_IN;
1150  else if (option->state & State_On)
1151  shadow = GTK_SHADOW_IN;
1152  else
1153  shadow = GTK_SHADOW_OUT;
1154 
1155  GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
1156  gint spacing;
1157  d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
1158  QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
1159  gtkPainter.setClipRect(option->rect);
1160  // ### Note: Ubuntulooks breaks when the proper widget is passed
1161  // Murrine engine requires a widget not to get RGBA check - warnings
1162  GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
1163  QString key(QLS("radiobutton"));
1164  if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
1165  key += QLatin1Char('f');
1166  GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
1167  }
1168  gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key);
1169  if (option->state & State_HasFocus)
1170  GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
1171  }
1172  break;
1173 
1174  case PE_IndicatorCheckBox: {
1175  GtkShadowType shadow = GTK_SHADOW_OUT;
1176  GtkStateType state = gtkPainter.gtkState(option);
1177 
1178  if (option->state & State_Sunken)
1179  state = GTK_STATE_ACTIVE;
1180 
1181  if (option->state & State_NoChange)
1182  shadow = GTK_SHADOW_ETCHED_IN;
1183  else if (option->state & State_On)
1184  shadow = GTK_SHADOW_IN;
1185  else
1186  shadow = GTK_SHADOW_OUT;
1187 
1188  int spacing;
1189 
1190  GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
1191  QString key(QLS("checkbutton"));
1192  if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
1193  key += QLatin1Char('f');
1194  GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
1195  }
1196 
1197  // Some styles such as aero-clone assume they can paint in the spacing area
1198  gtkPainter.setClipRect(option->rect);
1199 
1200  d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
1201 
1202  QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
1203 
1204  gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style,
1205  key);
1206  if (option->state & State_HasFocus)
1207  GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
1208 
1209  }
1210  break;
1211 
1212 #ifndef QT_NO_TABBAR
1213 
1214  case PE_FrameTabBarBase:
1215  if (const QStyleOptionTabBarBase *tbb
1216  = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
1217  QRect tabRect = tbb->rect;
1218  painter->save();
1219  painter->setPen(QPen(option->palette.dark().color().dark(110), 0));
1220  switch (tbb->shape) {
1221 
1222  case QTabBar::RoundedNorth:
1223  painter->drawLine(tabRect.topLeft(), tabRect.topRight());
1224  break;
1225 
1226  case QTabBar::RoundedWest:
1227  painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom());
1228  break;
1229 
1230  case QTabBar::RoundedSouth:
1231  painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
1232  tabRect.right(), tabRect.bottom());
1233  break;
1234 
1235  case QTabBar::RoundedEast:
1236  painter->drawLine(tabRect.topRight(), tabRect.bottomRight());
1237  break;
1238 
1243  painter->restore();
1244  QWindowsStyle::drawPrimitive(element, option, painter, widget);
1245  return;
1246  }
1247 
1248  painter->restore();
1249  }
1250  return;
1251 
1252 #endif // QT_NO_TABBAR
1253 
1254  case PE_Widget:
1255  break;
1256 
1257  default:
1258  QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
1259  }
1260 }
1261 
1266 
1267  QPainter *painter, const QWidget *widget) const
1268 {
1269  Q_D(const QGtkStyle);
1270 
1271  if (!d->isThemeAvailable()) {
1272  QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
1273  return;
1274  }
1275 
1276  GtkStyle* style = d->gtkStyle();
1277  QGtkPainter gtkPainter(painter);
1278  QColor button = option->palette.button().color();
1279  QColor dark;
1280  QColor grooveColor;
1281  QColor darkOutline;
1282  dark.setHsv(button.hue(),
1283  qMin(255, (int)(button.saturation()*1.9)),
1284  qMin(255, (int)(button.value()*0.7)));
1285  grooveColor.setHsv(button.hue(),
1286  qMin(255, (int)(button.saturation()*2.6)),
1287  qMin(255, (int)(button.value()*0.9)));
1288  darkOutline.setHsv(button.hue(),
1289  qMin(255, (int)(button.saturation()*3.0)),
1290  qMin(255, (int)(button.value()*0.6)));
1291 
1292  QColor alphaCornerColor;
1293 
1294  if (widget)
1295  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
1296  else
1297  alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
1298 
1299  switch (control) {
1300 
1301  case CC_TitleBar:
1302  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
1303  // Since this is drawn by metacity and not Gtk we
1304  // have to rely on Cleanlooks for a fallback
1305  QStyleOptionTitleBar copyOpt = *tb;
1306  QPalette pal = copyOpt.palette;
1307  // Bg color is closer to the window selection than
1308  // the base selection color
1309  GdkColor gdkBg = style->bg[GTK_STATE_SELECTED];
1310  QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
1312  copyOpt.palette = pal;
1313  QCleanlooksStyle::drawComplexControl(control, &copyOpt, painter, widget);
1314  }
1315  break;
1316 
1317 #ifndef QT_NO_GROUPBOX
1318 
1319  case CC_GroupBox:
1320  painter->save();
1321 
1322  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
1323  QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
1324  QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
1325  // Draw title
1326 
1327  if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
1328  // Draw prelight background
1329  GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
1330 
1331  if (option->state & State_MouseOver) {
1332  QRect bgRect = textRect | checkBoxRect;
1333  gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
1334  GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkCheckButton->style);
1335  }
1336 
1337  if (!groupBox->text.isEmpty()) {
1338  int alignment = int(groupBox->textAlignment);
1339  if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
1340  alignment |= Qt::TextHideMnemonic;
1341  QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored
1342  int labelState = GTK_STATE_INSENSITIVE;
1343 
1344  if (option->state & State_Enabled)
1345  labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
1346 
1347  GdkColor gdkText = gtkCheckButton->style->fg[labelState];
1348  textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
1349  painter->setPen(textColor);
1350  QFont font = painter->font();
1351  font.setBold(true);
1352  painter->setFont(font);
1353  painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
1354 
1355  if (option->state & State_HasFocus)
1356  gtkPainter.paintFocus( NULL, "tab", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
1357  }
1358  }
1359 
1360  if (groupBox->subControls & SC_GroupBoxCheckBox) {
1361  QStyleOptionButton box;
1362  box.QStyleOption::operator=(*groupBox);
1363  box.rect = checkBoxRect;
1364  proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
1365  }
1366  }
1367 
1368  painter->restore();
1369  break;
1370 #endif // QT_NO_GROUPBOX
1371 
1372 #ifndef QT_NO_COMBOBOX
1373 
1374  case CC_ComboBox:
1375  // See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox
1376  // and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry
1377  if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
1378  bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
1379  BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable));
1380  QGtkPainter gtkCachedPainter(p);
1381  gtkCachedPainter.setUsePixmapCache(false); // cached externally
1382 
1383  bool isEnabled = (comboBox->state & State_Enabled);
1384  bool focus = isEnabled && (comboBox->state & State_HasFocus);
1385  GtkStateType state = gtkPainter.gtkState(option);
1386  int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
1387  QStyleOptionComboBox comboBoxCopy = *comboBox;
1388  comboBoxCopy.rect = option->rect;
1389 
1390  bool reverse = (option->direction == Qt::RightToLeft);
1391  QRect rect = option->rect;
1392  QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
1393  SC_ComboBoxArrow, widget);
1394 
1395  GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
1396  GTK_SHADOW_IN : GTK_SHADOW_OUT;
1397  const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
1398 
1399  // We use the gtk widget to position arrows and separators for us
1400  GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
1401  GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
1402  d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
1403  d->gtk_widget_size_allocate(gtkCombo, &geometry);
1404 
1405  QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
1406  : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
1407  GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
1408  d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
1409  if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
1410  if (focus)
1411  GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
1412  // Draw the combo box as a line edit with a button next to it
1413  if (comboBox->editable || appears_as_list) {
1414  GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
1415  QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
1416  GtkWidget *gtkEntry = d->gtkWidget(entryPath);
1417  d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
1418  QRect frameRect = option->rect;
1419 
1420  if (reverse)
1421  frameRect.setLeft(arrowButtonRect.right());
1422  else
1423  frameRect.setRight(arrowButtonRect.left());
1424 
1425  // Fill the line edit background
1426  // We could have used flat_box with "entry_bg" but that is probably not worth the overhead
1427  uint resolve_mask = option->palette.resolve();
1428  int xt = gtkEntry->style->xthickness;
1429  int yt = gtkEntry->style->ythickness;
1430  QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
1431  // Required for inner blue highlight with clearlooks
1432  if (focus)
1433  GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
1434 
1435  if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
1436  resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
1437  p->fillRect(contentRect, option->palette.base().color());
1438  else {
1439  gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
1440  option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
1441  GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus));
1442  }
1443 
1444  gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
1445  GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() +
1446  QString::number(focus) + QString::number(comboBox->editable) +
1447  QString::number(option->direction));
1448  if (focus)
1449  GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
1450  }
1451 
1452  GtkStateType buttonState = GTK_STATE_NORMAL;
1453 
1454  if (!(option->state & State_Enabled))
1455  buttonState = GTK_STATE_INSENSITIVE;
1456  else if (option->state & State_Sunken || option->state & State_On)
1457  buttonState = GTK_STATE_ACTIVE;
1458  else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow)
1459  buttonState = GTK_STATE_PRELIGHT;
1460 
1461  Q_ASSERT(gtkToggleButton);
1462  gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
1463  shadow, gtkToggleButton->style, buttonPath.toString() +
1464  QString::number(focus) + QString::number(option->direction));
1465  if (focus)
1466  GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
1467  } else {
1468  // Draw combo box as a button
1469  QRect buttonRect = option->rect;
1470 
1471  if (focus) // Clearlooks actually check the widget for the default state
1472  GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
1473  gtkCachedPainter.paintBox(gtkToggleButton, "button",
1474  buttonRect, state,
1475  shadow, gtkToggleButton->style,
1476  buttonPath.toString() + QString::number(focus));
1477  if (focus)
1478  GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
1479 
1480 
1481  // Draw the separator between label and arrows
1482  QHashableLatin1Literal vSeparatorPath = comboBox->editable
1483  ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
1484  : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
1485 
1486  if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
1487  QRect vLineRect(gtkVSeparator->allocation.x,
1488  gtkVSeparator->allocation.y,
1489  gtkVSeparator->allocation.width,
1490  gtkVSeparator->allocation.height);
1491 
1492  gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
1493  vLineRect, state, gtkVSeparator->style,
1494  0, vLineRect.height(), 0, vSeparatorPath.toString());
1495 
1496 
1497  gint interiorFocus = true;
1498  d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
1499  int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
1500  int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
1501  if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
1502  gtkCachedPainter.paintFocus(gtkToggleButton, "button",
1503  option->rect.adjusted(xt, yt, -xt, -yt),
1504  option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
1505  gtkToggleButton->style);
1506  }
1507  }
1508 
1509  if (comboBox->subControls & SC_ComboBoxArrow) {
1510  if (!isEnabled)
1511  state = GTK_STATE_INSENSITIVE;
1512  else if (sunken)
1513  state = GTK_STATE_ACTIVE;
1514  else if (option->state & State_MouseOver)
1515  state = GTK_STATE_PRELIGHT;
1516  else
1517  state = GTK_STATE_NORMAL;
1518 
1519  QHashableLatin1Literal arrowPath("");
1520  if (comboBox->editable) {
1521  if (appears_as_list)
1522  arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
1523  else
1524  arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow");
1525  } else {
1526  if (appears_as_list)
1527  arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow");
1528  else
1529  arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
1530  }
1531 
1532  GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
1533  gfloat scale = 0.7;
1534  gint minSize = 15;
1535  QRect arrowWidgetRect;
1536 
1537  if (gtkArrow && !d->gtk_check_version(2, 12, 0)) {
1538  d->gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
1539  d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
1540  }
1541  if (gtkArrow) {
1542  arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y,
1543  gtkArrow->allocation.width, gtkArrow->allocation.height);
1544  style = gtkArrow->style;
1545  }
1546 
1547  // Note that for some reason the arrow-size is not properly respected with Hildon
1548  // Hence we enforce the minimum "arrow-size" ourselves
1549  int arrowSize = qMax(qMin(rect.height() - gtkCombo->style->ythickness * 2, minSize),
1550  qMin(arrowWidgetRect.width(), arrowWidgetRect.height()));
1551  QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale));
1552 
1553  arrowRect.moveCenter(arrowWidgetRect.center());
1554 
1555  if (sunken) {
1556  int xoff, yoff;
1557  const QHashableLatin1Literal toggleButtonPath = comboBox->editable
1558  ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
1559  : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
1560 
1561  GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath);
1562  d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
1563  d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
1564  arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
1565  }
1566 
1567  // Some styles such as Nimbus paint outside the arrowRect
1568  // hence we have provide the whole widget as the cliprect
1569  if (gtkArrow) {
1570  gtkCachedPainter.setClipRect(option->rect);
1571  gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect,
1572  GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE,
1573  style, arrowPath.toString() + QString::number(option->direction));
1574  }
1575  }
1577  }
1578  break;
1579 #endif // QT_NO_COMBOBOX
1580 #ifndef QT_NO_TOOLBUTTON
1581 
1582  case CC_ToolButton:
1583  if (const QStyleOptionToolButton *toolbutton
1584  = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
1585  QRect button, menuarea;
1586  button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
1587  menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
1588  State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver);
1589 
1590  if (bflags & State_AutoRaise)
1591  if (!(bflags & State_MouseOver))
1592  bflags &= ~State_Raised;
1593 
1594  State mflags = bflags;
1595 
1596  if (toolbutton->state & State_Sunken) {
1597  if (toolbutton->activeSubControls & SC_ToolButton)
1598  bflags |= State_Sunken;
1599  if (toolbutton->activeSubControls & SC_ToolButtonMenu)
1600  mflags |= State_Sunken;
1601  } else if (toolbutton->state & State_MouseOver) {
1602  if (toolbutton->activeSubControls & SC_ToolButton)
1603  bflags |= State_MouseOver;
1604  if (toolbutton->activeSubControls & SC_ToolButtonMenu)
1605  mflags |= State_MouseOver;
1606  }
1607 
1608  QStyleOption tool(0);
1609 
1610  tool.palette = toolbutton->palette;
1611 
1612  if (toolbutton->subControls & SC_ToolButton) {
1613  if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) {
1614  tool.rect = button;
1615  tool.state = bflags;
1616  proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
1617  }
1618  }
1619 
1620  bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu &&
1621  !(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup);
1622  int popupArrowSize = drawMenuArrow ? 7 : 0;
1623 
1624  if (toolbutton->state & State_HasFocus) {
1626  fr.QStyleOption::operator=(*toolbutton);
1627  fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
1628  fr.rect.adjust(1, 1, -1, -1);
1629  proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
1630  }
1631 
1632  QStyleOptionToolButton label = *toolbutton;
1633  label.state = bflags;
1634  GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
1635  QPalette pal = toolbutton->palette;
1636  if (option->state & State_Enabled &&
1637  option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
1638  GdkColor gdkText = gtkButton->style->fg[GTK_STATE_PRELIGHT];
1639  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
1640  pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
1641  label.palette = pal;
1642  }
1643  label.rect = button.adjusted(style->xthickness, style->ythickness,
1644  -style->xthickness - popupArrowSize, -style->ythickness);
1645  proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
1646 
1647  if (toolbutton->subControls & SC_ToolButtonMenu) {
1648  tool.rect = menuarea;
1649  tool.state = mflags;
1650  if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise))
1651  proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
1652 
1653  proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
1654 
1655  } else if (drawMenuArrow) {
1656  QRect ir = toolbutton->rect;
1657  QStyleOptionToolButton newBtn = *toolbutton;
1658  newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize);
1659  proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
1660  }
1661  }
1662  break;
1663 
1664 #endif // QT_NO_TOOLBUTTON
1665 #ifndef QT_NO_SCROLLBAR
1666 
1667  case CC_ScrollBar:
1668  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
1669  GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar");
1670  GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar");
1671 
1672  // Fill background in case the scrollbar is partially transparent
1673  painter->fillRect(option->rect, option->palette.background());
1674 
1675  QRect rect = scrollBar->rect;
1676  QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
1677  QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
1678  QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
1679  QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
1680  bool horizontal = scrollBar->orientation == Qt::Horizontal;
1681  GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
1682  style = scrollbarWidget->style;
1683  gboolean trough_under_steppers = true;
1684  gboolean trough_side_details = false;
1685  gboolean activate_slider = false;
1686  gboolean stepper_size = 14;
1687  gint trough_border = 1;
1688  if (!d->gtk_check_version(2, 10, 0)) {
1689  d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
1690  "trough-border", &trough_border,
1691  "trough-side-details", &trough_side_details,
1692  "trough-under-steppers", &trough_under_steppers,
1693  "activate-slider", &activate_slider,
1694  "stepper-size", &stepper_size, NULL);
1695  }
1696  if (trough_under_steppers) {
1697  scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
1698  scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
1699  scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border,
1700  horizontal ? trough_border : 0, horizontal ? 0 : trough_border);
1701  }
1702 
1703  // Some styles check the position of scrollbars in order to determine
1704  // if lines should be painted when the scrollbar is in max or min positions.
1705  int maximum = 2;
1706  int fakePos = 0;
1707  bool reverse = (option->direction == Qt::RightToLeft);
1708  if (scrollBar->minimum == scrollBar->maximum)
1709  maximum = 0;
1710  if (scrollBar->sliderPosition == scrollBar->maximum)
1711  fakePos = maximum;
1712  else if (scrollBar->sliderPosition > scrollBar->minimum)
1713  fakePos = maximum - 1;
1714 
1715 
1716  GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
1717  GtkAdjustment *adjustment = 0;
1718 
1719  if (d->gtk_adjustment_configure)
1720  adjustment = d->gtk_range_get_adjustment(range);
1721  if (adjustment) {
1722  d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
1723  } else {
1724  adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
1725  d->gtk_range_set_adjustment(range, adjustment);
1726  }
1727 
1728  if (scrollBar->subControls & SC_ScrollBarGroove) {
1729  GtkStateType state = GTK_STATE_ACTIVE;
1730 
1731  if (!(option->state & State_Enabled))
1732  state = GTK_STATE_INSENSITIVE;
1733 
1734  if (trough_under_steppers)
1735  grooveRect = option->rect;
1736 
1737  gtkPainter.paintBox( scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
1738  }
1739 
1740  //paint slider
1741  if (scrollBar->subControls & SC_ScrollBarSlider) {
1742  GtkStateType state = GTK_STATE_NORMAL;
1743 
1744  if (!(option->state & State_Enabled))
1745  state = GTK_STATE_INSENSITIVE;
1746  else if (activate_slider &&
1747  option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider))
1748  state = GTK_STATE_ACTIVE;
1749  else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider))
1750  state = GTK_STATE_PRELIGHT;
1751 
1752  GtkShadowType shadow = GTK_SHADOW_OUT;
1753 
1754  if (trough_under_steppers) {
1755  if (!horizontal)
1756  scrollBarSlider.adjust(trough_border, 0, -trough_border, 0);
1757  else
1758  scrollBarSlider.adjust(0, trough_border, 0, -trough_border);
1759  }
1760 
1761  gtkPainter.paintSlider( scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
1762 
1763  horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum));
1764  }
1765 
1766  if (scrollBar->subControls & SC_ScrollBarAddLine) {
1767  gtkVScrollBar->allocation.y = scrollBarAddLine.top();
1768  gtkVScrollBar->allocation.height = scrollBarAddLine.height() - rect.height() + 6;
1769  gtkHScrollBar->allocation.x = scrollBarAddLine.right();
1770  gtkHScrollBar->allocation.width = scrollBarAddLine.width() - rect.width();
1771 
1772  GtkShadowType shadow = GTK_SHADOW_OUT;
1773  GtkStateType state = GTK_STATE_NORMAL;
1774 
1775  if (!(option->state & State_Enabled) || (fakePos == maximum))
1776  state = GTK_STATE_INSENSITIVE;
1777  else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) {
1778  state = GTK_STATE_ACTIVE;
1779  shadow = GTK_SHADOW_IN;
1780 
1781  } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine))
1782  state = GTK_STATE_PRELIGHT;
1783 
1784  gtkPainter.paintBox( scrollbarWidget,
1785  horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine,
1786  state, shadow, style, QLS("add"));
1787 
1788  gtkPainter.paintArrow( scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
1789  horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) :
1790  GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, FALSE, style);
1791  }
1792 
1793  if (scrollBar->subControls & SC_ScrollBarSubLine) {
1794  gtkVScrollBar->allocation.y = 0;
1795  gtkVScrollBar->allocation.height = scrollBarSubLine.height();
1796  gtkHScrollBar->allocation.x = 0;
1797  gtkHScrollBar->allocation.width = scrollBarSubLine.width();
1798 
1799  GtkShadowType shadow = GTK_SHADOW_OUT;
1800  GtkStateType state = GTK_STATE_NORMAL;
1801 
1802  if (!(option->state & State_Enabled) || (fakePos == 0))
1803  state = GTK_STATE_INSENSITIVE;
1804  else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) {
1805  shadow = GTK_SHADOW_IN;
1806  state = GTK_STATE_ACTIVE;
1807 
1808  } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine))
1809  state = GTK_STATE_PRELIGHT;
1810 
1811  gtkPainter.paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
1812  state, shadow, style, QLS("sub"));
1813 
1814  gtkPainter.paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
1815  horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
1816  GTK_ARROW_UP, state, GTK_SHADOW_NONE, FALSE, style);
1817  }
1818  }
1819  break;
1820 
1821 #endif //QT_NO_SCROLLBAR
1822 #ifndef QT_NO_SPINBOX
1823 
1824  case CC_SpinBox:
1825  if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
1826 
1827  GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons
1828  ? d->gtkWidget("GtkEntry")
1829  : d->gtkWidget("GtkSpinButton");
1830  bool isEnabled = (spinBox->state & State_Enabled);
1831  bool hover = isEnabled && (spinBox->state & State_MouseOver);
1832  bool sunken = (spinBox->state & State_Sunken);
1833  bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
1834  bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
1835  bool reverse = (spinBox->direction == Qt::RightToLeft);
1836 
1837  QRect editArea = option->rect;
1838  QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
1839  QRect upRect, downRect, buttonRect;
1840  if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
1841  upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
1842  downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
1843 
1844  //### Move this to subControlRect
1845  upRect.setTop(option->rect.top());
1846 
1847  if (reverse)
1848  upRect.setLeft(option->rect.left());
1849  else
1850  upRect.setRight(option->rect.right());
1851 
1852  downRect.setBottom(option->rect.bottom());
1853 
1854  if (reverse)
1855  downRect.setLeft(option->rect.left());
1856  else
1857  downRect.setRight(option->rect.right());
1858 
1859  buttonRect = upRect | downRect;
1860 
1861  if (reverse)
1862  editArea.setLeft(upRect.right());
1863  else
1864  editArea.setRight(upRect.left());
1865  }
1866  if (spinBox->frame) {
1867  GtkStateType state = gtkPainter.gtkState(option);
1868 
1869  if (!(option->state & State_Enabled))
1870  state = GTK_STATE_INSENSITIVE;
1871  else if (option->state & State_HasFocus)
1872  state = GTK_STATE_NORMAL;
1873  else if (state == GTK_STATE_PRELIGHT)
1874  state = GTK_STATE_NORMAL;
1875 
1876  style = gtkPainter.getStyle(gtkSpinButton);
1877 
1878 
1879  QString key;
1880 
1881  if (option->state & State_HasFocus) {
1882  key += QLatin1Char('f');
1883  GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
1884  }
1885 
1886  uint resolve_mask = option->palette.resolve();
1887 
1888  if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
1889  painter->fillRect(editRect, option->palette.base().color());
1890  else
1891  gtkPainter.paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
1892  -style->xthickness, -style->ythickness),
1893  option->state & State_Enabled ?
1894  GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
1895 
1896  gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key);
1897  if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
1898  gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
1899 
1900  upRect.setSize(downRect.size());
1901  if (!(option->state & State_Enabled))
1902  gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
1903  else if (upIsActive && sunken)
1904  gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
1905  else if (upIsActive && hover)
1906  gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
1907  else
1908  gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
1909 
1910  if (!(option->state & State_Enabled))
1911  gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
1912  else if (downIsActive && sunken)
1913  gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
1914  else if (downIsActive && hover)
1915  gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
1916  else
1917  gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
1918 
1919  if (option->state & State_HasFocus)
1920  GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
1921  }
1922  }
1923 
1924  if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
1925  int centerX = upRect.center().x();
1926  int centerY = upRect.center().y();
1927  // plus/minus
1928 
1929  if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
1930  painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
1931  painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
1932 
1933  } else {
1934  painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
1935  painter->drawLine(centerX, centerY - 2, centerX, centerY + 2);
1936  }
1937  centerX = downRect.center().x();
1938  centerY = downRect.center().y();
1939 
1940  if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
1941  painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
1942  } else {
1943  painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
1944  }
1945 
1946  } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
1947  int size = d->getSpinboxArrowSize();
1948  int w = size / 2 - 1;
1949  w -= w % 2 - 1; // force odd
1950  int h = (w + 1)/2;
1951  QRect arrowRect(0, 0, w, h);
1952  arrowRect.moveCenter(upRect.center());
1953  // arrows
1954  GtkStateType state = GTK_STATE_NORMAL;
1955 
1956  if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
1957  state = GTK_STATE_INSENSITIVE;
1958 
1959  gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
1960  GTK_SHADOW_NONE, FALSE, style);
1961 
1962  arrowRect.moveCenter(downRect.center());
1963 
1964  if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
1965  state = GTK_STATE_INSENSITIVE;
1966 
1967  gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
1968  GTK_SHADOW_NONE, FALSE, style);
1969  }
1970  }
1971  break;
1972 
1973 #endif // QT_NO_SPINBOX
1974 
1975 #ifndef QT_NO_SLIDER
1976 
1977  case CC_Slider:
1978  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
1979  GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale");
1980  GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale");
1981 
1982  QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
1983  QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
1984 
1985  bool horizontal = slider->orientation == Qt::Horizontal;
1986  bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
1987  bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
1988 
1989  QBrush oldBrush = painter->brush();
1990  QPen oldPen = painter->pen();
1991 
1992  QColor shadowAlpha(Qt::black);
1993  shadowAlpha.setAlpha(10);
1994  QColor highlightAlpha(Qt::white);
1995  highlightAlpha.setAlpha(80);
1996 
1997  QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ?
1998  GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
1999  GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget;
2000  style = scaleWidget->style;
2001 
2002  if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
2003 
2004  GtkRange *range = (GtkRange*)scaleWidget;
2005  GtkAdjustment *adjustment = 0;
2006  if (d->gtk_adjustment_configure)
2007  adjustment = d->gtk_range_get_adjustment(range);
2008  if (adjustment) {
2009  d->gtk_adjustment_configure(adjustment,
2010  slider->sliderPosition,
2011  slider->minimum,
2012  slider->maximum,
2013  slider->singleStep,
2014  slider->singleStep,
2015  slider->pageStep);
2016  } else {
2017  adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
2018  slider->minimum,
2019  slider->maximum,
2020  slider->singleStep,
2021  slider->singleStep,
2022  slider->pageStep);
2023  d->gtk_range_set_adjustment(range, adjustment);
2024  }
2025 
2026  int outerSize;
2027  d->gtk_range_set_inverted(range, !horizontal);
2028  d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
2029  outerSize++;
2030 
2031  GtkStateType state = gtkPainter.gtkState(option);
2032  int focusFrameMargin = 2;
2033  QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
2034  -focusFrameMargin, -outerSize - focusFrameMargin);
2035 
2036  gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
2037  if (!d->gtk_check_version(2, 10, 0))
2038  d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
2039 
2040  if (!trough_side_details) {
2041  gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
2042  GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
2043  } else {
2044  QRect upperGroove = grooveRect;
2045  QRect lowerGroove = grooveRect;
2046 
2047  if (horizontal) {
2048  if (slider->upsideDown) {
2049  lowerGroove.setLeft(handle.center().x());
2050  upperGroove.setRight(handle.center().x());
2051  } else {
2052  upperGroove.setLeft(handle.center().x());
2053  lowerGroove.setRight(handle.center().x());
2054  }
2055  } else {
2056  if (!slider->upsideDown) {
2057  lowerGroove.setBottom(handle.center().y());
2058  upperGroove.setTop(handle.center().y());
2059  } else {
2060  upperGroove.setBottom(handle.center().y());
2061  lowerGroove.setTop(handle.center().y());
2062  }
2063  }
2064 
2065  gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
2066  GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
2067  gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
2068  GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
2069  }
2070  }
2071 
2072  if (option->subControls & SC_SliderTickmarks) {
2073  painter->setPen(darkOutline);
2074  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
2075  int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
2076  int interval = slider->tickInterval;
2077 
2078  if (interval <= 0) {
2079  interval = slider->singleStep;
2080 
2081  if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
2082  available)
2083  - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
2084  0, available) < 3)
2085  interval = slider->pageStep;
2086  }
2087 
2088  if (interval <= 0)
2089  interval = 1;
2090 
2091  int v = slider->minimum;
2092  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
2093  while (v <= slider->maximum + 1) {
2094  if (v == slider->maximum + 1 && interval == 1)
2095  break;
2096  const int v_ = qMin(v, slider->maximum);
2097  int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
2098  v_, (horizontal
2099  ? slider->rect.width()
2100  : slider->rect.height()) - len,
2101  slider->upsideDown) + len / 2;
2102  int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
2103  if (horizontal) {
2104  if (ticksAbove)
2105  painter->drawLine(pos, slider->rect.top() + extra,
2106  pos, slider->rect.top() + tickSize);
2107  if (ticksBelow)
2108  painter->drawLine(pos, slider->rect.bottom() - extra,
2109  pos, slider->rect.bottom() - tickSize);
2110 
2111  } else {
2112  if (ticksAbove)
2113  painter->drawLine(slider->rect.left() + extra, pos,
2114  slider->rect.left() + tickSize, pos);
2115  if (ticksBelow)
2116  painter->drawLine(slider->rect.right() - extra, pos,
2117  slider->rect.right() - tickSize, pos);
2118  }
2119 
2120  // In the case where maximum is max int
2121  int nextInterval = v + interval;
2122  if (nextInterval < v)
2123  break;
2124  v = nextInterval;
2125  }
2126  }
2127 
2128  // Draw slider handle
2129  if (option->subControls & SC_SliderHandle) {
2130  GtkShadowType shadow = GTK_SHADOW_OUT;
2131  GtkStateType state = GTK_STATE_NORMAL;
2132 
2133  if (!(option->state & State_Enabled))
2134  state = GTK_STATE_INSENSITIVE;
2135  else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle)
2136  state = GTK_STATE_PRELIGHT;
2137 
2138  bool horizontal = option->state & State_Horizontal;
2139 
2140  if (slider->state & State_HasFocus) {
2141  QStyleOptionFocusRect fropt;
2142  fropt.QStyleOption::operator=(*slider);
2143  fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1);
2144 
2145  if (horizontal) {
2146  fropt.rect.setTop(handle.top() - 3);
2147  fropt.rect.setBottom(handle.bottom() + 4);
2148 
2149  } else {
2150  fropt.rect.setLeft(handle.left() - 3);
2151  fropt.rect.setRight(handle.right() + 3);
2152  }
2153  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
2154  }
2155  gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
2156 
2157  horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
2158  }
2159  painter->setBrush(oldBrush);
2160  painter->setPen(oldPen);
2161  }
2162  break;
2163 
2164 #endif // QT_NO_SLIDER
2165 
2166  default:
2167  QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
2168 
2169  break;
2170  }
2171 }
2172 
2173 
2178  const QStyleOption *option,
2179  QPainter *painter,
2180  const QWidget *widget) const
2181 {
2182  Q_D(const QGtkStyle);
2183 
2184  if (!d->isThemeAvailable()) {
2185  QCleanlooksStyle::drawControl(element, option, painter, widget);
2186  return;
2187  }
2188 
2189  GtkStyle* style = d->gtkStyle();
2190  QGtkPainter gtkPainter(painter);
2191 
2192  switch (element) {
2193  case CE_ProgressBarLabel:
2194  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2195  GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
2196  if (!gtkProgressBar)
2197  return;
2198 
2199  QRect leftRect;
2200  QRect rect = bar->rect;
2201  GdkColor gdkText = gtkProgressBar->style->fg[GTK_STATE_NORMAL];
2202  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2203  gdkText = gtkProgressBar->style->fg[GTK_STATE_PRELIGHT];
2204  QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2205 
2206  painter->save();
2207  bool vertical = false, inverted = false;
2208  if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
2209  vertical = (bar2->orientation == Qt::Vertical);
2210  inverted = bar2->invertedAppearance;
2211  }
2212  if (vertical)
2213  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
2214  const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
2215  qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
2216  if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
2217  leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
2218  if (vertical)
2219  leftRect.translate(rect.width() - progressIndicatorPos, 0);
2220 
2221  bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) ||
2222  ((bar->direction == Qt::LeftToRight) && inverted)));
2223 
2224  QRegion rightRect = rect;
2225  rightRect = rightRect.subtracted(leftRect);
2226  painter->setClipRegion(rightRect);
2227  painter->setPen(flip ? alternateTextColor : textColor);
2229  if (!leftRect.isNull()) {
2230  painter->setPen(flip ? textColor : alternateTextColor);
2231  painter->setClipRect(leftRect);
2233  }
2234  painter->restore();
2235  }
2236  break;
2237  case CE_PushButtonLabel:
2238  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
2239  QRect ir = button->rect;
2241  QPoint buttonShift;
2242 
2243  if (option->state & State_Sunken)
2244  buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
2245  proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
2246 
2247  if (proxy()->styleHint(SH_UnderlineShortcut, button, widget))
2248  tf |= Qt::TextShowMnemonic;
2249  else
2250  tf |= Qt::TextHideMnemonic;
2251 
2252  if (!button->icon.isNull()) {
2253  //Center both icon and text
2254  QPoint point;
2255 
2256  QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
2257  if (mode == QIcon::Normal && button->state & State_HasFocus)
2258  mode = QIcon::Active;
2259 
2260  QIcon::State state = QIcon::Off;
2261 
2262  if (button->state & State_On)
2263  state = QIcon::On;
2264 
2265  QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
2266  int w = pixmap.width();
2267  int h = pixmap.height();
2268 
2269  if (!button->text.isEmpty())
2270  w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4;
2271 
2272  point = QPoint(ir.x() + ir.width() / 2 - w / 2,
2273  ir.y() + ir.height() / 2 - h / 2);
2274 
2275  if (button->direction == Qt::RightToLeft)
2276  point.rx() += pixmap.width();
2277 
2278  painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap);
2279 
2280  if (button->direction == Qt::RightToLeft)
2281  ir.translate(-point.x() - 2, 0);
2282  else
2283  ir.translate(point.x() + pixmap.width() + 2, 0);
2284 
2285  // left-align text if there is
2286  if (!button->text.isEmpty())
2287  tf |= Qt::AlignLeft;
2288 
2289  } else {
2290  tf |= Qt::AlignHCenter;
2291  }
2292 
2293  ir.translate(buttonShift);
2294 
2295  if (button->features & QStyleOptionButton::HasMenu)
2296  ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
2297 
2298  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
2299  QPalette pal = button->palette;
2300  int labelState = GTK_STATE_INSENSITIVE;
2301  if (option->state & State_Enabled)
2302  labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ?
2303  GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
2304 
2305  GdkColor gdkText = gtkButton->style->fg[labelState];
2306  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2307  pal.setBrush(QPalette::ButtonText, textColor);
2308  proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
2309  button->text, QPalette::ButtonText);
2310  }
2311  break;
2312 
2313  case CE_RadioButton: // Fall through
2314  case CE_CheckBox:
2315  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
2316  bool isRadio = (element == CE_RadioButton);
2317 
2318  // Draw prelight background
2319  GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
2320 
2321  if (option->state & State_MouseOver) {
2322  gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
2323  GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkRadioButton->style);
2324  }
2325 
2326  QStyleOptionButton subopt = *btn;
2327  subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
2328  : SE_CheckBoxIndicator, btn, widget);
2330  &subopt, painter, widget);
2331  subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
2332  : SE_CheckBoxContents, btn, widget);
2333  // Get label text color
2334  QPalette pal = subopt.palette;
2335  int labelState = GTK_STATE_INSENSITIVE;
2336  if (option->state & State_Enabled)
2337  labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
2338 
2339  GdkColor gdkText = gtkRadioButton->style->fg[labelState];
2340  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2341  pal.setBrush(QPalette::WindowText, textColor);
2342  subopt.palette = pal;
2343  proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
2344 
2345  if (btn->state & State_HasFocus) {
2346  QStyleOptionFocusRect fropt;
2347  fropt.QStyleOption::operator=(*btn);
2348  fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
2349  : SE_CheckBoxFocusRect, btn, widget);
2350  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
2351  }
2352  }
2353  break;
2354 
2355 #ifndef QT_NO_COMBOBOX
2356 
2357  case CE_ComboBoxLabel:
2358  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
2359  QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
2360  bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
2361  painter->save();
2362  painter->setClipRect(editRect);
2363 
2364  if (!cb->currentIcon.isNull()) {
2365  QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
2366  : QIcon::Disabled;
2367  QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
2368  QRect iconRect(editRect);
2369  iconRect.setWidth(cb->iconSize.width() + 4);
2370 
2371  iconRect = alignedRect(cb->direction,
2373  iconRect.size(), editRect);
2374 
2375  if (cb->editable)
2376  painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
2377 
2378  proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
2379 
2380  if (cb->direction == Qt::RightToLeft)
2381  editRect.translate(-4 - cb->iconSize.width(), 0);
2382  else
2383  editRect.translate(cb->iconSize.width() + 4, 0);
2384  }
2385 
2386  if (!cb->currentText.isEmpty() && !cb->editable) {
2387  GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
2388  QPalette pal = cb->palette;
2389  int labelState = GTK_STATE_INSENSITIVE;
2390 
2391  if (option->state & State_Enabled)
2392  labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
2393 
2394  GdkColor gdkText = gtkCombo->style->fg[labelState];
2395 
2396  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2397 
2398  pal.setBrush(QPalette::ButtonText, textColor);
2399 
2400  proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
2402  pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText);
2403  }
2404 
2405  painter->restore();
2406  }
2407  break;
2408 
2409 #endif // QT_NO_COMBOBOX
2410 
2411  case CE_DockWidgetTitle:
2412  painter->save();
2413  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
2414  const QStyleOptionDockWidgetV2 *v2
2416  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2417 
2418  QRect rect = dwOpt->rect;
2419  QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0);
2420  QRect r = rect.adjusted(0, 0, -1, -1);
2421  if (verticalTitleBar)
2422  r.adjust(0, 0, 0, -1);
2423 
2424  if (verticalTitleBar) {
2425  QRect r = rect;
2426  QSize s = r.size();
2427  s.transpose();
2428  r.setSize(s);
2429 
2430  titleRect = QRect(r.left() + rect.bottom()
2431  - titleRect.bottom(),
2432  r.top() + titleRect.left() - rect.left(),
2433  titleRect.height(), titleRect.width());
2434 
2435  painter->translate(r.left(), r.top() + r.width());
2436  painter->rotate(-90);
2437  painter->translate(-r.left(), -r.top());
2438 
2439  rect = r;
2440  }
2441 
2442  if (!dwOpt->title.isEmpty()) {
2443  QString titleText
2444  = painter->fontMetrics().elidedText(dwOpt->title,
2445  Qt::ElideRight, titleRect.width());
2446  proxy()->drawItemText(painter,
2447  titleRect,
2449  dwOpt->state & State_Enabled, titleText,
2451  }
2452  }
2453  painter->restore();
2454  break;
2455 
2456 
2457 
2458  case CE_HeaderSection:
2459  painter->save();
2460 
2461  // Draws the header in tables.
2462  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2463  Q_UNUSED(header);
2464  GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
2465  // Get the middle column
2466  GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
2467  Q_ASSERT(column);
2468 
2469  GtkWidget *gtkTreeHeader = column->button;
2470  GtkStateType state = gtkPainter.gtkState(option);
2471  GtkShadowType shadow = GTK_SHADOW_OUT;
2472 
2473  if (option->state & State_Sunken)
2474  shadow = GTK_SHADOW_IN;
2475 
2476  gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtkTreeHeader->style);
2477  }
2478 
2479  painter->restore();
2480  break;
2481 
2482 #ifndef QT_NO_SIZEGRIP
2483 
2484  case CE_SizeGrip: {
2485  GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
2486  QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
2487  gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
2488  GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
2489  GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
2490  gtkStatusbar->style);
2491  }
2492  break;
2493 
2494 #endif // QT_NO_SIZEGRIP
2495 
2496  case CE_MenuBarEmptyArea: {
2497  GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
2498  GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
2499  painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
2500  if (widget) { // See CE_MenuBarItem
2501  QRect menuBarRect = widget->rect();
2502  QPixmap pixmap(menuBarRect.size());
2503  pixmap.fill(Qt::transparent);
2504  QPainter pmPainter(&pixmap);
2505  QGtkPainter gtkMenuBarPainter(&pmPainter);
2506  GtkShadowType shadow_type;
2507  d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
2508  gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
2509  GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
2510  pmPainter.end();
2511  painter->drawPixmap(option->rect, pixmap, option->rect);
2512  }
2513  }
2514  break;
2515 
2516  case CE_MenuBarItem:
2517  painter->save();
2518 
2519  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
2520  GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
2521  GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
2522 
2523  style = gtkMenubarItem->style;
2524 
2525  if (widget) {
2526  // Since Qt does not currently allow filling the entire background
2527  // we use a hack for this by making a complete menubar each time and
2528  // paint with the correct offset inside it. Pixmap caching should resolve
2529  // most of the performance penalty.
2530  QRect menuBarRect = widget->rect();
2531  QPixmap pixmap(menuBarRect.size());
2532  pixmap.fill(Qt::transparent);
2533  QPainter pmPainter(&pixmap);
2534  QGtkPainter menubarPainter(&pmPainter);
2535  GtkShadowType shadow_type;
2536  d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
2537  GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
2538  painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
2539  menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
2540  GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
2541  pmPainter.end();
2542  painter->drawPixmap(option->rect, pixmap, option->rect);
2543  }
2544 
2545  QStyleOptionMenuItem item = *mbi;
2546  bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
2547  bool dis = !(mbi->state & State_Enabled);
2548  item.rect = mbi->rect;
2549  GdkColor gdkText = gtkMenubarItem->style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
2550  GdkColor gdkHText = gtkMenubarItem->style->fg[GTK_STATE_PRELIGHT];
2551  QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2552  QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
2553  item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor);
2554  item.palette.setBrush(QPalette::Text, normalTextColor);
2555  item.palette.setBrush(QPalette::ButtonText, normalTextColor);
2556  QCommonStyle::drawControl(element, &item, painter, widget);
2557 
2558  if (act) {
2559  GtkShadowType shadowType = GTK_SHADOW_NONE;
2560  d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
2561  gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
2562  GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style);
2563  //draw text
2566 
2567  if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
2568  alignment |= Qt::TextHideMnemonic;
2569 
2570  proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
2571  }
2572  }
2573  painter->restore();
2574  break;
2575 
2576  case CE_Splitter: {
2577  GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
2578  gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
2579  !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
2580  style);
2581  }
2582  break;
2583 
2584 #ifndef QT_NO_TOOLBAR
2585 
2586  case CE_ToolBar:
2587  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
2588  // Reserve the beveled appearance only for mainwindow toolbars
2589  if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
2590  break;
2591 
2592  QRect rect = option->rect;
2593  // There is a 1 pixel gap between toolbar lines in some styles (i.e Human)
2594  if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
2595  rect.adjust(0, 0, 1, 0);
2596 
2597  GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
2598  GtkShadowType shadow_type = GTK_SHADOW_NONE;
2599  d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
2600  gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
2601  GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
2602  }
2603  break;
2604 
2605 #endif // QT_NO_TOOLBAR
2606 
2607  case CE_MenuItem:
2608  painter->save();
2609 
2610  // Draws one item in a popup menu.
2611  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
2612  const int windowsItemFrame = 2; // menu item frame width
2613  const int windowsItemHMargin = 3; // menu item hor text margin
2614  const int windowsItemVMargin = 26; // menu item ver text margin
2615  const int windowsRightBorder = 15; // right border on windows
2616  GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
2617  d->gtkWidget("GtkMenu.GtkMenuItem");
2618 
2619  style = gtkPainter.getStyle(gtkMenuItem);
2620  QColor shadow = option->palette.dark().color();
2621 
2622  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
2623  GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
2624  painter->setPen(shadow.lighter(106));
2625  gboolean wide_separators = 0;
2626  gint separator_height = 0;
2627  guint horizontal_padding = 3;
2628  QRect separatorRect = option->rect;
2629  if (!d->gtk_check_version(2, 10, 0)) {
2630  d->gtk_widget_style_get(gtkMenuSeparator,
2631  "wide-separators", &wide_separators,
2632  "separator-height", &separator_height,
2633  "horizontal-padding", &horizontal_padding,
2634  NULL);
2635  }
2636  separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness);
2637  separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness));
2638  separatorRect.moveCenter(option->rect.center());
2639  if (wide_separators)
2640  gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
2641  separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style);
2642  else
2643  gtkPainter.paintHline( gtkMenuSeparator, "hseparator",
2644  separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style,
2645  0, option->rect.right() - 1, 1);
2646  painter->restore();
2647  break;
2648  }
2649 
2650  bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
2651 
2652  if (selected) {
2653  QRect rect = option->rect;
2654 #ifndef QT_NO_COMBOBOX
2655  if (qobject_cast<const QComboBox*>(widget))
2656  rect = option->rect;
2657 #endif
2658  gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
2659  }
2660 
2661  bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
2662  bool checked = menuItem->checked;
2663  bool enabled = menuItem->state & State_Enabled;
2664  bool ignoreCheckMark = false;
2665 
2666  gint checkSize;
2667  d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL);
2668 
2669  int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
2670 
2671 #ifndef QT_NO_COMBOBOX
2672 
2673  if (qobject_cast<const QComboBox*>(widget))
2674  ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate
2675 
2676 #endif
2677  if (!ignoreCheckMark) {
2678  // Check
2679  QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize);
2680  checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
2681 
2682  if (checkable && menuItem->icon.isNull()) {
2683  // Some themes such as aero-clone draw slightly outside the paint rect
2684  int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead
2685 
2686  if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
2687  // Radio button
2688  GtkShadowType shadow = GTK_SHADOW_OUT;
2689  GtkStateType state = gtkPainter.gtkState(option);
2690 
2691  if (selected)
2692  state = GTK_STATE_PRELIGHT;
2693  if (checked)
2694  shadow = GTK_SHADOW_IN;
2695 
2696  gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
2697  gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
2698  gtkMenuItem->style, QLS("option"));
2699  gtkPainter.setClipRect(QRect());
2700 
2701  } else {
2702  // Check box
2703  if (menuItem->icon.isNull()) {
2704  GtkShadowType shadow = GTK_SHADOW_OUT;
2705  GtkStateType state = gtkPainter.gtkState(option);
2706 
2707  if (selected)
2708  state = GTK_STATE_PRELIGHT;
2709  if (checked)
2710  shadow = GTK_SHADOW_IN;
2711 
2712  gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
2713  gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
2714  gtkMenuItem->style, QLS("check"));
2715  gtkPainter.setClipRect(QRect());
2716  }
2717  }
2718  }
2719 
2720  } else {
2721  // Ignore checkmark
2722  if (menuItem->icon.isNull())
2723  checkcol = 0;
2724  else
2725  checkcol = menuItem->maxIconWidth;
2726  }
2727 
2728  bool dis = !(menuItem->state & State_Enabled);
2729  bool act = menuItem->state & State_Selected;
2730  const QStyleOption *opt = option;
2731  const QStyleOptionMenuItem *menuitem = menuItem;
2732  QPainter *p = painter;
2733  QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
2734  QRect(menuitem->rect.x() + 3, menuitem->rect.y(),
2735  checkcol, menuitem->rect.height()));
2736 
2737  if (!menuItem->icon.isNull()) {
2738  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
2739 
2740  if (act && !dis)
2741  mode = QIcon::Active;
2742 
2743  QPixmap pixmap;
2744  int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
2745  QSize iconSize(smallIconSize, smallIconSize);
2746 
2747 #ifndef QT_NO_COMBOBOX
2748  if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
2749  iconSize = combo->iconSize();
2750 
2751 #endif // QT_NO_COMBOBOX
2752  if (checked)
2753  pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
2754  else
2755  pixmap = menuItem->icon.pixmap(iconSize, mode);
2756 
2757  int pixw = pixmap.width();
2758  int pixh = pixmap.height();
2759  QRect pmr(0, 0, pixw, pixh);
2760  pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
2761  painter->setPen(menuItem->palette.text().color());
2762  if (!ignoreCheckMark && checkable && checked) {
2763  QStyleOption opt = *option;
2764 
2765  if (act) {
2766  QColor activeColor = mergedColors(option->palette.background().color(),
2767  option->palette.highlight().color());
2768  opt.palette.setBrush(QPalette::Button, activeColor);
2769  }
2770  opt.state |= State_Sunken;
2771  opt.rect = vCheckRect;
2772  proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
2773  }
2774  painter->drawPixmap(pmr.topLeft(), pixmap);
2775  }
2776 
2777  GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
2778  GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
2779  GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
2780  uint resolve_mask = option->palette.resolve();
2781  QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
2782  QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
2783  if (resolve_mask & (1 << QPalette::ButtonText)) {
2784  textColor = option->palette.buttonText().color();
2785  disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
2786  }
2787 
2788  QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
2789  if (resolve_mask & (1 << QPalette::HighlightedText)) {
2790  highlightedTextColor = option->palette.highlightedText().color();
2791  }
2792 
2793  if (selected)
2794  painter->setPen(highlightedTextColor);
2795  else
2796  painter->setPen(textColor);
2797 
2798  int x, y, w, h;
2799  menuitem->rect.getRect(&x, &y, &w, &h);
2800  int tab = menuitem->tabWidth;
2801  int xm = windowsItemFrame + checkcol + windowsItemHMargin;
2802  int xpos = menuitem->rect.x() + xm + 1;
2803  QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
2804  QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
2805  QString s = menuitem->text;
2806 
2807  if (!s.isEmpty()) { // Draw text
2808  p->save();
2809  int t = s.indexOf(QLatin1Char('\t'));
2811 
2812  if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
2813  text_flags |= Qt::TextHideMnemonic;
2814 
2815  // Draw shortcut right aligned
2816  text_flags |= Qt::AlignRight;
2817 
2818  if (t >= 0) {
2819  int rightMargin = 12; // Hardcode for now
2820  QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
2821  QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom())));
2822 
2823  if (dis)
2824  p->setPen(disabledTextColor);
2825  p->drawText(vShortcutRect, text_flags , s.mid(t + 1));
2826  s = s.left(t);
2827  }
2828 
2829  text_flags &= ~Qt::AlignRight;
2830  text_flags |= Qt::AlignLeft;
2831  QFont font = menuitem->font;
2833  font.setBold(true);
2834  p->setFont(font);
2835 
2836  if (dis)
2837  p->setPen(disabledTextColor);
2838  p->drawText(vTextRect, text_flags, s.left(t));
2839  p->restore();
2840  }
2841 
2842  // Arrow
2843  if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
2844 
2845  QFontMetrics fm(menuitem->font);
2846  int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
2847  gfloat arrow_scaling = 0.8;
2848  int extra = 0;
2849  if (!d->gtk_check_version(2, 16, 0)) {
2850  // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
2851  // though the current documentation states otherwise
2852  d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
2853  // in versions < 2.16 ythickness was previously subtracted from the arrow_size
2854  extra = 2 * gtkMenuItem->style->ythickness;
2855  }
2856 
2857  int horizontal_padding;
2858  d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
2859 
2860  const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
2861  int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
2862  QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
2863  QRect(xpos, menuItem->rect.top() +
2864  menuItem->rect.height() / 2 - dim / 2, dim, dim));
2865  GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
2866  GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
2867  gtkPainter.paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
2868  shadowType, FALSE, style);
2869  }
2870  }
2871  painter->restore();
2872  break;
2873 
2874  case CE_PushButton:
2875  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
2876  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
2877  proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
2878  QStyleOptionButton subopt = *btn;
2879  subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
2880  gint interiorFocus = true;
2881  d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
2882  int xt = interiorFocus ? gtkButton->style->xthickness : 0;
2883  int yt = interiorFocus ? gtkButton->style->ythickness : 0;
2884 
2885  if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
2886  // The normal button focus rect does not work well for flat buttons in Clearlooks
2887  proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
2888  else if (btn->state & State_HasFocus)
2889  gtkPainter.paintFocus(gtkButton, "button",
2890  option->rect.adjusted(xt, yt, -xt, -yt),
2891  btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
2892  gtkButton->style);
2893 
2894  proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
2895  }
2896  break;
2897 
2898 #ifndef QT_NO_TABBAR
2899 
2900  case CE_TabBarTabShape:
2901  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
2902  GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
2903  style = gtkPainter.getStyle(gtkNotebook);
2904 
2905  QRect rect = option->rect;
2906  GtkShadowType shadow = GTK_SHADOW_OUT;
2907  GtkStateType state = GTK_STATE_ACTIVE;
2908  if (tab->state & State_Selected)
2909  state = GTK_STATE_NORMAL;
2910 
2911  bool selected = (tab->state & State_Selected);
2912  bool first = false, last = false;
2913  if (widget) {
2914  // This is most accurate and avoids resizing tabs while moving
2915  first = tab->rect.left() == widget->rect().left();
2916  last = tab->rect.right() == widget->rect().right();
2917  } else if (option->direction == Qt::RightToLeft) {
2918  bool tmp = first;
2919  first = last;
2920  last = tmp;
2921  }
2922  int topIndent = 3;
2923  int bottomIndent = 1;
2924  int tabOverlap = 1;
2925  painter->save();
2926 
2927  switch (tab->shape) {
2928  case QTabBar::RoundedNorth:
2929  if (!selected)
2930  rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent);
2931  gtkPainter.paintExtention( gtkNotebook, "tab", rect,
2932  state, shadow, GTK_POS_BOTTOM, style);
2933  break;
2934 
2935  case QTabBar::RoundedSouth:
2936  if (!selected)
2937  rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent);
2938  gtkPainter.paintExtention( gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
2939  state, shadow, GTK_POS_TOP, style);
2940  break;
2941 
2942  case QTabBar::RoundedWest:
2943  if (!selected)
2944  rect.adjust(topIndent, 0, -bottomIndent, 0);
2945  gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
2946  break;
2947 
2948  case QTabBar::RoundedEast:
2949  if (!selected)
2950  rect.adjust(bottomIndent, 0, -topIndent, 0);
2951  gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
2952  break;
2953 
2954  default:
2955  QCleanlooksStyle::drawControl(element, option, painter, widget);
2956  break;
2957  }
2958 
2959  painter->restore();
2960  }
2961 
2962  break;
2963 
2964 #endif //QT_NO_TABBAR
2965 
2966  case CE_ProgressBarGroove:
2967  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2968  Q_UNUSED(bar);
2969  GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
2970  GtkStateType state = gtkPainter.gtkState(option);
2971  gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
2972  }
2973 
2974  break;
2975 
2977  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2978  GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
2979  GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
2980  style = gtkProgressBar->style;
2981  gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
2982  int xt = style->xthickness;
2983  int yt = style->ythickness;
2984  QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt);
2985  bool vertical = false;
2986  bool inverted = false;
2987  bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
2988  // Get extra style options if version 2
2989 
2990  if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
2991  vertical = (bar2->orientation == Qt::Vertical);
2992  inverted = bar2->invertedAppearance;
2993  }
2994 
2995  // If the orientation is vertical, we use a transform to rotate
2996  // the progress bar 90 degrees clockwise. This way we can use the
2997  // same rendering code for both orientations.
2998  if (vertical) {
2999  rect.translate(xt, -yt * 2);
3000  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height
3002  m.rotate(90.0);
3003  painter->setTransform(m);
3004  }
3005 
3006  int maxWidth = rect.width();
3007  int minWidth = 4;
3008 
3009  qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar
3010  double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth;
3011  int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth;
3012  int width = indeterminate ? maxWidth : progressBarWidth;
3013  bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
3014 
3015  if (inverted)
3016  reverse = !reverse;
3017 
3018  int maximum = 2;
3019  int fakePos = 0;
3020  if (bar->minimum == bar->maximum)
3021  maximum = 0;
3022  if (bar->progress == bar->maximum)
3023  fakePos = maximum;
3024  else if (bar->progress > bar->minimum)
3025  fakePos = maximum - 1;
3026 
3027  d->gtk_progress_configure((GtkProgress*)gtkProgressBar, fakePos, 0, maximum);
3028 
3029  QRect progressBar;
3030 
3031  if (!indeterminate) {
3032  if (!reverse)
3033  progressBar.setRect(rect.left(), rect.top(), width, rect.height());
3034  else
3035  progressBar.setRect(rect.right() - width, rect.top(), width, rect.height());
3036 
3037  } else {
3038  Q_D(const QGtkStyle);
3039  int slideWidth = ((rect.width() - 4) * 2) / 3;
3040  int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
3041  if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
3042  step = slideWidth - step;
3043  progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height());
3044  }
3045 
3046  QString key = QString(QLS("%0")).arg(fakePos);
3047  if (inverted) {
3048  key += QLatin1String("inv");
3049  gtkPainter.setFlipHorizontal(true);
3050  }
3051  gtkPainter.paintBox( gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
3052  }
3053 
3054  break;
3055 
3056  default:
3057  QCleanlooksStyle::drawControl(element, option, painter, widget);
3058  }
3059 }
3060 
3065  SubControl subControl, const QWidget *widget) const
3066 {
3067  Q_D(const QGtkStyle);
3068 
3069  QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
3070  if (!d->isThemeAvailable())
3071  return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
3072 
3073  switch (control) {
3074  case CC_TitleBar:
3075  return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
3076 
3077  case CC_Slider:
3078  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3079  // Reserve space for outside focus rect
3080  QStyleOptionSlider sliderCopy = *slider;
3081  sliderCopy.rect = option->rect.adjusted(2, 2, -2, -2);
3082  return QCleanlooksStyle::subControlRect(control, &sliderCopy, subControl, widget);
3083  }
3084 
3085  break;
3086 
3087 #ifndef QT_NO_GROUPBOX
3088 
3089  case CC_GroupBox:
3090  if (qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
3091  rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin);
3092  int topMargin = 0;
3093  int topHeight = 0;
3094  topHeight = 10;
3095  QRect frameRect = rect;
3096  frameRect.setTop(topMargin);
3097 
3098  if (subControl == SC_GroupBoxFrame)
3099  return rect;
3100  else if (subControl == SC_GroupBoxContents) {
3101  int margin = 0;
3102  int leftMarginExtension = 8;
3103  return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin);
3104  }
3105 
3106  if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
3107  //Prepare metrics for a bold font
3108  QFont font = widget->font();
3109  font.setBold(true);
3110  QFontMetrics fontMetrics(font);
3111  QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4);
3112  int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
3113  int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
3114 
3115  if (subControl == SC_GroupBoxCheckBox) {
3116  rect.setWidth(indicatorWidth);
3117  rect.setHeight(indicatorHeight);
3118  rect.moveTop((textRect.height() - indicatorHeight) / 2);
3119 
3120  } else if (subControl == SC_GroupBoxLabel) {
3121  if (groupBoxWidget->isCheckable())
3122  rect.adjust(indicatorWidth + 4, 0, 0, 0);
3123  rect.setSize(textRect);
3124  }
3125  rect = visualRect(option->direction, option->rect, rect);
3126  }
3127  }
3128 
3129  return rect;
3130 
3131 #endif
3132 #ifndef QT_NO_SPINBOX
3133 
3134  case CC_SpinBox:
3135  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
3136  GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
3137  int center = spinbox->rect.height() / 2;
3138  int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
3139  int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
3140  int y = yt;
3141 
3142  QSize bs;
3143  bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
3144  bs.setWidth(d->getSpinboxArrowSize());
3145  int x, lx, rx;
3146  x = spinbox->rect.width() - y - bs.width() + 2;
3147  lx = xt;
3148  rx = x - xt;
3149 
3150  switch (subControl) {
3151 
3152  case SC_SpinBoxUp:
3153  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
3154  return QRect();
3155  rect = QRect(x, xt, bs.width(), center - yt);
3156  break;
3157 
3158  case SC_SpinBoxDown:
3159  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
3160  return QRect();
3161  rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1);
3162  break;
3163 
3164  case SC_SpinBoxEditField:
3165  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
3166  rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt);
3167  else
3168  rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt);
3169  break;
3170 
3171  case SC_SpinBoxFrame:
3172  rect = spinbox->rect;
3173 
3174  default:
3175  break;
3176  }
3177 
3178  rect = visualRect(spinbox->direction, spinbox->rect, rect);
3179  }
3180 
3181  break;
3182 
3183 #endif // Qt_NO_SPINBOX
3184 #ifndef QT_NO_COMBOBOX
3185 
3186  case CC_ComboBox:
3187  if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3188  // We employ the gtk widget to position arrows and separators for us
3189  GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
3190  : d->gtkWidget("GtkComboBox");
3191  d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
3192  GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
3193  d->gtk_widget_size_allocate(gtkCombo, &geometry);
3194  int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
3195  QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
3196  if (!box->editable) {
3197  if (appears_as_list)
3198  arrowPath = "GtkComboBox.GtkToggleButton";
3199  else
3200  arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
3201  }
3202 
3203  GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
3204  if (!arrowWidget)
3205  return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
3206 
3207  QRect buttonRect(option->rect.left() + arrowWidget->allocation.x,
3208  option->rect.top() + arrowWidget->allocation.y,
3209  arrowWidget->allocation.width, arrowWidget->allocation.height);
3210 
3211  switch (subControl) {
3212 
3213  case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos
3214  rect = buttonRect;
3215  break;
3216 
3217  case SC_ComboBoxEditField: {
3218  rect = visualRect(option->direction, option->rect, rect);
3219  int xMargin = box->editable ? 1 : 4, yMargin = 2;
3220  rect.setRect(option->rect.left() + gtkCombo->style->xthickness + xMargin,
3221  option->rect.top() + gtkCombo->style->ythickness + yMargin,
3222  option->rect.width() - buttonRect.width() - 2*(gtkCombo->style->xthickness + xMargin),
3223  option->rect.height() - 2*(gtkCombo->style->ythickness + yMargin));
3224  rect = visualRect(option->direction, option->rect, rect);
3225  break;
3226  }
3227 
3228  default:
3229  break;
3230  }
3231  }
3232 
3233  break;
3234 
3235 #endif // QT_NO_COMBOBOX
3236 
3237  default:
3238  break;
3239  }
3240 
3241  return rect;
3242 }
3243 
3248  const QSize &size, const QWidget *widget) const
3249 {
3250  Q_D(const QGtkStyle);
3251 
3252  QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget);
3253  if (!d->isThemeAvailable())
3254  return newSize;
3255 
3256  switch (type) {
3257 
3258  case CT_ToolButton:
3259  if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
3260  GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
3261  newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
3262  if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
3263  QSize minSize(0, 25);
3264  if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
3265  minSize = toolbutton->iconSize + QSize(12, 12);
3266  newSize = newSize.expandedTo(minSize);
3267  }
3268 
3269  if (toolbutton->features & QStyleOptionToolButton::HasMenu)
3270  newSize += QSize(6, 0);
3271  }
3272  break;
3273  case CT_MenuItem:
3274  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
3275  int textMargin = 8;
3276 
3277  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
3278  GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
3279  GtkRequisition sizeReq = {0, 0};
3280  d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq);
3281  newSize = QSize(size.width(), sizeReq.height);
3282  break;
3283  }
3284 
3285  GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
3286  GtkStyle* style = gtkMenuItem->style;
3287 
3288  // Note we get the perfect height for the default font since we
3289  // set a fake text label on the gtkMenuItem
3290  // But if custom fonts are used on the widget we need a minimum size
3291  GtkRequisition sizeReq = {0, 0};
3292  d->gtk_widget_size_request(gtkMenuItem, &sizeReq);
3293  newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height));
3294  newSize += QSize(textMargin + style->xthickness - 1, 0);
3295 
3296  // Cleanlooks assumes a check column of 20 pixels so we need to
3297  // expand it a bit
3298  gint checkSize;
3299  d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL);
3300  newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
3301  }
3302 
3303  break;
3304 
3305  case CT_SpinBox:
3306  // QSpinBox does some nasty things that depends on CT_LineEdit
3307  newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2);
3308  break;
3309 
3310  case CT_PushButton:
3311  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
3312  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
3313  gint focusPadding, focusWidth;
3314  d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
3315  d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
3316  newSize = size;
3317  newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
3318  newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
3319 
3320  GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
3321  gint minWidth = 85, minHeight = 0;
3322  d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
3323  "child-min-height", &minHeight, NULL);
3324  if (!btn->text.isEmpty() && newSize.width() < minWidth)
3325  newSize.setWidth(minWidth);
3326  if (newSize.height() < minHeight)
3327  newSize.setHeight(minHeight);
3328  }
3329 
3330  break;
3331 
3332  case CT_Slider: {
3333  GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
3334  newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
3335  }
3336  break;
3337 
3338  case CT_LineEdit: {
3339  GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
3340  newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
3341  }
3342  break;
3343 
3344  case CT_ItemViewItem:
3345  newSize += QSize(0, 2);
3346  break;
3347 
3348  case CT_ComboBox:
3349  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3350  GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
3351  QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
3352  newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
3353 
3354  if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
3355  newSize += QSize(0, 2);
3356  }
3357  break;
3358 
3359  case CT_GroupBox:
3360  newSize += QSize(4, groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox
3361  break;
3362 
3363  case CT_TabBarTab:
3364  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
3365  if (!tab->icon.isNull())
3366  newSize += QSize(6, 0);
3367  }
3368  newSize += QSize(1, 1);
3369  break;
3370 
3371  default:
3372  break;
3373  }
3374 
3375  return newSize;
3376 }
3377 
3378 
3381  const QWidget *widget) const
3382 {
3383  Q_D(const QGtkStyle);
3384 
3385  if (!d->isThemeAvailable())
3386  return QCleanlooksStyle::standardPixmap(sp, option, widget);
3387 
3388  QPixmap pixmap;
3389  switch (sp) {
3390 
3391  case SP_TitleBarNormalButton: {
3392  QImage restoreButton((const char **)dock_widget_restore_xpm);
3393  QColor alphaCorner = restoreButton.color(2);
3394  alphaCorner.setAlpha(80);
3395  restoreButton.setColor(2, alphaCorner.rgba());
3396  alphaCorner.setAlpha(180);
3397  restoreButton.setColor(4, alphaCorner.rgba());
3398  return QPixmap::fromImage(restoreButton);
3399  }
3400  break;
3401 
3402  case SP_TitleBarCloseButton: // Fall through
3403  case SP_DockWidgetCloseButton: {
3404 
3405  QImage closeButton((const char **)dock_widget_close_xpm);
3406  QColor alphaCorner = closeButton.color(2);
3407  alphaCorner.setAlpha(80);
3408  closeButton.setColor(2, alphaCorner.rgba());
3409  return QPixmap::fromImage(closeButton);
3410  }
3411  break;
3412 
3414  return QGtkPainter::getIcon(GTK_STOCK_DELETE);
3415  case SP_DialogOkButton:
3416  return QGtkPainter::getIcon(GTK_STOCK_OK);
3417  case SP_DialogCancelButton:
3418  return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
3419  case SP_DialogYesButton:
3420  return QGtkPainter::getIcon(GTK_STOCK_YES);
3421  case SP_DialogNoButton:
3422  return QGtkPainter::getIcon(GTK_STOCK_NO);
3423  case SP_DialogOpenButton:
3424  return QGtkPainter::getIcon(GTK_STOCK_OPEN);
3425  case SP_DialogCloseButton:
3426  return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
3427  case SP_DialogApplyButton:
3428  return QGtkPainter::getIcon(GTK_STOCK_APPLY);
3429  case SP_DialogSaveButton:
3430  return QGtkPainter::getIcon(GTK_STOCK_SAVE);
3431  case SP_MessageBoxWarning:
3432  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
3433  case SP_MessageBoxQuestion:
3434  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
3436  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
3437  case SP_MessageBoxCritical:
3438  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
3439  default:
3440  return QCleanlooksStyle::standardPixmap(sp, option, widget);
3441  }
3442  return pixmap;
3443 }
3444 
3449  const QStyleOption *option,
3450  const QWidget *widget) const
3451 {
3452  Q_D(const QGtkStyle);
3453 
3454  if (!d->isThemeAvailable())
3455  return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
3456  switch (standardIcon) {
3458  return QGtkPainter::getIcon(GTK_STOCK_DELETE);
3459  case SP_DialogOkButton:
3460  return QGtkPainter::getIcon(GTK_STOCK_OK);
3461  case SP_DialogCancelButton:
3462  return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
3463  case SP_DialogYesButton:
3464  return QGtkPainter::getIcon(GTK_STOCK_YES);
3465  case SP_DialogNoButton:
3466  return QGtkPainter::getIcon(GTK_STOCK_NO);
3467  case SP_DialogOpenButton:
3468  return QGtkPainter::getIcon(GTK_STOCK_OPEN);
3469  case SP_DialogCloseButton:
3470  return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
3471  case SP_DialogApplyButton:
3472  return QGtkPainter::getIcon(GTK_STOCK_APPLY);
3473  case SP_DialogSaveButton:
3474  return QGtkPainter::getIcon(GTK_STOCK_SAVE);
3475  case SP_MessageBoxWarning:
3476  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
3477  case SP_MessageBoxQuestion:
3478  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
3480  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
3481  case SP_MessageBoxCritical:
3482  return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
3483  default:
3484  return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
3485  }
3486 }
3487 
3488 
3491 {
3492  Q_D(const QGtkStyle);
3493 
3494  QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
3495  if (!d->isThemeAvailable())
3496  return r;
3497 
3498  switch (element) {
3499  case SE_ProgressBarLabel:
3501  case SE_ProgressBarGroove:
3502  return option->rect;
3503  case SE_PushButtonContents:
3504  if (!d->gtk_check_version(2, 10, 0)) {
3505  GtkWidget *gtkButton = d->gtkWidget("GtkButton");
3506  GtkBorder *border = 0;
3507  d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
3508  if (border) {
3509  r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
3510  d->gtk_border_free(border);
3511  } else {
3512  r = option->rect.adjusted(1, 1, -1, -1);
3513  }
3514  r = visualRect(option->direction, option->rect, r);
3515  }
3516  break;
3517  default:
3518  break;
3519  }
3520 
3521  return r;
3522 }
3523 
3527 QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
3528 {
3529  return QCleanlooksStyle::itemPixmapRect(r, flags, pixmap);
3530 }
3531 
3535 void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
3536  int alignment, const QPixmap &pixmap) const
3537 {
3538  QCleanlooksStyle::drawItemPixmap(painter, rect, alignment, pixmap);
3539 }
3540 
3545  const QPoint &pt, const QWidget *w) const
3546 {
3547  return QCleanlooksStyle::hitTestComplexControl(cc, opt, pt, w);
3548 }
3549 
3554  const QStyleOption *opt) const
3555 {
3556  return QCleanlooksStyle::generatedIconPixmap(iconMode, pixmap, opt);
3557 }
3558 
3562 void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
3563  bool enabled, const QString& text, QPalette::ColorRole textRole) const
3564 {
3565  return QCleanlooksStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
3566 }
3567 
3569 
3570 #endif
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition: qstyle_p.h:76
void polish(QWidget *widget)
Reimplemented Function
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void setRed(int red)
Sets the red color component of this color to red.
Definition: qcolor.cpp:1143
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
Definition: qstyle.cpp:2120
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
Reimplemented Function
Definition: qgtkstyle.cpp:3553
static int pmKey(const QSize &size, QIcon::Mode mode, QIcon::State state)
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
Reimplemented Function
int type
Definition: qmetatype.cpp:239
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
StyleHint
This enum describes the available style hints.
Definition: qstyle.h:640
double qreal
Definition: qglobal.h:1193
#define disabled
The QStyleHintReturn class provides style hints that return more than basic data types.
Definition: qstyleoption.h:907
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setClipRect(const QRect &rect)
Definition: qgtkpainter_p.h:76
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook
Definition: qfiledialog.cpp:85
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
ushort hue
Returns the hue color component of this color.
Definition: qcolor.h:250
QPointer< QWidget > widget
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
void paintExpander(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey=QString())
void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const
Reimplemented Function
Definition: qgtkstyle.cpp:3562
void paintFocus(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, const QString &pmKey=QString())
static Ptr_gtk_widget_set_direction gtk_widget_set_direction
Definition: qgtkstyle_p.h:432
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
int descent() const
Returns the descent of the font.
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
void paintShadow(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &pmKey=QString())
static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
void paintHandle(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style)
static const int groupBoxTitleMargin
Definition: qgtkstyle.cpp:128
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
void paintFlatBox(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &=QString())
void paintArrow(GtkWidget *gtkWidget, const gchar *part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow, gboolean fill, GtkStyle *style, const QString &pmKey=QString())
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QGtkStyle()
Constructs a QGtkStyle object.
Definition: qgtkstyle.cpp:192
QFont font
the font used for the menu item text
Definition: qstyleoption.h:454
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
static QPixmap getIcon(const char *iconName, GtkIconSize size=GTK_ICON_SIZE_BUTTON)
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook
Definition: qfiledialog.cpp:88
void paintResizeGrip(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GdkWindowEdge edge, GtkStyle *style, const QString &pmKey=QString())
QFont font
the font currently set for the widget
Definition: qwidget.h:181
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
void setGreen(int green)
Sets the green color component of this color to green.
Definition: qcolor.cpp:1170
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
~QGtkStyle()
Destroys the QGtkStyle object.
Definition: qgtkstyle.cpp:218
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
#define END_STYLE_PIXMAPCACHE
Definition: qstyle_p.h:96
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
static const char *const dock_widget_close_xpm[]
Definition: qgtkstyle.cpp:81
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
Definition: qgtkstyle.cpp:408
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void setFlipHorizontal(bool value)
Definition: qgtkpainter_p.h:77
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
GtkStateType gtkState(const QStyleOption *option)
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:1265
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
static GdkColor fromQColor(const QColor &color)
Definition: qgtkstyle.cpp:159
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
Reimplemented Function
static const uint base
Definition: qurl.cpp:268
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void paintSlider(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, GtkOrientation orientation, const QString &pmKey=QString())
NSToolbar * toolbar
QString text
the text for the menu item
Definition: qstyleoption.h:450
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
void paintBox(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &pmKey=QString())
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_pos, GtkStyle *style)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
static QPixmap * find(const QString &key)
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition: qcolor.cpp:734
QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w) const
Reimplemented Function
Definition: qgtkstyle.cpp:3544
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Reimplemented Function
int ascent() const
Returns the ascent of the font.
void setUsePixmapCache(bool value)
Definition: qgtkpainter_p.h:79
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
static const int groupBoxTopMargin
Definition: qgtkstyle.cpp:129
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
Definition: qgtkstyle.cpp:3448
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Reimplemented Function
Definition: qgtkstyle.cpp:3535
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
static void setSystemFont(const QFont &font)
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
void drawControl(ControlElement control, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:2177
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
ushort value
Returns the value color component of this color.
Definition: qcolor.h:252
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
Shape
This enum type lists the built-in shapes supported by QTabBar.
Definition: qtabbar.h:81
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Reimplemented Function
Definition: qgtkstyle.cpp:3527
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
static const int windowsItemFrame
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
ushort saturation
Returns the saturation color component of this color.
Definition: qcolor.h:251
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
#define QLS(x)
Definition: qgtkstyle_p.h:77
ContentsType
This enum describes the available contents types.
Definition: qstyle.h:602
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
QColor dark(int f=200) const
Use darker(factor) instead.
Definition: qcolor.cpp:2447
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
static void clear()
Removes all pixmaps from the cache.
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
QPalette standardPalette() const
Reimplemented Function
Definition: qgtkstyle.cpp:225
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
static const int groupBoxBottomMargin
Definition: qgtkstyle.cpp:127
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:686
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
static bool getGConfBool(const QString &key, bool fallback=0)
Returns the configuration boolean for key.
Definition: qgtkstyle.cpp:144
unsigned int uint
Definition: qglobal.h:996
static QString getGConfString(const QString &key, const QString &fallback=QString())
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
The QSlider widget provides a vertical or horizontal slider.
Definition: qslider.h:57
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QStyleOptionTabBarBase class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:218
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
__int64 qint64
Definition: qglobal.h:942
GtkStyle * getStyle(GtkWidget *gtkWidget)
The State element defines configurations of objects and properties.
static QString getGConfString(const QString &key, const QString &fallback=QString())
Returns the configuration string for value.
Definition: qgtkstyle.cpp:135
quint16 values[128]
MenuItemType menuItemType
the type of menu item
Definition: qstyleoption.h:445
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
static const char *const dock_widget_restore_xpm[]
Definition: qgtkstyle.cpp:104
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
void setBlue(int blue)
Sets the blue color component of this color to blue.
Definition: qcolor.cpp:1199
void polish(QWidget *widget)
Reimplemented Function
Definition: qgtkstyle.cpp:376
void setAlphaSupport(bool value)
Definition: qgtkpainter_p.h:75
bool isEnabled() const
Definition: qwidget.h:948
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook
Definition: qfiledialog.cpp:94
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition: qstyle.cpp:2149
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QCleanlooksStyle class provides a widget style similar to the Clearlooks style available in GNOME...
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
Definition: qgtkstyle.cpp:149
void paintHline(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int x1, int x2, int y, const QString &pmKey=QString())
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:3247
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QPalette standardPalette() const
Reimplemented Function
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:3380
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int tabWidth
the tab width for the menu item
Definition: qstyleoption.h:453
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
The QSpinBox class provides a spin box widget.
Definition: qspinbox.h:56
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
QString toString() const
Definition: qgtkstyle_p.h:110
static void setSystemPalette(const QPalette &pal)
static const int windowsItemHMargin
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
ControlElement
This enum represents a control element.
Definition: qstyle.h:217
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const
Reimplemented Function
Definition: qgtkstyle.cpp:3064
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
Reimplemented Function
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
void unpolish(QWidget *widget)
Reimplemented Function
Definition: qgtkstyle.cpp:400
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
QRegion subtracted(const QRegion &r) const
Returns a region which is r subtracted from this region.
Definition: qregion.h:114
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
static const int windowsItemVMargin
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
void drawPrimitive(PrimitiveElement elem, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
Reimplemented Function
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook
Definition: qfiledialog.cpp:91
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
Reimplemented Function
Definition: qgtkstyle.cpp:3490
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition: qpalette.h:135
void paintVline(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkStyle *style, int y1, int y2, int x, const QString &pmKey=QString())
static bool getGConfBool(const QString &key, bool fallback=0)
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Reimplemented Function
QRgb color(int i) const
Returns the color in the color table at index i.
Definition: qimage.cpp:1829
int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
Reimplemented Function
Definition: qgtkstyle.cpp:582
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
#define enabled
void unpolish(QWidget *widget)
Reimplemented Function
bool end()
Ends painting.
Definition: qpainter.cpp:1929
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
Reimplemented Function
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
SubElement
This enum represents a sub-area of a widget.
Definition: qstyle.h:289
static QMenuBar * fallback
Definition: qmenu_mac.mm:1617
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
The QGtkStyle class provides a widget style rendered by GTK+.
Definition: qgtkstyle.h:61
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
void paintBoxGap(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x, gint width, GtkStyle *style)
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
static const int windowsRightBorder
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60