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