1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qwindowsstyle.h"
|
---|
43 | #include "qwindowsstyle_p.h"
|
---|
44 | #include <private/qstylehelper_p.h>
|
---|
45 |
|
---|
46 | #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
|
---|
47 |
|
---|
48 | #include "qlibrary.h"
|
---|
49 | #include "qapplication.h"
|
---|
50 | #include "qbitmap.h"
|
---|
51 | #include "qdrawutil.h" // for now
|
---|
52 | #include "qevent.h"
|
---|
53 | #include "qmenu.h"
|
---|
54 | #include "qmenubar.h"
|
---|
55 | #include <private/qmenubar_p.h>
|
---|
56 | #include "qpaintengine.h"
|
---|
57 | #include "qpainter.h"
|
---|
58 | #include "qprogressbar.h"
|
---|
59 | #include "qrubberband.h"
|
---|
60 | #include "qstyleoption.h"
|
---|
61 | #include "qtabbar.h"
|
---|
62 | #include "qwidget.h"
|
---|
63 | #include "qdebug.h"
|
---|
64 | #include "qmainwindow.h"
|
---|
65 | #include "qfile.h"
|
---|
66 | #include "qtextstream.h"
|
---|
67 | #include "qpixmapcache.h"
|
---|
68 | #include "qwizard.h"
|
---|
69 | #include "qlistview.h"
|
---|
70 | #include <private/qmath_p.h>
|
---|
71 | #include <qmath.h>
|
---|
72 |
|
---|
73 |
|
---|
74 | #ifdef Q_WS_X11
|
---|
75 | #include "qfileinfo.h"
|
---|
76 | #include "qdir.h"
|
---|
77 | #include <private/qt_x11_p.h>
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | QT_BEGIN_NAMESPACE
|
---|
81 |
|
---|
82 | #if defined(Q_WS_WIN)
|
---|
83 |
|
---|
84 | QT_BEGIN_INCLUDE_NAMESPACE
|
---|
85 | #include "qt_windows.h"
|
---|
86 | QT_END_INCLUDE_NAMESPACE
|
---|
87 | # ifndef COLOR_GRADIENTACTIVECAPTION
|
---|
88 | # define COLOR_GRADIENTACTIVECAPTION 27
|
---|
89 | # endif
|
---|
90 | # ifndef COLOR_GRADIENTINACTIVECAPTION
|
---|
91 | # define COLOR_GRADIENTINACTIVECAPTION 28
|
---|
92 | # endif
|
---|
93 |
|
---|
94 |
|
---|
95 | typedef struct
|
---|
96 | {
|
---|
97 | DWORD cbSize;
|
---|
98 | HICON hIcon;
|
---|
99 | int iSysImageIndex;
|
---|
100 | int iIcon;
|
---|
101 | WCHAR szPath[MAX_PATH];
|
---|
102 | } QSHSTOCKICONINFO;
|
---|
103 |
|
---|
104 | #define _SHGFI_SMALLICON 0x000000001
|
---|
105 | #define _SHGFI_LARGEICON 0x000000000
|
---|
106 | #define _SHGFI_ICON 0x000000100
|
---|
107 | #define _SIID_SHIELD 77
|
---|
108 |
|
---|
109 | typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
|
---|
110 | static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
|
---|
111 |
|
---|
112 | #endif //Q_WS_WIN
|
---|
113 |
|
---|
114 | QT_BEGIN_INCLUDE_NAMESPACE
|
---|
115 | #include <limits.h>
|
---|
116 | QT_END_INCLUDE_NAMESPACE
|
---|
117 |
|
---|
118 | enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
|
---|
119 |
|
---|
120 | /*
|
---|
121 | \internal
|
---|
122 | */
|
---|
123 | QWindowsStylePrivate::QWindowsStylePrivate()
|
---|
124 | : alt_down(false), menuBarTimer(0), animationFps(10), animateTimer(0), animateStep(0)
|
---|
125 | {
|
---|
126 | #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
|
---|
127 | if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
|
---|
128 | && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
|
---|
129 | QLibrary shellLib(QLatin1String("shell32"));
|
---|
130 | pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
|
---|
131 | }
|
---|
132 | #endif
|
---|
133 | }
|
---|
134 |
|
---|
135 | // Returns true if the toplevel parent of \a widget has seen the Alt-key
|
---|
136 | bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
|
---|
137 | {
|
---|
138 | widget = widget->window();
|
---|
139 | return seenAlt.contains(widget);
|
---|
140 | }
|
---|
141 |
|
---|
142 | /*!
|
---|
143 | \reimp
|
---|
144 | */
|
---|
145 | void QWindowsStyle::timerEvent(QTimerEvent *event)
|
---|
146 | {
|
---|
147 | #ifndef QT_NO_PROGRESSBAR
|
---|
148 | Q_D(QWindowsStyle);
|
---|
149 | if (event->timerId() == d->animateTimer) {
|
---|
150 | Q_ASSERT(d->animationFps> 0);
|
---|
151 | d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
|
---|
152 | foreach (QProgressBar *bar, d->bars) {
|
---|
153 | if ((bar->minimum() == 0 && bar->maximum() == 0))
|
---|
154 | bar->update();
|
---|
155 | }
|
---|
156 | }
|
---|
157 | #endif // QT_NO_PROGRESSBAR
|
---|
158 | event->ignore();
|
---|
159 | }
|
---|
160 |
|
---|
161 | /*!
|
---|
162 | \reimp
|
---|
163 | */
|
---|
164 | bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
|
---|
165 | {
|
---|
166 | // Records Alt- and Focus events
|
---|
167 | if (!o->isWidgetType())
|
---|
168 | return QObject::eventFilter(o, e);
|
---|
169 |
|
---|
170 | QWidget *widget = qobject_cast<QWidget*>(o);
|
---|
171 | Q_D(QWindowsStyle);
|
---|
172 | switch(e->type()) {
|
---|
173 | case QEvent::KeyPress:
|
---|
174 | if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
|
---|
175 | widget = widget->window();
|
---|
176 |
|
---|
177 | // Alt has been pressed - find all widgets that care
|
---|
178 | QList<QWidget *> l = qFindChildren<QWidget *>(widget);
|
---|
179 | for (int pos=0 ; pos < l.size() ; ++pos) {
|
---|
180 | QWidget *w = l.at(pos);
|
---|
181 | if (w->isWindow() || !w->isVisible() ||
|
---|
182 | w->style()->styleHint(SH_UnderlineShortcut, 0, w))
|
---|
183 | l.removeAt(pos);
|
---|
184 | }
|
---|
185 | // Update states before repainting
|
---|
186 | d->seenAlt.append(widget);
|
---|
187 | d->alt_down = true;
|
---|
188 |
|
---|
189 | // Repaint all relevant widgets
|
---|
190 | for (int pos = 0; pos < l.size(); ++pos)
|
---|
191 | l.at(pos)->update();
|
---|
192 | }
|
---|
193 | break;
|
---|
194 | case QEvent::KeyRelease:
|
---|
195 | if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
|
---|
196 | widget = widget->window();
|
---|
197 |
|
---|
198 | // Update state and repaint the menu bars.
|
---|
199 | d->alt_down = false;
|
---|
200 | #ifndef QT_NO_MENUBAR
|
---|
201 | QList<QMenuBar *> l = qFindChildren<QMenuBar *>(widget);
|
---|
202 | for (int i = 0; i < l.size(); ++i)
|
---|
203 | l.at(i)->update();
|
---|
204 | #endif
|
---|
205 | }
|
---|
206 | break;
|
---|
207 | case QEvent::Close:
|
---|
208 | // Reset widget when closing
|
---|
209 | d->seenAlt.removeAll(widget);
|
---|
210 | d->seenAlt.removeAll(widget->window());
|
---|
211 | break;
|
---|
212 | #ifndef QT_NO_PROGRESSBAR
|
---|
213 | case QEvent::StyleChange:
|
---|
214 | case QEvent::Show:
|
---|
215 | if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
|
---|
216 | if (!d->bars.contains(bar)) {
|
---|
217 | d->bars << bar;
|
---|
218 | if (d->bars.size() == 1) {
|
---|
219 | Q_ASSERT(d->animationFps> 0);
|
---|
220 | d->animateTimer = startTimer(1000 / d->animationFps);
|
---|
221 | }
|
---|
222 | }
|
---|
223 | }
|
---|
224 | break;
|
---|
225 | case QEvent::Destroy:
|
---|
226 | case QEvent::Hide:
|
---|
227 | // reinterpret_cast because there is no type info when getting
|
---|
228 | // the destroy event. We know that it is a QProgressBar.
|
---|
229 | if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
|
---|
230 | d->bars.removeAll(bar);
|
---|
231 | if (d->bars.isEmpty() && d->animateTimer) {
|
---|
232 | killTimer(d->animateTimer);
|
---|
233 | d->animateTimer = 0;
|
---|
234 | }
|
---|
235 | }
|
---|
236 | break;
|
---|
237 | #endif // QT_NO_PROGRESSBAR
|
---|
238 | default:
|
---|
239 | break;
|
---|
240 | }
|
---|
241 | return QCommonStyle::eventFilter(o, e);
|
---|
242 | }
|
---|
243 |
|
---|
244 | /*!
|
---|
245 | \class QWindowsStyle
|
---|
246 | \brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
|
---|
247 |
|
---|
248 | \ingroup appearance
|
---|
249 |
|
---|
250 | This style is Qt's default GUI style on Windows.
|
---|
251 |
|
---|
252 | \img qwindowsstyle.png
|
---|
253 | \sa QWindowsXPStyle, QMacStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
|
---|
254 | */
|
---|
255 |
|
---|
256 | /*!
|
---|
257 | Constructs a QWindowsStyle object.
|
---|
258 | */
|
---|
259 | QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate)
|
---|
260 | {
|
---|
261 | }
|
---|
262 |
|
---|
263 | /*!
|
---|
264 | \internal
|
---|
265 |
|
---|
266 | Constructs a QWindowsStyle object.
|
---|
267 | */
|
---|
268 | QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
|
---|
269 | {
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 | /*! Destroys the QWindowsStyle object. */
|
---|
274 | QWindowsStyle::~QWindowsStyle()
|
---|
275 | {
|
---|
276 | }
|
---|
277 |
|
---|
278 | #ifdef Q_WS_WIN
|
---|
279 | static inline QRgb colorref2qrgb(COLORREF col)
|
---|
280 | {
|
---|
281 | return qRgb(GetRValue(col), GetGValue(col), GetBValue(col));
|
---|
282 | }
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | /*! \reimp */
|
---|
286 | void QWindowsStyle::polish(QApplication *app)
|
---|
287 | {
|
---|
288 | QCommonStyle::polish(app);
|
---|
289 | QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
|
---|
290 | // We only need the overhead when shortcuts are sometimes hidden
|
---|
291 | if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
|
---|
292 | app->installEventFilter(this);
|
---|
293 |
|
---|
294 | d->activeCaptionColor = app->palette().highlight().color();
|
---|
295 | d->activeGradientCaptionColor = app->palette().highlight() .color();
|
---|
296 | d->inactiveCaptionColor = app->palette().dark().color();
|
---|
297 | d->inactiveGradientCaptionColor = app->palette().dark().color();
|
---|
298 | d->inactiveCaptionText = app->palette().background().color();
|
---|
299 |
|
---|
300 | #if defined(Q_WS_WIN) //fetch native title bar colors
|
---|
301 | if(app->desktopSettingsAware()){
|
---|
302 | DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
|
---|
303 | DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
|
---|
304 | DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
|
---|
305 | DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
|
---|
306 | DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
|
---|
307 | d->activeCaptionColor = colorref2qrgb(activeCaption);
|
---|
308 | d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
|
---|
309 | d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
|
---|
310 | d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
|
---|
311 | d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
|
---|
312 | }
|
---|
313 | #endif
|
---|
314 | }
|
---|
315 |
|
---|
316 | /*! \reimp */
|
---|
317 | void QWindowsStyle::unpolish(QApplication *app)
|
---|
318 | {
|
---|
319 | QCommonStyle::unpolish(app);
|
---|
320 | app->removeEventFilter(this);
|
---|
321 | }
|
---|
322 |
|
---|
323 | /*! \reimp */
|
---|
324 | void QWindowsStyle::polish(QWidget *widget)
|
---|
325 | {
|
---|
326 | QCommonStyle::polish(widget);
|
---|
327 | #ifndef QT_NO_PROGRESSBAR
|
---|
328 | if (qobject_cast<QProgressBar *>(widget))
|
---|
329 | widget->installEventFilter(this);
|
---|
330 | #endif
|
---|
331 | }
|
---|
332 |
|
---|
333 | /*! \reimp */
|
---|
334 | void QWindowsStyle::unpolish(QWidget *widget)
|
---|
335 | {
|
---|
336 | QCommonStyle::unpolish(widget);
|
---|
337 | #ifndef QT_NO_PROGRESSBAR
|
---|
338 | if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
|
---|
339 | Q_D(QWindowsStyle);
|
---|
340 | widget->removeEventFilter(this);
|
---|
341 | d->bars.removeAll(bar);
|
---|
342 | }
|
---|
343 | #endif
|
---|
344 | }
|
---|
345 |
|
---|
346 | /*!
|
---|
347 | \reimp
|
---|
348 | */
|
---|
349 | void QWindowsStyle::polish(QPalette &pal)
|
---|
350 | {
|
---|
351 | QCommonStyle::polish(pal);
|
---|
352 | }
|
---|
353 |
|
---|
354 | /*!
|
---|
355 | \reimp
|
---|
356 | */
|
---|
357 | int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const
|
---|
358 | {
|
---|
359 | int ret;
|
---|
360 |
|
---|
361 | switch (pm) {
|
---|
362 | case PM_ButtonDefaultIndicator:
|
---|
363 | case PM_ButtonShiftHorizontal:
|
---|
364 | case PM_ButtonShiftVertical:
|
---|
365 | case PM_MenuHMargin:
|
---|
366 | case PM_MenuVMargin:
|
---|
367 | ret = 1;
|
---|
368 | break;
|
---|
369 | #ifndef QT_NO_TABBAR
|
---|
370 | case PM_TabBarTabShiftHorizontal:
|
---|
371 | ret = 0;
|
---|
372 | break;
|
---|
373 | case PM_TabBarTabShiftVertical:
|
---|
374 | ret = 2;
|
---|
375 | break;
|
---|
376 | #endif
|
---|
377 | case PM_MaximumDragDistance:
|
---|
378 | #if defined(Q_WS_WIN)
|
---|
379 | {
|
---|
380 | HDC hdcScreen = GetDC(0);
|
---|
381 | int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
|
---|
382 | ReleaseDC(0, hdcScreen);
|
---|
383 | ret = (int)(dpi * 1.375);
|
---|
384 | }
|
---|
385 | #else
|
---|
386 | ret = 60;
|
---|
387 | #endif
|
---|
388 | break;
|
---|
389 |
|
---|
390 | #ifndef QT_NO_SLIDER
|
---|
391 | case PM_SliderLength:
|
---|
392 | ret = int(QStyleHelper::dpiScaled(11.));
|
---|
393 | break;
|
---|
394 |
|
---|
395 | // Returns the number of pixels to use for the business part of the
|
---|
396 | // slider (i.e., the non-tickmark portion). The remaining space is shared
|
---|
397 | // equally between the tickmark regions.
|
---|
398 | case PM_SliderControlThickness:
|
---|
399 | if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
|
---|
400 | int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
|
---|
401 | int ticks = sl->tickPosition;
|
---|
402 | int n = 0;
|
---|
403 | if (ticks & QSlider::TicksAbove)
|
---|
404 | ++n;
|
---|
405 | if (ticks & QSlider::TicksBelow)
|
---|
406 | ++n;
|
---|
407 | if (!n) {
|
---|
408 | ret = space;
|
---|
409 | break;
|
---|
410 | }
|
---|
411 |
|
---|
412 | int thick = 6; // Magic constant to get 5 + 16 + 5
|
---|
413 | if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
|
---|
414 | thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
|
---|
415 |
|
---|
416 | space -= thick;
|
---|
417 | if (space > 0)
|
---|
418 | thick += (space * 2) / (n + 2);
|
---|
419 | ret = thick;
|
---|
420 | } else {
|
---|
421 | ret = 0;
|
---|
422 | }
|
---|
423 | break;
|
---|
424 | #endif // QT_NO_SLIDER
|
---|
425 |
|
---|
426 | #ifndef QT_NO_MENU
|
---|
427 | case PM_MenuBarHMargin:
|
---|
428 | ret = 0;
|
---|
429 | break;
|
---|
430 |
|
---|
431 | case PM_MenuBarVMargin:
|
---|
432 | ret = 0;
|
---|
433 | break;
|
---|
434 |
|
---|
435 | case PM_MenuBarPanelWidth:
|
---|
436 | ret = 0;
|
---|
437 | break;
|
---|
438 |
|
---|
439 | case PM_SmallIconSize:
|
---|
440 | #if defined(Q_WS_PM)
|
---|
441 | if (QApplication::desktopSettingsAware())
|
---|
442 | return QCommonStyle::pixelMetric(pm, opt, widget);
|
---|
443 | #endif
|
---|
444 | ret = int(QStyleHelper::dpiScaled(16.));
|
---|
445 | break;
|
---|
446 |
|
---|
447 | case PM_LargeIconSize:
|
---|
448 | #if defined(Q_WS_PM)
|
---|
449 | if (QApplication::desktopSettingsAware())
|
---|
450 | return QCommonStyle::pixelMetric(pm, opt, widget);
|
---|
451 | #endif
|
---|
452 | ret = int(QStyleHelper::dpiScaled(32.));
|
---|
453 | break;
|
---|
454 |
|
---|
455 | case PM_IconViewIconSize:
|
---|
456 | ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
|
---|
457 | break;
|
---|
458 |
|
---|
459 | case PM_DockWidgetTitleMargin:
|
---|
460 | ret = int(QStyleHelper::dpiScaled(2.));
|
---|
461 | break;
|
---|
462 | case PM_DockWidgetTitleBarButtonMargin:
|
---|
463 | ret = int(QStyleHelper::dpiScaled(4.));
|
---|
464 | break;
|
---|
465 | #if defined(Q_WS_WIN)
|
---|
466 | case PM_DockWidgetFrameWidth:
|
---|
467 | #if defined(Q_OS_WINCE)
|
---|
468 | ret = GetSystemMetrics(SM_CXDLGFRAME);
|
---|
469 | #else
|
---|
470 | ret = GetSystemMetrics(SM_CXFRAME);
|
---|
471 | #endif
|
---|
472 | break;
|
---|
473 | #else
|
---|
474 | case PM_DockWidgetFrameWidth:
|
---|
475 | ret = 4;
|
---|
476 | break;
|
---|
477 | #endif // Q_WS_WIN
|
---|
478 | break;
|
---|
479 |
|
---|
480 | #endif // QT_NO_MENU
|
---|
481 |
|
---|
482 |
|
---|
483 | #if defined(Q_WS_WIN)
|
---|
484 | case PM_TitleBarHeight:
|
---|
485 | #ifdef QT3_SUPPORT
|
---|
486 | // qt3 dockwindow height should be equal to tool windows
|
---|
487 | if (widget && widget->inherits("Q3DockWindowTitleBar")) {
|
---|
488 | ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
|
---|
489 | } else
|
---|
490 | #endif
|
---|
491 | if (widget && (widget->windowType() == Qt::Tool)) {
|
---|
492 | // MS always use one less than they say
|
---|
493 | #if defined(Q_OS_WINCE)
|
---|
494 | ret = GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
495 | #else
|
---|
496 | ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
|
---|
497 | #endif
|
---|
498 | } else {
|
---|
499 | ret = GetSystemMetrics(SM_CYCAPTION) - 1;
|
---|
500 | }
|
---|
501 |
|
---|
502 | break;
|
---|
503 |
|
---|
504 | case PM_ScrollBarExtent:
|
---|
505 | {
|
---|
506 | #ifndef Q_OS_WINCE
|
---|
507 | NONCLIENTMETRICS ncm;
|
---|
508 | ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
---|
509 | if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
|
---|
510 | ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
|
---|
511 | else
|
---|
512 | #endif
|
---|
513 | ret = QCommonStyle::pixelMetric(pm, opt, widget);
|
---|
514 | }
|
---|
515 | break;
|
---|
516 | #endif // Q_WS_WIN
|
---|
517 |
|
---|
518 | case PM_SplitterWidth:
|
---|
519 | ret = qMax(4, QApplication::globalStrut().width());
|
---|
520 | break;
|
---|
521 |
|
---|
522 | #if defined(Q_WS_WIN)
|
---|
523 | case PM_MdiSubWindowFrameWidth:
|
---|
524 | #if defined(Q_OS_WINCE)
|
---|
525 | ret = GetSystemMetrics(SM_CYDLGFRAME);
|
---|
526 | #else
|
---|
527 | ret = GetSystemMetrics(SM_CYFRAME);
|
---|
528 | #endif
|
---|
529 | break;
|
---|
530 | case PM_TextCursorWidth: {
|
---|
531 | DWORD caretWidth = 1;
|
---|
532 | #if defined(SPI_GETCARETWIDTH)
|
---|
533 | SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0);
|
---|
534 | #endif
|
---|
535 | ret = (int)caretWidth;
|
---|
536 | break; }
|
---|
537 | #endif
|
---|
538 | case PM_ToolBarItemMargin:
|
---|
539 | ret = 1;
|
---|
540 | break;
|
---|
541 | case PM_ToolBarItemSpacing:
|
---|
542 | ret = 0;
|
---|
543 | break;
|
---|
544 | case PM_ToolBarHandleExtent:
|
---|
545 | ret = int(QStyleHelper::dpiScaled(10.));
|
---|
546 | break;
|
---|
547 | default:
|
---|
548 | ret = QCommonStyle::pixelMetric(pm, opt, widget);
|
---|
549 | break;
|
---|
550 | }
|
---|
551 |
|
---|
552 | return ret;
|
---|
553 | }
|
---|
554 |
|
---|
555 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
---|
556 |
|
---|
557 | /* XPM */
|
---|
558 | static const char * const qt_menu_xpm[] = {
|
---|
559 | "16 16 72 1",
|
---|
560 | " c None",
|
---|
561 | ". c #65AF36",
|
---|
562 | "+ c #66B036",
|
---|
563 | "@ c #77B94C",
|
---|
564 | "# c #A7D28C",
|
---|
565 | "$ c #BADBA4",
|
---|
566 | "% c #A4D088",
|
---|
567 | "& c #72B646",
|
---|
568 | "* c #9ACB7A",
|
---|
569 | "= c #7FBD56",
|
---|
570 | "- c #85C05F",
|
---|
571 | "; c #F4F9F0",
|
---|
572 | "> c #FFFFFF",
|
---|
573 | ", c #E5F1DC",
|
---|
574 | "' c #ECF5E7",
|
---|
575 | ") c #7ABA50",
|
---|
576 | "! c #83BF5C",
|
---|
577 | "~ c #AED595",
|
---|
578 | "{ c #D7EACA",
|
---|
579 | "] c #A9D28D",
|
---|
580 | "^ c #BCDDA8",
|
---|
581 | "/ c #C4E0B1",
|
---|
582 | "( c #81BE59",
|
---|
583 | "_ c #D0E7C2",
|
---|
584 | ": c #D4E9C6",
|
---|
585 | "< c #6FB542",
|
---|
586 | "[ c #6EB440",
|
---|
587 | "} c #88C162",
|
---|
588 | "| c #98CA78",
|
---|
589 | "1 c #F4F9F1",
|
---|
590 | "2 c #8FC56C",
|
---|
591 | "3 c #F1F8EC",
|
---|
592 | "4 c #E8F3E1",
|
---|
593 | "5 c #D4E9C7",
|
---|
594 | "6 c #74B748",
|
---|
595 | "7 c #80BE59",
|
---|
596 | "8 c #73B747",
|
---|
597 | "9 c #6DB43F",
|
---|
598 | "0 c #CBE4BA",
|
---|
599 | "a c #80BD58",
|
---|
600 | "b c #6DB33F",
|
---|
601 | "c c #FEFFFE",
|
---|
602 | "d c #68B138",
|
---|
603 | "e c #F9FCF7",
|
---|
604 | "f c #91C66F",
|
---|
605 | "g c #E8F3E0",
|
---|
606 | "h c #DCEDD0",
|
---|
607 | "i c #91C66E",
|
---|
608 | "j c #A3CF86",
|
---|
609 | "k c #C9E3B8",
|
---|
610 | "l c #B0D697",
|
---|
611 | "m c #E3F0DA",
|
---|
612 | "n c #95C873",
|
---|
613 | "o c #E6F2DE",
|
---|
614 | "p c #9ECD80",
|
---|
615 | "q c #BEDEAA",
|
---|
616 | "r c #C7E2B6",
|
---|
617 | "s c #79BA4F",
|
---|
618 | "t c #6EB441",
|
---|
619 | "u c #BCDCA7",
|
---|
620 | "v c #FAFCF8",
|
---|
621 | "w c #F6FAF3",
|
---|
622 | "x c #84BF5D",
|
---|
623 | "y c #EDF6E7",
|
---|
624 | "z c #FAFDF9",
|
---|
625 | "A c #88C263",
|
---|
626 | "B c #98CA77",
|
---|
627 | "C c #CDE5BE",
|
---|
628 | "D c #67B037",
|
---|
629 | "E c #D9EBCD",
|
---|
630 | "F c #6AB23C",
|
---|
631 | "G c #77B94D",
|
---|
632 | " .++++++++++++++",
|
---|
633 | ".+++++++++++++++",
|
---|
634 | "+++@#$%&+++*=+++",
|
---|
635 | "++-;>,>')+!>~+++",
|
---|
636 | "++{>]+^>/(_>:~<+",
|
---|
637 | "+[>>}+|>123>456+",
|
---|
638 | "+7>>8+->>90>~+++",
|
---|
639 | "+a>>b+a>c[0>~+++",
|
---|
640 | "+de>=+f>g+0>~+++",
|
---|
641 | "++h>i+j>k+0>~+++",
|
---|
642 | "++l>mno>p+q>rst+",
|
---|
643 | "++duv>wl++xy>zA+",
|
---|
644 | "++++B>Cb++++&D++",
|
---|
645 | "+++++0zE++++++++",
|
---|
646 | "++++++FG+++++++.",
|
---|
647 | "++++++++++++++. "};
|
---|
648 |
|
---|
649 | static const char * const qt_close_xpm[] = {
|
---|
650 | "10 10 2 1",
|
---|
651 | "# c #000000",
|
---|
652 | ". c None",
|
---|
653 | "..........",
|
---|
654 | ".##....##.",
|
---|
655 | "..##..##..",
|
---|
656 | "...####...",
|
---|
657 | "....##....",
|
---|
658 | "...####...",
|
---|
659 | "..##..##..",
|
---|
660 | ".##....##.",
|
---|
661 | "..........",
|
---|
662 | ".........."};
|
---|
663 |
|
---|
664 | static const char * const qt_maximize_xpm[]={
|
---|
665 | "10 10 2 1",
|
---|
666 | "# c #000000",
|
---|
667 | ". c None",
|
---|
668 | "#########.",
|
---|
669 | "#########.",
|
---|
670 | "#.......#.",
|
---|
671 | "#.......#.",
|
---|
672 | "#.......#.",
|
---|
673 | "#.......#.",
|
---|
674 | "#.......#.",
|
---|
675 | "#.......#.",
|
---|
676 | "#########.",
|
---|
677 | ".........."};
|
---|
678 |
|
---|
679 | static const char * const qt_minimize_xpm[] = {
|
---|
680 | "10 10 2 1",
|
---|
681 | "# c #000000",
|
---|
682 | ". c None",
|
---|
683 | "..........",
|
---|
684 | "..........",
|
---|
685 | "..........",
|
---|
686 | "..........",
|
---|
687 | "..........",
|
---|
688 | "..........",
|
---|
689 | "..........",
|
---|
690 | ".#######..",
|
---|
691 | ".#######..",
|
---|
692 | ".........."};
|
---|
693 |
|
---|
694 | static const char * const qt_normalizeup_xpm[] = {
|
---|
695 | "10 10 2 1",
|
---|
696 | "# c #000000",
|
---|
697 | ". c None",
|
---|
698 | "...######.",
|
---|
699 | "...######.",
|
---|
700 | "...#....#.",
|
---|
701 | ".######.#.",
|
---|
702 | ".######.#.",
|
---|
703 | ".#....###.",
|
---|
704 | ".#....#...",
|
---|
705 | ".#....#...",
|
---|
706 | ".######...",
|
---|
707 | ".........."};
|
---|
708 |
|
---|
709 | static const char * const qt_help_xpm[] = {
|
---|
710 | "10 10 2 1",
|
---|
711 | ". c None",
|
---|
712 | "# c #000000",
|
---|
713 | "..........",
|
---|
714 | "..######..",
|
---|
715 | ".##....##.",
|
---|
716 | "......##..",
|
---|
717 | ".....##...",
|
---|
718 | "....##....",
|
---|
719 | "....##....",
|
---|
720 | "..........",
|
---|
721 | "....##....",
|
---|
722 | ".........."};
|
---|
723 |
|
---|
724 | static const char * const qt_shade_xpm[] = {
|
---|
725 | "10 10 2 1",
|
---|
726 | "# c #000000",
|
---|
727 | ". c None",
|
---|
728 | "..........",
|
---|
729 | "..........",
|
---|
730 | "..........",
|
---|
731 | "..........",
|
---|
732 | "....#.....",
|
---|
733 | "...###....",
|
---|
734 | "..#####...",
|
---|
735 | ".#######..",
|
---|
736 | "..........",
|
---|
737 | ".........."};
|
---|
738 |
|
---|
739 | static const char * const qt_unshade_xpm[] = {
|
---|
740 | "10 10 2 1",
|
---|
741 | "# c #000000",
|
---|
742 | ". c None",
|
---|
743 | "..........",
|
---|
744 | "..........",
|
---|
745 | "..........",
|
---|
746 | ".#######..",
|
---|
747 | "..#####...",
|
---|
748 | "...###....",
|
---|
749 | "....#.....",
|
---|
750 | "..........",
|
---|
751 | "..........",
|
---|
752 | ".........."};
|
---|
753 |
|
---|
754 | static const char * dock_widget_close_xpm[] = {
|
---|
755 | "8 8 2 1",
|
---|
756 | "# c #000000",
|
---|
757 | ". c None",
|
---|
758 | "........",
|
---|
759 | ".##..##.",
|
---|
760 | "..####..",
|
---|
761 | "...##...",
|
---|
762 | "..####..",
|
---|
763 | ".##..##.",
|
---|
764 | "........",
|
---|
765 | "........"};
|
---|
766 |
|
---|
767 | /* XPM */
|
---|
768 | static const char * const information_xpm[]={
|
---|
769 | "32 32 5 1",
|
---|
770 | ". c None",
|
---|
771 | "c c #000000",
|
---|
772 | "* c #999999",
|
---|
773 | "a c #ffffff",
|
---|
774 | "b c #0000ff",
|
---|
775 | "...........********.............",
|
---|
776 | "........***aaaaaaaa***..........",
|
---|
777 | "......**aaaaaaaaaaaaaa**........",
|
---|
778 | ".....*aaaaaaaaaaaaaaaaaa*.......",
|
---|
779 | "....*aaaaaaaabbbbaaaaaaaac......",
|
---|
780 | "...*aaaaaaaabbbbbbaaaaaaaac.....",
|
---|
781 | "..*aaaaaaaaabbbbbbaaaaaaaaac....",
|
---|
782 | ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
|
---|
783 | ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
|
---|
784 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
|
---|
785 | "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
|
---|
786 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
787 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
788 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
789 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
790 | "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
|
---|
791 | ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
|
---|
792 | ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
|
---|
793 | "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
|
---|
794 | "...caaaaaaabbbbbbbbbaaaaaac****.",
|
---|
795 | "....caaaaaaaaaaaaaaaaaaaac****..",
|
---|
796 | ".....caaaaaaaaaaaaaaaaaac****...",
|
---|
797 | "......ccaaaaaaaaaaaaaacc****....",
|
---|
798 | ".......*cccaaaaaaaaccc*****.....",
|
---|
799 | "........***cccaaaac*******......",
|
---|
800 | "..........****caaac*****........",
|
---|
801 | ".............*caaac**...........",
|
---|
802 | "...............caac**...........",
|
---|
803 | "................cac**...........",
|
---|
804 | ".................cc**...........",
|
---|
805 | "..................***...........",
|
---|
806 | "...................**..........."};
|
---|
807 | /* XPM */
|
---|
808 | static const char* const warning_xpm[]={
|
---|
809 | "32 32 4 1",
|
---|
810 | ". c None",
|
---|
811 | "a c #ffff00",
|
---|
812 | "* c #000000",
|
---|
813 | "b c #999999",
|
---|
814 | ".............***................",
|
---|
815 | "............*aaa*...............",
|
---|
816 | "...........*aaaaa*b.............",
|
---|
817 | "...........*aaaaa*bb............",
|
---|
818 | "..........*aaaaaaa*bb...........",
|
---|
819 | "..........*aaaaaaa*bb...........",
|
---|
820 | ".........*aaaaaaaaa*bb..........",
|
---|
821 | ".........*aaaaaaaaa*bb..........",
|
---|
822 | "........*aaaaaaaaaaa*bb.........",
|
---|
823 | "........*aaaa***aaaa*bb.........",
|
---|
824 | ".......*aaaa*****aaaa*bb........",
|
---|
825 | ".......*aaaa*****aaaa*bb........",
|
---|
826 | "......*aaaaa*****aaaaa*bb.......",
|
---|
827 | "......*aaaaa*****aaaaa*bb.......",
|
---|
828 | ".....*aaaaaa*****aaaaaa*bb......",
|
---|
829 | ".....*aaaaaa*****aaaaaa*bb......",
|
---|
830 | "....*aaaaaaaa***aaaaaaaa*bb.....",
|
---|
831 | "....*aaaaaaaa***aaaaaaaa*bb.....",
|
---|
832 | "...*aaaaaaaaa***aaaaaaaaa*bb....",
|
---|
833 | "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
|
---|
834 | "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
|
---|
835 | "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
|
---|
836 | ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
|
---|
837 | ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
|
---|
838 | "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
|
---|
839 | "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
|
---|
840 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
|
---|
841 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
|
---|
842 | ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
|
---|
843 | "..*************************bbbbb",
|
---|
844 | "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
|
---|
845 | ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
|
---|
846 | /* XPM */
|
---|
847 | static const char* const critical_xpm[]={
|
---|
848 | "32 32 4 1",
|
---|
849 | ". c None",
|
---|
850 | "a c #999999",
|
---|
851 | "* c #ff0000",
|
---|
852 | "b c #ffffff",
|
---|
853 | "...........********.............",
|
---|
854 | ".........************...........",
|
---|
855 | ".......****************.........",
|
---|
856 | "......******************........",
|
---|
857 | ".....********************a......",
|
---|
858 | "....**********************a.....",
|
---|
859 | "...************************a....",
|
---|
860 | "..*******b**********b*******a...",
|
---|
861 | "..******bbb********bbb******a...",
|
---|
862 | ".******bbbbb******bbbbb******a..",
|
---|
863 | ".*******bbbbb****bbbbb*******a..",
|
---|
864 | "*********bbbbb**bbbbb*********a.",
|
---|
865 | "**********bbbbbbbbbb**********a.",
|
---|
866 | "***********bbbbbbbb***********aa",
|
---|
867 | "************bbbbbb************aa",
|
---|
868 | "************bbbbbb************aa",
|
---|
869 | "***********bbbbbbbb***********aa",
|
---|
870 | "**********bbbbbbbbbb**********aa",
|
---|
871 | "*********bbbbb**bbbbb*********aa",
|
---|
872 | ".*******bbbbb****bbbbb*******aa.",
|
---|
873 | ".******bbbbb******bbbbb******aa.",
|
---|
874 | "..******bbb********bbb******aaa.",
|
---|
875 | "..*******b**********b*******aa..",
|
---|
876 | "...************************aaa..",
|
---|
877 | "....**********************aaa...",
|
---|
878 | "....a********************aaa....",
|
---|
879 | ".....a******************aaa.....",
|
---|
880 | "......a****************aaa......",
|
---|
881 | ".......aa************aaaa.......",
|
---|
882 | ".........aa********aaaaa........",
|
---|
883 | "...........aaaaaaaaaaa..........",
|
---|
884 | ".............aaaaaaa............"};
|
---|
885 | /* XPM */
|
---|
886 | static const char *const question_xpm[] = {
|
---|
887 | "32 32 5 1",
|
---|
888 | ". c None",
|
---|
889 | "c c #000000",
|
---|
890 | "* c #999999",
|
---|
891 | "a c #ffffff",
|
---|
892 | "b c #0000ff",
|
---|
893 | "...........********.............",
|
---|
894 | "........***aaaaaaaa***..........",
|
---|
895 | "......**aaaaaaaaaaaaaa**........",
|
---|
896 | ".....*aaaaaaaaaaaaaaaaaa*.......",
|
---|
897 | "....*aaaaaaaaaaaaaaaaaaaac......",
|
---|
898 | "...*aaaaaaaabbbbbbaaaaaaaac.....",
|
---|
899 | "..*aaaaaaaabaaabbbbaaaaaaaac....",
|
---|
900 | ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
|
---|
901 | ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
|
---|
902 | "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
|
---|
903 | "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
|
---|
904 | "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
|
---|
905 | "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
|
---|
906 | "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
|
---|
907 | "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
|
---|
908 | "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
|
---|
909 | ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
|
---|
910 | ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
|
---|
911 | "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
|
---|
912 | "...caaaaaaaaaabbaaaaaaaaaac****.",
|
---|
913 | "....caaaaaaaaaaaaaaaaaaaac****..",
|
---|
914 | ".....caaaaaaaaaaaaaaaaaac****...",
|
---|
915 | "......ccaaaaaaaaaaaaaacc****....",
|
---|
916 | ".......*cccaaaaaaaaccc*****.....",
|
---|
917 | "........***cccaaaac*******......",
|
---|
918 | "..........****caaac*****........",
|
---|
919 | ".............*caaac**...........",
|
---|
920 | "...............caac**...........",
|
---|
921 | "................cac**...........",
|
---|
922 | ".................cc**...........",
|
---|
923 | "..................***...........",
|
---|
924 | "...................**..........."};
|
---|
925 |
|
---|
926 | #endif //QT_NO_IMAGEFORMAT_XPM
|
---|
927 |
|
---|
928 | #ifdef Q_OS_WIN
|
---|
929 | static QPixmap loadIconFromShell32( int resourceId, int size )
|
---|
930 | {
|
---|
931 | #ifdef Q_OS_WINCE
|
---|
932 | HMODULE hmod = LoadLibrary(L"ceshell.dll");
|
---|
933 | #else
|
---|
934 | HMODULE hmod = LoadLibrary(L"shell32.dll");
|
---|
935 | #endif
|
---|
936 | if( hmod ) {
|
---|
937 | HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
|
---|
938 | if( iconHandle ) {
|
---|
939 | QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle );
|
---|
940 | DestroyIcon(iconHandle);
|
---|
941 | return iconpixmap;
|
---|
942 | }
|
---|
943 | }
|
---|
944 | return QPixmap();
|
---|
945 | }
|
---|
946 | #endif
|
---|
947 |
|
---|
948 | /*!
|
---|
949 | \reimp
|
---|
950 | */
|
---|
951 | QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
---|
952 | const QWidget *widget) const
|
---|
953 | {
|
---|
954 | #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
|
---|
955 | QPixmap desktopIcon;
|
---|
956 | switch(standardPixmap) {
|
---|
957 | case SP_DriveCDIcon:
|
---|
958 | case SP_DriveDVDIcon:
|
---|
959 | {
|
---|
960 | desktopIcon = loadIconFromShell32(12, 16);
|
---|
961 | break;
|
---|
962 | }
|
---|
963 | case SP_DriveNetIcon:
|
---|
964 | {
|
---|
965 | desktopIcon = loadIconFromShell32(10, 16);
|
---|
966 | break;
|
---|
967 | }
|
---|
968 | case SP_DriveHDIcon:
|
---|
969 | {
|
---|
970 | desktopIcon = loadIconFromShell32(9, 16);
|
---|
971 | break;
|
---|
972 | }
|
---|
973 | case SP_DriveFDIcon:
|
---|
974 | {
|
---|
975 | desktopIcon = loadIconFromShell32(7, 16);
|
---|
976 | break;
|
---|
977 | }
|
---|
978 | case SP_FileIcon:
|
---|
979 | {
|
---|
980 | desktopIcon = loadIconFromShell32(1, 16);
|
---|
981 | break;
|
---|
982 | }
|
---|
983 | case SP_FileLinkIcon:
|
---|
984 | {
|
---|
985 | desktopIcon = loadIconFromShell32(1, 16);
|
---|
986 | QPainter painter(&desktopIcon);
|
---|
987 | QPixmap link = loadIconFromShell32(30, 16);
|
---|
988 | painter.drawPixmap(0, 0, 16, 16, link);
|
---|
989 | break;
|
---|
990 | }
|
---|
991 | case SP_DirLinkIcon:
|
---|
992 | {
|
---|
993 | desktopIcon = loadIconFromShell32(4, 16);
|
---|
994 | QPainter painter(&desktopIcon);
|
---|
995 | QPixmap link = loadIconFromShell32(30, 16);
|
---|
996 | painter.drawPixmap(0, 0, 16, 16, link);
|
---|
997 | break;
|
---|
998 | }
|
---|
999 | case SP_DirClosedIcon:
|
---|
1000 | {
|
---|
1001 | desktopIcon = loadIconFromShell32(4, 16);
|
---|
1002 | break;
|
---|
1003 | }
|
---|
1004 | case SP_DesktopIcon:
|
---|
1005 | {
|
---|
1006 | desktopIcon = loadIconFromShell32(35, 16);
|
---|
1007 | break;
|
---|
1008 | }
|
---|
1009 | case SP_ComputerIcon:
|
---|
1010 | {
|
---|
1011 | desktopIcon = loadIconFromShell32(16, 16);
|
---|
1012 | break;
|
---|
1013 | }
|
---|
1014 | case SP_DirOpenIcon:
|
---|
1015 | {
|
---|
1016 | desktopIcon = loadIconFromShell32(5, 16);
|
---|
1017 | break;
|
---|
1018 | }
|
---|
1019 | case SP_FileDialogNewFolder:
|
---|
1020 | {
|
---|
1021 | desktopIcon = loadIconFromShell32(319, 16);
|
---|
1022 | break;
|
---|
1023 | }
|
---|
1024 | case SP_DirHomeIcon:
|
---|
1025 | {
|
---|
1026 | desktopIcon = loadIconFromShell32(235, 16);
|
---|
1027 | break;
|
---|
1028 | }
|
---|
1029 | case SP_TrashIcon:
|
---|
1030 | {
|
---|
1031 | desktopIcon = loadIconFromShell32(191, 16);
|
---|
1032 | break;
|
---|
1033 | }
|
---|
1034 | case SP_MessageBoxInformation:
|
---|
1035 | {
|
---|
1036 | HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
|
---|
1037 | desktopIcon = QPixmap::fromWinHICON( iconHandle );
|
---|
1038 | DestroyIcon(iconHandle);
|
---|
1039 | break;
|
---|
1040 | }
|
---|
1041 | case SP_MessageBoxWarning:
|
---|
1042 | {
|
---|
1043 | HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
|
---|
1044 | desktopIcon = QPixmap::fromWinHICON( iconHandle );
|
---|
1045 | DestroyIcon(iconHandle);
|
---|
1046 | break;
|
---|
1047 | }
|
---|
1048 | case SP_MessageBoxCritical:
|
---|
1049 | {
|
---|
1050 | HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
|
---|
1051 | desktopIcon = QPixmap::fromWinHICON( iconHandle );
|
---|
1052 | DestroyIcon(iconHandle);
|
---|
1053 | break;
|
---|
1054 | }
|
---|
1055 | case SP_MessageBoxQuestion:
|
---|
1056 | {
|
---|
1057 | HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
|
---|
1058 | desktopIcon = QPixmap::fromWinHICON( iconHandle );
|
---|
1059 | DestroyIcon(iconHandle);
|
---|
1060 | break;
|
---|
1061 | }
|
---|
1062 | case SP_VistaShield:
|
---|
1063 | {
|
---|
1064 | if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
|
---|
1065 | && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
|
---|
1066 | && pSHGetStockIconInfo)
|
---|
1067 | {
|
---|
1068 | QPixmap pixmap;
|
---|
1069 | QSHSTOCKICONINFO iconInfo;
|
---|
1070 | memset(&iconInfo, 0, sizeof(iconInfo));
|
---|
1071 | iconInfo.cbSize = sizeof(iconInfo);
|
---|
1072 | if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
|
---|
1073 | pixmap = QPixmap::fromWinHICON(iconInfo.hIcon);
|
---|
1074 | DestroyIcon(iconInfo.hIcon);
|
---|
1075 | return pixmap;
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 | break;
|
---|
1080 | default:
|
---|
1081 | break;
|
---|
1082 | }
|
---|
1083 | if (!desktopIcon.isNull()) {
|
---|
1084 | return desktopIcon;
|
---|
1085 | }
|
---|
1086 | #endif
|
---|
1087 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
---|
1088 | switch (standardPixmap) {
|
---|
1089 | case SP_TitleBarMenuButton:
|
---|
1090 | return QPixmap(qt_menu_xpm);
|
---|
1091 | case SP_TitleBarShadeButton:
|
---|
1092 | return QPixmap(qt_shade_xpm);
|
---|
1093 | case SP_TitleBarUnshadeButton:
|
---|
1094 | return QPixmap(qt_unshade_xpm);
|
---|
1095 | case SP_TitleBarNormalButton:
|
---|
1096 | return QPixmap(qt_normalizeup_xpm);
|
---|
1097 | case SP_TitleBarMinButton:
|
---|
1098 | return QPixmap(qt_minimize_xpm);
|
---|
1099 | case SP_TitleBarMaxButton:
|
---|
1100 | return QPixmap(qt_maximize_xpm);
|
---|
1101 | case SP_TitleBarCloseButton:
|
---|
1102 | return QPixmap(qt_close_xpm);
|
---|
1103 | case SP_TitleBarContextHelpButton:
|
---|
1104 | return QPixmap(qt_help_xpm);
|
---|
1105 | case SP_DockWidgetCloseButton:
|
---|
1106 | return QPixmap(dock_widget_close_xpm);
|
---|
1107 | case SP_MessageBoxInformation:
|
---|
1108 | return QPixmap(information_xpm);
|
---|
1109 | case SP_MessageBoxWarning:
|
---|
1110 | return QPixmap(warning_xpm);
|
---|
1111 | case SP_MessageBoxCritical:
|
---|
1112 | return QPixmap(critical_xpm);
|
---|
1113 | case SP_MessageBoxQuestion:
|
---|
1114 | return QPixmap(question_xpm);
|
---|
1115 | default:
|
---|
1116 | break;
|
---|
1117 | }
|
---|
1118 | #endif //QT_NO_IMAGEFORMAT_XPM
|
---|
1119 | return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | /*! \reimp */
|
---|
1123 | int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
|
---|
1124 | QStyleHintReturn *returnData) const
|
---|
1125 | {
|
---|
1126 | int ret = 0;
|
---|
1127 |
|
---|
1128 | switch (hint) {
|
---|
1129 | case SH_EtchDisabledText:
|
---|
1130 | case SH_Slider_SnapToValue:
|
---|
1131 | case SH_PrintDialog_RightAlignButtons:
|
---|
1132 | case SH_FontDialog_SelectAssociatedText:
|
---|
1133 | case SH_Menu_AllowActiveAndDisabled:
|
---|
1134 | case SH_MenuBar_AltKeyNavigation:
|
---|
1135 | case SH_MenuBar_MouseTracking:
|
---|
1136 | case SH_Menu_MouseTracking:
|
---|
1137 | case SH_ComboBox_ListMouseTracking:
|
---|
1138 | case SH_ScrollBar_StopMouseOverSlider:
|
---|
1139 | case SH_MainWindow_SpaceBelowMenuBar:
|
---|
1140 | ret = 1;
|
---|
1141 |
|
---|
1142 | break;
|
---|
1143 | case SH_ItemView_ShowDecorationSelected:
|
---|
1144 | #ifndef QT_NO_LISTVIEW
|
---|
1145 | if (qobject_cast<const QListView*>(widget))
|
---|
1146 | ret = 1;
|
---|
1147 | #endif
|
---|
1148 | break;
|
---|
1149 | case SH_ItemView_ChangeHighlightOnFocus:
|
---|
1150 | ret = 1;
|
---|
1151 | break;
|
---|
1152 | case SH_ToolBox_SelectedPageTitleBold:
|
---|
1153 | ret = 0;
|
---|
1154 | break;
|
---|
1155 |
|
---|
1156 | #if defined(Q_WS_WIN)
|
---|
1157 | case SH_UnderlineShortcut:
|
---|
1158 | {
|
---|
1159 | ret = 1;
|
---|
1160 | BOOL cues = false;
|
---|
1161 | SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
|
---|
1162 | ret = int(cues);
|
---|
1163 | // Do nothing if we always paint underlines
|
---|
1164 | Q_D(const QWindowsStyle);
|
---|
1165 | if (!ret && widget && d) {
|
---|
1166 | #ifndef QT_NO_MENUBAR
|
---|
1167 | const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
|
---|
1168 | if (!menuBar && qobject_cast<const QMenu *>(widget)) {
|
---|
1169 | QWidget *w = QApplication::activeWindow();
|
---|
1170 | if (w && w != widget)
|
---|
1171 | menuBar = qFindChild<QMenuBar *>(w);
|
---|
1172 | }
|
---|
1173 | // If we paint a menu bar draw underlines if is in the keyboardState
|
---|
1174 | if (menuBar) {
|
---|
1175 | if (menuBar->d_func()->keyboardState || d->altDown())
|
---|
1176 | ret = 1;
|
---|
1177 | // Otherwise draw underlines if the toplevel widget has seen an alt-press
|
---|
1178 | } else
|
---|
1179 | #endif // QT_NO_MENUBAR
|
---|
1180 | if (d->hasSeenAlt(widget)) {
|
---|
1181 | ret = 1;
|
---|
1182 | }
|
---|
1183 | }
|
---|
1184 | break;
|
---|
1185 | }
|
---|
1186 | #endif
|
---|
1187 | #ifndef QT_NO_RUBBERBAND
|
---|
1188 | case SH_RubberBand_Mask:
|
---|
1189 | if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
|
---|
1190 | ret = 0;
|
---|
1191 | if (rbOpt->shape == QRubberBand::Rectangle) {
|
---|
1192 | ret = true;
|
---|
1193 | if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
|
---|
1194 | mask->region = opt->rect;
|
---|
1195 | int size = 1;
|
---|
1196 | if (widget && widget->isWindow())
|
---|
1197 | size = 4;
|
---|
1198 | mask->region -= opt->rect.adjusted(size, size, -size, -size);
|
---|
1199 | }
|
---|
1200 | }
|
---|
1201 | }
|
---|
1202 | break;
|
---|
1203 | #endif // QT_NO_RUBBERBAND
|
---|
1204 | case SH_LineEdit_PasswordCharacter:
|
---|
1205 | {
|
---|
1206 | #ifdef Q_WS_WIN
|
---|
1207 | if (widget && (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
|
---|
1208 | const QFontMetrics &fm = widget->fontMetrics();
|
---|
1209 | if (fm.inFont(QChar(0x25CF)))
|
---|
1210 | ret = 0x25CF;
|
---|
1211 | else if (fm.inFont(QChar(0x2022)))
|
---|
1212 | ret = 0x2022;
|
---|
1213 | }
|
---|
1214 | #endif
|
---|
1215 | if (!ret)
|
---|
1216 | ret = '*';
|
---|
1217 | }
|
---|
1218 | break;
|
---|
1219 | #ifndef QT_NO_WIZARD
|
---|
1220 | case SH_WizardStyle:
|
---|
1221 | ret = QWizard::ModernStyle;
|
---|
1222 | break;
|
---|
1223 | #endif
|
---|
1224 | case SH_ItemView_ArrowKeysNavigateIntoChildren:
|
---|
1225 | ret = true;
|
---|
1226 | break;
|
---|
1227 | case SH_DialogButtonBox_ButtonsHaveIcons:
|
---|
1228 | ret = 0;
|
---|
1229 | break;
|
---|
1230 | default:
|
---|
1231 | ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
|
---|
1232 | break;
|
---|
1233 | }
|
---|
1234 | return ret;
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | /*! \reimp */
|
---|
1238 | void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
|
---|
1239 | const QWidget *w) const
|
---|
1240 | {
|
---|
1241 | // Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
|
---|
1242 | bool doRestore = false;
|
---|
1243 |
|
---|
1244 | switch (pe) {
|
---|
1245 | #ifndef QT_NO_TOOLBAR
|
---|
1246 | case PE_IndicatorToolBarSeparator:
|
---|
1247 | {
|
---|
1248 | QRect rect = opt->rect;
|
---|
1249 | const int margin = 2;
|
---|
1250 | QPen oldPen = p->pen();
|
---|
1251 | if(opt->state & State_Horizontal){
|
---|
1252 | const int offset = rect.width()/2;
|
---|
1253 | p->setPen(QPen(opt->palette.dark().color()));
|
---|
1254 | p->drawLine(rect.bottomLeft().x() + offset,
|
---|
1255 | rect.bottomLeft().y() - margin,
|
---|
1256 | rect.topLeft().x() + offset,
|
---|
1257 | rect.topLeft().y() + margin);
|
---|
1258 | p->setPen(QPen(opt->palette.light().color()));
|
---|
1259 | p->drawLine(rect.bottomLeft().x() + offset + 1,
|
---|
1260 | rect.bottomLeft().y() - margin,
|
---|
1261 | rect.topLeft().x() + offset + 1,
|
---|
1262 | rect.topLeft().y() + margin);
|
---|
1263 | }
|
---|
1264 | else{ //Draw vertical separator
|
---|
1265 | const int offset = rect.height()/2;
|
---|
1266 | p->setPen(QPen(opt->palette.dark().color()));
|
---|
1267 | p->drawLine(rect.topLeft().x() + margin ,
|
---|
1268 | rect.topLeft().y() + offset,
|
---|
1269 | rect.topRight().x() - margin,
|
---|
1270 | rect.topRight().y() + offset);
|
---|
1271 | p->setPen(QPen(opt->palette.light().color()));
|
---|
1272 | p->drawLine(rect.topLeft().x() + margin ,
|
---|
1273 | rect.topLeft().y() + offset + 1,
|
---|
1274 | rect.topRight().x() - margin,
|
---|
1275 | rect.topRight().y() + offset + 1);
|
---|
1276 | }
|
---|
1277 | p->setPen(oldPen);
|
---|
1278 | }
|
---|
1279 | break;
|
---|
1280 | case PE_IndicatorToolBarHandle:
|
---|
1281 | p->save();
|
---|
1282 | p->translate(opt->rect.x(), opt->rect.y());
|
---|
1283 | if (opt->state & State_Horizontal) {
|
---|
1284 | int x = opt->rect.width() / 2 - 4;
|
---|
1285 | if (opt->direction == Qt::RightToLeft)
|
---|
1286 | x -= 2;
|
---|
1287 | if (opt->rect.height() > 4) {
|
---|
1288 | qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
|
---|
1289 | opt->palette, false, 1, 0);
|
---|
1290 | qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
|
---|
1291 | opt->palette, false, 1, 0);
|
---|
1292 | }
|
---|
1293 | } else {
|
---|
1294 | if (opt->rect.width() > 4) {
|
---|
1295 | int y = opt->rect.height() / 2 - 4;
|
---|
1296 | qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
|
---|
1297 | opt->palette, false, 1, 0);
|
---|
1298 | qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
|
---|
1299 | opt->palette, false, 1, 0);
|
---|
1300 | }
|
---|
1301 | }
|
---|
1302 | p->restore();
|
---|
1303 | break;
|
---|
1304 |
|
---|
1305 | #endif // QT_NO_TOOLBAR
|
---|
1306 | case PE_FrameButtonTool:
|
---|
1307 | case PE_PanelButtonTool: {
|
---|
1308 | QPen oldPen = p->pen();
|
---|
1309 | #ifndef QT_NO_DOCKWIDGET
|
---|
1310 | if (w && w->inherits("QDockWidgetTitleButton")) {
|
---|
1311 | if (const QWidget *dw = w->parentWidget())
|
---|
1312 | if (dw->isWindow()){
|
---|
1313 | qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
|
---|
1314 | &opt->palette.button());
|
---|
1315 |
|
---|
1316 | return;
|
---|
1317 | }
|
---|
1318 | }
|
---|
1319 | #endif // QT_NO_DOCKWIDGET
|
---|
1320 | QBrush fill;
|
---|
1321 | bool stippled;
|
---|
1322 | bool panel = (pe == PE_PanelButtonTool);
|
---|
1323 | if ((!(opt->state & State_Sunken ))
|
---|
1324 | && (!(opt->state & State_Enabled)
|
---|
1325 | || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
|
---|
1326 | && (opt->state & State_On)) {
|
---|
1327 | fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
|
---|
1328 | stippled = true;
|
---|
1329 | } else {
|
---|
1330 | fill = opt->palette.brush(QPalette::Button);
|
---|
1331 | stippled = false;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | if (opt->state & (State_Raised | State_Sunken | State_On)) {
|
---|
1335 | if (opt->state & State_AutoRaise) {
|
---|
1336 | if(opt->state & (State_Enabled | State_Sunken | State_On)){
|
---|
1337 | if (panel)
|
---|
1338 | qDrawShadePanel(p, opt->rect, opt->palette,
|
---|
1339 | opt->state & (State_Sunken | State_On), 1, &fill);
|
---|
1340 | else
|
---|
1341 | qDrawShadeRect(p, opt->rect, opt->palette,
|
---|
1342 | opt->state & (State_Sunken | State_On), 1);
|
---|
1343 | }
|
---|
1344 | if (stippled) {
|
---|
1345 | p->setPen(opt->palette.button().color());
|
---|
1346 | p->drawRect(opt->rect.adjusted(1,1,-2,-2));
|
---|
1347 | }
|
---|
1348 | } else {
|
---|
1349 | qDrawWinButton(p, opt->rect, opt->palette,
|
---|
1350 | opt->state & (State_Sunken | State_On), panel ? &fill : 0);
|
---|
1351 | }
|
---|
1352 | } else {
|
---|
1353 | p->fillRect(opt->rect, fill);
|
---|
1354 | }
|
---|
1355 | p->setPen(oldPen);
|
---|
1356 | break; }
|
---|
1357 | case PE_PanelButtonCommand:
|
---|
1358 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
|
---|
1359 | QBrush fill;
|
---|
1360 | State flags = opt->state;
|
---|
1361 | QPalette pal = opt->palette;
|
---|
1362 | QRect r = opt->rect;
|
---|
1363 | if (! (flags & State_Sunken) && (flags & State_On))
|
---|
1364 | fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
|
---|
1365 | else
|
---|
1366 | fill = pal.brush(QPalette::Button);
|
---|
1367 |
|
---|
1368 | if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
|
---|
1369 | p->setPen(pal.dark().color());
|
---|
1370 | p->setBrush(fill);
|
---|
1371 | p->drawRect(r.adjusted(0, 0, -1, -1));
|
---|
1372 | } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
|
---|
1373 | qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
|
---|
1374 | &fill);
|
---|
1375 | } else {
|
---|
1376 | p->fillRect(r, fill);
|
---|
1377 | }
|
---|
1378 | }
|
---|
1379 | break;
|
---|
1380 | case PE_FrameDefaultButton: {
|
---|
1381 | QPen oldPen = p->pen();
|
---|
1382 | p->setPen(opt->palette.shadow().color());
|
---|
1383 | QRect rect = opt->rect;
|
---|
1384 | rect.adjust(0, 0, -1, -1);
|
---|
1385 | p->drawRect(rect);
|
---|
1386 | p->setPen(oldPen);
|
---|
1387 | break;
|
---|
1388 | }
|
---|
1389 | case PE_IndicatorArrowUp:
|
---|
1390 | case PE_IndicatorArrowDown:
|
---|
1391 | case PE_IndicatorArrowRight:
|
---|
1392 | case PE_IndicatorArrowLeft:
|
---|
1393 | {
|
---|
1394 | if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
|
---|
1395 | break;
|
---|
1396 | QRect r = opt->rect;
|
---|
1397 | int size = qMin(r.height(), r.width());
|
---|
1398 | QPixmap pixmap;
|
---|
1399 | QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size))
|
---|
1400 | + QLatin1Char('-') + QString::number(pe);
|
---|
1401 | if (!QPixmapCache::find(pixmapName, pixmap)) {
|
---|
1402 | int border = size/5;
|
---|
1403 | int sqsize = 2*(size/2);
|
---|
1404 | QImage image(sqsize, sqsize, QImage::Format_ARGB32);
|
---|
1405 | image.fill(Qt::transparent);
|
---|
1406 | QPainter imagePainter(&image);
|
---|
1407 |
|
---|
1408 | QPolygon a;
|
---|
1409 | switch (pe) {
|
---|
1410 | case PE_IndicatorArrowUp:
|
---|
1411 | a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
|
---|
1412 | break;
|
---|
1413 | case PE_IndicatorArrowDown:
|
---|
1414 | a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
|
---|
1415 | break;
|
---|
1416 | case PE_IndicatorArrowRight:
|
---|
1417 | a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
|
---|
1418 | break;
|
---|
1419 | case PE_IndicatorArrowLeft:
|
---|
1420 | a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
|
---|
1421 | break;
|
---|
1422 | default:
|
---|
1423 | break;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | int bsx = 0;
|
---|
1427 | int bsy = 0;
|
---|
1428 |
|
---|
1429 | if (opt->state & State_Sunken) {
|
---|
1430 | bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
|
---|
1431 | bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | QRect bounds = a.boundingRect();
|
---|
1435 | int sx = sqsize / 2 - bounds.center().x() - 1;
|
---|
1436 | int sy = sqsize / 2 - bounds.center().y() - 1;
|
---|
1437 | imagePainter.translate(sx + bsx, sy + bsy);
|
---|
1438 | imagePainter.setPen(opt->palette.buttonText().color());
|
---|
1439 | imagePainter.setBrush(opt->palette.buttonText());
|
---|
1440 |
|
---|
1441 | if (!(opt->state & State_Enabled)) {
|
---|
1442 | imagePainter.translate(1, 1);
|
---|
1443 | imagePainter.setBrush(opt->palette.light().color());
|
---|
1444 | imagePainter.setPen(opt->palette.light().color());
|
---|
1445 | imagePainter.drawPolygon(a);
|
---|
1446 | imagePainter.translate(-1, -1);
|
---|
1447 | imagePainter.setBrush(opt->palette.mid().color());
|
---|
1448 | imagePainter.setPen(opt->palette.mid().color());
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | imagePainter.drawPolygon(a);
|
---|
1452 | imagePainter.end();
|
---|
1453 | pixmap = QPixmap::fromImage(image);
|
---|
1454 | QPixmapCache::insert(pixmapName, pixmap);
|
---|
1455 | }
|
---|
1456 | int xOffset = r.x() + (r.width() - size)/2;
|
---|
1457 | int yOffset = r.y() + (r.height() - size)/2;
|
---|
1458 | p->drawPixmap(xOffset, yOffset, pixmap);
|
---|
1459 | }
|
---|
1460 | break;
|
---|
1461 | case PE_IndicatorCheckBox: {
|
---|
1462 | QBrush fill;
|
---|
1463 | if (opt->state & State_NoChange)
|
---|
1464 | fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
|
---|
1465 | else if (opt->state & State_Sunken)
|
---|
1466 | fill = opt->palette.button();
|
---|
1467 | else if (opt->state & State_Enabled)
|
---|
1468 | fill = opt->palette.base();
|
---|
1469 | else
|
---|
1470 | fill = opt->palette.background();
|
---|
1471 | p->save();
|
---|
1472 | doRestore = true;
|
---|
1473 | qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
|
---|
1474 | if (opt->state & State_NoChange)
|
---|
1475 | p->setPen(opt->palette.dark().color());
|
---|
1476 | else
|
---|
1477 | p->setPen(opt->palette.text().color());
|
---|
1478 | } // Fall through!
|
---|
1479 | case PE_IndicatorViewItemCheck:
|
---|
1480 | case PE_Q3CheckListIndicator:
|
---|
1481 | if (!doRestore) {
|
---|
1482 | p->save();
|
---|
1483 | doRestore = true;
|
---|
1484 | }
|
---|
1485 | if (pe == PE_Q3CheckListIndicator || pe == PE_IndicatorViewItemCheck) {
|
---|
1486 | const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
|
---|
1487 | p->setPen(itemViewOpt
|
---|
1488 | && itemViewOpt->showDecorationSelected
|
---|
1489 | && opt->state & State_Selected
|
---|
1490 | ? opt->palette.highlightedText().color()
|
---|
1491 | : opt->palette.text().color());
|
---|
1492 | if (opt->state & State_NoChange)
|
---|
1493 | p->setBrush(opt->palette.brush(QPalette::Button));
|
---|
1494 | p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
|
---|
1495 | }
|
---|
1496 | if (!(opt->state & State_Off)) {
|
---|
1497 | QLineF lines[7];
|
---|
1498 | int i, xx, yy;
|
---|
1499 | xx = opt->rect.x() + 3;
|
---|
1500 | yy = opt->rect.y() + 5;
|
---|
1501 | for (i = 0; i < 3; ++i) {
|
---|
1502 | lines[i] = QLineF(xx, yy, xx, yy + 2);
|
---|
1503 | ++xx;
|
---|
1504 | ++yy;
|
---|
1505 | }
|
---|
1506 | yy -= 2;
|
---|
1507 | for (i = 3; i < 7; ++i) {
|
---|
1508 | lines[i] = QLineF(xx, yy, xx, yy + 2);
|
---|
1509 | ++xx;
|
---|
1510 | --yy;
|
---|
1511 | }
|
---|
1512 | p->drawLines(lines, 7);
|
---|
1513 | }
|
---|
1514 | if (doRestore)
|
---|
1515 | p->restore();
|
---|
1516 | break;
|
---|
1517 | case PE_FrameFocusRect:
|
---|
1518 | if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
|
---|
1519 | //### check for d->alt_down
|
---|
1520 | if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
|
---|
1521 | return;
|
---|
1522 | QRect r = opt->rect;
|
---|
1523 | p->save();
|
---|
1524 | p->setBackgroundMode(Qt::TransparentMode);
|
---|
1525 | QColor bg_col = fropt->backgroundColor;
|
---|
1526 | if (!bg_col.isValid())
|
---|
1527 | bg_col = p->background().color();
|
---|
1528 | // Create an "XOR" color.
|
---|
1529 | QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
|
---|
1530 | (bg_col.green() ^ 0xff) & 0xff,
|
---|
1531 | (bg_col.blue() ^ 0xff) & 0xff);
|
---|
1532 | p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
|
---|
1533 | p->setBrushOrigin(r.topLeft());
|
---|
1534 | p->setPen(Qt::NoPen);
|
---|
1535 | p->drawRect(r.left(), r.top(), r.width(), 1); // Top
|
---|
1536 | p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
|
---|
1537 | p->drawRect(r.left(), r.top(), 1, r.height()); // Left
|
---|
1538 | p->drawRect(r.right(), r.top(), 1, r.height()); // Right
|
---|
1539 | p->restore();
|
---|
1540 | }
|
---|
1541 | break;
|
---|
1542 | case PE_IndicatorRadioButton:
|
---|
1543 | {
|
---|
1544 | #define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
|
---|
1545 | static const QPoint pts1[] = { // dark lines
|
---|
1546 | QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
|
---|
1547 | QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
|
---|
1548 | };
|
---|
1549 | static const QPoint pts2[] = { // black lines
|
---|
1550 | QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
|
---|
1551 | QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
|
---|
1552 | };
|
---|
1553 | static const QPoint pts3[] = { // background lines
|
---|
1554 | QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
|
---|
1555 | QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
|
---|
1556 | };
|
---|
1557 | static const QPoint pts4[] = { // white lines
|
---|
1558 | QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
|
---|
1559 | QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
|
---|
1560 | QPoint(10, 3), QPoint(10, 2)
|
---|
1561 | };
|
---|
1562 | static const QPoint pts5[] = { // inner fill
|
---|
1563 | QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
|
---|
1564 | QPoint(2, 7), QPoint(2, 4)
|
---|
1565 | };
|
---|
1566 |
|
---|
1567 | // make sure the indicator is square
|
---|
1568 | QRect ir = opt->rect;
|
---|
1569 |
|
---|
1570 | if (opt->rect.width() < opt->rect.height()) {
|
---|
1571 | ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
|
---|
1572 | ir.setHeight(opt->rect.width());
|
---|
1573 | } else if (opt->rect.height() < opt->rect.width()) {
|
---|
1574 | ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
|
---|
1575 | ir.setWidth(opt->rect.height());
|
---|
1576 | }
|
---|
1577 |
|
---|
1578 | p->save();
|
---|
1579 | bool down = opt->state & State_Sunken;
|
---|
1580 | bool enabled = opt->state & State_Enabled;
|
---|
1581 | bool on = opt->state & State_On;
|
---|
1582 | QPolygon a;
|
---|
1583 |
|
---|
1584 | //center when rect is larger than indicator size
|
---|
1585 | int xOffset = 0;
|
---|
1586 | int yOffset = 0;
|
---|
1587 | int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
|
---|
1588 | int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
|
---|
1589 | if (ir.width() > indicatorWidth)
|
---|
1590 | xOffset += (ir.width() - indicatorWidth)/2;
|
---|
1591 | if (ir.height() > indicatorHeight)
|
---|
1592 | yOffset += (ir.height() - indicatorHeight)/2;
|
---|
1593 | p->translate(xOffset, yOffset);
|
---|
1594 |
|
---|
1595 | p->translate(ir.x(), ir.y());
|
---|
1596 |
|
---|
1597 | p->setPen(opt->palette.dark().color());
|
---|
1598 | p->drawPolyline(pts1, PTSARRLEN(pts1));
|
---|
1599 |
|
---|
1600 | p->setPen(opt->palette.shadow().color());
|
---|
1601 | p->drawPolyline(pts2, PTSARRLEN(pts2));
|
---|
1602 |
|
---|
1603 | p->setPen(opt->palette.midlight().color());
|
---|
1604 | p->drawPolyline(pts3, PTSARRLEN(pts3));
|
---|
1605 |
|
---|
1606 | p->setPen(opt->palette.light().color());
|
---|
1607 | p->drawPolyline(pts4, PTSARRLEN(pts4));
|
---|
1608 |
|
---|
1609 | QColor fillColor = (down || !enabled)
|
---|
1610 | ? opt->palette.button().color()
|
---|
1611 | : opt->palette.base().color();
|
---|
1612 | p->setPen(fillColor);
|
---|
1613 | p->setBrush(fillColor) ;
|
---|
1614 | p->drawPolygon(pts5, PTSARRLEN(pts5));
|
---|
1615 |
|
---|
1616 | p->translate(-ir.x(), -ir.y()); // restore translate
|
---|
1617 |
|
---|
1618 | if (on) {
|
---|
1619 | p->setPen(Qt::NoPen);
|
---|
1620 | p->setBrush(opt->palette.text());
|
---|
1621 | p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
|
---|
1622 | p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
|
---|
1623 | }
|
---|
1624 | p->restore();
|
---|
1625 | break;
|
---|
1626 | }
|
---|
1627 | #ifndef QT_NO_FRAME
|
---|
1628 | case PE_Frame:
|
---|
1629 | case PE_FrameMenu:
|
---|
1630 | if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
---|
1631 | if (frame->lineWidth == 2 || pe == PE_Frame) {
|
---|
1632 | QPalette popupPal = frame->palette;
|
---|
1633 | if (pe == PE_FrameMenu) {
|
---|
1634 | popupPal.setColor(QPalette::Light, frame->palette.background().color());
|
---|
1635 | popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
|
---|
1636 | }
|
---|
1637 | if (pe == PE_Frame && (frame->state & State_Raised))
|
---|
1638 | qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
|
---|
1639 | else if (pe == PE_Frame && (frame->state & State_Sunken))
|
---|
1640 | {
|
---|
1641 | popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
|
---|
1642 | qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
|
---|
1643 | }
|
---|
1644 | else
|
---|
1645 | qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
|
---|
1646 | } else {
|
---|
1647 | QCommonStyle::drawPrimitive(pe, opt, p, w);
|
---|
1648 | }
|
---|
1649 | } else {
|
---|
1650 | QPalette popupPal = opt->palette;
|
---|
1651 | popupPal.setColor(QPalette::Light, opt->palette.background().color());
|
---|
1652 | popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
|
---|
1653 | qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
|
---|
1654 | }
|
---|
1655 | break;
|
---|
1656 | #endif // QT_NO_FRAME
|
---|
1657 | case PE_IndicatorBranch: {
|
---|
1658 | // This is _way_ too similar to the common style.
|
---|
1659 | static const int decoration_size = 9;
|
---|
1660 | int mid_h = opt->rect.x() + opt->rect.width() / 2;
|
---|
1661 | int mid_v = opt->rect.y() + opt->rect.height() / 2;
|
---|
1662 | int bef_h = mid_h;
|
---|
1663 | int bef_v = mid_v;
|
---|
1664 | int aft_h = mid_h;
|
---|
1665 | int aft_v = mid_v;
|
---|
1666 | if (opt->state & State_Children) {
|
---|
1667 | int delta = decoration_size / 2;
|
---|
1668 | bef_h -= delta;
|
---|
1669 | bef_v -= delta;
|
---|
1670 | aft_h += delta;
|
---|
1671 | aft_v += delta;
|
---|
1672 | p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
|
---|
1673 | if (!(opt->state & State_Open))
|
---|
1674 | p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
|
---|
1675 | QPen oldPen = p->pen();
|
---|
1676 | p->setPen(opt->palette.dark().color());
|
---|
1677 | p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
|
---|
1678 | p->setPen(oldPen);
|
---|
1679 | }
|
---|
1680 | QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
|
---|
1681 | if (opt->state & State_Item) {
|
---|
1682 | if (opt->direction == Qt::RightToLeft)
|
---|
1683 | p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
|
---|
1684 | else
|
---|
1685 | p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
|
---|
1686 | }
|
---|
1687 | if (opt->state & State_Sibling)
|
---|
1688 | p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
|
---|
1689 | if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))
|
---|
1690 | p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
|
---|
1691 | break; }
|
---|
1692 | case PE_FrameButtonBevel:
|
---|
1693 | case PE_PanelButtonBevel: {
|
---|
1694 | QBrush fill;
|
---|
1695 | bool panel = pe != PE_FrameButtonBevel;
|
---|
1696 | p->setBrushOrigin(opt->rect.topLeft());
|
---|
1697 | if (!(opt->state & State_Sunken) && (opt->state & State_On))
|
---|
1698 | fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
|
---|
1699 | else
|
---|
1700 | fill = opt->palette.brush(QPalette::Button);
|
---|
1701 |
|
---|
1702 | if (opt->state & (State_Raised | State_On | State_Sunken)) {
|
---|
1703 | qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
|
---|
1704 | panel ? &fill : 0);
|
---|
1705 | } else {
|
---|
1706 | if (panel)
|
---|
1707 | p->fillRect(opt->rect, fill);
|
---|
1708 | else
|
---|
1709 | p->drawRect(opt->rect);
|
---|
1710 | }
|
---|
1711 | break; }
|
---|
1712 | case PE_FrameWindow: {
|
---|
1713 | QPalette popupPal = opt->palette;
|
---|
1714 | popupPal.setColor(QPalette::Light, opt->palette.background().color());
|
---|
1715 | popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
|
---|
1716 | qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
|
---|
1717 | break; }
|
---|
1718 | #ifndef QT_NO_DOCKWIDGET
|
---|
1719 | case PE_IndicatorDockWidgetResizeHandle: {
|
---|
1720 | QPen oldPen = p->pen();
|
---|
1721 | p->setPen(opt->palette.light().color());
|
---|
1722 | if (opt->state & State_Horizontal) {
|
---|
1723 | p->drawLine(opt->rect.left(), opt->rect.top(),
|
---|
1724 | opt->rect.right(), opt->rect.top());
|
---|
1725 | p->setPen(opt->palette.dark().color());
|
---|
1726 | p->drawLine(opt->rect.left(), opt->rect.bottom() - 1,
|
---|
1727 | opt->rect.right(), opt->rect.bottom() - 1);
|
---|
1728 | p->setPen(opt->palette.shadow().color());
|
---|
1729 | p->drawLine(opt->rect.left(), opt->rect.bottom(),
|
---|
1730 | opt->rect.right(), opt->rect.bottom());
|
---|
1731 | } else {
|
---|
1732 | p->drawLine(opt->rect.left(), opt->rect.top(),
|
---|
1733 | opt->rect.left(), opt->rect.bottom());
|
---|
1734 | p->setPen(opt->palette.dark().color());
|
---|
1735 | p->drawLine(opt->rect.right() - 1, opt->rect.top(),
|
---|
1736 | opt->rect.right() - 1, opt->rect.bottom());
|
---|
1737 | p->setPen(opt->palette.shadow().color());
|
---|
1738 | p->drawLine(opt->rect.right(), opt->rect.top(),
|
---|
1739 | opt->rect.right(), opt->rect.bottom());
|
---|
1740 | }
|
---|
1741 | p->setPen(oldPen);
|
---|
1742 | break; }
|
---|
1743 | case PE_FrameDockWidget:
|
---|
1744 | if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
---|
1745 | proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
|
---|
1746 | }
|
---|
1747 | break;
|
---|
1748 | #endif // QT_NO_DOCKWIDGET
|
---|
1749 |
|
---|
1750 | case PE_FrameStatusBarItem:
|
---|
1751 | qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
|
---|
1752 | break;
|
---|
1753 |
|
---|
1754 | #ifndef QT_NO_PROGRESSBAR
|
---|
1755 | case PE_IndicatorProgressChunk:
|
---|
1756 | {
|
---|
1757 | bool vertical = false, inverted = false;
|
---|
1758 | if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
|
---|
1759 | vertical = (pb2->orientation == Qt::Vertical);
|
---|
1760 | inverted = pb2->invertedAppearance;
|
---|
1761 | }
|
---|
1762 |
|
---|
1763 | int space = 2;
|
---|
1764 | int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
|
---|
1765 | if (!vertical) {
|
---|
1766 | if (opt->rect.width() <= chunksize)
|
---|
1767 | space = 0;
|
---|
1768 |
|
---|
1769 | if (inverted)
|
---|
1770 | p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
|
---|
1771 | opt->palette.brush(QPalette::Highlight));
|
---|
1772 | else
|
---|
1773 | p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
|
---|
1774 | opt->palette.brush(QPalette::Highlight));
|
---|
1775 | } else {
|
---|
1776 | if (opt->rect.height() <= chunksize)
|
---|
1777 | space = 0;
|
---|
1778 |
|
---|
1779 | if (inverted)
|
---|
1780 | p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
|
---|
1781 | opt->palette.brush(QPalette::Highlight));
|
---|
1782 | else
|
---|
1783 | p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
|
---|
1784 | opt->palette.brush(QPalette::Highlight));
|
---|
1785 | }
|
---|
1786 | }
|
---|
1787 | break;
|
---|
1788 | #endif // QT_NO_PROGRESSBAR
|
---|
1789 |
|
---|
1790 | case PE_FrameTabWidget: {
|
---|
1791 | qDrawWinButton(p, opt->rect, opt->palette, false, 0);
|
---|
1792 | break;
|
---|
1793 | }
|
---|
1794 | default:
|
---|
1795 | QCommonStyle::drawPrimitive(pe, opt, p, w);
|
---|
1796 | }
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | /*! \reimp */
|
---|
1800 | void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
|
---|
1801 | const QWidget *widget) const
|
---|
1802 | {
|
---|
1803 | switch (ce) {
|
---|
1804 | #ifndef QT_NO_RUBBERBAND
|
---|
1805 | case CE_RubberBand:
|
---|
1806 | if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
|
---|
1807 | // ### workaround for slow general painter path
|
---|
1808 | QPixmap tiledPixmap(16, 16);
|
---|
1809 | QPainter pixmapPainter(&tiledPixmap);
|
---|
1810 | pixmapPainter.setPen(Qt::NoPen);
|
---|
1811 | pixmapPainter.setBrush(Qt::Dense4Pattern);
|
---|
1812 | pixmapPainter.setBackground(Qt::white);
|
---|
1813 | pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
|
---|
1814 | pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
|
---|
1815 | pixmapPainter.end();
|
---|
1816 | tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
|
---|
1817 | p->save();
|
---|
1818 | QRect r = opt->rect;
|
---|
1819 | QStyleHintReturnMask mask;
|
---|
1820 | if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
|
---|
1821 | p->setClipRegion(mask.region);
|
---|
1822 | p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
|
---|
1823 | p->restore();
|
---|
1824 | return;
|
---|
1825 | }
|
---|
1826 | break;
|
---|
1827 | #endif // QT_NO_RUBBERBAND
|
---|
1828 |
|
---|
1829 | #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
|
---|
1830 | case CE_MenuBarEmptyArea:
|
---|
1831 | if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
|
---|
1832 | p->fillRect(opt->rect, opt->palette.button());
|
---|
1833 | QPen oldPen = p->pen();
|
---|
1834 | p->setPen(QPen(opt->palette.dark().color()));
|
---|
1835 | p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
|
---|
1836 | p->setPen(oldPen);
|
---|
1837 | }
|
---|
1838 | break;
|
---|
1839 | #endif
|
---|
1840 | #ifndef QT_NO_MENU
|
---|
1841 | case CE_MenuItem:
|
---|
1842 | if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
|
---|
1843 | int x, y, w, h;
|
---|
1844 | menuitem->rect.getRect(&x, &y, &w, &h);
|
---|
1845 | int tab = menuitem->tabWidth;
|
---|
1846 | bool dis = !(menuitem->state & State_Enabled);
|
---|
1847 | bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
|
---|
1848 | ? menuitem->checked : false;
|
---|
1849 | bool act = menuitem->state & State_Selected;
|
---|
1850 |
|
---|
1851 | // windows always has a check column, regardless whether we have an icon or not
|
---|
1852 | int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
|
---|
1853 |
|
---|
1854 | QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
|
---|
1855 | p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
|
---|
1856 |
|
---|
1857 | if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
|
---|
1858 | int yoff = y-1 + h / 2;
|
---|
1859 | p->setPen(menuitem->palette.dark().color());
|
---|
1860 | p->drawLine(x + 2, yoff, x + w - 4, yoff);
|
---|
1861 | p->setPen(menuitem->palette.light().color());
|
---|
1862 | p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
|
---|
1863 | return;
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
|
---|
1867 | if (checked) {
|
---|
1868 | if (act && !dis) {
|
---|
1869 | qDrawShadePanel(p, vCheckRect,
|
---|
1870 | menuitem->palette, true, 1,
|
---|
1871 | &menuitem->palette.brush(QPalette::Button));
|
---|
1872 | } else {
|
---|
1873 | QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
|
---|
1874 | qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
|
---|
1875 | }
|
---|
1876 | } else if (!act) {
|
---|
1877 | p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | // On Windows Style, if we have a checkable item and an icon we
|
---|
1881 | // draw the icon recessed to indicate an item is checked. If we
|
---|
1882 | // have no icon, we draw a checkmark instead.
|
---|
1883 | if (!menuitem->icon.isNull()) {
|
---|
1884 | QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
---|
1885 | if (act && !dis)
|
---|
1886 | mode = QIcon::Active;
|
---|
1887 | QPixmap pixmap;
|
---|
1888 | if (checked)
|
---|
1889 | pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
|
---|
1890 | else
|
---|
1891 | pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
|
---|
1892 | int pixw = pixmap.width();
|
---|
1893 | int pixh = pixmap.height();
|
---|
1894 | if (act && !dis && !checked)
|
---|
1895 | qDrawShadePanel(p, vCheckRect, menuitem->palette, false, 1,
|
---|
1896 | &menuitem->palette.brush(QPalette::Button));
|
---|
1897 | QRect pmr(0, 0, pixw, pixh);
|
---|
1898 | pmr.moveCenter(vCheckRect.center());
|
---|
1899 | p->setPen(menuitem->palette.text().color());
|
---|
1900 | p->drawPixmap(pmr.topLeft(), pixmap);
|
---|
1901 | } else if (checked) {
|
---|
1902 | QStyleOptionMenuItem newMi = *menuitem;
|
---|
1903 | newMi.state = State_None;
|
---|
1904 | if (!dis)
|
---|
1905 | newMi.state |= State_Enabled;
|
---|
1906 | if (act)
|
---|
1907 | newMi.state |= State_On;
|
---|
1908 | newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
|
---|
1909 | menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
|
---|
1910 | checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
|
---|
1911 | menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
|
---|
1912 | proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
|
---|
1913 | }
|
---|
1914 | p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
|
---|
1915 |
|
---|
1916 | QColor discol;
|
---|
1917 | if (dis) {
|
---|
1918 | discol = menuitem->palette.text().color();
|
---|
1919 | p->setPen(discol);
|
---|
1920 | }
|
---|
1921 |
|
---|
1922 | int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin;
|
---|
1923 | int xpos = menuitem->rect.x() + xm;
|
---|
1924 | QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
|
---|
1925 | w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
|
---|
1926 | QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
|
---|
1927 | QString s = menuitem->text;
|
---|
1928 | if (!s.isEmpty()) { // draw text
|
---|
1929 | p->save();
|
---|
1930 | int t = s.indexOf(QLatin1Char('\t'));
|
---|
1931 | int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
---|
1932 | if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
|
---|
1933 | text_flags |= Qt::TextHideMnemonic;
|
---|
1934 | text_flags |= Qt::AlignLeft;
|
---|
1935 | if (t >= 0) {
|
---|
1936 | QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
|
---|
1937 | QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
|
---|
1938 | if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
|
---|
1939 | p->setPen(menuitem->palette.light().color());
|
---|
1940 | p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
|
---|
1941 | p->setPen(discol);
|
---|
1942 | }
|
---|
1943 | p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
|
---|
1944 | s = s.left(t);
|
---|
1945 | }
|
---|
1946 | QFont font = menuitem->font;
|
---|
1947 | if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
|
---|
1948 | font.setBold(true);
|
---|
1949 | p->setFont(font);
|
---|
1950 | if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
|
---|
1951 | p->setPen(menuitem->palette.light().color());
|
---|
1952 | p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
|
---|
1953 | p->setPen(discol);
|
---|
1954 | }
|
---|
1955 | p->drawText(vTextRect, text_flags, s.left(t));
|
---|
1956 | p->restore();
|
---|
1957 | }
|
---|
1958 | if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
|
---|
1959 | int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
|
---|
1960 | PrimitiveElement arrow;
|
---|
1961 | arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
---|
1962 | xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
|
---|
1963 | QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
|
---|
1964 | QStyleOptionMenuItem newMI = *menuitem;
|
---|
1965 | newMI.rect = vSubMenuRect;
|
---|
1966 | newMI.state = dis ? State_None : State_Enabled;
|
---|
1967 | if (act)
|
---|
1968 | newMI.palette.setColor(QPalette::ButtonText,
|
---|
1969 | newMI.palette.highlightedText().color());
|
---|
1970 | proxy()->drawPrimitive(arrow, &newMI, p, widget);
|
---|
1971 | }
|
---|
1972 |
|
---|
1973 | }
|
---|
1974 | break;
|
---|
1975 | #endif // QT_NO_MENU
|
---|
1976 | #ifndef QT_NO_MENUBAR
|
---|
1977 | case CE_MenuBarItem:
|
---|
1978 | if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
|
---|
1979 | bool active = mbi->state & State_Selected;
|
---|
1980 | bool hasFocus = mbi->state & State_HasFocus;
|
---|
1981 | bool down = mbi->state & State_Sunken;
|
---|
1982 | QStyleOptionMenuItem newMbi = *mbi;
|
---|
1983 | p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
|
---|
1984 | if (active || hasFocus) {
|
---|
1985 | QBrush b = mbi->palette.brush(QPalette::Button);
|
---|
1986 | if (active && down)
|
---|
1987 | p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
|
---|
1988 | if (active && hasFocus)
|
---|
1989 | qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
|
---|
1990 | mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
|
---|
1991 | if (active && down) {
|
---|
1992 | newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
|
---|
1993 | proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
|
---|
1994 | p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
|
---|
1995 | }
|
---|
1996 | }
|
---|
1997 | QCommonStyle::drawControl(ce, &newMbi, p, widget);
|
---|
1998 | }
|
---|
1999 | break;
|
---|
2000 | #endif // QT_NO_MENUBAR
|
---|
2001 | #ifndef QT_NO_TABBAR
|
---|
2002 | case CE_TabBarTabShape:
|
---|
2003 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
|
---|
2004 | bool rtlHorTabs = (tab->direction == Qt::RightToLeft
|
---|
2005 | && (tab->shape == QTabBar::RoundedNorth
|
---|
2006 | || tab->shape == QTabBar::RoundedSouth));
|
---|
2007 | bool selected = tab->state & State_Selected;
|
---|
2008 | bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
|
---|
2009 | || (rtlHorTabs
|
---|
2010 | && tab->position == QStyleOptionTab::Beginning));
|
---|
2011 | bool firstTab = ((!rtlHorTabs
|
---|
2012 | && tab->position == QStyleOptionTab::Beginning)
|
---|
2013 | || (rtlHorTabs
|
---|
2014 | && tab->position == QStyleOptionTab::End));
|
---|
2015 | bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
|
---|
2016 | bool previousSelected =
|
---|
2017 | ((!rtlHorTabs
|
---|
2018 | && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
|
---|
2019 | || (rtlHorTabs
|
---|
2020 | && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
|
---|
2021 | bool nextSelected =
|
---|
2022 | ((!rtlHorTabs
|
---|
2023 | && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
|
---|
2024 | || (rtlHorTabs
|
---|
2025 | && tab->selectedPosition
|
---|
2026 | == QStyleOptionTab::PreviousIsSelected));
|
---|
2027 | int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
|
---|
2028 | bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
|
---|
2029 | || (rtlHorTabs
|
---|
2030 | && tabBarAlignment == Qt::AlignRight);
|
---|
2031 |
|
---|
2032 | bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
|
---|
2033 | || (rtlHorTabs
|
---|
2034 | && tabBarAlignment == Qt::AlignLeft);
|
---|
2035 |
|
---|
2036 | QColor light = tab->palette.light().color();
|
---|
2037 | QColor midlight = tab->palette.midlight().color();
|
---|
2038 | QColor dark = tab->palette.dark().color();
|
---|
2039 | QColor shadow = tab->palette.shadow().color();
|
---|
2040 | QColor background = tab->palette.background().color();
|
---|
2041 | int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
|
---|
2042 | if (selected)
|
---|
2043 | borderThinkness /= 2;
|
---|
2044 | QRect r2(opt->rect);
|
---|
2045 | int x1 = r2.left();
|
---|
2046 | int x2 = r2.right();
|
---|
2047 | int y1 = r2.top();
|
---|
2048 | int y2 = r2.bottom();
|
---|
2049 | switch (tab->shape) {
|
---|
2050 | default:
|
---|
2051 | QCommonStyle::drawControl(ce, tab, p, widget);
|
---|
2052 | break;
|
---|
2053 | case QTabBar::RoundedNorth: {
|
---|
2054 | if (!selected) {
|
---|
2055 | y1 += 2;
|
---|
2056 | x1 += onlyOne || firstTab ? borderThinkness : 0;
|
---|
2057 | x2 -= onlyOne || lastTab ? borderThinkness : 0;
|
---|
2058 | }
|
---|
2059 |
|
---|
2060 | p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
|
---|
2061 |
|
---|
2062 | // Delete border
|
---|
2063 | if (selected) {
|
---|
2064 | p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
|
---|
2065 | p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
|
---|
2066 | }
|
---|
2067 | // Left
|
---|
2068 | if (firstTab || selected || onlyOne || !previousSelected) {
|
---|
2069 | p->setPen(light);
|
---|
2070 | p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
|
---|
2071 | p->drawPoint(x1 + 1, y1 + 1);
|
---|
2072 | }
|
---|
2073 | // Top
|
---|
2074 | {
|
---|
2075 | int beg = x1 + (previousSelected ? 0 : 2);
|
---|
2076 | int end = x2 - (nextSelected ? 0 : 2);
|
---|
2077 | p->setPen(light);
|
---|
2078 | p->drawLine(beg, y1, end, y1);
|
---|
2079 | }
|
---|
2080 | // Right
|
---|
2081 | if (lastTab || selected || onlyOne || !nextSelected) {
|
---|
2082 | p->setPen(shadow);
|
---|
2083 | p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2084 | p->drawPoint(x2 - 1, y1 + 1);
|
---|
2085 | p->setPen(dark);
|
---|
2086 | p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2087 | }
|
---|
2088 | break; }
|
---|
2089 | case QTabBar::RoundedSouth: {
|
---|
2090 | if (!selected) {
|
---|
2091 | y2 -= 2;
|
---|
2092 | x1 += firstTab ? borderThinkness : 0;
|
---|
2093 | x2 -= lastTab ? borderThinkness : 0;
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 | p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
|
---|
2097 |
|
---|
2098 | // Delete border
|
---|
2099 | if (selected) {
|
---|
2100 | p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
|
---|
2101 | p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
|
---|
2102 | }
|
---|
2103 | // Left
|
---|
2104 | if (firstTab || selected || onlyOne || !previousSelected) {
|
---|
2105 | p->setPen(light);
|
---|
2106 | p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
|
---|
2107 | p->drawPoint(x1 + 1, y2 - 1);
|
---|
2108 | }
|
---|
2109 | // Bottom
|
---|
2110 | {
|
---|
2111 | int beg = x1 + (previousSelected ? 0 : 2);
|
---|
2112 | int end = x2 - (nextSelected ? 0 : 2);
|
---|
2113 | p->setPen(shadow);
|
---|
2114 | p->drawLine(beg, y2, end, y2);
|
---|
2115 | p->setPen(dark);
|
---|
2116 | p->drawLine(beg, y2 - 1, end, y2 - 1);
|
---|
2117 | }
|
---|
2118 | // Right
|
---|
2119 | if (lastTab || selected || onlyOne || !nextSelected) {
|
---|
2120 | p->setPen(shadow);
|
---|
2121 | p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2122 | p->drawPoint(x2 - 1, y2 - 1);
|
---|
2123 | p->setPen(dark);
|
---|
2124 | p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2125 | }
|
---|
2126 | break; }
|
---|
2127 | case QTabBar::RoundedWest: {
|
---|
2128 | if (!selected) {
|
---|
2129 | x1 += 2;
|
---|
2130 | y1 += firstTab ? borderThinkness : 0;
|
---|
2131 | y2 -= lastTab ? borderThinkness : 0;
|
---|
2132 | }
|
---|
2133 |
|
---|
2134 | p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
|
---|
2135 |
|
---|
2136 | // Delete border
|
---|
2137 | if (selected) {
|
---|
2138 | p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
|
---|
2139 | p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
|
---|
2140 | }
|
---|
2141 | // Top
|
---|
2142 | if (firstTab || selected || onlyOne || !previousSelected) {
|
---|
2143 | p->setPen(light);
|
---|
2144 | p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
|
---|
2145 | p->drawPoint(x1 + 1, y1 + 1);
|
---|
2146 | }
|
---|
2147 | // Left
|
---|
2148 | {
|
---|
2149 | int beg = y1 + (previousSelected ? 0 : 2);
|
---|
2150 | int end = y2 - (nextSelected ? 0 : 2);
|
---|
2151 | p->setPen(light);
|
---|
2152 | p->drawLine(x1, beg, x1, end);
|
---|
2153 | }
|
---|
2154 | // Bottom
|
---|
2155 | if (lastTab || selected || onlyOne || !nextSelected) {
|
---|
2156 | p->setPen(shadow);
|
---|
2157 | p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
|
---|
2158 | p->drawPoint(x1 + 2, y2 - 1);
|
---|
2159 | p->setPen(dark);
|
---|
2160 | p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
|
---|
2161 | p->drawPoint(x1 + 1, y2 - 1);
|
---|
2162 | p->drawPoint(x1 + 2, y2);
|
---|
2163 | }
|
---|
2164 | break; }
|
---|
2165 | case QTabBar::RoundedEast: {
|
---|
2166 | if (!selected) {
|
---|
2167 | x2 -= 2;
|
---|
2168 | y1 += firstTab ? borderThinkness : 0;
|
---|
2169 | y2 -= lastTab ? borderThinkness : 0;
|
---|
2170 | }
|
---|
2171 |
|
---|
2172 | p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
|
---|
2173 |
|
---|
2174 | // Delete border
|
---|
2175 | if (selected) {
|
---|
2176 | p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
|
---|
2177 | p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
|
---|
2178 | }
|
---|
2179 | // Top
|
---|
2180 | if (firstTab || selected || onlyOne || !previousSelected) {
|
---|
2181 | p->setPen(light);
|
---|
2182 | p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
|
---|
2183 | p->drawPoint(x2 - 1, y1 + 1);
|
---|
2184 | }
|
---|
2185 | // Right
|
---|
2186 | {
|
---|
2187 | int beg = y1 + (previousSelected ? 0 : 2);
|
---|
2188 | int end = y2 - (nextSelected ? 0 : 2);
|
---|
2189 | p->setPen(shadow);
|
---|
2190 | p->drawLine(x2, beg, x2, end);
|
---|
2191 | p->setPen(dark);
|
---|
2192 | p->drawLine(x2 - 1, beg, x2 - 1, end);
|
---|
2193 | }
|
---|
2194 | // Bottom
|
---|
2195 | if (lastTab || selected || onlyOne || !nextSelected) {
|
---|
2196 | p->setPen(shadow);
|
---|
2197 | p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
|
---|
2198 | p->drawPoint(x2 - 1, y2 - 1);
|
---|
2199 | p->setPen(dark);
|
---|
2200 | p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
|
---|
2201 | }
|
---|
2202 | break; }
|
---|
2203 | }
|
---|
2204 | }
|
---|
2205 | break;
|
---|
2206 | #endif // QT_NO_TABBAR
|
---|
2207 | case CE_ToolBoxTabShape:
|
---|
2208 | qDrawShadePanel(p, opt->rect, opt->palette,
|
---|
2209 | opt->state & (State_Sunken | State_On), 1,
|
---|
2210 | &opt->palette.brush(QPalette::Button));
|
---|
2211 | break;
|
---|
2212 | #ifndef QT_NO_SPLITTER
|
---|
2213 | case CE_Splitter:
|
---|
2214 | p->eraseRect(opt->rect);
|
---|
2215 | break;
|
---|
2216 | #endif // QT_NO_SPLITTER
|
---|
2217 | #ifndef QT_NO_SCROLLBAR
|
---|
2218 | case CE_ScrollBarSubLine:
|
---|
2219 | case CE_ScrollBarAddLine: {
|
---|
2220 | if ((opt->state & State_Sunken)) {
|
---|
2221 | p->setPen(opt->palette.dark().color());
|
---|
2222 | p->setBrush(opt->palette.brush(QPalette::Button));
|
---|
2223 | p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
|
---|
2224 | } else {
|
---|
2225 | QStyleOption buttonOpt = *opt;
|
---|
2226 | if (!(buttonOpt.state & State_Sunken))
|
---|
2227 | buttonOpt.state |= State_Raised;
|
---|
2228 | QPalette pal(opt->palette);
|
---|
2229 | pal.setColor(QPalette::Button, opt->palette.light().color());
|
---|
2230 | pal.setColor(QPalette::Light, opt->palette.button().color());
|
---|
2231 | qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
|
---|
2232 | &opt->palette.brush(QPalette::Button));
|
---|
2233 | }
|
---|
2234 | PrimitiveElement arrow;
|
---|
2235 | if (opt->state & State_Horizontal) {
|
---|
2236 | if (ce == CE_ScrollBarAddLine)
|
---|
2237 | arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
|
---|
2238 | else
|
---|
2239 | arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
---|
2240 | } else {
|
---|
2241 | if (ce == CE_ScrollBarAddLine)
|
---|
2242 | arrow = PE_IndicatorArrowDown;
|
---|
2243 | else
|
---|
2244 | arrow = PE_IndicatorArrowUp;
|
---|
2245 | }
|
---|
2246 | QStyleOption arrowOpt = *opt;
|
---|
2247 | arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
|
---|
2248 | proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
|
---|
2249 | break; }
|
---|
2250 | case CE_ScrollBarAddPage:
|
---|
2251 | case CE_ScrollBarSubPage: {
|
---|
2252 | QBrush br;
|
---|
2253 | QBrush bg = p->background();
|
---|
2254 | Qt::BGMode bg_mode = p->backgroundMode();
|
---|
2255 | p->setPen(Qt::NoPen);
|
---|
2256 | p->setBackgroundMode(Qt::OpaqueMode);
|
---|
2257 |
|
---|
2258 | if (opt->state & State_Sunken) {
|
---|
2259 | br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
|
---|
2260 | p->setBackground(opt->palette.dark().color());
|
---|
2261 | p->setBrush(br);
|
---|
2262 | } else {
|
---|
2263 | QPixmap pm = opt->palette.brush(QPalette::Light).texture();
|
---|
2264 | br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
|
---|
2265 | p->setBackground(opt->palette.background().color());
|
---|
2266 | p->setBrush(br);
|
---|
2267 | }
|
---|
2268 | p->drawRect(opt->rect);
|
---|
2269 | p->setBackground(bg);
|
---|
2270 | p->setBackgroundMode(bg_mode);
|
---|
2271 | break; }
|
---|
2272 | case CE_ScrollBarSlider:
|
---|
2273 | if (!(opt->state & State_Enabled)) {
|
---|
2274 | QPixmap pm = opt->palette.brush(QPalette::Light).texture();
|
---|
2275 | QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
|
---|
2276 | p->setPen(Qt::NoPen);
|
---|
2277 | p->setBrush(br);
|
---|
2278 | p->setBackgroundMode(Qt::OpaqueMode);
|
---|
2279 | p->drawRect(opt->rect);
|
---|
2280 | } else {
|
---|
2281 | QStyleOptionButton buttonOpt;
|
---|
2282 | buttonOpt.QStyleOption::operator=(*opt);
|
---|
2283 | buttonOpt.state = State_Enabled | State_Raised;
|
---|
2284 |
|
---|
2285 | QPalette pal(opt->palette);
|
---|
2286 | pal.setColor(QPalette::Button, opt->palette.light().color());
|
---|
2287 | pal.setColor(QPalette::Light, opt->palette.button().color());
|
---|
2288 | qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
|
---|
2289 | }
|
---|
2290 | break;
|
---|
2291 | #endif // QT_NO_SCROLLBAR
|
---|
2292 | case CE_HeaderSection: {
|
---|
2293 | QBrush fill;
|
---|
2294 | if (opt->state & State_On)
|
---|
2295 | fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
|
---|
2296 | else
|
---|
2297 | fill = opt->palette.brush(QPalette::Button);
|
---|
2298 |
|
---|
2299 | if (opt->state & (State_Raised | State_Sunken)) {
|
---|
2300 | qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
|
---|
2301 | } else {
|
---|
2302 | p->fillRect(opt->rect, fill);
|
---|
2303 | }
|
---|
2304 | break; }
|
---|
2305 | #ifndef QT_NO_TOOLBAR
|
---|
2306 | case CE_ToolBar:
|
---|
2307 | if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
|
---|
2308 | QRect rect = opt->rect;
|
---|
2309 |
|
---|
2310 | bool paintLeftBorder = true;
|
---|
2311 | bool paintRightBorder = true;
|
---|
2312 | bool paintBottomBorder = true;
|
---|
2313 |
|
---|
2314 | switch (toolbar->toolBarArea){
|
---|
2315 | case Qt::BottomToolBarArea :
|
---|
2316 | switch(toolbar->positionOfLine){
|
---|
2317 | case QStyleOptionToolBar::Beginning:
|
---|
2318 | case QStyleOptionToolBar::OnlyOne:
|
---|
2319 | paintBottomBorder = false;
|
---|
2320 | default:
|
---|
2321 | break;
|
---|
2322 | }
|
---|
2323 | case Qt::TopToolBarArea :
|
---|
2324 | switch(toolbar->positionWithinLine){
|
---|
2325 | case QStyleOptionToolBar::Beginning:
|
---|
2326 | paintLeftBorder = false;
|
---|
2327 | break;
|
---|
2328 | case QStyleOptionToolBar::End:
|
---|
2329 | paintRightBorder = false;
|
---|
2330 | break;
|
---|
2331 | case QStyleOptionToolBar::OnlyOne:
|
---|
2332 | paintRightBorder = false;
|
---|
2333 | paintLeftBorder = false;
|
---|
2334 | default:
|
---|
2335 | break;
|
---|
2336 | }
|
---|
2337 | if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
|
---|
2338 | bool tmp = paintLeftBorder;
|
---|
2339 | paintRightBorder=paintLeftBorder;
|
---|
2340 | paintLeftBorder=tmp;
|
---|
2341 | }
|
---|
2342 | break;
|
---|
2343 | case Qt::RightToolBarArea :
|
---|
2344 | switch (toolbar->positionOfLine){
|
---|
2345 | case QStyleOptionToolBar::Beginning:
|
---|
2346 | case QStyleOptionToolBar::OnlyOne:
|
---|
2347 | paintRightBorder = false;
|
---|
2348 | break;
|
---|
2349 | default:
|
---|
2350 | break;
|
---|
2351 | }
|
---|
2352 | break;
|
---|
2353 | case Qt::LeftToolBarArea :
|
---|
2354 | switch (toolbar->positionOfLine){
|
---|
2355 | case QStyleOptionToolBar::Beginning:
|
---|
2356 | case QStyleOptionToolBar::OnlyOne:
|
---|
2357 | paintLeftBorder = false;
|
---|
2358 | break;
|
---|
2359 | default:
|
---|
2360 | break;
|
---|
2361 | }
|
---|
2362 | break;
|
---|
2363 | default:
|
---|
2364 | break;
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 |
|
---|
2368 | //draw top border
|
---|
2369 | p->setPen(QPen(opt->palette.light().color()));
|
---|
2370 | p->drawLine(rect.topLeft().x(),
|
---|
2371 | rect.topLeft().y(),
|
---|
2372 | rect.topRight().x(),
|
---|
2373 | rect.topRight().y());
|
---|
2374 |
|
---|
2375 | if (paintLeftBorder){
|
---|
2376 | p->setPen(QPen(opt->palette.light().color()));
|
---|
2377 | p->drawLine(rect.topLeft().x(),
|
---|
2378 | rect.topLeft().y(),
|
---|
2379 | rect.bottomLeft().x(),
|
---|
2380 | rect.bottomLeft().y());
|
---|
2381 | }
|
---|
2382 |
|
---|
2383 | if (paintRightBorder){
|
---|
2384 | p->setPen(QPen(opt->palette.dark().color()));
|
---|
2385 | p->drawLine(rect.topRight().x(),
|
---|
2386 | rect.topRight().y(),
|
---|
2387 | rect.bottomRight().x(),
|
---|
2388 | rect.bottomRight().y());
|
---|
2389 | }
|
---|
2390 |
|
---|
2391 | if (paintBottomBorder){
|
---|
2392 | p->setPen(QPen(opt->palette.dark().color()));
|
---|
2393 | p->drawLine(rect.bottomLeft().x(),
|
---|
2394 | rect.bottomLeft().y(),
|
---|
2395 | rect.bottomRight().x(),
|
---|
2396 | rect.bottomRight().y());
|
---|
2397 | }
|
---|
2398 | }
|
---|
2399 | break;
|
---|
2400 |
|
---|
2401 |
|
---|
2402 | #endif // QT_NO_TOOLBAR
|
---|
2403 | #ifndef QT_NO_PROGRESSBAR
|
---|
2404 | case CE_ProgressBarContents:
|
---|
2405 | if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
---|
2406 |
|
---|
2407 | QRect rect = pb->rect;
|
---|
2408 | bool vertical = false;
|
---|
2409 | bool inverted = false;
|
---|
2410 |
|
---|
2411 | // Get extra style options if version 2
|
---|
2412 | const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
|
---|
2413 | if (pb2) {
|
---|
2414 | vertical = (pb2->orientation == Qt::Vertical);
|
---|
2415 | inverted = pb2->invertedAppearance;
|
---|
2416 | }
|
---|
2417 | QMatrix m;
|
---|
2418 | if (vertical) {
|
---|
2419 | rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
|
---|
2420 | m.rotate(90);
|
---|
2421 | m.translate(0, -(rect.height() + rect.y()*2));
|
---|
2422 | }
|
---|
2423 | QPalette pal2 = pb->palette;
|
---|
2424 | // Correct the highlight color if it is the same as the background
|
---|
2425 | if (pal2.highlight() == pal2.background())
|
---|
2426 | pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
|
---|
2427 | QPalette::Highlight));
|
---|
2428 | bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
|
---|
2429 | if (inverted)
|
---|
2430 | reverse = !reverse;
|
---|
2431 | int w = rect.width();
|
---|
2432 | if (pb->minimum == 0 && pb->maximum == 0) {
|
---|
2433 | Q_D(const QWindowsStyle);
|
---|
2434 | const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
|
---|
2435 | QStyleOptionProgressBarV2 pbBits = *pb;
|
---|
2436 | Q_ASSERT(unit_width >0);
|
---|
2437 |
|
---|
2438 | pbBits.rect = rect;
|
---|
2439 | pbBits.palette = pal2;
|
---|
2440 |
|
---|
2441 | int chunkCount = w / unit_width + 1;
|
---|
2442 | int step = d->animateStep%chunkCount;
|
---|
2443 | int chunksInRow = 5;
|
---|
2444 | int myY = pbBits.rect.y();
|
---|
2445 | int myHeight = pbBits.rect.height();
|
---|
2446 | int chunksToDraw = chunksInRow;
|
---|
2447 |
|
---|
2448 | if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
|
---|
2449 | p->save();
|
---|
2450 | p->setClipRect(m.mapRect(QRectF(rect)).toRect());
|
---|
2451 |
|
---|
2452 | int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
|
---|
2453 | int x = 0;
|
---|
2454 |
|
---|
2455 | for (int i = 0; i < chunksToDraw ; ++i) {
|
---|
2456 | pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
|
---|
2457 | pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
|
---|
2458 | proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
|
---|
2459 | x += reverse ? -unit_width : unit_width;
|
---|
2460 | }
|
---|
2461 | //Draw wrap-around chunks
|
---|
2462 | if( step > chunkCount-5){
|
---|
2463 | x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
|
---|
2464 | x = 0;
|
---|
2465 | int chunksToDraw = step - (chunkCount - chunksInRow);
|
---|
2466 | for (int i = 0; i < chunksToDraw ; ++i) {
|
---|
2467 | pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
|
---|
2468 | pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
|
---|
2469 | proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
|
---|
2470 | x += reverse ? -unit_width : unit_width;
|
---|
2471 | }
|
---|
2472 | }
|
---|
2473 | p->restore(); //restore state
|
---|
2474 | }
|
---|
2475 | else {
|
---|
2476 | QCommonStyle::drawControl(ce, opt, p, widget);
|
---|
2477 | }
|
---|
2478 | }
|
---|
2479 | break;
|
---|
2480 | #endif // QT_NO_PROGRESSBAR
|
---|
2481 |
|
---|
2482 | #ifndef QT_NO_DOCKWIDGET
|
---|
2483 | case CE_DockWidgetTitle:
|
---|
2484 |
|
---|
2485 | if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
|
---|
2486 | Q_D(const QWindowsStyle);
|
---|
2487 |
|
---|
2488 | const QStyleOptionDockWidgetV2 *v2
|
---|
2489 | = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
|
---|
2490 | bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
---|
2491 |
|
---|
2492 | QRect rect = dwOpt->rect;
|
---|
2493 | QRect r = rect;
|
---|
2494 |
|
---|
2495 | if (verticalTitleBar) {
|
---|
2496 | QSize s = r.size();
|
---|
2497 | s.transpose();
|
---|
2498 | r.setSize(s);
|
---|
2499 |
|
---|
2500 | p->save();
|
---|
2501 | p->translate(r.left(), r.top() + r.width());
|
---|
2502 | p->rotate(-90);
|
---|
2503 | p->translate(-r.left(), -r.top());
|
---|
2504 | }
|
---|
2505 |
|
---|
2506 | bool floating = false;
|
---|
2507 | bool active = dwOpt->state & State_Active;
|
---|
2508 | QColor inactiveCaptionTextColor = d->inactiveCaptionText;
|
---|
2509 | if (dwOpt->movable) {
|
---|
2510 | QColor left, right;
|
---|
2511 |
|
---|
2512 | //Titlebar gradient
|
---|
2513 | if (widget && widget->isWindow()) {
|
---|
2514 | floating = true;
|
---|
2515 | if (active) {
|
---|
2516 | left = d->activeCaptionColor;
|
---|
2517 | right = d->activeGradientCaptionColor;
|
---|
2518 | } else {
|
---|
2519 | left = d->inactiveCaptionColor;
|
---|
2520 | right = d->inactiveGradientCaptionColor;
|
---|
2521 | }
|
---|
2522 | QBrush fillBrush(left);
|
---|
2523 | if (left != right) {
|
---|
2524 | QPoint p1(r.x(), r.top() + r.height()/2);
|
---|
2525 | QPoint p2(rect.right(), r.top() + r.height()/2);
|
---|
2526 | QLinearGradient lg(p1, p2);
|
---|
2527 | lg.setColorAt(0, left);
|
---|
2528 | lg.setColorAt(1, right);
|
---|
2529 | fillBrush = lg;
|
---|
2530 | }
|
---|
2531 | p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
|
---|
2532 | }
|
---|
2533 | p->setPen(dwOpt->palette.color(QPalette::Light));
|
---|
2534 | if (!widget || !widget->isWindow()) {
|
---|
2535 | p->drawLine(r.topLeft(), r.topRight());
|
---|
2536 | p->setPen(dwOpt->palette.color(QPalette::Dark));
|
---|
2537 | p->drawLine(r.bottomLeft(), r.bottomRight()); }
|
---|
2538 | }
|
---|
2539 | if (!dwOpt->title.isEmpty()) {
|
---|
2540 | QFont oldFont = p->font();
|
---|
2541 | if (floating) {
|
---|
2542 | QFont font = oldFont;
|
---|
2543 | font.setBold(true);
|
---|
2544 | p->setFont(font);
|
---|
2545 | }
|
---|
2546 | QPalette palette = dwOpt->palette;
|
---|
2547 | palette.setColor(QPalette::Window, inactiveCaptionTextColor);
|
---|
2548 | QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
|
---|
2549 | if (verticalTitleBar) {
|
---|
2550 | titleRect = QRect(r.left() + rect.bottom()
|
---|
2551 | - titleRect.bottom(),
|
---|
2552 | r.top() + titleRect.left() - rect.left(),
|
---|
2553 | titleRect.height(), titleRect.width());
|
---|
2554 | }
|
---|
2555 | proxy()->drawItemText(p, titleRect,
|
---|
2556 | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
|
---|
2557 | dwOpt->state & State_Enabled, dwOpt->title,
|
---|
2558 | floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
|
---|
2559 | p->setFont(oldFont);
|
---|
2560 | }
|
---|
2561 | if (verticalTitleBar)
|
---|
2562 | p->restore();
|
---|
2563 | }
|
---|
2564 | return;
|
---|
2565 | #endif // QT_NO_DOCKWIDGET
|
---|
2566 | default:
|
---|
2567 | QCommonStyle::drawControl(ce, opt, p, widget);
|
---|
2568 | }
|
---|
2569 | }
|
---|
2570 |
|
---|
2571 | /*! \reimp */
|
---|
2572 | QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
|
---|
2573 | {
|
---|
2574 | QRect r;
|
---|
2575 | switch (sr) {
|
---|
2576 | case SE_SliderFocusRect:
|
---|
2577 | case SE_ToolBoxTabContents:
|
---|
2578 | r = visualRect(opt->direction, opt->rect, opt->rect);
|
---|
2579 | break;
|
---|
2580 | case SE_DockWidgetTitleBarText: {
|
---|
2581 | r = QCommonStyle::subElementRect(sr, opt, w);
|
---|
2582 | const QStyleOptionDockWidgetV2 *v2
|
---|
2583 | = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
|
---|
2584 | bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
---|
2585 | int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
|
---|
2586 | if (verticalTitleBar) {
|
---|
2587 | r.adjust(0, 0, 0, -m);
|
---|
2588 | } else {
|
---|
2589 | if (opt->direction == Qt::LeftToRight)
|
---|
2590 | r.adjust(m, 0, 0, 0);
|
---|
2591 | else
|
---|
2592 | r.adjust(0, 0, -m, 0);
|
---|
2593 | }
|
---|
2594 | break;
|
---|
2595 | }
|
---|
2596 | case SE_ProgressBarContents:
|
---|
2597 | r = QCommonStyle::subElementRect(SE_ProgressBarGroove, opt, w);
|
---|
2598 | r.adjust(3, 3, -3, -3);
|
---|
2599 | break;
|
---|
2600 | default:
|
---|
2601 | r = QCommonStyle::subElementRect(sr, opt, w);
|
---|
2602 | }
|
---|
2603 | return r;
|
---|
2604 | }
|
---|
2605 |
|
---|
2606 | #ifdef QT3_SUPPORT
|
---|
2607 | Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalVerticalLine, (1, 129))
|
---|
2608 | Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalHorizontalLine, (128, 1))
|
---|
2609 | #endif
|
---|
2610 |
|
---|
2611 | /*! \reimp */
|
---|
2612 | void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
|
---|
2613 | QPainter *p, const QWidget *widget) const
|
---|
2614 | {
|
---|
2615 | switch (cc) {
|
---|
2616 | #ifndef QT_NO_SLIDER
|
---|
2617 | case CC_Slider:
|
---|
2618 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
|
---|
2619 | int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
|
---|
2620 | int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
|
---|
2621 | int ticks = slider->tickPosition;
|
---|
2622 | QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
|
---|
2623 | QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
|
---|
2624 |
|
---|
2625 | if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
|
---|
2626 | int mid = thickness / 2;
|
---|
2627 |
|
---|
2628 | if (ticks & QSlider::TicksAbove)
|
---|
2629 | mid += len / 8;
|
---|
2630 | if (ticks & QSlider::TicksBelow)
|
---|
2631 | mid -= len / 8;
|
---|
2632 |
|
---|
2633 | p->setPen(slider->palette.shadow().color());
|
---|
2634 | if (slider->orientation == Qt::Horizontal) {
|
---|
2635 | qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
|
---|
2636 | groove.width(), 4, slider->palette, true);
|
---|
2637 | p->drawLine(groove.x() + 1, groove.y() + mid - 1,
|
---|
2638 | groove.x() + groove.width() - 3, groove.y() + mid - 1);
|
---|
2639 | } else {
|
---|
2640 | qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
|
---|
2641 | 4, groove.height(), slider->palette, true);
|
---|
2642 | p->drawLine(groove.x() + mid - 1, groove.y() + 1,
|
---|
2643 | groove.x() + mid - 1, groove.y() + groove.height() - 3);
|
---|
2644 | }
|
---|
2645 | }
|
---|
2646 |
|
---|
2647 | if (slider->subControls & SC_SliderTickmarks) {
|
---|
2648 | QStyleOptionSlider tmpSlider = *slider;
|
---|
2649 | tmpSlider.subControls = SC_SliderTickmarks;
|
---|
2650 | QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
|
---|
2651 | }
|
---|
2652 |
|
---|
2653 | if (slider->subControls & SC_SliderHandle) {
|
---|
2654 | // 4444440
|
---|
2655 | // 4333310
|
---|
2656 | // 4322210
|
---|
2657 | // 4322210
|
---|
2658 | // 4322210
|
---|
2659 | // 4322210
|
---|
2660 | // *43210*
|
---|
2661 | // **410**
|
---|
2662 | // ***0***
|
---|
2663 | const QColor c0 = slider->palette.shadow().color();
|
---|
2664 | const QColor c1 = slider->palette.dark().color();
|
---|
2665 | // const QColor c2 = g.button();
|
---|
2666 | const QColor c3 = slider->palette.midlight().color();
|
---|
2667 | const QColor c4 = slider->palette.light().color();
|
---|
2668 | QBrush handleBrush;
|
---|
2669 |
|
---|
2670 | if (slider->state & State_Enabled) {
|
---|
2671 | handleBrush = slider->palette.color(QPalette::Button);
|
---|
2672 | } else {
|
---|
2673 | handleBrush = QBrush(slider->palette.color(QPalette::Button),
|
---|
2674 | Qt::Dense4Pattern);
|
---|
2675 | }
|
---|
2676 |
|
---|
2677 |
|
---|
2678 | int x = handle.x(), y = handle.y(),
|
---|
2679 | wi = handle.width(), he = handle.height();
|
---|
2680 |
|
---|
2681 | int x1 = x;
|
---|
2682 | int x2 = x+wi-1;
|
---|
2683 | int y1 = y;
|
---|
2684 | int y2 = y+he-1;
|
---|
2685 |
|
---|
2686 | Qt::Orientation orient = slider->orientation;
|
---|
2687 | bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
|
---|
2688 | bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
|
---|
2689 |
|
---|
2690 | if (slider->state & State_HasFocus) {
|
---|
2691 | QStyleOptionFocusRect fropt;
|
---|
2692 | fropt.QStyleOption::operator=(*slider);
|
---|
2693 | fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
|
---|
2694 | proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
|
---|
2695 | }
|
---|
2696 |
|
---|
2697 | if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
|
---|
2698 | Qt::BGMode oldMode = p->backgroundMode();
|
---|
2699 | p->setBackgroundMode(Qt::OpaqueMode);
|
---|
2700 | qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
|
---|
2701 | &handleBrush);
|
---|
2702 | p->setBackgroundMode(oldMode);
|
---|
2703 | return;
|
---|
2704 | }
|
---|
2705 |
|
---|
2706 | QSliderDirection dir;
|
---|
2707 |
|
---|
2708 | if (orient == Qt::Horizontal)
|
---|
2709 | if (tickAbove)
|
---|
2710 | dir = SlUp;
|
---|
2711 | else
|
---|
2712 | dir = SlDown;
|
---|
2713 | else
|
---|
2714 | if (tickAbove)
|
---|
2715 | dir = SlLeft;
|
---|
2716 | else
|
---|
2717 | dir = SlRight;
|
---|
2718 |
|
---|
2719 | QPolygon a;
|
---|
2720 |
|
---|
2721 | int d = 0;
|
---|
2722 | switch (dir) {
|
---|
2723 | case SlUp:
|
---|
2724 | y1 = y1 + wi/2;
|
---|
2725 | d = (wi + 1) / 2 - 1;
|
---|
2726 | a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
|
---|
2727 | break;
|
---|
2728 | case SlDown:
|
---|
2729 | y2 = y2 - wi/2;
|
---|
2730 | d = (wi + 1) / 2 - 1;
|
---|
2731 | a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
|
---|
2732 | break;
|
---|
2733 | case SlLeft:
|
---|
2734 | d = (he + 1) / 2 - 1;
|
---|
2735 | x1 = x1 + he/2;
|
---|
2736 | a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
|
---|
2737 | break;
|
---|
2738 | case SlRight:
|
---|
2739 | d = (he + 1) / 2 - 1;
|
---|
2740 | x2 = x2 - he/2;
|
---|
2741 | a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
|
---|
2742 | break;
|
---|
2743 | }
|
---|
2744 |
|
---|
2745 | QBrush oldBrush = p->brush();
|
---|
2746 | p->setPen(Qt::NoPen);
|
---|
2747 | p->setBrush(handleBrush);
|
---|
2748 | Qt::BGMode oldMode = p->backgroundMode();
|
---|
2749 | p->setBackgroundMode(Qt::OpaqueMode);
|
---|
2750 | p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
|
---|
2751 | p->drawPolygon(a);
|
---|
2752 | p->setBrush(oldBrush);
|
---|
2753 | p->setBackgroundMode(oldMode);
|
---|
2754 |
|
---|
2755 | if (dir != SlUp) {
|
---|
2756 | p->setPen(c4);
|
---|
2757 | p->drawLine(x1, y1, x2, y1);
|
---|
2758 | p->setPen(c3);
|
---|
2759 | p->drawLine(x1, y1+1, x2, y1+1);
|
---|
2760 | }
|
---|
2761 | if (dir != SlLeft) {
|
---|
2762 | p->setPen(c3);
|
---|
2763 | p->drawLine(x1+1, y1+1, x1+1, y2);
|
---|
2764 | p->setPen(c4);
|
---|
2765 | p->drawLine(x1, y1, x1, y2);
|
---|
2766 | }
|
---|
2767 | if (dir != SlRight) {
|
---|
2768 | p->setPen(c0);
|
---|
2769 | p->drawLine(x2, y1, x2, y2);
|
---|
2770 | p->setPen(c1);
|
---|
2771 | p->drawLine(x2-1, y1+1, x2-1, y2-1);
|
---|
2772 | }
|
---|
2773 | if (dir != SlDown) {
|
---|
2774 | p->setPen(c0);
|
---|
2775 | p->drawLine(x1, y2, x2, y2);
|
---|
2776 | p->setPen(c1);
|
---|
2777 | p->drawLine(x1+1, y2-1, x2-1, y2-1);
|
---|
2778 | }
|
---|
2779 |
|
---|
2780 | switch (dir) {
|
---|
2781 | case SlUp:
|
---|
2782 | p->setPen(c4);
|
---|
2783 | p->drawLine(x1, y1, x1+d, y1-d);
|
---|
2784 | p->setPen(c0);
|
---|
2785 | d = wi - d - 1;
|
---|
2786 | p->drawLine(x2, y1, x2-d, y1-d);
|
---|
2787 | d--;
|
---|
2788 | p->setPen(c3);
|
---|
2789 | p->drawLine(x1+1, y1, x1+1+d, y1-d);
|
---|
2790 | p->setPen(c1);
|
---|
2791 | p->drawLine(x2-1, y1, x2-1-d, y1-d);
|
---|
2792 | break;
|
---|
2793 | case SlDown:
|
---|
2794 | p->setPen(c4);
|
---|
2795 | p->drawLine(x1, y2, x1+d, y2+d);
|
---|
2796 | p->setPen(c0);
|
---|
2797 | d = wi - d - 1;
|
---|
2798 | p->drawLine(x2, y2, x2-d, y2+d);
|
---|
2799 | d--;
|
---|
2800 | p->setPen(c3);
|
---|
2801 | p->drawLine(x1+1, y2, x1+1+d, y2+d);
|
---|
2802 | p->setPen(c1);
|
---|
2803 | p->drawLine(x2-1, y2, x2-1-d, y2+d);
|
---|
2804 | break;
|
---|
2805 | case SlLeft:
|
---|
2806 | p->setPen(c4);
|
---|
2807 | p->drawLine(x1, y1, x1-d, y1+d);
|
---|
2808 | p->setPen(c0);
|
---|
2809 | d = he - d - 1;
|
---|
2810 | p->drawLine(x1, y2, x1-d, y2-d);
|
---|
2811 | d--;
|
---|
2812 | p->setPen(c3);
|
---|
2813 | p->drawLine(x1, y1+1, x1-d, y1+1+d);
|
---|
2814 | p->setPen(c1);
|
---|
2815 | p->drawLine(x1, y2-1, x1-d, y2-1-d);
|
---|
2816 | break;
|
---|
2817 | case SlRight:
|
---|
2818 | p->setPen(c4);
|
---|
2819 | p->drawLine(x2, y1, x2+d, y1+d);
|
---|
2820 | p->setPen(c0);
|
---|
2821 | d = he - d - 1;
|
---|
2822 | p->drawLine(x2, y2, x2+d, y2-d);
|
---|
2823 | d--;
|
---|
2824 | p->setPen(c3);
|
---|
2825 | p->drawLine(x2, y1+1, x2+d, y1+1+d);
|
---|
2826 | p->setPen(c1);
|
---|
2827 | p->drawLine(x2, y2-1, x2+d, y2-1-d);
|
---|
2828 | break;
|
---|
2829 | }
|
---|
2830 | }
|
---|
2831 | }
|
---|
2832 | break;
|
---|
2833 | #endif // QT_NO_SLIDER
|
---|
2834 | #ifndef QT_NO_SCROLLBAR
|
---|
2835 | case CC_ScrollBar:
|
---|
2836 | if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
|
---|
2837 | QStyleOptionSlider newScrollbar = *scrollbar;
|
---|
2838 | if (scrollbar->minimum == scrollbar->maximum)
|
---|
2839 | newScrollbar.state &= ~State_Enabled; //do not draw the slider.
|
---|
2840 | QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
|
---|
2841 | }
|
---|
2842 | break;
|
---|
2843 | #endif // QT_NO_SCROLLBAR
|
---|
2844 | #ifdef QT3_SUPPORT
|
---|
2845 | case CC_Q3ListView:
|
---|
2846 | if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
|
---|
2847 | int i;
|
---|
2848 | if (lv->subControls & SC_Q3ListView)
|
---|
2849 | QCommonStyle::drawComplexControl(cc, lv, p, widget);
|
---|
2850 | if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
|
---|
2851 | if (lv->items.isEmpty())
|
---|
2852 | break;
|
---|
2853 | QStyleOptionQ3ListViewItem item = lv->items.at(0);
|
---|
2854 | int y = lv->rect.y();
|
---|
2855 | int c;
|
---|
2856 | int dotoffset = 0;
|
---|
2857 | QPolygon dotlines;
|
---|
2858 | if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand)) {
|
---|
2859 | c = 2;
|
---|
2860 | dotlines.resize(2);
|
---|
2861 | dotlines[0] = QPoint(lv->rect.right(), lv->rect.top());
|
---|
2862 | dotlines[1] = QPoint(lv->rect.right(), lv->rect.bottom());
|
---|
2863 | } else {
|
---|
2864 | int linetop = 0, linebot = 0;
|
---|
2865 | // each branch needs at most two lines, ie. four end points
|
---|
2866 | dotoffset = (item.itemY + item.height - y) % 2;
|
---|
2867 | dotlines.resize(item.childCount * 4);
|
---|
2868 | c = 0;
|
---|
2869 |
|
---|
2870 | // skip the stuff above the exposed rectangle
|
---|
2871 | for (i = 1; i < lv->items.size(); ++i) {
|
---|
2872 | QStyleOptionQ3ListViewItem child = lv->items.at(i);
|
---|
2873 | if (child.height + y > 0)
|
---|
2874 | break;
|
---|
2875 | y += child.totalHeight;
|
---|
2876 | }
|
---|
2877 | int bx = lv->rect.width() / 2;
|
---|
2878 |
|
---|
2879 | // paint stuff in the magical area
|
---|
2880 | while (i < lv->items.size() && y < lv->rect.height()) {
|
---|
2881 | QStyleOptionQ3ListViewItem child = lv->items.at(i);
|
---|
2882 | if (child.features & QStyleOptionQ3ListViewItem::Visible) {
|
---|
2883 | int lh;
|
---|
2884 | if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
|
---|
2885 | lh = child.height;
|
---|
2886 | else
|
---|
2887 | lh = p->fontMetrics().height() + 2 * lv->itemMargin;
|
---|
2888 | lh = qMax(lh, QApplication::globalStrut().height());
|
---|
2889 | if (lh % 2 > 0)
|
---|
2890 | ++lh;
|
---|
2891 | linebot = y + lh / 2;
|
---|
2892 | if (child.features & QStyleOptionQ3ListViewItem::Expandable
|
---|
2893 | || (child.childCount > 0 && child.height > 0)) {
|
---|
2894 | // needs a box
|
---|
2895 | p->setPen(lv->palette.mid().color());
|
---|
2896 | p->drawRect(bx - 4, linebot - 4, 8, 8);
|
---|
2897 | // plus or minus
|
---|
2898 | p->setPen(lv->palette.text().color());
|
---|
2899 | p->drawLine(bx - 2, linebot, bx + 2, linebot);
|
---|
2900 | if (!(child.state & State_Open))
|
---|
2901 | p->drawLine(bx, linebot - 2, bx, linebot + 2);
|
---|
2902 | // dotlinery
|
---|
2903 | p->setPen(lv->palette.mid().color());
|
---|
2904 | dotlines[c++] = QPoint(bx, linetop);
|
---|
2905 | dotlines[c++] = QPoint(bx, linebot - 4);
|
---|
2906 | dotlines[c++] = QPoint(bx + 5, linebot);
|
---|
2907 | dotlines[c++] = QPoint(lv->rect.width(), linebot);
|
---|
2908 | linetop = linebot + 5;
|
---|
2909 | } else {
|
---|
2910 | // just dotlinery
|
---|
2911 | dotlines[c++] = QPoint(bx+1, linebot -1);
|
---|
2912 | dotlines[c++] = QPoint(lv->rect.width(), linebot -1);
|
---|
2913 | }
|
---|
2914 | y += child.totalHeight;
|
---|
2915 | }
|
---|
2916 | ++i;
|
---|
2917 | }
|
---|
2918 |
|
---|
2919 | // Expand line height to edge of rectangle if there's any
|
---|
2920 | // visible child below
|
---|
2921 | while (i < lv->items.size() && lv->items.at(i).height <= 0)
|
---|
2922 | ++i;
|
---|
2923 | if (i < lv->items.size())
|
---|
2924 | linebot = lv->rect.height();
|
---|
2925 |
|
---|
2926 | if (linetop < linebot) {
|
---|
2927 | dotlines[c++] = QPoint(bx, linetop);
|
---|
2928 | dotlines[c++] = QPoint(bx, linebot);
|
---|
2929 | }
|
---|
2930 | }
|
---|
2931 | p->setPen(lv->palette.text().color());
|
---|
2932 | QBitmap *verticalLine = globalVerticalLine();
|
---|
2933 | QBitmap *horizontalLine = globalHorizontalLine();
|
---|
2934 | static bool isInit = false;
|
---|
2935 | if (!isInit) {
|
---|
2936 | isInit = true;
|
---|
2937 | // make 128*1 and 1*128 bitmaps that can be used for
|
---|
2938 | // drawing the right sort of lines.
|
---|
2939 | verticalLine->clear();
|
---|
2940 | horizontalLine->clear();
|
---|
2941 | QPolygon a(64);
|
---|
2942 | QPainter p;
|
---|
2943 | p.begin(verticalLine);
|
---|
2944 | for(i = 0; i < 64; ++i)
|
---|
2945 | a.setPoint(i, 0, i * 2 + 1);
|
---|
2946 | p.setPen(Qt::color1);
|
---|
2947 | p.drawPoints(a);
|
---|
2948 | p.end();
|
---|
2949 | QApplication::flush();
|
---|
2950 | verticalLine->setMask(*verticalLine);
|
---|
2951 | p.begin(horizontalLine);
|
---|
2952 | for(i = 0; i < 64; ++i)
|
---|
2953 | a.setPoint(i, i * 2 + 1, 0);
|
---|
2954 | p.setPen(Qt::color1);
|
---|
2955 | p.drawPoints(a);
|
---|
2956 | p.end();
|
---|
2957 | QApplication::flush();
|
---|
2958 | horizontalLine->setMask(*horizontalLine);
|
---|
2959 | }
|
---|
2960 |
|
---|
2961 | int line; // index into dotlines
|
---|
2962 | if (lv->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
|
---|
2963 | // assumptions here: lines are horizontal or vertical.
|
---|
2964 | // lines always start with the numerically lowest
|
---|
2965 | // coordinate.
|
---|
2966 |
|
---|
2967 | // point ... relevant coordinate of current point
|
---|
2968 | // end ..... same coordinate of the end of the current line
|
---|
2969 | // other ... the other coordinate of the current point/line
|
---|
2970 | if (dotlines[line].y() == dotlines[line+1].y()) {
|
---|
2971 | int end = dotlines[line + 1].x();
|
---|
2972 | int point = dotlines[line].x();
|
---|
2973 | int other = dotlines[line].y();
|
---|
2974 | while (point < end) {
|
---|
2975 | int i = 128;
|
---|
2976 | if (i + point > end)
|
---|
2977 | i = end-point;
|
---|
2978 | p->drawPixmap(point, other, *horizontalLine, 0, 0, i, 1);
|
---|
2979 | point += i;
|
---|
2980 | }
|
---|
2981 | } else {
|
---|
2982 | int end = dotlines[line + 1].y();
|
---|
2983 | int point = dotlines[line].y();
|
---|
2984 | int other = dotlines[line].x();
|
---|
2985 | int pixmapoffset = ((point & 1) != dotoffset) ? 1 : 0;
|
---|
2986 | while(point < end) {
|
---|
2987 | int i = 128;
|
---|
2988 | if (i + point > end)
|
---|
2989 | i = end-point;
|
---|
2990 | p->drawPixmap(other, point, *verticalLine, 0, pixmapoffset, 1, i);
|
---|
2991 | point += i;
|
---|
2992 | }
|
---|
2993 | }
|
---|
2994 | }
|
---|
2995 | }
|
---|
2996 | }
|
---|
2997 | break;
|
---|
2998 | #endif // QT3_SUPPORT
|
---|
2999 | #ifndef QT_NO_COMBOBOX
|
---|
3000 | case CC_ComboBox:
|
---|
3001 | if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
|
---|
3002 | QBrush editBrush = cmb->palette.brush(QPalette::Base);
|
---|
3003 | if ((cmb->subControls & SC_ComboBoxFrame)) {
|
---|
3004 | if (cmb->frame) {
|
---|
3005 | QPalette shadePal = opt->palette;
|
---|
3006 | shadePal.setColor(QPalette::Midlight, shadePal.button().color());
|
---|
3007 | qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
|
---|
3008 | }
|
---|
3009 | else {
|
---|
3010 | p->fillRect(opt->rect, editBrush);
|
---|
3011 | }
|
---|
3012 | }
|
---|
3013 | if (cmb->subControls & SC_ComboBoxArrow) {
|
---|
3014 | State flags = State_None;
|
---|
3015 |
|
---|
3016 | QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
|
---|
3017 | bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
|
---|
3018 | && cmb->state & State_Sunken;
|
---|
3019 | if (sunkenArrow) {
|
---|
3020 | p->setPen(cmb->palette.dark().color());
|
---|
3021 | p->setBrush(cmb->palette.brush(QPalette::Button));
|
---|
3022 | p->drawRect(ar.adjusted(0,0,-1,-1));
|
---|
3023 | } else {
|
---|
3024 | // Make qDrawWinButton use the right colors for drawing the shade of the button
|
---|
3025 | QPalette pal(cmb->palette);
|
---|
3026 | pal.setColor(QPalette::Button, cmb->palette.light().color());
|
---|
3027 | pal.setColor(QPalette::Light, cmb->palette.button().color());
|
---|
3028 | qDrawWinButton(p, ar, pal, false,
|
---|
3029 | &cmb->palette.brush(QPalette::Button));
|
---|
3030 | }
|
---|
3031 |
|
---|
3032 | ar.adjust(2, 2, -2, -2);
|
---|
3033 | if (opt->state & State_Enabled)
|
---|
3034 | flags |= State_Enabled;
|
---|
3035 | if (opt->state & State_HasFocus)
|
---|
3036 | flags |= State_HasFocus;
|
---|
3037 |
|
---|
3038 | if (sunkenArrow)
|
---|
3039 | flags |= State_Sunken;
|
---|
3040 | QStyleOption arrowOpt(0);
|
---|
3041 | arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
|
---|
3042 | arrowOpt.palette = cmb->palette;
|
---|
3043 | arrowOpt.state = flags;
|
---|
3044 | proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
|
---|
3045 | }
|
---|
3046 |
|
---|
3047 | if (cmb->subControls & SC_ComboBoxEditField) {
|
---|
3048 | QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
|
---|
3049 | if (cmb->state & State_HasFocus && !cmb->editable)
|
---|
3050 | p->fillRect(re.x(), re.y(), re.width(), re.height(),
|
---|
3051 | cmb->palette.brush(QPalette::Highlight));
|
---|
3052 |
|
---|
3053 | if (cmb->state & State_HasFocus) {
|
---|
3054 | p->setPen(cmb->palette.highlightedText().color());
|
---|
3055 | p->setBackground(cmb->palette.highlight());
|
---|
3056 |
|
---|
3057 | } else {
|
---|
3058 | p->setPen(cmb->palette.text().color());
|
---|
3059 | p->setBackground(cmb->palette.background());
|
---|
3060 | }
|
---|
3061 |
|
---|
3062 | if (cmb->state & State_HasFocus && !cmb->editable) {
|
---|
3063 | QStyleOptionFocusRect focus;
|
---|
3064 | focus.QStyleOption::operator=(*cmb);
|
---|
3065 | focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
|
---|
3066 | focus.state |= State_FocusAtBorder;
|
---|
3067 | focus.backgroundColor = cmb->palette.highlight().color();
|
---|
3068 | proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
|
---|
3069 | }
|
---|
3070 | }
|
---|
3071 | }
|
---|
3072 | break;
|
---|
3073 | #endif // QT_NO_COMBOBOX
|
---|
3074 | #ifndef QT_NO_SPINBOX
|
---|
3075 | case CC_SpinBox:
|
---|
3076 | if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
|
---|
3077 | QStyleOptionSpinBox copy = *sb;
|
---|
3078 | PrimitiveElement pe;
|
---|
3079 | bool enabled = opt->state & State_Enabled;
|
---|
3080 | if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
|
---|
3081 | QBrush editBrush = sb->palette.brush(QPalette::Base);
|
---|
3082 | QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
|
---|
3083 | QPalette shadePal = sb->palette;
|
---|
3084 | shadePal.setColor(QPalette::Midlight, shadePal.button().color());
|
---|
3085 | qDrawWinPanel(p, r, shadePal, true, &editBrush);
|
---|
3086 | }
|
---|
3087 |
|
---|
3088 | QPalette shadePal(opt->palette);
|
---|
3089 | shadePal.setColor(QPalette::Button, opt->palette.light().color());
|
---|
3090 | shadePal.setColor(QPalette::Light, opt->palette.button().color());
|
---|
3091 |
|
---|
3092 | if (sb->subControls & SC_SpinBoxUp) {
|
---|
3093 | copy.subControls = SC_SpinBoxUp;
|
---|
3094 | QPalette pal2 = sb->palette;
|
---|
3095 | if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
|
---|
3096 | pal2.setCurrentColorGroup(QPalette::Disabled);
|
---|
3097 | copy.state &= ~State_Enabled;
|
---|
3098 | }
|
---|
3099 |
|
---|
3100 | copy.palette = pal2;
|
---|
3101 |
|
---|
3102 | if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
|
---|
3103 | copy.state |= State_On;
|
---|
3104 | copy.state |= State_Sunken;
|
---|
3105 | } else {
|
---|
3106 | copy.state |= State_Raised;
|
---|
3107 | copy.state &= ~State_Sunken;
|
---|
3108 | }
|
---|
3109 | pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
|
---|
3110 | : PE_IndicatorSpinUp);
|
---|
3111 |
|
---|
3112 | copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
|
---|
3113 | qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
|
---|
3114 | ©.palette.brush(QPalette::Button));
|
---|
3115 | copy.rect.adjust(4, 1, -5, -1);
|
---|
3116 | if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) ) {
|
---|
3117 | QStyleOptionSpinBox lightCopy = copy;
|
---|
3118 | lightCopy.rect.adjust(1, 1, 1, 1);
|
---|
3119 | lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
|
---|
3120 | proxy()->drawPrimitive(pe, &lightCopy, p, widget);
|
---|
3121 | }
|
---|
3122 | proxy()->drawPrimitive(pe, ©, p, widget);
|
---|
3123 | }
|
---|
3124 |
|
---|
3125 | if (sb->subControls & SC_SpinBoxDown) {
|
---|
3126 | copy.subControls = SC_SpinBoxDown;
|
---|
3127 | copy.state = sb->state;
|
---|
3128 | QPalette pal2 = sb->palette;
|
---|
3129 | if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
|
---|
3130 | pal2.setCurrentColorGroup(QPalette::Disabled);
|
---|
3131 | copy.state &= ~State_Enabled;
|
---|
3132 | }
|
---|
3133 | copy.palette = pal2;
|
---|
3134 |
|
---|
3135 | if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
|
---|
3136 | copy.state |= State_On;
|
---|
3137 | copy.state |= State_Sunken;
|
---|
3138 | } else {
|
---|
3139 | copy.state |= State_Raised;
|
---|
3140 | copy.state &= ~State_Sunken;
|
---|
3141 | }
|
---|
3142 | pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
|
---|
3143 | : PE_IndicatorSpinDown);
|
---|
3144 |
|
---|
3145 | copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
|
---|
3146 | qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
|
---|
3147 | ©.palette.brush(QPalette::Button));
|
---|
3148 | copy.rect.adjust(4, 0, -5, -1);
|
---|
3149 | if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) ) {
|
---|
3150 | QStyleOptionSpinBox lightCopy = copy;
|
---|
3151 | lightCopy.rect.adjust(1, 1, 1, 1);
|
---|
3152 | lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
|
---|
3153 | proxy()->drawPrimitive(pe, &lightCopy, p, widget);
|
---|
3154 | }
|
---|
3155 | proxy()->drawPrimitive(pe, ©, p, widget);
|
---|
3156 | }
|
---|
3157 | }
|
---|
3158 | break;
|
---|
3159 | #endif // QT_NO_SPINBOX
|
---|
3160 |
|
---|
3161 | default:
|
---|
3162 | QCommonStyle::drawComplexControl(cc, opt, p, widget);
|
---|
3163 | }
|
---|
3164 | }
|
---|
3165 |
|
---|
3166 | /*! \reimp */
|
---|
3167 | QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
---|
3168 | const QSize &csz, const QWidget *widget) const
|
---|
3169 | {
|
---|
3170 | QSize sz(csz);
|
---|
3171 | switch (ct) {
|
---|
3172 | case CT_PushButton:
|
---|
3173 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
|
---|
3174 | sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
|
---|
3175 | int w = sz.width(),
|
---|
3176 | h = sz.height();
|
---|
3177 | int defwidth = 0;
|
---|
3178 | if (btn->features & QStyleOptionButton::AutoDefaultButton)
|
---|
3179 | defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
|
---|
3180 | int minwidth = int(QStyleHelper::dpiScaled(75.));
|
---|
3181 | int minheight = int(QStyleHelper::dpiScaled(23.));
|
---|
3182 |
|
---|
3183 | #ifndef QT_QWS_SMALL_PUSHBUTTON
|
---|
3184 | if (w < minwidth + defwidth && !btn->text.isEmpty())
|
---|
3185 | w = minwidth + defwidth;
|
---|
3186 | if (h < minheight + defwidth)
|
---|
3187 | h = minheight + defwidth;
|
---|
3188 | #endif
|
---|
3189 | sz = QSize(w, h);
|
---|
3190 | }
|
---|
3191 | break;
|
---|
3192 | #ifndef QT_NO_MENU
|
---|
3193 | case CT_MenuItem:
|
---|
3194 | if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
|
---|
3195 | int w = sz.width();
|
---|
3196 | sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
|
---|
3197 |
|
---|
3198 | if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
|
---|
3199 | sz = QSize(10, QWindowsStylePrivate::windowsSepHeight);
|
---|
3200 | }
|
---|
3201 | else if (mi->icon.isNull()) {
|
---|
3202 | sz.setHeight(sz.height() - 2);
|
---|
3203 | w -= 6;
|
---|
3204 | }
|
---|
3205 |
|
---|
3206 | if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
|
---|
3207 | int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
---|
3208 | sz.setHeight(qMax(sz.height(),
|
---|
3209 | mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
|
---|
3210 | + 2 * QWindowsStylePrivate::windowsItemFrame));
|
---|
3211 | }
|
---|
3212 | int maxpmw = mi->maxIconWidth;
|
---|
3213 | int tabSpacing = 20;
|
---|
3214 | if (mi->text.contains(QLatin1Char('\t')))
|
---|
3215 | w += tabSpacing;
|
---|
3216 | else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
|
---|
3217 | w += 2 * QWindowsStylePrivate::windowsArrowHMargin;
|
---|
3218 | else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
|
---|
3219 | // adjust the font and add the difference in size.
|
---|
3220 | // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
|
---|
3221 | QFontMetrics fm(mi->font);
|
---|
3222 | QFont fontBold = mi->font;
|
---|
3223 | fontBold.setBold(true);
|
---|
3224 | QFontMetrics fmBold(fontBold);
|
---|
3225 | w += fmBold.width(mi->text) - fm.width(mi->text);
|
---|
3226 | }
|
---|
3227 |
|
---|
3228 | int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
|
---|
3229 | w += checkcol;
|
---|
3230 | w += QWindowsStylePrivate::windowsRightBorder + 10;
|
---|
3231 | sz.setWidth(w);
|
---|
3232 | }
|
---|
3233 | break;
|
---|
3234 | #endif // QT_NO_MENU
|
---|
3235 | #ifndef QT_NO_MENUBAR
|
---|
3236 | case CT_MenuBarItem:
|
---|
3237 | if (!sz.isEmpty())
|
---|
3238 | sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
|
---|
3239 | break;
|
---|
3240 | #endif
|
---|
3241 | // Otherwise, fall through
|
---|
3242 | case CT_ToolButton:
|
---|
3243 | if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
|
---|
3244 | return sz += QSize(7, 6);
|
---|
3245 | // Otherwise, fall through
|
---|
3246 |
|
---|
3247 | default:
|
---|
3248 | sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
|
---|
3249 | }
|
---|
3250 | return sz;
|
---|
3251 | }
|
---|
3252 |
|
---|
3253 | /*!
|
---|
3254 | \internal
|
---|
3255 | */
|
---|
3256 | QIcon QWindowsStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
|
---|
3257 | const QWidget *widget) const
|
---|
3258 | {
|
---|
3259 | QIcon icon;
|
---|
3260 | QPixmap pixmap;
|
---|
3261 | #ifdef Q_OS_WIN
|
---|
3262 | switch (standardIcon) {
|
---|
3263 | case SP_FileDialogNewFolder:
|
---|
3264 | {
|
---|
3265 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3266 | pixmap = loadIconFromShell32(319, size);
|
---|
3267 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3268 | }
|
---|
3269 | break;
|
---|
3270 | }
|
---|
3271 | case SP_DirHomeIcon:
|
---|
3272 | {
|
---|
3273 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3274 | pixmap = loadIconFromShell32(235, size);
|
---|
3275 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3276 | }
|
---|
3277 | break;
|
---|
3278 | }
|
---|
3279 | case SP_DirIcon:
|
---|
3280 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3281 | pixmap = loadIconFromShell32(4, size);
|
---|
3282 | icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
|
---|
3283 | pixmap = loadIconFromShell32(5, size);
|
---|
3284 | icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
|
---|
3285 | }
|
---|
3286 | break;
|
---|
3287 | case SP_DirLinkIcon:
|
---|
3288 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3289 | QPixmap link = loadIconFromShell32(30, size);
|
---|
3290 | pixmap = loadIconFromShell32(4, size);
|
---|
3291 | if (!pixmap.isNull() && !link.isNull()) {
|
---|
3292 | QPainter painter(&pixmap);
|
---|
3293 | painter.drawPixmap(0, 0, size, size, link);
|
---|
3294 | icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
|
---|
3295 | }
|
---|
3296 | link = loadIconFromShell32(30, size);
|
---|
3297 | pixmap = loadIconFromShell32(5, size);
|
---|
3298 | if (!pixmap.isNull() && !link.isNull()) {
|
---|
3299 | QPainter painter(&pixmap);
|
---|
3300 | painter.drawPixmap(0, 0, size, size, link);
|
---|
3301 | icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
|
---|
3302 | }
|
---|
3303 | }
|
---|
3304 | break;
|
---|
3305 | case SP_FileIcon:
|
---|
3306 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3307 | pixmap = loadIconFromShell32(1, size);
|
---|
3308 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3309 | }
|
---|
3310 | break;
|
---|
3311 | case SP_ComputerIcon:
|
---|
3312 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3313 | pixmap = loadIconFromShell32(16, size);
|
---|
3314 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3315 | }
|
---|
3316 | break;
|
---|
3317 |
|
---|
3318 | case SP_DesktopIcon:
|
---|
3319 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3320 | pixmap = loadIconFromShell32(35, size);
|
---|
3321 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3322 | }
|
---|
3323 | break;
|
---|
3324 | case SP_DriveCDIcon:
|
---|
3325 | case SP_DriveDVDIcon:
|
---|
3326 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3327 | pixmap = loadIconFromShell32(12, size);
|
---|
3328 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3329 | }
|
---|
3330 | break;
|
---|
3331 | case SP_DriveNetIcon:
|
---|
3332 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3333 | pixmap = loadIconFromShell32(10, size);
|
---|
3334 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3335 | }
|
---|
3336 | break;
|
---|
3337 | case SP_DriveHDIcon:
|
---|
3338 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3339 | pixmap = loadIconFromShell32(9, size);
|
---|
3340 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3341 | }
|
---|
3342 | break;
|
---|
3343 | case SP_DriveFDIcon:
|
---|
3344 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3345 | pixmap = loadIconFromShell32(7, size);
|
---|
3346 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3347 | }
|
---|
3348 | break;
|
---|
3349 | case SP_FileLinkIcon:
|
---|
3350 | for (int size = 16 ; size <= 32 ; size += 16) {
|
---|
3351 | QPixmap link;
|
---|
3352 | link = loadIconFromShell32(30, size);
|
---|
3353 | pixmap = loadIconFromShell32(1, size);
|
---|
3354 | if (!pixmap.isNull() && !link.isNull()) {
|
---|
3355 | QPainter painter(&pixmap);
|
---|
3356 | painter.drawPixmap(0, 0, size, size, link);
|
---|
3357 | icon.addPixmap(pixmap, QIcon::Normal);
|
---|
3358 | }
|
---|
3359 | }
|
---|
3360 | break;
|
---|
3361 | case SP_VistaShield:
|
---|
3362 | {
|
---|
3363 | if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
|
---|
3364 | && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
|
---|
3365 | && pSHGetStockIconInfo)
|
---|
3366 | {
|
---|
3367 | icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
|
---|
3368 | QSHSTOCKICONINFO iconInfo; //append large icon
|
---|
3369 | memset(&iconInfo, 0, sizeof(iconInfo));
|
---|
3370 | iconInfo.cbSize = sizeof(iconInfo);
|
---|
3371 | if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
|
---|
3372 | icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon));
|
---|
3373 | DestroyIcon(iconInfo.hIcon);
|
---|
3374 | }
|
---|
3375 | }
|
---|
3376 | }
|
---|
3377 | break;
|
---|
3378 | default:
|
---|
3379 | break;
|
---|
3380 | }
|
---|
3381 | #endif
|
---|
3382 |
|
---|
3383 | if (icon.isNull())
|
---|
3384 | icon = QCommonStyle::standardIconImplementation(standardIcon, option, widget);
|
---|
3385 | return icon;
|
---|
3386 | }
|
---|
3387 |
|
---|
3388 |
|
---|
3389 |
|
---|
3390 | QT_END_NAMESPACE
|
---|
3391 |
|
---|
3392 | #endif // QT_NO_STYLE_WINDOWS
|
---|