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