author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 8 | 3f74d0d4af4c |
parent 5 | d3bac044e0f0 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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")); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1109 |
QString key(QLS("radiobutton")); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1110 |
if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1111 |
key += QLatin1Char('f'); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1112 |
GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1113 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1114 |
gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1115 |
if (option->state & State_HasFocus) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1116 |
GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); |
0 | 1117 |
} |
1118 |
break; |
|
1119 |
||
1120 |
case PE_IndicatorCheckBox: { |
|
1121 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
1122 |
GtkStateType state = gtkPainter.gtkState(option); |
|
1123 |
||
1124 |
if (option->state & State_Sunken) |
|
1125 |
state = GTK_STATE_ACTIVE; |
|
1126 |
||
1127 |
if (option->state & State_NoChange) |
|
1128 |
shadow = GTK_SHADOW_ETCHED_IN; |
|
1129 |
else if (option->state & State_On) |
|
1130 |
shadow = GTK_SHADOW_IN; |
|
1131 |
else |
|
1132 |
shadow = GTK_SHADOW_OUT; |
|
1133 |
||
1134 |
int spacing; |
|
1135 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1136 |
GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1137 |
QString key(QLS("checkbutton")); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1138 |
if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1139 |
key += QLatin1Char('f'); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1140 |
GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1141 |
} |
0 | 1142 |
|
1143 |
// Some styles such as aero-clone assume they can paint in the spacing area |
|
1144 |
gtkPainter.setClipRect(option->rect); |
|
1145 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1146 |
d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL); |
0 | 1147 |
|
1148 |
QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); |
|
1149 |
||
1150 |
gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style, |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1151 |
key); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1152 |
if (option->state & State_HasFocus) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1153 |
GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1154 |
|
0 | 1155 |
} |
1156 |
break; |
|
1157 |
||
1158 |
#ifndef QT_NO_TABBAR |
|
1159 |
||
1160 |
case PE_FrameTabBarBase: |
|
1161 |
if (const QStyleOptionTabBarBase *tbb |
|
1162 |
= qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) { |
|
1163 |
QRect tabRect = tbb->rect; |
|
1164 |
QRegion region(tabRect); |
|
1165 |
painter->save(); |
|
1166 |
painter->setPen(QPen(option->palette.dark().color().dark(110), 0)); |
|
1167 |
switch (tbb->shape) { |
|
1168 |
||
1169 |
case QTabBar::RoundedNorth: |
|
1170 |
painter->drawLine(tabRect.topLeft(), tabRect.topRight()); |
|
1171 |
break; |
|
1172 |
||
1173 |
case QTabBar::RoundedWest: |
|
1174 |
painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom()); |
|
1175 |
break; |
|
1176 |
||
1177 |
case QTabBar::RoundedSouth: |
|
1178 |
painter->drawLine(tbb->rect.left(), tbb->rect.bottom(), |
|
1179 |
tabRect.right(), tabRect.bottom()); |
|
1180 |
break; |
|
1181 |
||
1182 |
case QTabBar::RoundedEast: |
|
1183 |
painter->drawLine(tabRect.topRight(), tabRect.bottomRight()); |
|
1184 |
break; |
|
1185 |
||
1186 |
case QTabBar::TriangularNorth: |
|
1187 |
case QTabBar::TriangularEast: |
|
1188 |
case QTabBar::TriangularWest: |
|
1189 |
case QTabBar::TriangularSouth: |
|
1190 |
painter->restore(); |
|
1191 |
QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
1192 |
return; |
|
1193 |
} |
|
1194 |
||
1195 |
painter->restore(); |
|
1196 |
} |
|
1197 |
return; |
|
1198 |
||
1199 |
#endif // QT_NO_TABBAR |
|
1200 |
||
1201 |
case PE_Widget: |
|
1202 |
break; |
|
1203 |
||
1204 |
default: |
|
1205 |
QCleanlooksStyle::drawPrimitive(element, option, painter, widget); |
|
1206 |
} |
|
1207 |
} |
|
1208 |
||
1209 |
/*! |
|
1210 |
\reimp |
|
1211 |
*/ |
|
1212 |
void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
1213 |
||
1214 |
QPainter *painter, const QWidget *widget) const |
|
1215 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1216 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1217 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1218 |
if (!d->isThemeAvailable()) { |
0 | 1219 |
QCleanlooksStyle::drawComplexControl(control, option, painter, widget); |
1220 |
return; |
|
1221 |
} |
|
1222 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1223 |
GtkStyle* style = d->gtkStyle(); |
0 | 1224 |
QGtkPainter gtkPainter(painter); |
1225 |
QColor button = option->palette.button().color(); |
|
1226 |
QColor dark; |
|
1227 |
QColor grooveColor; |
|
1228 |
QColor darkOutline; |
|
1229 |
dark.setHsv(button.hue(), |
|
1230 |
qMin(255, (int)(button.saturation()*1.9)), |
|
1231 |
qMin(255, (int)(button.value()*0.7))); |
|
1232 |
grooveColor.setHsv(button.hue(), |
|
1233 |
qMin(255, (int)(button.saturation()*2.6)), |
|
1234 |
qMin(255, (int)(button.value()*0.9))); |
|
1235 |
darkOutline.setHsv(button.hue(), |
|
1236 |
qMin(255, (int)(button.saturation()*3.0)), |
|
1237 |
qMin(255, (int)(button.value()*0.6))); |
|
1238 |
||
1239 |
QColor alphaCornerColor; |
|
1240 |
||
1241 |
if (widget) |
|
1242 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline); |
|
1243 |
else |
|
1244 |
alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline); |
|
1245 |
||
1246 |
QPalette palette = option->palette; |
|
1247 |
||
1248 |
switch (control) { |
|
1249 |
||
1250 |
case CC_TitleBar: |
|
1251 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { |
|
1252 |
// Since this is drawn by metacity and not Gtk we |
|
1253 |
// have to rely on Cleanlooks for a fallback |
|
1254 |
QStyleOptionTitleBar copyOpt = *tb; |
|
1255 |
QPalette pal = copyOpt.palette; |
|
1256 |
// Bg color is closer to the window selection than |
|
1257 |
// the base selection color |
|
1258 |
GdkColor gdkBg = style->bg[GTK_STATE_SELECTED]; |
|
1259 |
QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); |
|
1260 |
pal.setBrush(QPalette::Active, QPalette::Highlight, bgColor); |
|
1261 |
copyOpt.palette = pal; |
|
1262 |
QCleanlooksStyle::drawComplexControl(control, ©Opt, painter, widget); |
|
1263 |
} |
|
1264 |
break; |
|
1265 |
||
1266 |
#ifndef QT_NO_GROUPBOX |
|
1267 |
||
1268 |
case CC_GroupBox: |
|
1269 |
painter->save(); |
|
1270 |
||
1271 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1272 |
QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); |
|
1273 |
QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); |
|
1274 |
// Draw title |
|
1275 |
||
1276 |
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
|
1277 |
// Draw prelight background |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1278 |
GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); |
0 | 1279 |
|
1280 |
if (option->state & State_MouseOver) { |
|
1281 |
QRect bgRect = textRect | checkBoxRect; |
|
1282 |
gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2), |
|
1283 |
GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkCheckButton->style); |
|
1284 |
} |
|
1285 |
||
1286 |
if (!groupBox->text.isEmpty()) { |
|
1287 |
int alignment = int(groupBox->textAlignment); |
|
1288 |
if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) |
|
1289 |
alignment |= Qt::TextHideMnemonic; |
|
1290 |
QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored |
|
1291 |
int labelState = GTK_STATE_INSENSITIVE; |
|
1292 |
||
1293 |
if (option->state & State_Enabled) |
|
1294 |
labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; |
|
1295 |
||
1296 |
GdkColor gdkText = gtkCheckButton->style->fg[labelState]; |
|
1297 |
textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
1298 |
painter->setPen(textColor); |
|
1299 |
QFont font = painter->font(); |
|
1300 |
font.setBold(true); |
|
1301 |
painter->setFont(font); |
|
1302 |
painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text); |
|
1303 |
||
1304 |
if (option->state & State_HasFocus) |
|
1305 |
gtkPainter.paintFocus( NULL, "tab", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style); |
|
1306 |
} |
|
1307 |
} |
|
1308 |
||
1309 |
if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
1310 |
QStyleOptionButton box; |
|
1311 |
box.QStyleOption::operator=(*groupBox); |
|
1312 |
box.rect = checkBoxRect; |
|
1313 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); |
|
1314 |
} |
|
1315 |
} |
|
1316 |
||
1317 |
painter->restore(); |
|
1318 |
break; |
|
1319 |
#endif // QT_NO_GROUPBOX |
|
1320 |
||
1321 |
#ifndef QT_NO_COMBOBOX |
|
1322 |
||
1323 |
case CC_ComboBox: |
|
1324 |
// See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox |
|
1325 |
// and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry |
|
1326 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1327 |
bool sunken = comboBox->state & State_On; // play dead, if combobox has no items |
|
1328 |
BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable)); |
|
1329 |
QGtkPainter gtkCachedPainter(p); |
|
1330 |
gtkCachedPainter.setUsePixmapCache(false); // cached externally |
|
1331 |
||
1332 |
bool isEnabled = (comboBox->state & State_Enabled); |
|
1333 |
bool focus = isEnabled && (comboBox->state & State_HasFocus); |
|
1334 |
QColor buttonShadow = option->palette.dark().color(); |
|
1335 |
GtkStateType state = gtkPainter.gtkState(option); |
|
1336 |
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); |
|
1337 |
QPixmap cache; |
|
1338 |
QString pixmapName; |
|
1339 |
QStyleOptionComboBox comboBoxCopy = *comboBox; |
|
1340 |
comboBoxCopy.rect = option->rect; |
|
1341 |
||
1342 |
bool reverse = (option->direction == Qt::RightToLeft); |
|
1343 |
QRect rect = option->rect; |
|
1344 |
QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, |
|
1345 |
SC_ComboBoxArrow, widget); |
|
1346 |
QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, |
|
1347 |
SC_ComboBoxEditField, widget); |
|
1348 |
||
1349 |
GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? |
|
1350 |
GTK_SHADOW_IN : GTK_SHADOW_OUT; |
|
1351 |
QString comboBoxPath = QLS(comboBox->editable ? "GtkComboBoxEntry" : "GtkComboBox"); |
|
1352 |
||
1353 |
// 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
|
1354 |
GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); |
0 | 1355 |
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
|
1356 |
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
|
1357 |
d->gtk_widget_size_allocate(gtkCombo, &geometry); |
0 | 1358 |
|
1359 |
QString buttonPath = comboBoxPath + QLS(".GtkToggleButton"); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1360 |
GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1361 |
d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); |
0 | 1362 |
if (gtkToggleButton && (appears_as_list || comboBox->editable)) { |
1363 |
if (focus) |
|
1364 |
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); |
|
1365 |
// Draw the combo box as a line edit with a button next to it |
|
1366 |
if (comboBox->editable || appears_as_list) { |
|
1367 |
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state; |
|
1368 |
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
|
1369 |
GtkWidget *gtkEntry = d->gtkWidget(entryPath); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1370 |
d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); |
0 | 1371 |
QRect frameRect = option->rect; |
1372 |
||
1373 |
if (reverse) |
|
1374 |
frameRect.setLeft(arrowButtonRect.right()); |
|
1375 |
else |
|
1376 |
frameRect.setRight(arrowButtonRect.left()); |
|
1377 |
||
1378 |
// Fill the line edit background |
|
1379 |
// We could have used flat_box with "entry_bg" but that is probably not worth the overhead |
|
1380 |
uint resolve_mask = option->palette.resolve(); |
|
1381 |
int xt = gtkEntry->style->xthickness; |
|
1382 |
int yt = gtkEntry->style->ythickness; |
|
1383 |
QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt); |
|
1384 |
// Required for inner blue highlight with clearlooks |
|
1385 |
if (focus) |
|
1386 |
GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS); |
|
1387 |
||
1388 |
if (widget && widget->testAttribute(Qt::WA_SetPalette) && |
|
1389 |
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user |
|
1390 |
p->fillRect(contentRect, option->palette.base().color()); |
|
1391 |
else { |
|
1392 |
gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, |
|
1393 |
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1394 |
GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus)); |
0 | 1395 |
} |
1396 |
||
1397 |
gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, |
|
1398 |
GTK_SHADOW_IN, gtkEntry->style, entryPath + |
|
1399 |
QString::number(focus) + QString::number(comboBox->editable) + |
|
1400 |
QString::number(option->direction)); |
|
1401 |
if (focus) |
|
1402 |
GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS); |
|
1403 |
} |
|
1404 |
||
1405 |
GtkStateType buttonState = GTK_STATE_NORMAL; |
|
1406 |
||
1407 |
if (!(option->state & State_Enabled)) |
|
1408 |
buttonState = GTK_STATE_INSENSITIVE; |
|
1409 |
else if (option->state & State_Sunken || option->state & State_On) |
|
1410 |
buttonState = GTK_STATE_ACTIVE; |
|
1411 |
else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow) |
|
1412 |
buttonState = GTK_STATE_PRELIGHT; |
|
1413 |
||
1414 |
QRect buttonrect = QRect(gtkToggleButton->allocation.x, gtkToggleButton->allocation.y, |
|
1415 |
gtkToggleButton->allocation.width, gtkToggleButton->allocation.height); |
|
1416 |
||
1417 |
Q_ASSERT(gtkToggleButton); |
|
1418 |
gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState, |
|
1419 |
shadow, gtkToggleButton->style, buttonPath + |
|
1420 |
QString::number(focus) + QString::number(option->direction)); |
|
1421 |
if (focus) |
|
1422 |
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); |
|
1423 |
} else { |
|
1424 |
// Draw combo box as a button |
|
1425 |
QRect buttonRect = option->rect; |
|
1426 |
||
1427 |
if (focus) // Clearlooks actually check the widget for the default state |
|
1428 |
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); |
|
1429 |
gtkCachedPainter.paintBox(gtkToggleButton, "button", |
|
1430 |
buttonRect, state, |
|
1431 |
shadow, gtkToggleButton->style, |
|
1432 |
buttonPath + QString::number(focus)); |
|
1433 |
if (focus) |
|
1434 |
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); |
|
1435 |
||
1436 |
// Draw the separator between label and arrows |
|
1437 |
QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator"); |
|
1438 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1439 |
if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) { |
0 | 1440 |
QRect vLineRect(gtkVSeparator->allocation.x, |
1441 |
gtkVSeparator->allocation.y, |
|
1442 |
gtkVSeparator->allocation.width, |
|
1443 |
gtkVSeparator->allocation.height); |
|
1444 |
||
1445 |
gtkCachedPainter.paintVline( gtkVSeparator, "vseparator", |
|
1446 |
vLineRect, state, gtkVSeparator->style, |
|
1447 |
0, vLineRect.height(), 0, vSeparatorPath); |
|
1448 |
||
1449 |
||
1450 |
gint interiorFocus = true; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1451 |
d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL); |
0 | 1452 |
int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0; |
1453 |
int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0; |
|
1454 |
if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) |
|
1455 |
gtkCachedPainter.paintFocus(gtkToggleButton, "button", |
|
1456 |
option->rect.adjusted(xt, yt, -xt, -yt), |
|
1457 |
option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, |
|
1458 |
gtkToggleButton->style); |
|
1459 |
} |
|
1460 |
} |
|
1461 |
||
1462 |
if (comboBox->subControls & SC_ComboBoxArrow) { |
|
1463 |
if (!isEnabled) |
|
1464 |
state = GTK_STATE_INSENSITIVE; |
|
1465 |
else if (sunken) |
|
1466 |
state = GTK_STATE_ACTIVE; |
|
1467 |
else if (option->state & State_MouseOver) |
|
1468 |
state = GTK_STATE_PRELIGHT; |
|
1469 |
else |
|
1470 |
state = GTK_STATE_NORMAL; |
|
1471 |
||
1472 |
QString arrowPath = comboBoxPath + QLS(appears_as_list ? ".GtkToggleButton.GtkArrow" |
|
1473 |
: ".GtkToggleButton.GtkHBox.GtkArrow"); |
|
1474 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1475 |
GtkWidget *gtkArrow = d->gtkWidget(arrowPath); |
0 | 1476 |
gfloat scale = 0.7; |
1477 |
gint minSize = 15; |
|
1478 |
QRect arrowWidgetRect; |
|
1479 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1480 |
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
|
1481 |
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
|
1482 |
d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL); |
0 | 1483 |
} |
1484 |
if (gtkArrow) { |
|
1485 |
arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y, |
|
1486 |
gtkArrow->allocation.width, gtkArrow->allocation.height); |
|
1487 |
style = gtkArrow->style; |
|
1488 |
} |
|
1489 |
||
1490 |
// Note that for some reason the arrow-size is not properly respected with Hildon |
|
1491 |
// Hence we enforce the minimum "arrow-size" ourselves |
|
1492 |
int arrowSize = qMax(qMin(rect.height() - gtkCombo->style->ythickness * 2, minSize), |
|
1493 |
qMin(arrowWidgetRect.width(), arrowWidgetRect.height())); |
|
1494 |
QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale)); |
|
1495 |
||
1496 |
arrowRect.moveCenter(arrowWidgetRect.center()); |
|
1497 |
||
1498 |
if (sunken) { |
|
1499 |
int xoff, yoff; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1500 |
GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1501 |
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
|
1502 |
d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL); |
0 | 1503 |
arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff); |
1504 |
} |
|
1505 |
||
1506 |
// Some styles such as Nimbus paint outside the arrowRect |
|
1507 |
// hence we have provide the whole widget as the cliprect |
|
1508 |
if (gtkArrow) { |
|
1509 |
gtkCachedPainter.setClipRect(option->rect); |
|
1510 |
gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect, |
|
1511 |
GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE, |
|
1512 |
style, arrowPath + QString::number(option->direction)); |
|
1513 |
} |
|
1514 |
} |
|
1515 |
END_STYLE_PIXMAPCACHE; |
|
1516 |
} |
|
1517 |
break; |
|
1518 |
#endif // QT_NO_COMBOBOX |
|
1519 |
#ifndef QT_NO_TOOLBUTTON |
|
1520 |
||
1521 |
case CC_ToolButton: |
|
1522 |
if (const QStyleOptionToolButton *toolbutton |
|
1523 |
= qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1524 |
QRect button, menuarea; |
|
1525 |
button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget); |
|
1526 |
menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); |
|
1527 |
State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver); |
|
1528 |
||
1529 |
if (bflags & State_AutoRaise) |
|
1530 |
if (!(bflags & State_MouseOver)) |
|
1531 |
bflags &= ~State_Raised; |
|
1532 |
||
1533 |
State mflags = bflags; |
|
1534 |
||
1535 |
if (toolbutton->state & State_Sunken) { |
|
1536 |
if (toolbutton->activeSubControls & SC_ToolButton) |
|
1537 |
bflags |= State_Sunken; |
|
1538 |
if (toolbutton->activeSubControls & SC_ToolButtonMenu) |
|
1539 |
mflags |= State_Sunken; |
|
1540 |
} else if (toolbutton->state & State_MouseOver) { |
|
1541 |
if (toolbutton->activeSubControls & SC_ToolButton) |
|
1542 |
bflags |= State_MouseOver; |
|
1543 |
if (toolbutton->activeSubControls & SC_ToolButtonMenu) |
|
1544 |
mflags |= State_MouseOver; |
|
1545 |
} |
|
1546 |
||
1547 |
QStyleOption tool(0); |
|
1548 |
||
1549 |
tool.palette = toolbutton->palette; |
|
1550 |
||
1551 |
if (toolbutton->subControls & SC_ToolButton) { |
|
1552 |
if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) { |
|
1553 |
tool.rect = button; |
|
1554 |
tool.state = bflags; |
|
1555 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
|
1556 |
} |
|
1557 |
} |
|
1558 |
||
1559 |
bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu && |
|
1560 |
!(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup); |
|
1561 |
int popupArrowSize = drawMenuArrow ? 7 : 0; |
|
1562 |
||
1563 |
if (toolbutton->state & State_HasFocus) { |
|
1564 |
QStyleOptionFocusRect fr; |
|
1565 |
fr.QStyleOption::operator=(*toolbutton); |
|
1566 |
fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget); |
|
1567 |
fr.rect.adjust(1, 1, -1, -1); |
|
1568 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); |
|
1569 |
} |
|
1570 |
||
1571 |
QStyleOptionToolButton label = *toolbutton; |
|
1572 |
label.state = bflags; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1573 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); |
0 | 1574 |
QPalette pal = toolbutton->palette; |
1575 |
if (option->state & State_Enabled && |
|
1576 |
option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { |
|
1577 |
GdkColor gdkText = gtkButton->style->fg[GTK_STATE_PRELIGHT]; |
|
1578 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
1579 |
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor); |
|
1580 |
label.palette = pal; |
|
1581 |
} |
|
1582 |
label.rect = button.adjusted(style->xthickness, style->ythickness, |
|
1583 |
-style->xthickness - popupArrowSize, -style->ythickness); |
|
1584 |
proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); |
|
1585 |
||
1586 |
if (toolbutton->subControls & SC_ToolButtonMenu) { |
|
1587 |
tool.rect = menuarea; |
|
1588 |
tool.state = mflags; |
|
1589 |
if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise)) |
|
1590 |
proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget); |
|
1591 |
||
1592 |
proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
|
1593 |
||
1594 |
} else if (drawMenuArrow) { |
|
1595 |
QRect ir = toolbutton->rect; |
|
1596 |
QStyleOptionToolButton newBtn = *toolbutton; |
|
1597 |
newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize); |
|
1598 |
proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); |
|
1599 |
} |
|
1600 |
} |
|
1601 |
break; |
|
1602 |
||
1603 |
#endif // QT_NO_TOOLBUTTON |
|
1604 |
#ifndef QT_NO_SCROLLBAR |
|
1605 |
||
1606 |
case CC_ScrollBar: |
|
1607 |
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
|
1608 |
GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1609 |
GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar")); |
0 | 1610 |
|
1611 |
// Fill background in case the scrollbar is partially transparent |
|
1612 |
painter->fillRect(option->rect, option->palette.background()); |
|
1613 |
||
1614 |
QRect rect = scrollBar->rect; |
|
1615 |
QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); |
|
1616 |
QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); |
|
1617 |
QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); |
|
1618 |
QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); |
|
1619 |
bool horizontal = scrollBar->orientation == Qt::Horizontal; |
|
1620 |
GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar; |
|
1621 |
style = scrollbarWidget->style; |
|
1622 |
gboolean trough_under_steppers = true; |
|
1623 |
gboolean trough_side_details = false; |
|
1624 |
gboolean stepper_size = 14; |
|
1625 |
gint trough_border = 1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1626 |
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
|
1627 |
d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget), |
0 | 1628 |
"trough-border", &trough_border, |
1629 |
"trough-side-details", &trough_side_details, |
|
1630 |
"trough-under-steppers", &trough_under_steppers, |
|
1631 |
"stepper-size", &stepper_size, NULL); |
|
1632 |
} |
|
1633 |
if (trough_under_steppers) { |
|
1634 |
scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border); |
|
1635 |
scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border); |
|
1636 |
scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border, |
|
1637 |
horizontal ? trough_border : 0, horizontal ? 0 : trough_border); |
|
1638 |
} |
|
1639 |
||
1640 |
// Some styles check the position of scrollbars in order to determine |
|
1641 |
// if lines should be painted when the scrollbar is in max or min positions. |
|
1642 |
int maximum = 2; |
|
1643 |
int fakePos = 0; |
|
1644 |
bool reverse = (option->direction == Qt::RightToLeft); |
|
1645 |
if (scrollBar->minimum == scrollBar->maximum) |
|
1646 |
maximum = 0; |
|
1647 |
if (scrollBar->sliderPosition == scrollBar->maximum) |
|
1648 |
fakePos = maximum; |
|
1649 |
else if (scrollBar->sliderPosition > scrollBar->minimum) |
|
1650 |
fakePos = maximum - 1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1651 |
GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0); |
0 | 1652 |
|
1653 |
if (horizontal) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1654 |
d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment)); |
0 | 1655 |
else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1656 |
d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment)); |
0 | 1657 |
|
1658 |
if (scrollBar->subControls & SC_ScrollBarGroove) { |
|
1659 |
GtkStateType state = GTK_STATE_ACTIVE; |
|
1660 |
||
1661 |
if (!(option->state & State_Enabled)) |
|
1662 |
state = GTK_STATE_INSENSITIVE; |
|
1663 |
||
1664 |
if (trough_under_steppers) |
|
1665 |
grooveRect = option->rect; |
|
1666 |
||
1667 |
gtkPainter.paintBox( scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style); |
|
1668 |
} |
|
1669 |
||
1670 |
//paint slider |
|
1671 |
if (scrollBar->subControls & SC_ScrollBarSlider) { |
|
1672 |
GtkStateType state = GTK_STATE_NORMAL; |
|
1673 |
||
1674 |
if (!(option->state & State_Enabled)) |
|
1675 |
state = GTK_STATE_INSENSITIVE; |
|
1676 |
else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider)) |
|
1677 |
state = GTK_STATE_PRELIGHT; |
|
1678 |
||
1679 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
1680 |
||
1681 |
if (trough_under_steppers) { |
|
1682 |
if (!horizontal) |
|
1683 |
scrollBarSlider.adjust(trough_border, 0, -trough_border, 0); |
|
1684 |
else |
|
1685 |
scrollBarSlider.adjust(0, trough_border, 0, -trough_border); |
|
1686 |
} |
|
1687 |
||
1688 |
gtkPainter.paintSlider( scrollbarWidget, "slider", scrollBarSlider, state, shadow, style, |
|
1689 |
||
1690 |
horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum)); |
|
1691 |
} |
|
1692 |
||
1693 |
if (scrollBar->subControls & SC_ScrollBarAddLine) { |
|
1694 |
gtkVScrollBar->allocation.y = scrollBarAddLine.top(); |
|
1695 |
gtkVScrollBar->allocation.height = scrollBarAddLine.height() - rect.height() + 6; |
|
1696 |
gtkHScrollBar->allocation.x = scrollBarAddLine.right(); |
|
1697 |
gtkHScrollBar->allocation.width = scrollBarAddLine.width() - rect.width(); |
|
1698 |
||
1699 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
1700 |
GtkStateType state = GTK_STATE_NORMAL; |
|
1701 |
||
1702 |
if (!(option->state & State_Enabled) || (fakePos == maximum)) |
|
1703 |
state = GTK_STATE_INSENSITIVE; |
|
1704 |
else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) { |
|
1705 |
state = GTK_STATE_ACTIVE; |
|
1706 |
shadow = GTK_SHADOW_IN; |
|
1707 |
||
1708 |
} else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) |
|
1709 |
state = GTK_STATE_PRELIGHT; |
|
1710 |
||
1711 |
gtkPainter.paintBox( scrollbarWidget, |
|
1712 |
horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine, |
|
1713 |
state, shadow, style, QLS("add")); |
|
1714 |
||
1715 |
gtkPainter.paintArrow( scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4), |
|
1716 |
horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) : |
|
1717 |
GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, FALSE, style); |
|
1718 |
} |
|
1719 |
||
1720 |
if (scrollBar->subControls & SC_ScrollBarSubLine) { |
|
1721 |
gtkVScrollBar->allocation.y = 0; |
|
1722 |
gtkVScrollBar->allocation.height = scrollBarSubLine.height(); |
|
1723 |
gtkHScrollBar->allocation.x = 0; |
|
1724 |
gtkHScrollBar->allocation.width = scrollBarSubLine.width(); |
|
1725 |
||
1726 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
1727 |
GtkStateType state = GTK_STATE_NORMAL; |
|
1728 |
||
1729 |
if (!(option->state & State_Enabled) || (fakePos == 0)) |
|
1730 |
state = GTK_STATE_INSENSITIVE; |
|
1731 |
else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) { |
|
1732 |
shadow = GTK_SHADOW_IN; |
|
1733 |
state = GTK_STATE_ACTIVE; |
|
1734 |
||
1735 |
} else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) |
|
1736 |
state = GTK_STATE_PRELIGHT; |
|
1737 |
||
1738 |
gtkPainter.paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine, |
|
1739 |
state, shadow, style, QLS("sub")); |
|
1740 |
||
1741 |
gtkPainter.paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4), |
|
1742 |
horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) : |
|
1743 |
GTK_ARROW_UP, state, GTK_SHADOW_NONE, FALSE, style); |
|
1744 |
} |
|
1745 |
} |
|
1746 |
break; |
|
1747 |
||
1748 |
#endif //QT_NO_SCROLLBAR |
|
1749 |
#ifndef QT_NO_SPINBOX |
|
1750 |
||
1751 |
case CC_SpinBox: |
|
1752 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1753 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1754 |
GtkWidget *gtkSpinButton = d->gtkWidget( |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1755 |
spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ? |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1756 |
QLS("GtkEntry") : |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1757 |
QLS("GtkSpinButton")); |
0 | 1758 |
bool isEnabled = (spinBox->state & State_Enabled); |
1759 |
bool hover = isEnabled && (spinBox->state & State_MouseOver); |
|
1760 |
bool sunken = (spinBox->state & State_Sunken); |
|
1761 |
bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp); |
|
1762 |
bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown); |
|
1763 |
bool reverse = (spinBox->direction == Qt::RightToLeft); |
|
1764 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1765 |
QRect editArea = option->rect; |
0 | 1766 |
QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1767 |
QRect upRect, downRect, buttonRect; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1768 |
if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1769 |
upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1770 |
downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1771 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1772 |
//### Move this to subControlRect |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1773 |
upRect.setTop(option->rect.top()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1774 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1775 |
if (reverse) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1776 |
upRect.setLeft(option->rect.left()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1777 |
else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1778 |
upRect.setRight(option->rect.right()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1779 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1780 |
downRect.setBottom(option->rect.bottom()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1781 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1782 |
if (reverse) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1783 |
downRect.setLeft(option->rect.left()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1784 |
else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1785 |
downRect.setRight(option->rect.right()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1786 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1787 |
buttonRect = upRect | downRect; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1788 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1789 |
if (reverse) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1790 |
editArea.setLeft(upRect.right()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1791 |
else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1792 |
editArea.setRight(upRect.left()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1793 |
} |
0 | 1794 |
if (spinBox->frame) { |
1795 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
1796 |
GtkStateType state = gtkPainter.gtkState(option); |
|
1797 |
||
1798 |
if (!(option->state & State_Enabled)) |
|
1799 |
state = GTK_STATE_INSENSITIVE; |
|
1800 |
else if (option->state & State_HasFocus) |
|
1801 |
state = GTK_STATE_NORMAL; |
|
1802 |
else if (state == GTK_STATE_PRELIGHT) |
|
1803 |
state = GTK_STATE_NORMAL; |
|
1804 |
||
1805 |
shadow = GTK_SHADOW_IN; |
|
1806 |
style = gtkPainter.getStyle(gtkSpinButton); |
|
1807 |
||
1808 |
||
1809 |
QString key; |
|
1810 |
||
1811 |
if (option->state & State_HasFocus) { |
|
1812 |
key += QLatin1Char('f'); |
|
1813 |
GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); |
|
1814 |
} |
|
1815 |
||
1816 |
uint resolve_mask = option->palette.resolve(); |
|
1817 |
||
1818 |
if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user |
|
1819 |
painter->fillRect(editRect, option->palette.base().color()); |
|
1820 |
else |
|
1821 |
gtkPainter.paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness, |
|
1822 |
-style->xthickness, -style->ythickness), |
|
1823 |
option->state & State_Enabled ? |
|
1824 |
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key); |
|
1825 |
||
1826 |
gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1827 |
if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1828 |
gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1829 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1830 |
upRect.setSize(downRect.size()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1831 |
if (!(option->state & State_Enabled)) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1832 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1833 |
else if (upIsActive && sunken) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1834 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1835 |
else if (upIsActive && hover) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1836 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1837 |
else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1838 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1839 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1840 |
if (!(option->state & State_Enabled)) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1841 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1842 |
else if (downIsActive && sunken) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1843 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1844 |
else if (downIsActive && hover) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1845 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1846 |
else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1847 |
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1848 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1849 |
if (option->state & State_HasFocus) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1850 |
GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1851 |
} |
0 | 1852 |
} |
1853 |
||
1854 |
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { |
|
1855 |
int centerX = upRect.center().x(); |
|
1856 |
int centerY = upRect.center().y(); |
|
1857 |
// plus/minus |
|
1858 |
||
1859 |
if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) { |
|
1860 |
painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); |
|
1861 |
painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2); |
|
1862 |
||
1863 |
} else { |
|
1864 |
painter->drawLine(centerX - 2, centerY, centerX + 2, centerY); |
|
1865 |
painter->drawLine(centerX, centerY - 2, centerX, centerY + 2); |
|
1866 |
} |
|
1867 |
centerX = downRect.center().x(); |
|
1868 |
centerY = downRect.center().y(); |
|
1869 |
||
1870 |
if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) { |
|
1871 |
painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY); |
|
1872 |
} else { |
|
1873 |
painter->drawLine(centerX - 2, centerY, centerX + 2, centerY); |
|
1874 |
} |
|
1875 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1876 |
} else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1877 |
int size = d->getSpinboxArrowSize(); |
0 | 1878 |
int w = size / 2 - 1; |
1879 |
w -= w % 2 - 1; // force odd |
|
1880 |
int h = (w + 1)/2; |
|
1881 |
QRect arrowRect(0, 0, w, h); |
|
1882 |
arrowRect.moveCenter(upRect.center()); |
|
1883 |
// arrows |
|
1884 |
GtkStateType state = GTK_STATE_NORMAL; |
|
1885 |
||
1886 |
if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) |
|
1887 |
state = GTK_STATE_INSENSITIVE; |
|
1888 |
||
1889 |
gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state, |
|
1890 |
GTK_SHADOW_NONE, FALSE, style); |
|
1891 |
||
1892 |
arrowRect.moveCenter(downRect.center()); |
|
1893 |
||
1894 |
if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) |
|
1895 |
state = GTK_STATE_INSENSITIVE; |
|
1896 |
||
1897 |
gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state, |
|
1898 |
GTK_SHADOW_NONE, FALSE, style); |
|
1899 |
} |
|
1900 |
} |
|
1901 |
break; |
|
1902 |
||
1903 |
#endif // QT_NO_SPINBOX |
|
1904 |
||
1905 |
#ifndef QT_NO_SLIDER |
|
1906 |
||
1907 |
case CC_Slider: |
|
1908 |
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
|
1909 |
GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1910 |
GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale")); |
0 | 1911 |
|
1912 |
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); |
|
1913 |
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); |
|
1914 |
QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); |
|
1915 |
||
1916 |
bool horizontal = slider->orientation == Qt::Horizontal; |
|
1917 |
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; |
|
1918 |
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; |
|
1919 |
QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight); |
|
1920 |
||
1921 |
QPixmap cache; |
|
1922 |
QBrush oldBrush = painter->brush(); |
|
1923 |
QPen oldPen = painter->pen(); |
|
1924 |
||
1925 |
QColor shadowAlpha(Qt::black); |
|
1926 |
shadowAlpha.setAlpha(10); |
|
1927 |
QColor highlightAlpha(Qt::white); |
|
1928 |
highlightAlpha.setAlpha(80); |
|
1929 |
||
1930 |
GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget; |
|
1931 |
style = scaleWidget->style; |
|
1932 |
||
1933 |
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
|
1934 |
GtkObject *adjustment = d->gtk_adjustment_new(slider->sliderPosition, |
0 | 1935 |
slider->minimum, |
1936 |
slider->maximum, |
|
1937 |
slider->singleStep, |
|
1938 |
slider->singleStep, |
|
1939 |
slider->pageStep); |
|
1940 |
int outerSize; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1941 |
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
|
1942 |
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
|
1943 |
d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL); |
0 | 1944 |
outerSize++; |
1945 |
||
1946 |
GtkStateType state = gtkPainter.gtkState(option); |
|
1947 |
int focusFrameMargin = 2; |
|
1948 |
QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin, |
|
1949 |
-focusFrameMargin, -outerSize - focusFrameMargin); |
|
1950 |
||
1951 |
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
|
1952 |
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
|
1953 |
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
|
1954 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1955 |
if (!trough_side_details) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1956 |
gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1957 |
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
|
1958 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1959 |
QRect upperGroove = grooveRect; |
0 | 1960 |
QRect lowerGroove = grooveRect; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1961 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1962 |
if (horizontal) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1963 |
upperGroove.setLeft(handle.center().x()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1964 |
lowerGroove.setRight(handle.center().x()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1965 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1966 |
upperGroove.setBottom(handle.center().y()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1967 |
lowerGroove.setTop(handle.center().y()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1968 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1969 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1970 |
gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1971 |
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); |
0 | 1972 |
gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state, |
1973 |
GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); |
|
1974 |
} |
|
1975 |
} |
|
1976 |
||
1977 |
if (option->subControls & SC_SliderTickmarks) { |
|
1978 |
painter->setPen(darkOutline); |
|
1979 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); |
|
1980 |
int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); |
|
1981 |
int interval = slider->tickInterval; |
|
1982 |
||
1983 |
if (interval <= 0) { |
|
1984 |
interval = slider->singleStep; |
|
1985 |
||
1986 |
if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, |
|
1987 |
available) |
|
1988 |
- QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, |
|
1989 |
0, available) < 3) |
|
1990 |
interval = slider->pageStep; |
|
1991 |
} |
|
1992 |
||
1993 |
if (interval <= 0) |
|
1994 |
interval = 1; |
|
1995 |
||
1996 |
int v = slider->minimum; |
|
1997 |
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); |
|
1998 |
while (v <= slider->maximum + 1) { |
|
1999 |
if (v == slider->maximum + 1 && interval == 1) |
|
2000 |
break; |
|
2001 |
const int v_ = qMin(v, slider->maximum); |
|
2002 |
int pos = sliderPositionFromValue(slider->minimum, slider->maximum, |
|
2003 |
v_, (horizontal |
|
2004 |
? slider->rect.width() |
|
2005 |
: slider->rect.height()) - len, |
|
2006 |
slider->upsideDown) + len / 2; |
|
2007 |
int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0); |
|
2008 |
if (horizontal) { |
|
2009 |
if (ticksAbove) |
|
2010 |
painter->drawLine(pos, slider->rect.top() + extra, |
|
2011 |
pos, slider->rect.top() + tickSize); |
|
2012 |
if (ticksBelow) |
|
2013 |
painter->drawLine(pos, slider->rect.bottom() - extra, |
|
2014 |
pos, slider->rect.bottom() - tickSize); |
|
2015 |
||
2016 |
} else { |
|
2017 |
if (ticksAbove) |
|
2018 |
painter->drawLine(slider->rect.left() + extra, pos, |
|
2019 |
slider->rect.left() + tickSize, pos); |
|
2020 |
if (ticksBelow) |
|
2021 |
painter->drawLine(slider->rect.right() - extra, pos, |
|
2022 |
slider->rect.right() - tickSize, pos); |
|
2023 |
} |
|
2024 |
||
2025 |
// In the case where maximum is max int |
|
2026 |
int nextInterval = v + interval; |
|
2027 |
if (nextInterval < v) |
|
2028 |
break; |
|
2029 |
v = nextInterval; |
|
2030 |
} |
|
2031 |
} |
|
2032 |
||
2033 |
// Draw slider handle |
|
2034 |
if (option->subControls & SC_SliderHandle) { |
|
2035 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
2036 |
GtkStateType state = GTK_STATE_NORMAL; |
|
2037 |
||
2038 |
if (!(option->state & State_Enabled)) |
|
2039 |
state = GTK_STATE_INSENSITIVE; |
|
2040 |
else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle) |
|
2041 |
state = GTK_STATE_PRELIGHT; |
|
2042 |
||
2043 |
bool horizontal = option->state & State_Horizontal; |
|
2044 |
||
2045 |
if (slider->state & State_HasFocus) { |
|
2046 |
QStyleOptionFocusRect fropt; |
|
2047 |
fropt.QStyleOption::operator=(*slider); |
|
2048 |
fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1); |
|
2049 |
||
2050 |
if (horizontal) { |
|
2051 |
fropt.rect.setTop(handle.top() - 3); |
|
2052 |
fropt.rect.setBottom(handle.bottom() + 4); |
|
2053 |
||
2054 |
} else { |
|
2055 |
fropt.rect.setLeft(handle.left() - 3); |
|
2056 |
fropt.rect.setRight(handle.right() + 3); |
|
2057 |
} |
|
2058 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
2059 |
} |
|
2060 |
gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style, |
|
2061 |
||
2062 |
horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); |
|
2063 |
} |
|
2064 |
painter->setBrush(oldBrush); |
|
2065 |
painter->setPen(oldPen); |
|
2066 |
} |
|
2067 |
break; |
|
2068 |
||
2069 |
#endif // QT_NO_SLIDER |
|
2070 |
||
2071 |
default: |
|
2072 |
QCleanlooksStyle::drawComplexControl(control, option, painter, widget); |
|
2073 |
||
2074 |
break; |
|
2075 |
} |
|
2076 |
} |
|
2077 |
||
2078 |
||
2079 |
/*! |
|
2080 |
\reimp |
|
2081 |
*/ |
|
2082 |
void QGtkStyle::drawControl(ControlElement element, |
|
2083 |
const QStyleOption *option, |
|
2084 |
QPainter *painter, |
|
2085 |
const QWidget *widget) const |
|
2086 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2087 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2088 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2089 |
if (!d->isThemeAvailable()) { |
0 | 2090 |
QCleanlooksStyle::drawControl(element, option, painter, widget); |
2091 |
return; |
|
2092 |
} |
|
2093 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2094 |
GtkStyle* style = d->gtkStyle(); |
0 | 2095 |
QGtkPainter gtkPainter(painter); |
2096 |
||
2097 |
switch (element) { |
|
2098 |
case CE_ProgressBarLabel: |
|
2099 |
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
|
2100 |
GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); |
0 | 2101 |
if (!gtkProgressBar) |
2102 |
return; |
|
2103 |
||
2104 |
QRect leftRect; |
|
2105 |
QRect rect = bar->rect; |
|
2106 |
GdkColor gdkText = gtkProgressBar->style->fg[GTK_STATE_NORMAL]; |
|
2107 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2108 |
gdkText = gtkProgressBar->style->fg[GTK_STATE_PRELIGHT]; |
|
2109 |
QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2110 |
||
2111 |
painter->save(); |
|
2112 |
bool vertical = false, inverted = false; |
|
2113 |
if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
2114 |
vertical = (bar2->orientation == Qt::Vertical); |
|
2115 |
inverted = bar2->invertedAppearance; |
|
2116 |
} |
|
2117 |
if (vertical) |
|
2118 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height |
|
2119 |
const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / |
|
2120 |
qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); |
|
2121 |
if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) |
|
2122 |
leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); |
|
2123 |
if (vertical) |
|
2124 |
leftRect.translate(rect.width() - progressIndicatorPos, 0); |
|
2125 |
||
2126 |
bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) || |
|
2127 |
((bar->direction == Qt::LeftToRight) && inverted))); |
|
2128 |
||
2129 |
QRegion rightRect = rect; |
|
2130 |
rightRect = rightRect.subtracted(leftRect); |
|
2131 |
painter->setClipRegion(rightRect); |
|
2132 |
painter->setPen(flip ? alternateTextColor : textColor); |
|
2133 |
painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); |
|
2134 |
if (!leftRect.isNull()) { |
|
2135 |
painter->setPen(flip ? textColor : alternateTextColor); |
|
2136 |
painter->setClipRect(leftRect); |
|
2137 |
painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); |
|
2138 |
} |
|
2139 |
painter->restore(); |
|
2140 |
} |
|
2141 |
break; |
|
2142 |
case CE_PushButtonLabel: |
|
2143 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
2144 |
QRect ir = button->rect; |
|
2145 |
uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
2146 |
QPoint buttonShift; |
|
2147 |
||
2148 |
if (option->state & State_Sunken) |
|
2149 |
buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget), |
|
2150 |
proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); |
|
2151 |
||
2152 |
if (proxy()->styleHint(SH_UnderlineShortcut, button, widget)) |
|
2153 |
tf |= Qt::TextShowMnemonic; |
|
2154 |
else |
|
2155 |
tf |= Qt::TextHideMnemonic; |
|
2156 |
||
2157 |
if (!button->icon.isNull()) { |
|
2158 |
//Center both icon and text |
|
2159 |
QPoint point; |
|
2160 |
||
2161 |
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
|
2162 |
if (mode == QIcon::Normal && button->state & State_HasFocus) |
|
2163 |
mode = QIcon::Active; |
|
2164 |
||
2165 |
QIcon::State state = QIcon::Off; |
|
2166 |
||
2167 |
if (button->state & State_On) |
|
2168 |
state = QIcon::On; |
|
2169 |
||
2170 |
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); |
|
2171 |
int w = pixmap.width(); |
|
2172 |
int h = pixmap.height(); |
|
2173 |
||
2174 |
if (!button->text.isEmpty()) |
|
2175 |
w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4; |
|
2176 |
||
2177 |
point = QPoint(ir.x() + ir.width() / 2 - w / 2, |
|
2178 |
ir.y() + ir.height() / 2 - h / 2); |
|
2179 |
||
2180 |
if (button->direction == Qt::RightToLeft) |
|
2181 |
point.rx() += pixmap.width(); |
|
2182 |
||
2183 |
painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap); |
|
2184 |
||
2185 |
if (button->direction == Qt::RightToLeft) |
|
2186 |
ir.translate(-point.x() - 2, 0); |
|
2187 |
else |
|
2188 |
ir.translate(point.x() + pixmap.width() + 2, 0); |
|
2189 |
||
2190 |
// left-align text if there is |
|
2191 |
if (!button->text.isEmpty()) |
|
2192 |
tf |= Qt::AlignLeft; |
|
2193 |
||
2194 |
} else { |
|
2195 |
tf |= Qt::AlignHCenter; |
|
2196 |
} |
|
2197 |
||
2198 |
ir.translate(buttonShift); |
|
2199 |
||
2200 |
if (button->features & QStyleOptionButton::HasMenu) |
|
2201 |
ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); |
|
2202 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2203 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); |
0 | 2204 |
QPalette pal = button->palette; |
2205 |
int labelState = GTK_STATE_INSENSITIVE; |
|
2206 |
if (option->state & State_Enabled) |
|
2207 |
labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ? |
|
2208 |
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; |
|
2209 |
||
2210 |
GdkColor gdkText = gtkButton->style->fg[labelState]; |
|
2211 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2212 |
pal.setBrush(QPalette::ButtonText, textColor); |
|
2213 |
proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled), |
|
2214 |
button->text, QPalette::ButtonText); |
|
2215 |
} |
|
2216 |
break; |
|
2217 |
||
2218 |
case CE_RadioButton: // Fall through |
|
2219 |
case CE_CheckBox: |
|
2220 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
2221 |
bool isRadio = (element == CE_RadioButton); |
|
2222 |
||
2223 |
// Draw prelight background |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2224 |
GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); |
0 | 2225 |
|
2226 |
if (option->state & State_MouseOver) { |
|
2227 |
gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect, |
|
2228 |
GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkRadioButton->style); |
|
2229 |
} |
|
2230 |
||
2231 |
QStyleOptionButton subopt = *btn; |
|
2232 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
|
2233 |
: SE_CheckBoxIndicator, btn, widget); |
|
2234 |
proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
|
2235 |
&subopt, painter, widget); |
|
2236 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents |
|
2237 |
: SE_CheckBoxContents, btn, widget); |
|
2238 |
// Get label text color |
|
2239 |
QPalette pal = subopt.palette; |
|
2240 |
int labelState = GTK_STATE_INSENSITIVE; |
|
2241 |
if (option->state & State_Enabled) |
|
2242 |
labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; |
|
2243 |
||
2244 |
GdkColor gdkText = gtkRadioButton->style->fg[labelState]; |
|
2245 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2246 |
pal.setBrush(QPalette::WindowText, textColor); |
|
2247 |
subopt.palette = pal; |
|
2248 |
proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); |
|
2249 |
||
2250 |
if (btn->state & State_HasFocus) { |
|
2251 |
QStyleOptionFocusRect fropt; |
|
2252 |
fropt.QStyleOption::operator=(*btn); |
|
2253 |
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
|
2254 |
: SE_CheckBoxFocusRect, btn, widget); |
|
2255 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
2256 |
} |
|
2257 |
} |
|
2258 |
break; |
|
2259 |
||
2260 |
#ifndef QT_NO_COMBOBOX |
|
2261 |
||
2262 |
case CE_ComboBoxLabel: |
|
2263 |
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
2264 |
QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); |
|
2265 |
bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget); |
|
2266 |
painter->save(); |
|
2267 |
painter->setClipRect(editRect); |
|
2268 |
||
2269 |
if (!cb->currentIcon.isNull()) { |
|
2270 |
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal |
|
2271 |
: QIcon::Disabled; |
|
2272 |
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); |
|
2273 |
QRect iconRect(editRect); |
|
2274 |
iconRect.setWidth(cb->iconSize.width() + 4); |
|
2275 |
||
2276 |
iconRect = alignedRect(cb->direction, |
|
2277 |
Qt::AlignLeft | Qt::AlignVCenter, |
|
2278 |
iconRect.size(), editRect); |
|
2279 |
||
2280 |
if (cb->editable) |
|
2281 |
painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); |
|
2282 |
||
2283 |
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
|
2284 |
||
2285 |
if (cb->direction == Qt::RightToLeft) |
|
2286 |
editRect.translate(-4 - cb->iconSize.width(), 0); |
|
2287 |
else |
|
2288 |
editRect.translate(cb->iconSize.width() + 4, 0); |
|
2289 |
} |
|
2290 |
||
2291 |
if (!cb->currentText.isEmpty() && !cb->editable) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2292 |
GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); |
0 | 2293 |
QPalette pal = cb->palette; |
2294 |
int labelState = GTK_STATE_INSENSITIVE; |
|
2295 |
||
2296 |
if (option->state & State_Enabled) |
|
2297 |
labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL; |
|
2298 |
||
2299 |
GdkColor gdkText = gtkCombo->style->fg[labelState]; |
|
2300 |
||
2301 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2302 |
||
2303 |
pal.setBrush(QPalette::ButtonText, textColor); |
|
2304 |
||
2305 |
proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), |
|
2306 |
visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), |
|
2307 |
pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText); |
|
2308 |
} |
|
2309 |
||
2310 |
painter->restore(); |
|
2311 |
} |
|
2312 |
break; |
|
2313 |
||
2314 |
#endif // QT_NO_COMBOBOX |
|
2315 |
||
2316 |
case CE_DockWidgetTitle: |
|
2317 |
painter->save(); |
|
2318 |
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { |
|
2319 |
const QStyleOptionDockWidgetV2 *v2 |
|
2320 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt); |
|
2321 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; |
|
2322 |
||
2323 |
QRect rect = dwOpt->rect; |
|
2324 |
QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0); |
|
2325 |
QRect r = rect.adjusted(0, 0, -1, -1); |
|
2326 |
if (verticalTitleBar) |
|
2327 |
r.adjust(0, 0, 0, -1); |
|
2328 |
||
2329 |
if (verticalTitleBar) { |
|
2330 |
QRect r = rect; |
|
2331 |
QSize s = r.size(); |
|
2332 |
s.transpose(); |
|
2333 |
r.setSize(s); |
|
2334 |
||
2335 |
titleRect = QRect(r.left() + rect.bottom() |
|
2336 |
- titleRect.bottom(), |
|
2337 |
r.top() + titleRect.left() - rect.left(), |
|
2338 |
titleRect.height(), titleRect.width()); |
|
2339 |
||
2340 |
painter->translate(r.left(), r.top() + r.width()); |
|
2341 |
painter->rotate(-90); |
|
2342 |
painter->translate(-r.left(), -r.top()); |
|
2343 |
||
2344 |
rect = r; |
|
2345 |
} |
|
2346 |
||
2347 |
if (!dwOpt->title.isEmpty()) { |
|
2348 |
QString titleText |
|
2349 |
= painter->fontMetrics().elidedText(dwOpt->title, |
|
2350 |
Qt::ElideRight, titleRect.width()); |
|
2351 |
proxy()->drawItemText(painter, |
|
2352 |
titleRect, |
|
2353 |
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, |
|
2354 |
dwOpt->state & State_Enabled, titleText, |
|
2355 |
QPalette::WindowText); |
|
2356 |
} |
|
2357 |
} |
|
2358 |
painter->restore(); |
|
2359 |
break; |
|
2360 |
||
2361 |
||
2362 |
||
2363 |
case CE_HeaderSection: |
|
2364 |
painter->save(); |
|
2365 |
||
2366 |
// Draws the header in tables. |
|
2367 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
2368 |
Q_UNUSED(header); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2369 |
GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); |
0 | 2370 |
// Get the middle column |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2371 |
GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1); |
0 | 2372 |
Q_ASSERT(column); |
2373 |
||
2374 |
GtkWidget *gtkTreeHeader = column->button; |
|
2375 |
GtkStateType state = gtkPainter.gtkState(option); |
|
2376 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
2377 |
||
2378 |
if (option->state & State_Sunken) |
|
2379 |
shadow = GTK_SHADOW_IN; |
|
2380 |
||
2381 |
gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtkTreeHeader->style); |
|
2382 |
} |
|
2383 |
||
2384 |
painter->restore(); |
|
2385 |
break; |
|
2386 |
||
2387 |
#ifndef QT_NO_SIZEGRIP |
|
2388 |
||
2389 |
case CE_SizeGrip: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2390 |
GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); |
0 | 2391 |
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness); |
2392 |
gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL, |
|
2393 |
GTK_SHADOW_OUT, QApplication::isRightToLeft() ? |
|
2394 |
GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST, |
|
2395 |
gtkStatusbar->style); |
|
2396 |
} |
|
2397 |
break; |
|
2398 |
||
2399 |
#endif // QT_NO_SIZEGRIP |
|
2400 |
||
2401 |
case CE_MenuBarEmptyArea: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2402 |
GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); |
0 | 2403 |
GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency |
2404 |
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); |
|
2405 |
if (widget) { // See CE_MenuBarItem |
|
2406 |
QRect menuBarRect = widget->rect(); |
|
2407 |
QPixmap pixmap(menuBarRect.size()); |
|
2408 |
pixmap.fill(Qt::transparent); |
|
2409 |
QPainter pmPainter(&pixmap); |
|
2410 |
QGtkPainter gtkMenuBarPainter(&pmPainter); |
|
2411 |
GtkShadowType shadow_type; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2412 |
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL); |
0 | 2413 |
gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect, |
2414 |
GTK_STATE_NORMAL, shadow_type, gtkMenubar->style); |
|
2415 |
pmPainter.end(); |
|
2416 |
painter->drawPixmap(option->rect, pixmap, option->rect); |
|
2417 |
} |
|
2418 |
} |
|
2419 |
break; |
|
2420 |
||
2421 |
case CE_MenuBarItem: |
|
2422 |
painter->save(); |
|
2423 |
||
2424 |
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
|
2425 |
GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2426 |
GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); |
0 | 2427 |
|
2428 |
style = gtkMenubarItem->style; |
|
2429 |
||
2430 |
if (widget) { |
|
2431 |
// Since Qt does not currently allow filling the entire background |
|
2432 |
// we use a hack for this by making a complete menubar each time and |
|
2433 |
// paint with the correct offset inside it. Pixmap caching should resolve |
|
2434 |
// most of the performance penalty. |
|
2435 |
QRect menuBarRect = widget->rect(); |
|
2436 |
QPixmap pixmap(menuBarRect.size()); |
|
2437 |
pixmap.fill(Qt::transparent); |
|
2438 |
QPainter pmPainter(&pixmap); |
|
2439 |
QGtkPainter menubarPainter(&pmPainter); |
|
2440 |
GtkShadowType shadow_type; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2441 |
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL); |
0 | 2442 |
GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency |
2443 |
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); |
|
2444 |
menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect, |
|
2445 |
GTK_STATE_NORMAL, shadow_type, gtkMenubar->style); |
|
2446 |
pmPainter.end(); |
|
2447 |
painter->drawPixmap(option->rect, pixmap, option->rect); |
|
2448 |
} |
|
2449 |
||
2450 |
QStyleOptionMenuItem item = *mbi; |
|
2451 |
bool act = mbi->state & State_Selected && mbi->state & State_Sunken; |
|
2452 |
bool dis = !(mbi->state & State_Enabled); |
|
2453 |
item.rect = mbi->rect; |
|
2454 |
GdkColor gdkText = gtkMenubarItem->style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL]; |
|
2455 |
GdkColor gdkHText = gtkMenubarItem->style->fg[GTK_STATE_PRELIGHT]; |
|
2456 |
QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2457 |
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8); |
|
2458 |
item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor); |
|
2459 |
item.palette.setBrush(QPalette::Text, normalTextColor); |
|
2460 |
item.palette.setBrush(QPalette::ButtonText, normalTextColor); |
|
2461 |
QCommonStyle::drawControl(element, &item, painter, widget); |
|
2462 |
||
2463 |
if (act) { |
|
2464 |
GtkShadowType shadowType = GTK_SHADOW_NONE; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2465 |
d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL); |
0 | 2466 |
gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3), |
2467 |
GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style); |
|
2468 |
//draw text |
|
2469 |
QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; |
|
2470 |
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; |
|
2471 |
||
2472 |
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) |
|
2473 |
alignment |= Qt::TextHideMnemonic; |
|
2474 |
||
2475 |
proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole); |
|
2476 |
} |
|
2477 |
} |
|
2478 |
painter->restore(); |
|
2479 |
break; |
|
2480 |
||
2481 |
case CE_Splitter: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2482 |
GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed |
0 | 2483 |
gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE, |
2484 |
!(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, |
|
2485 |
style); |
|
2486 |
} |
|
2487 |
break; |
|
2488 |
||
2489 |
#ifndef QT_NO_TOOLBAR |
|
2490 |
||
2491 |
case CE_ToolBar: |
|
2492 |
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { |
|
2493 |
// Reserve the beveled appearance only for mainwindow toolbars |
|
2494 |
if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget()))) |
|
2495 |
break; |
|
2496 |
||
2497 |
QRect rect = option->rect; |
|
2498 |
// There is a 1 pixel gap between toolbar lines in some styles (i.e Human) |
|
2499 |
if (toolbar->positionWithinLine != QStyleOptionToolBar::End) |
|
2500 |
rect.adjust(0, 0, 1, 0); |
|
2501 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2502 |
GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); |
0 | 2503 |
GtkShadowType shadow_type = GTK_SHADOW_NONE; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2504 |
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); |
0 | 2505 |
gtkPainter.paintBox( gtkToolbar, "toolbar", rect, |
2506 |
GTK_STATE_NORMAL, shadow_type, gtkToolbar->style); |
|
2507 |
} |
|
2508 |
break; |
|
2509 |
||
2510 |
#endif // QT_NO_TOOLBAR |
|
2511 |
||
2512 |
case CE_MenuItem: |
|
2513 |
painter->save(); |
|
2514 |
||
2515 |
// Draws one item in a popup menu. |
|
2516 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
2517 |
const int windowsItemFrame = 2; // menu item frame width |
|
2518 |
const int windowsItemHMargin = 3; // menu item hor text margin |
|
2519 |
const int windowsItemVMargin = 26; // menu item ver text margin |
|
2520 |
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
|
2521 |
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
|
2522 |
d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); |
0 | 2523 |
|
2524 |
style = gtkPainter.getStyle(gtkMenuItem); |
|
2525 |
QColor borderColor = option->palette.background().color().darker(160); |
|
2526 |
QColor shadow = option->palette.dark().color(); |
|
2527 |
||
2528 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2529 |
GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
0 | 2530 |
painter->setPen(shadow.lighter(106)); |
2531 |
gboolean wide_separators = 0; |
|
2532 |
gint separator_height = 0; |
|
2533 |
guint horizontal_padding = 3; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2534 |
QRect separatorRect = option->rect; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2535 |
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
|
2536 |
d->gtk_widget_style_get(gtkMenuSeparator, |
0 | 2537 |
"wide-separators", &wide_separators, |
2538 |
"separator-height", &separator_height, |
|
2539 |
"horizontal-padding", &horizontal_padding, |
|
2540 |
NULL); |
|
2541 |
} |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2542 |
separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2543 |
separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness)); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2544 |
separatorRect.moveCenter(option->rect.center()); |
0 | 2545 |
if (wide_separators) |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2546 |
gtkPainter.paintBox( gtkMenuSeparator, "hseparator", |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2547 |
separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style); |
0 | 2548 |
else |
2549 |
gtkPainter.paintHline( gtkMenuSeparator, "hseparator", |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2550 |
separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2551 |
0, option->rect.right() - 1, 1); |
0 | 2552 |
painter->restore(); |
2553 |
break; |
|
2554 |
} |
|
2555 |
||
2556 |
bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; |
|
2557 |
||
2558 |
if (selected) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2559 |
QRect rect = option->rect; |
0 | 2560 |
#ifndef QT_NO_COMBOBOX |
2561 |
if (qobject_cast<const QComboBox*>(widget)) |
|
2562 |
rect = option->rect; |
|
2563 |
#endif |
|
2564 |
gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style); |
|
2565 |
} |
|
2566 |
||
2567 |
bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
|
2568 |
bool checked = menuItem->checked; |
|
2569 |
bool enabled = menuItem->state & State_Enabled; |
|
2570 |
bool ignoreCheckMark = false; |
|
2571 |
||
2572 |
gint checkSize; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2573 |
d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); |
0 | 2574 |
|
2575 |
int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize)); |
|
2576 |
||
2577 |
#ifndef QT_NO_COMBOBOX |
|
2578 |
||
2579 |
if (qobject_cast<const QComboBox*>(widget)) |
|
2580 |
ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate |
|
2581 |
||
2582 |
#endif |
|
2583 |
if (!ignoreCheckMark) { |
|
2584 |
// Check |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2585 |
QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize); |
0 | 2586 |
checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); |
2587 |
||
2588 |
if (checkable && menuItem->icon.isNull()) { |
|
2589 |
// Some themes such as aero-clone draw slightly outside the paint rect |
|
2590 |
int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead |
|
2591 |
||
2592 |
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { |
|
2593 |
// Radio button |
|
2594 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
2595 |
GtkStateType state = gtkPainter.gtkState(option); |
|
2596 |
||
2597 |
if (selected) |
|
2598 |
state = GTK_STATE_PRELIGHT; |
|
2599 |
if (checked) |
|
2600 |
shadow = GTK_SHADOW_IN; |
|
2601 |
||
2602 |
gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing)); |
|
2603 |
gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow, |
|
2604 |
gtkMenuItem->style, QLS("option")); |
|
2605 |
gtkPainter.setClipRect(QRect()); |
|
2606 |
||
2607 |
} else { |
|
2608 |
// Check box |
|
2609 |
if (menuItem->icon.isNull()) { |
|
2610 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
2611 |
GtkStateType state = gtkPainter.gtkState(option); |
|
2612 |
||
2613 |
if (selected) |
|
2614 |
state = GTK_STATE_PRELIGHT; |
|
2615 |
if (checked) |
|
2616 |
shadow = GTK_SHADOW_IN; |
|
2617 |
||
2618 |
gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing)); |
|
2619 |
gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow, |
|
2620 |
gtkMenuItem->style, QLS("check")); |
|
2621 |
gtkPainter.setClipRect(QRect()); |
|
2622 |
} |
|
2623 |
} |
|
2624 |
} |
|
2625 |
||
2626 |
} else { |
|
2627 |
// Ignore checkmark |
|
2628 |
if (menuItem->icon.isNull()) |
|
2629 |
checkcol = 0; |
|
2630 |
else |
|
2631 |
checkcol = menuItem->maxIconWidth; |
|
2632 |
} |
|
2633 |
||
2634 |
bool dis = !(menuItem->state & State_Enabled); |
|
2635 |
bool act = menuItem->state & State_Selected; |
|
2636 |
const QStyleOption *opt = option; |
|
2637 |
const QStyleOptionMenuItem *menuitem = menuItem; |
|
2638 |
QPainter *p = painter; |
|
2639 |
QRect vCheckRect = visualRect(opt->direction, menuitem->rect, |
|
2640 |
QRect(menuitem->rect.x() + 3, menuitem->rect.y(), |
|
2641 |
checkcol, menuitem->rect.height())); |
|
2642 |
||
2643 |
if (!menuItem->icon.isNull()) { |
|
2644 |
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; |
|
2645 |
||
2646 |
if (act && !dis) |
|
2647 |
mode = QIcon::Active; |
|
2648 |
||
2649 |
QPixmap pixmap; |
|
2650 |
int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); |
|
2651 |
QSize iconSize(smallIconSize, smallIconSize); |
|
2652 |
||
2653 |
#ifndef QT_NO_COMBOBOX |
|
2654 |
if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) |
|
2655 |
iconSize = combo->iconSize(); |
|
2656 |
||
2657 |
#endif // QT_NO_COMBOBOX |
|
2658 |
if (checked) |
|
2659 |
pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); |
|
2660 |
else |
|
2661 |
pixmap = menuItem->icon.pixmap(iconSize, mode); |
|
2662 |
||
2663 |
int pixw = pixmap.width(); |
|
2664 |
int pixh = pixmap.height(); |
|
2665 |
QRect pmr(0, 0, pixw, pixh); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2666 |
pmr.moveCenter(vCheckRect.center() - QPoint(0, 1)); |
0 | 2667 |
painter->setPen(menuItem->palette.text().color()); |
2668 |
if (!ignoreCheckMark && checkable && checked) { |
|
2669 |
QStyleOption opt = *option; |
|
2670 |
||
2671 |
if (act) { |
|
2672 |
QColor activeColor = mergedColors(option->palette.background().color(), |
|
2673 |
option->palette.highlight().color()); |
|
2674 |
opt.palette.setBrush(QPalette::Button, activeColor); |
|
2675 |
} |
|
2676 |
opt.state |= State_Sunken; |
|
2677 |
opt.rect = vCheckRect; |
|
2678 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); |
|
2679 |
} |
|
2680 |
painter->drawPixmap(pmr.topLeft(), pixmap); |
|
2681 |
} |
|
2682 |
||
2683 |
GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL]; |
|
2684 |
GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE]; |
|
2685 |
GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT]; |
|
2686 |
uint resolve_mask = option->palette.resolve(); |
|
2687 |
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); |
|
2688 |
QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8); |
|
2689 |
if (resolve_mask & (1 << QPalette::ButtonText)) { |
|
2690 |
textColor = option->palette.buttonText().color(); |
|
2691 |
disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color(); |
|
2692 |
} |
|
2693 |
||
2694 |
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8); |
|
2695 |
if (resolve_mask & (1 << QPalette::HighlightedText)) { |
|
2696 |
highlightedTextColor = option->palette.highlightedText().color(); |
|
2697 |
} |
|
2698 |
||
2699 |
if (selected) |
|
2700 |
painter->setPen(highlightedTextColor); |
|
2701 |
else |
|
2702 |
painter->setPen(textColor); |
|
2703 |
||
2704 |
int x, y, w, h; |
|
2705 |
menuitem->rect.getRect(&x, &y, &w, &h); |
|
2706 |
int tab = menuitem->tabWidth; |
|
2707 |
int xm = windowsItemFrame + checkcol + windowsItemHMargin; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2708 |
int xpos = menuitem->rect.x() + xm + 1; |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2709 |
QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); |
0 | 2710 |
QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); |
2711 |
QString s = menuitem->text; |
|
2712 |
||
2713 |
if (!s.isEmpty()) { // Draw text |
|
2714 |
p->save(); |
|
2715 |
int t = s.indexOf(QLatin1Char('\t')); |
|
2716 |
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; |
|
2717 |
||
2718 |
if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) |
|
2719 |
text_flags |= Qt::TextHideMnemonic; |
|
2720 |
||
2721 |
// Draw shortcut right aligned |
|
2722 |
text_flags |= Qt::AlignRight; |
|
2723 |
||
2724 |
if (t >= 0) { |
|
2725 |
int rightMargin = 12; // Hardcode for now |
|
2726 |
QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, |
|
2727 |
QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom()))); |
|
2728 |
||
2729 |
if (dis) |
|
2730 |
p->setPen(disabledTextColor); |
|
2731 |
p->drawText(vShortcutRect, text_flags , s.mid(t + 1)); |
|
2732 |
s = s.left(t); |
|
2733 |
} |
|
2734 |
||
2735 |
text_flags &= ~Qt::AlignRight; |
|
2736 |
text_flags |= Qt::AlignLeft; |
|
2737 |
QFont font = menuitem->font; |
|
2738 |
if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) |
|
2739 |
font.setBold(true); |
|
2740 |
p->setFont(font); |
|
2741 |
||
2742 |
if (dis) |
|
2743 |
p->setPen(disabledTextColor); |
|
2744 |
p->drawText(vTextRect, text_flags, s.left(t)); |
|
2745 |
p->restore(); |
|
2746 |
} |
|
2747 |
||
2748 |
// Arrow |
|
2749 |
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow |
|
2750 |
QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget), |
|
2751 |
proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); |
|
2752 |
||
2753 |
QFontMetrics fm(menuitem->font); |
|
2754 |
int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; |
|
2755 |
gfloat arrow_scaling = 0.8; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2756 |
int extra = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2757 |
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
|
2758 |
// "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
|
2759 |
// though the current documentation states otherwise |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2760 |
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
|
2761 |
// 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
|
2762 |
extra = 2 * gtkMenuItem->style->ythickness; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2763 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2764 |
|
0 | 2765 |
int horizontal_padding; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2766 |
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
|
2767 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2768 |
const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra; |
0 | 2769 |
int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim; |
2770 |
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, |
|
2771 |
QRect(xpos, menuItem->rect.top() + |
|
2772 |
menuItem->rect.height() / 2 - dim / 2, dim, dim)); |
|
2773 |
GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE; |
|
2774 |
GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN; |
|
2775 |
gtkPainter.paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state, |
|
2776 |
shadowType, FALSE, style); |
|
2777 |
} |
|
2778 |
} |
|
2779 |
painter->restore(); |
|
2780 |
break; |
|
2781 |
||
2782 |
case CE_PushButton: |
|
2783 |
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
|
2784 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); |
0 | 2785 |
proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); |
2786 |
QStyleOptionButton subopt = *btn; |
|
2787 |
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); |
|
2788 |
gint interiorFocus = true; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2789 |
d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL); |
0 | 2790 |
int xt = interiorFocus ? gtkButton->style->xthickness : 0; |
2791 |
int yt = interiorFocus ? gtkButton->style->ythickness : 0; |
|
2792 |
||
2793 |
if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus) |
|
2794 |
// The normal button focus rect does not work well for flat buttons in Clearlooks |
|
2795 |
proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget); |
|
2796 |
else if (btn->state & State_HasFocus) |
|
2797 |
gtkPainter.paintFocus(gtkButton, "button", |
|
2798 |
option->rect.adjusted(xt, yt, -xt, -yt), |
|
2799 |
btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, |
|
2800 |
gtkButton->style); |
|
2801 |
||
2802 |
proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
|
2803 |
} |
|
2804 |
break; |
|
2805 |
||
2806 |
#ifndef QT_NO_TABBAR |
|
2807 |
||
2808 |
case CE_TabBarTabShape: |
|
2809 |
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
|
2810 |
GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); |
0 | 2811 |
style = gtkPainter.getStyle(gtkNotebook); |
2812 |
||
2813 |
QRect rect = option->rect; |
|
2814 |
GtkShadowType shadow = GTK_SHADOW_OUT; |
|
2815 |
GtkStateType state = GTK_STATE_ACTIVE; |
|
2816 |
if (tab->state & State_Selected) |
|
2817 |
state = GTK_STATE_NORMAL; |
|
2818 |
||
2819 |
bool selected = (tab->state & State_Selected); |
|
2820 |
bool first = false, last = false; |
|
2821 |
if (widget) { |
|
2822 |
// This is most accurate and avoids resizing tabs while moving |
|
2823 |
first = tab->rect.left() == widget->rect().left(); |
|
2824 |
last = tab->rect.right() == widget->rect().right(); |
|
2825 |
} else if (option->direction == Qt::RightToLeft) { |
|
2826 |
bool tmp = first; |
|
2827 |
first = last; |
|
2828 |
last = tmp; |
|
2829 |
} |
|
2830 |
int topIndent = 3; |
|
2831 |
int bottomIndent = 1; |
|
2832 |
int tabOverlap = 1; |
|
2833 |
painter->save(); |
|
2834 |
||
2835 |
switch (tab->shape) { |
|
2836 |
case QTabBar::RoundedNorth: |
|
2837 |
if (!selected) |
|
2838 |
rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent); |
|
2839 |
gtkPainter.paintExtention( gtkNotebook, "tab", rect, |
|
2840 |
state, shadow, GTK_POS_BOTTOM, style); |
|
2841 |
break; |
|
2842 |
||
2843 |
case QTabBar::RoundedSouth: |
|
2844 |
if (!selected) |
|
2845 |
rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent); |
|
2846 |
gtkPainter.paintExtention( gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0), |
|
2847 |
state, shadow, GTK_POS_TOP, style); |
|
2848 |
break; |
|
2849 |
||
2850 |
case QTabBar::RoundedWest: |
|
2851 |
if (!selected) |
|
2852 |
rect.adjust(topIndent, 0, -bottomIndent, 0); |
|
2853 |
gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style); |
|
2854 |
break; |
|
2855 |
||
2856 |
case QTabBar::RoundedEast: |
|
2857 |
if (!selected) |
|
2858 |
rect.adjust(bottomIndent, 0, -topIndent, 0); |
|
2859 |
gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style); |
|
2860 |
break; |
|
2861 |
||
2862 |
default: |
|
2863 |
QCleanlooksStyle::drawControl(element, option, painter, widget); |
|
2864 |
break; |
|
2865 |
} |
|
2866 |
||
2867 |
painter->restore(); |
|
2868 |
} |
|
2869 |
||
2870 |
break; |
|
2871 |
||
2872 |
#endif //QT_NO_TABBAR |
|
2873 |
||
2874 |
case CE_ProgressBarGroove: |
|
2875 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { |
|
2876 |
Q_UNUSED(bar); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2877 |
GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); |
0 | 2878 |
GtkStateType state = gtkPainter.gtkState(option); |
2879 |
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style); |
|
2880 |
} |
|
2881 |
||
2882 |
break; |
|
2883 |
||
2884 |
case CE_ProgressBarContents: |
|
2885 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { |
|
2886 |
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
|
2887 |
GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); |
0 | 2888 |
style = gtkProgressBar->style; |
2889 |
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style); |
|
2890 |
int xt = style->xthickness; |
|
2891 |
int yt = style->ythickness; |
|
2892 |
QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt); |
|
2893 |
bool vertical = false; |
|
2894 |
bool inverted = false; |
|
2895 |
bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); |
|
2896 |
// Get extra style options if version 2 |
|
2897 |
||
2898 |
if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
2899 |
vertical = (bar2->orientation == Qt::Vertical); |
|
2900 |
inverted = bar2->invertedAppearance; |
|
2901 |
} |
|
2902 |
||
2903 |
// If the orientation is vertical, we use a transform to rotate |
|
2904 |
// the progress bar 90 degrees clockwise. This way we can use the |
|
2905 |
// same rendering code for both orientations. |
|
2906 |
if (vertical) { |
|
2907 |
rect.translate(xt, -yt * 2); |
|
2908 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height |
|
2909 |
QTransform m = QTransform::fromTranslate(rect.height(), 0); |
|
2910 |
m.rotate(90.0); |
|
2911 |
painter->setTransform(m); |
|
2912 |
} |
|
2913 |
||
2914 |
int maxWidth = rect.width(); |
|
2915 |
int minWidth = 4; |
|
2916 |
||
2917 |
qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar |
|
2918 |
double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth; |
|
2919 |
int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth; |
|
2920 |
int width = indeterminate ? maxWidth : progressBarWidth; |
|
2921 |
bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; |
|
2922 |
||
2923 |
if (inverted) |
|
2924 |
reverse = !reverse; |
|
2925 |
||
2926 |
int maximum = 2; |
|
2927 |
int fakePos = 0; |
|
2928 |
if (bar->minimum == bar->maximum) |
|
2929 |
maximum = 0; |
|
2930 |
if (bar->progress == bar->maximum) |
|
2931 |
fakePos = maximum; |
|
2932 |
else if (bar->progress > bar->minimum) |
|
2933 |
fakePos = maximum - 1; |
|
2934 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2935 |
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
|
2936 |
d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment)); |
0 | 2937 |
|
2938 |
QRect progressBar; |
|
2939 |
||
2940 |
if (!indeterminate) { |
|
2941 |
if (!reverse) |
|
2942 |
progressBar.setRect(rect.left(), rect.top(), width, rect.height()); |
|
2943 |
else |
|
2944 |
progressBar.setRect(rect.right() - width, rect.top(), width, rect.height()); |
|
2945 |
||
2946 |
} else { |
|
2947 |
Q_D(const QGtkStyle); |
|
2948 |
int slideWidth = ((rect.width() - 4) * 2) / 3; |
|
2949 |
int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth; |
|
2950 |
if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth) |
|
2951 |
step = slideWidth - step; |
|
2952 |
progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height()); |
|
2953 |
} |
|
2954 |
||
2955 |
QString key = QString(QLS("%0")).arg(fakePos); |
|
2956 |
if (inverted) { |
|
2957 |
key += QLatin1String("inv"); |
|
2958 |
gtkPainter.setFlipHorizontal(true); |
|
2959 |
} |
|
2960 |
gtkPainter.paintBox( gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key); |
|
2961 |
} |
|
2962 |
||
2963 |
break; |
|
2964 |
||
2965 |
default: |
|
2966 |
QCleanlooksStyle::drawControl(element, option, painter, widget); |
|
2967 |
} |
|
2968 |
} |
|
2969 |
||
2970 |
/*! |
|
2971 |
\reimp |
|
2972 |
*/ |
|
2973 |
QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, |
|
2974 |
SubControl subControl, const QWidget *widget) const |
|
2975 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2976 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2977 |
|
0 | 2978 |
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
|
2979 |
if (!d->isThemeAvailable()) |
0 | 2980 |
return QCleanlooksStyle::subControlRect(control, option, subControl, widget); |
2981 |
||
2982 |
switch (control) { |
|
2983 |
case CC_TitleBar: |
|
2984 |
return QCleanlooksStyle::subControlRect(control, option, subControl, widget); |
|
2985 |
||
2986 |
case CC_Slider: |
|
2987 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
2988 |
// Reserve space for outside focus rect |
|
2989 |
QStyleOptionSlider sliderCopy = *slider; |
|
2990 |
sliderCopy.rect = option->rect.adjusted(2, 2, -2, -2); |
|
2991 |
return QCleanlooksStyle::subControlRect(control, &sliderCopy, subControl, widget); |
|
2992 |
} |
|
2993 |
||
2994 |
break; |
|
2995 |
||
2996 |
#ifndef QT_NO_GROUPBOX |
|
2997 |
||
2998 |
case CC_GroupBox: |
|
2999 |
if (qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
3000 |
rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin); |
|
3001 |
int topMargin = 0; |
|
3002 |
int topHeight = 0; |
|
3003 |
topHeight = 10; |
|
3004 |
QRect frameRect = rect; |
|
3005 |
frameRect.setTop(topMargin); |
|
3006 |
||
3007 |
if (subControl == SC_GroupBoxFrame) |
|
3008 |
return rect; |
|
3009 |
else if (subControl == SC_GroupBoxContents) { |
|
3010 |
int margin = 0; |
|
3011 |
int leftMarginExtension = 8; |
|
3012 |
return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin); |
|
3013 |
} |
|
3014 |
||
3015 |
if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) { |
|
3016 |
//Prepare metrics for a bold font |
|
3017 |
QFont font = widget->font(); |
|
3018 |
font.setBold(true); |
|
3019 |
QFontMetrics fontMetrics(font); |
|
3020 |
QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4); |
|
3021 |
int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); |
|
3022 |
int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); |
|
3023 |
||
3024 |
if (subControl == SC_GroupBoxCheckBox) { |
|
3025 |
rect.setWidth(indicatorWidth); |
|
3026 |
rect.setHeight(indicatorHeight); |
|
3027 |
rect.moveTop((textRect.height() - indicatorHeight) / 2); |
|
3028 |
||
3029 |
} else if (subControl == SC_GroupBoxLabel) { |
|
3030 |
if (groupBoxWidget->isCheckable()) |
|
3031 |
rect.adjust(indicatorWidth + 4, 0, 0, 0); |
|
3032 |
rect.setSize(textRect); |
|
3033 |
} |
|
3034 |
rect = visualRect(option->direction, option->rect, rect); |
|
3035 |
} |
|
3036 |
} |
|
3037 |
||
3038 |
return rect; |
|
3039 |
||
3040 |
#endif |
|
3041 |
#ifndef QT_NO_SPINBOX |
|
3042 |
||
3043 |
case CC_SpinBox: |
|
3044 |
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
|
3045 |
GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); |
0 | 3046 |
int center = spinbox->rect.height() / 2; |
3047 |
int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0; |
|
3048 |
int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0; |
|
3049 |
int y = yt; |
|
3050 |
||
3051 |
QSize bs; |
|
3052 |
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
|
3053 |
bs.setWidth(d->getSpinboxArrowSize()); |
0 | 3054 |
int x, lx, rx; |
3055 |
x = spinbox->rect.width() - y - bs.width() + 2; |
|
3056 |
lx = xt; |
|
3057 |
rx = x - xt; |
|
3058 |
||
3059 |
switch (subControl) { |
|
3060 |
||
3061 |
case SC_SpinBoxUp: |
|
3062 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
3063 |
return QRect(); |
|
3064 |
rect = QRect(x, xt, bs.width(), center - yt); |
|
3065 |
break; |
|
3066 |
||
3067 |
case SC_SpinBoxDown: |
|
3068 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
3069 |
return QRect(); |
|
3070 |
rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1); |
|
3071 |
break; |
|
3072 |
||
3073 |
case SC_SpinBoxEditField: |
|
3074 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
3075 |
rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt); |
|
3076 |
else |
|
3077 |
rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt); |
|
3078 |
break; |
|
3079 |
||
3080 |
case SC_SpinBoxFrame: |
|
3081 |
rect = spinbox->rect; |
|
3082 |
||
3083 |
default: |
|
3084 |
break; |
|
3085 |
} |
|
3086 |
||
3087 |
rect = visualRect(spinbox->direction, spinbox->rect, rect); |
|
3088 |
} |
|
3089 |
||
3090 |
break; |
|
3091 |
||
3092 |
#endif // Qt_NO_SPINBOX |
|
3093 |
#ifndef QT_NO_COMBOBOX |
|
3094 |
||
3095 |
case CC_ComboBox: |
|
3096 |
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
3097 |
// We employ the gtk widget to position arrows and separators for us |
|
3098 |
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
|
3099 |
GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3100 |
d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); |
0 | 3101 |
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
|
3102 |
d->gtk_widget_size_allocate(gtkCombo, &geometry); |
0 | 3103 |
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget); |
3104 |
QString arrowPath = comboBoxPath + QLS(".GtkToggleButton"); |
|
3105 |
||
3106 |
if (!box->editable && !appears_as_list) |
|
3107 |
arrowPath += QLS(".GtkHBox.GtkArrow"); |
|
3108 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3109 |
GtkWidget *arrowWidget = d->gtkWidget(arrowPath); |
0 | 3110 |
if (!arrowWidget) |
3111 |
return QCleanlooksStyle::subControlRect(control, option, subControl, widget); |
|
3112 |
||
3113 |
QRect buttonRect(option->rect.left() + arrowWidget->allocation.x, |
|
3114 |
option->rect.top() + arrowWidget->allocation.y, |
|
3115 |
arrowWidget->allocation.width, arrowWidget->allocation.height); |
|
3116 |
||
3117 |
switch (subControl) { |
|
3118 |
||
3119 |
case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos |
|
3120 |
rect = buttonRect; |
|
3121 |
break; |
|
3122 |
||
3123 |
case SC_ComboBoxEditField: { |
|
3124 |
rect = visualRect(option->direction, option->rect, rect); |
|
3125 |
int xMargin = box->editable ? 1 : 4, yMargin = 2; |
|
3126 |
rect.setRect(option->rect.left() + gtkCombo->style->xthickness + xMargin, |
|
3127 |
option->rect.top() + gtkCombo->style->ythickness + yMargin, |
|
3128 |
option->rect.width() - buttonRect.width() - 2*(gtkCombo->style->xthickness + xMargin), |
|
3129 |
option->rect.height() - 2*(gtkCombo->style->ythickness + yMargin)); |
|
3130 |
rect = visualRect(option->direction, option->rect, rect); |
|
3131 |
break; |
|
3132 |
} |
|
3133 |
||
3134 |
default: |
|
3135 |
break; |
|
3136 |
} |
|
3137 |
} |
|
3138 |
||
3139 |
break; |
|
3140 |
||
3141 |
#endif // QT_NO_COMBOBOX |
|
3142 |
||
3143 |
default: |
|
3144 |
break; |
|
3145 |
} |
|
3146 |
||
3147 |
return rect; |
|
3148 |
} |
|
3149 |
||
3150 |
/*! |
|
3151 |
\reimp |
|
3152 |
*/ |
|
3153 |
QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, |
|
3154 |
const QSize &size, const QWidget *widget) const |
|
3155 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3156 |
Q_D(const QGtkStyle); |
0 | 3157 |
|
3158 |
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
|
3159 |
if (!d->isThemeAvailable()) |
0 | 3160 |
return newSize; |
3161 |
||
3162 |
switch (type) { |
|
3163 |
||
3164 |
case CT_ToolButton: |
|
3165 |
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
|
3166 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3167 |
newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness); |
0 | 3168 |
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { |
3169 |
QSize minSize(0, 25); |
|
3170 |
if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly) |
|
3171 |
minSize = toolbutton->iconSize + QSize(12, 12); |
|
3172 |
newSize = newSize.expandedTo(minSize); |
|
3173 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3174 |
|
0 | 3175 |
if (toolbutton->features & QStyleOptionToolButton::HasMenu) |
3176 |
newSize += QSize(6, 0); |
|
3177 |
} |
|
3178 |
break; |
|
3179 |
case CT_MenuItem: |
|
3180 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
3181 |
int textMargin = 8; |
|
3182 |
||
3183 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3184 |
GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3185 |
GtkRequisition sizeReq = {0, 0}; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3186 |
d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3187 |
newSize = QSize(size.width(), sizeReq.height); |
0 | 3188 |
break; |
3189 |
} |
|
3190 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3191 |
GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); |
0 | 3192 |
GtkStyle* style = gtkMenuItem->style; |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3193 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3194 |
// Note we get the perfect height for the default font since we |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3195 |
// set a fake text label on the gtkMenuItem |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3196 |
// But if custom fonts are used on the widget we need a minimum size |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3197 |
GtkRequisition sizeReq = {0, 0}; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3198 |
d->gtk_widget_size_request(gtkMenuItem, &sizeReq); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3199 |
newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3200 |
newSize += QSize(textMargin + style->xthickness - 1, 0); |
0 | 3201 |
|
3202 |
// Cleanlooks assumes a check column of 20 pixels so we need to |
|
3203 |
// expand it a bit |
|
3204 |
gint checkSize; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3205 |
d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); |
0 | 3206 |
newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); |
3207 |
} |
|
3208 |
||
3209 |
break; |
|
3210 |
||
3211 |
case CT_SpinBox: |
|
3212 |
// 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
|
3213 |
newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2); |
0 | 3214 |
break; |
3215 |
||
3216 |
case CT_PushButton: |
|
3217 |
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
|
3218 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); |
0 | 3219 |
gint focusPadding, focusWidth; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3220 |
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
|
3221 |
d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL); |
0 | 3222 |
newSize = size; |
3223 |
newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness); |
|
3224 |
newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding)); |
|
3225 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3226 |
GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox")); |
0 | 3227 |
gint minWidth = 85, minHeight = 0; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3228 |
d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth, |
0 | 3229 |
"child-min-height", &minHeight, NULL); |
3230 |
if (!btn->text.isEmpty() && newSize.width() < minWidth) |
|
3231 |
newSize.setWidth(minWidth); |
|
3232 |
if (newSize.height() < minHeight) |
|
3233 |
newSize.setHeight(minHeight); |
|
3234 |
} |
|
3235 |
||
3236 |
break; |
|
3237 |
||
3238 |
case CT_Slider: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3239 |
GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale")); |
0 | 3240 |
newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness); |
3241 |
} |
|
3242 |
break; |
|
3243 |
||
3244 |
case CT_LineEdit: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3245 |
GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3246 |
newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness); |
0 | 3247 |
} |
3248 |
break; |
|
3249 |
||
3250 |
case CT_ItemViewItem: |
|
3251 |
newSize += QSize(0, 2); |
|
3252 |
break; |
|
3253 |
||
3254 |
case CT_ComboBox: |
|
3255 |
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
|
3256 |
GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); |
0 | 3257 |
QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget); |
3258 |
newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness); |
|
3259 |
||
3260 |
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
|
3261 |
newSize += QSize(0, 2); |
0 | 3262 |
} |
3263 |
break; |
|
3264 |
||
3265 |
case CT_GroupBox: |
|
3266 |
newSize += QSize(4, groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox |
|
3267 |
break; |
|
3268 |
||
3269 |
case CT_TabBarTab: |
|
3270 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
3271 |
if (!tab->icon.isNull()) |
|
3272 |
newSize += QSize(6, 0); |
|
3273 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3274 |
newSize += QSize(1, 1); |
0 | 3275 |
break; |
3276 |
||
3277 |
default: |
|
3278 |
break; |
|
3279 |
} |
|
3280 |
||
3281 |
return newSize; |
|
3282 |
} |
|
3283 |
||
3284 |
||
3285 |
/*! \reimp */ |
|
3286 |
QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, |
|
3287 |
const QWidget *widget) const |
|
3288 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3289 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3290 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3291 |
if (!d->isThemeAvailable()) |
0 | 3292 |
return QCleanlooksStyle::standardPixmap(sp, option, widget); |
3293 |
||
3294 |
QPixmap pixmap; |
|
3295 |
switch (sp) { |
|
3296 |
||
3297 |
case SP_TitleBarNormalButton: { |
|
3298 |
QImage restoreButton((const char **)dock_widget_restore_xpm); |
|
3299 |
QColor alphaCorner = restoreButton.color(2); |
|
3300 |
alphaCorner.setAlpha(80); |
|
3301 |
restoreButton.setColor(2, alphaCorner.rgba()); |
|
3302 |
alphaCorner.setAlpha(180); |
|
3303 |
restoreButton.setColor(4, alphaCorner.rgba()); |
|
3304 |
return QPixmap::fromImage(restoreButton); |
|
3305 |
} |
|
3306 |
break; |
|
3307 |
||
3308 |
case SP_TitleBarCloseButton: // Fall through |
|
3309 |
case SP_DockWidgetCloseButton: { |
|
3310 |
||
3311 |
QImage closeButton((const char **)dock_widget_close_xpm); |
|
3312 |
QColor alphaCorner = closeButton.color(2); |
|
3313 |
alphaCorner.setAlpha(80); |
|
3314 |
closeButton.setColor(2, alphaCorner.rgba()); |
|
3315 |
return QPixmap::fromImage(closeButton); |
|
3316 |
} |
|
3317 |
break; |
|
3318 |
||
3319 |
case SP_DialogDiscardButton: |
|
3320 |
return QGtkPainter::getIcon(GTK_STOCK_DELETE); |
|
3321 |
case SP_DialogOkButton: |
|
3322 |
return QGtkPainter::getIcon(GTK_STOCK_OK); |
|
3323 |
case SP_DialogCancelButton: |
|
3324 |
return QGtkPainter::getIcon(GTK_STOCK_CANCEL); |
|
3325 |
case SP_DialogYesButton: |
|
3326 |
return QGtkPainter::getIcon(GTK_STOCK_YES); |
|
3327 |
case SP_DialogNoButton: |
|
3328 |
return QGtkPainter::getIcon(GTK_STOCK_NO); |
|
3329 |
case SP_DialogOpenButton: |
|
3330 |
return QGtkPainter::getIcon(GTK_STOCK_OPEN); |
|
3331 |
case SP_DialogCloseButton: |
|
3332 |
return QGtkPainter::getIcon(GTK_STOCK_CLOSE); |
|
3333 |
case SP_DialogApplyButton: |
|
3334 |
return QGtkPainter::getIcon(GTK_STOCK_APPLY); |
|
3335 |
case SP_DialogSaveButton: |
|
3336 |
return QGtkPainter::getIcon(GTK_STOCK_SAVE); |
|
3337 |
case SP_MessageBoxWarning: |
|
3338 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); |
|
3339 |
case SP_MessageBoxQuestion: |
|
3340 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
|
3341 |
case SP_MessageBoxInformation: |
|
3342 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); |
|
3343 |
case SP_MessageBoxCritical: |
|
3344 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); |
|
3345 |
default: |
|
3346 |
return QCleanlooksStyle::standardPixmap(sp, option, widget); |
|
3347 |
} |
|
3348 |
return pixmap; |
|
3349 |
} |
|
3350 |
||
3351 |
/*! |
|
3352 |
\internal |
|
3353 |
*/ |
|
3354 |
QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon, |
|
3355 |
const QStyleOption *option, |
|
3356 |
const QWidget *widget) const |
|
3357 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3358 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3359 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3360 |
if (!d->isThemeAvailable()) |
0 | 3361 |
return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget); |
3362 |
switch (standardIcon) { |
|
3363 |
case SP_DialogDiscardButton: |
|
3364 |
return QGtkPainter::getIcon(GTK_STOCK_DELETE); |
|
3365 |
case SP_DialogOkButton: |
|
3366 |
return QGtkPainter::getIcon(GTK_STOCK_OK); |
|
3367 |
case SP_DialogCancelButton: |
|
3368 |
return QGtkPainter::getIcon(GTK_STOCK_CANCEL); |
|
3369 |
case SP_DialogYesButton: |
|
3370 |
return QGtkPainter::getIcon(GTK_STOCK_YES); |
|
3371 |
case SP_DialogNoButton: |
|
3372 |
return QGtkPainter::getIcon(GTK_STOCK_NO); |
|
3373 |
case SP_DialogOpenButton: |
|
3374 |
return QGtkPainter::getIcon(GTK_STOCK_OPEN); |
|
3375 |
case SP_DialogCloseButton: |
|
3376 |
return QGtkPainter::getIcon(GTK_STOCK_CLOSE); |
|
3377 |
case SP_DialogApplyButton: |
|
3378 |
return QGtkPainter::getIcon(GTK_STOCK_APPLY); |
|
3379 |
case SP_DialogSaveButton: |
|
3380 |
return QGtkPainter::getIcon(GTK_STOCK_SAVE); |
|
3381 |
case SP_MessageBoxWarning: |
|
3382 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); |
|
3383 |
case SP_MessageBoxQuestion: |
|
3384 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
|
3385 |
case SP_MessageBoxInformation: |
|
3386 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); |
|
3387 |
case SP_MessageBoxCritical: |
|
3388 |
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); |
|
3389 |
default: |
|
3390 |
return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget); |
|
3391 |
} |
|
3392 |
} |
|
3393 |
||
3394 |
||
3395 |
/*! \reimp */ |
|
3396 |
QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const |
|
3397 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3398 |
Q_D(const QGtkStyle); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3399 |
|
0 | 3400 |
QRect r = QCleanlooksStyle::subElementRect(element, option, widget); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
3401 |
if (!d->isThemeAvailable()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
3402 |
return r; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
3403 |
|
0 | 3404 |
switch (element) { |
3405 |
case SE_ProgressBarLabel: |
|
3406 |
case SE_ProgressBarContents: |
|
3407 |
case SE_ProgressBarGroove: |
|
3408 |
return option->rect; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3409 |
case SE_PushButtonContents: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3410 |
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
|
3411 |
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3412 |
GtkBorder *border = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3413 |
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
|
3414 |
if (border) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3415 |
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
|
3416 |
d->gtk_border_free(border); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3417 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3418 |
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
|
3419 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3420 |
r = visualRect(option->direction, option->rect, r); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3421 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3422 |
break; |
0 | 3423 |
default: |
3424 |
break; |
|
3425 |
} |
|
3426 |
||
3427 |
return r; |
|
3428 |
} |
|
3429 |
||
3430 |
/*! |
|
3431 |
\reimp |
|
3432 |
*/ |
|
3433 |
QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const |
|
3434 |
{ |
|
3435 |
return QCleanlooksStyle::itemPixmapRect(r, flags, pixmap); |
|
3436 |
} |
|
3437 |
||
3438 |
/*! |
|
3439 |
\reimp |
|
3440 |
*/ |
|
3441 |
void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect, |
|
3442 |
int alignment, const QPixmap &pixmap) const |
|
3443 |
{ |
|
3444 |
QCleanlooksStyle::drawItemPixmap(painter, rect, alignment, pixmap); |
|
3445 |
} |
|
3446 |
||
3447 |
/*! |
|
3448 |
\reimp |
|
3449 |
*/ |
|
3450 |
QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, |
|
3451 |
const QPoint &pt, const QWidget *w) const |
|
3452 |
{ |
|
3453 |
return QCleanlooksStyle::hitTestComplexControl(cc, opt, pt, w); |
|
3454 |
} |
|
3455 |
||
3456 |
/*! |
|
3457 |
\reimp |
|
3458 |
*/ |
|
3459 |
QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, |
|
3460 |
const QStyleOption *opt) const |
|
3461 |
{ |
|
3462 |
return QCleanlooksStyle::generatedIconPixmap(iconMode, pixmap, opt); |
|
3463 |
} |
|
3464 |
||
3465 |
/*! |
|
3466 |
\reimp |
|
3467 |
*/ |
|
3468 |
void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, |
|
3469 |
bool enabled, const QString& text, QPalette::ColorRole textRole) const |
|
3470 |
{ |
|
3471 |
return QCleanlooksStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole); |
|
3472 |
} |
|
3473 |
||
3474 |
QT_END_NAMESPACE |
|
3475 |
||
3476 |
#endif //!defined(QT_NO_STYLE_QGTK) |