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