From 64288d509c634e6fabc6aaf7a464932a211c799e Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 21 Jan 2022 15:38:48 +0200 Subject: [PATCH] remove plastique and motif styles [ci reset] Signed-off-by: Ivailo Monev --- package/freebsd/pkg-plist | 4 - package/netbsd/PLIST | 4 - package/openbsd/pkg/PLIST | 4 - scripts/namefsck.py | 2 - src/core/global/qconfig.h.cmake | 9 +- src/core/global/qnamespace.qdoc | 3 +- src/gui/CMakeLists.txt | 6 - src/gui/kernel/qformlayout.cpp | 38 +- src/gui/qguicommon_p.h | 170 - src/gui/styles/qcleanlooksstyle.cpp | 3 +- src/gui/styles/qcommonstyle.cpp | 2 +- src/gui/styles/qmotifstyle.cpp | 2349 -------- src/gui/styles/qmotifstyle.h | 96 - src/gui/styles/qmotifstyle_p.h | 66 - src/gui/styles/qplastiquestyle.cpp | 5819 -------------------- src/gui/styles/qplastiquestyle.h | 85 - src/gui/styles/qstyle.cpp | 9 +- src/gui/styles/qstylefactory.cpp | 28 +- src/gui/styles/qstylesheetstyle.cpp | 5 +- src/gui/styles/qstylesheetstyle_default.cpp | 7 +- src/gui/styles/qwindowsstyle.cpp | 170 +- src/gui/widgets/qmenubar.cpp | 88 - src/tools/uic/cpp/cppwriteincludes.cpp | 6 - tests/auto/qformlayout/tst_qformlayout.cpp | 9 - tests/auto/qlistwidget/tst_qlistwidget.cpp | 2 +- tests/auto/qstyle/tst_qstyle.cpp | 81 +- .../auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 4 +- 27 files changed, 195 insertions(+), 8874 deletions(-) delete mode 100644 src/gui/styles/qmotifstyle.cpp delete mode 100644 src/gui/styles/qmotifstyle.h delete mode 100644 src/gui/styles/qmotifstyle_p.h delete mode 100644 src/gui/styles/qplastiquestyle.cpp delete mode 100644 src/gui/styles/qplastiquestyle.h diff --git a/package/freebsd/pkg-plist b/package/freebsd/pkg-plist index 29d58498a..de2fe7094 100644 --- a/package/freebsd/pkg-plist +++ b/package/freebsd/pkg-plist @@ -762,7 +762,6 @@ include/katie/QtGui/QMdiSubWindow include/katie/QtGui/QMenu include/katie/QtGui/QMenuBar include/katie/QtGui/QMessageBox -include/katie/QtGui/QMotifStyle include/katie/QtGui/QMouseEvent include/katie/QtGui/QMoveEvent include/katie/QtGui/QMovie @@ -783,7 +782,6 @@ include/katie/QtGui/QPixmap include/katie/QtGui/QPixmapCache include/katie/QtGui/QPlainTextDocumentLayout include/katie/QtGui/QPlainTextEdit -include/katie/QtGui/QPlastiqueStyle include/katie/QtGui/QPolygon include/katie/QtGui/QPolygonF include/katie/QtGui/QPrintDialog @@ -1067,7 +1065,6 @@ include/katie/QtGui/qmdisubwindow.h include/katie/QtGui/qmenu.h include/katie/QtGui/qmenubar.h include/katie/QtGui/qmessagebox.h -include/katie/QtGui/qmotifstyle.h include/katie/QtGui/qmovie.h include/katie/QtGui/qpagesetupdialog.h include/katie/QtGui/qpaintdevice.h @@ -1081,7 +1078,6 @@ include/katie/QtGui/qpen.h include/katie/QtGui/qpixmap.h include/katie/QtGui/qpixmapcache.h include/katie/QtGui/qplaintextedit.h -include/katie/QtGui/qplastiquestyle.h include/katie/QtGui/qpolygon.h include/katie/QtGui/qprintdialog.h include/katie/QtGui/qprintengine.h diff --git a/package/netbsd/PLIST b/package/netbsd/PLIST index bf12f7a53..cec99cc44 100644 --- a/package/netbsd/PLIST +++ b/package/netbsd/PLIST @@ -765,7 +765,6 @@ include/katie/QtGui/QMdiSubWindow include/katie/QtGui/QMenu include/katie/QtGui/QMenuBar include/katie/QtGui/QMessageBox -include/katie/QtGui/QMotifStyle include/katie/QtGui/QMouseEvent include/katie/QtGui/QMoveEvent include/katie/QtGui/QMovie @@ -786,7 +785,6 @@ include/katie/QtGui/QPixmap include/katie/QtGui/QPixmapCache include/katie/QtGui/QPlainTextDocumentLayout include/katie/QtGui/QPlainTextEdit -include/katie/QtGui/QPlastiqueStyle include/katie/QtGui/QPolygon include/katie/QtGui/QPolygonF include/katie/QtGui/QPrintDialog @@ -1070,7 +1068,6 @@ include/katie/QtGui/qmdisubwindow.h include/katie/QtGui/qmenu.h include/katie/QtGui/qmenubar.h include/katie/QtGui/qmessagebox.h -include/katie/QtGui/qmotifstyle.h include/katie/QtGui/qmovie.h include/katie/QtGui/qpagesetupdialog.h include/katie/QtGui/qpaintdevice.h @@ -1084,7 +1081,6 @@ include/katie/QtGui/qpen.h include/katie/QtGui/qpixmap.h include/katie/QtGui/qpixmapcache.h include/katie/QtGui/qplaintextedit.h -include/katie/QtGui/qplastiquestyle.h include/katie/QtGui/qpolygon.h include/katie/QtGui/qprintdialog.h include/katie/QtGui/qprintengine.h diff --git a/package/openbsd/pkg/PLIST b/package/openbsd/pkg/PLIST index bac35cce9..3739ead0f 100644 --- a/package/openbsd/pkg/PLIST +++ b/package/openbsd/pkg/PLIST @@ -770,7 +770,6 @@ include/katie/QtGui/QMdiSubWindow include/katie/QtGui/QMenu include/katie/QtGui/QMenuBar include/katie/QtGui/QMessageBox -include/katie/QtGui/QMotifStyle include/katie/QtGui/QMouseEvent include/katie/QtGui/QMoveEvent include/katie/QtGui/QMovie @@ -791,7 +790,6 @@ include/katie/QtGui/QPixmap include/katie/QtGui/QPixmapCache include/katie/QtGui/QPlainTextDocumentLayout include/katie/QtGui/QPlainTextEdit -include/katie/QtGui/QPlastiqueStyle include/katie/QtGui/QPolygon include/katie/QtGui/QPolygonF include/katie/QtGui/QPrintDialog @@ -1075,7 +1073,6 @@ include/katie/QtGui/qmdisubwindow.h include/katie/QtGui/qmenu.h include/katie/QtGui/qmenubar.h include/katie/QtGui/qmessagebox.h -include/katie/QtGui/qmotifstyle.h include/katie/QtGui/qmovie.h include/katie/QtGui/qpagesetupdialog.h include/katie/QtGui/qpaintdevice.h @@ -1089,7 +1086,6 @@ include/katie/QtGui/qpen.h include/katie/QtGui/qpixmap.h include/katie/QtGui/qpixmapcache.h include/katie/QtGui/qplaintextedit.h -include/katie/QtGui/qplastiquestyle.h include/katie/QtGui/qpolygon.h include/katie/QtGui/qprintdialog.h include/katie/QtGui/qprintengine.h diff --git a/scripts/namefsck.py b/scripts/namefsck.py index 7390db704..ddf63f7f4 100755 --- a/scripts/namefsck.py +++ b/scripts/namefsck.py @@ -416,7 +416,6 @@ classlist = [ "QMimeData", "QModelIndex", "QModelIndexList", - "QMotifStyle", "QMouseEvent", "QMoveEvent", "QMovie", @@ -469,7 +468,6 @@ classlist = [ "QPixmapCache", "QPlainTextDocumentLayout", "QPlainTextEdit", - "QPlastiqueStyle", "QPlugin", "QPluginLoader", "QPoint", diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index 59a7187a4..28e5cb571 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -109,6 +109,8 @@ #define QT_NO_STL_WCHAR #define QT_NO_BEARERMANAGEMENT #define QT_NO_GESTURES +#define QT_NO_STYLE_MOTIF +#define QT_NO_STYLE_PLASTIQUE // Not supported, used to bootstrap #cmakedefine QT_NO_QOBJECT @@ -268,8 +270,6 @@ #cmakedefine QT_NO_STATUSTIP #cmakedefine QT_NO_STRINGLISTMODEL #cmakedefine QT_NO_STYLE_CLEANLOOKS -#cmakedefine QT_NO_STYLE_MOTIF -#cmakedefine QT_NO_STYLE_PLASTIQUE #cmakedefine QT_NO_STYLE_PROXY #cmakedefine QT_NO_STYLE_STYLESHEET #cmakedefine QT_NO_STYLE_WINDOWS @@ -477,11 +477,6 @@ # define QT_NO_STYLE_CLEANLOOKS #endif -// QPlastiqueStyle -#if !defined(QT_NO_STYLE_PLASTIQUE) && (defined(QT_NO_STYLE_WINDOWS) || defined(QT_NO_XPM)) -# define QT_NO_STYLE_PLASTIQUE -#endif - // QStyleSheetStyle #if !defined(QT_NO_STYLE_STYLESHEET) && (defined(QT_NO_STYLE_WINDOWS) || defined(QT_NO_PROPERTIES) || defined(QT_NO_CSSPARSER)) # define QT_NO_STYLE_STYLESHEET diff --git a/src/core/global/qnamespace.qdoc b/src/core/global/qnamespace.qdoc index df842aaea..ea4ccb73a 100644 --- a/src/core/global/qnamespace.qdoc +++ b/src/core/global/qnamespace.qdoc @@ -702,8 +702,7 @@ on QWidget::contentsRect(). This is set by the widget's author. \value WA_LayoutUsesWidgetRect Ignore the layout item rect from the style - when laying out this widget with QLayout. This makes a difference in - QPlastiqueStyle for some widgets. + when laying out this widget with QLayout. \value WA_Mapped Indicates that the widget is mapped on screen. This is set/cleared by the Qt kernel. diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 0fefcc6bf..c5275628b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -115,7 +115,6 @@ set(GUI_PUBLIC_HEADERS QMdiSubWindow QMenu QMenuBar - QMotifStyle QMovie QPageSetupDialog QPaintDevice @@ -127,7 +126,6 @@ set(GUI_PUBLIC_HEADERS QPixmap QPixmapCache QPlainTextEdit - QPlastiqueStyle QPolygon QPrintDialog QPrintEngine @@ -466,8 +464,6 @@ set(GUI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/styles/qproxystyle.h ${CMAKE_CURRENT_SOURCE_DIR}/styles/qproxystyle_p.h ${CMAKE_CURRENT_SOURCE_DIR}/styles/qstylesheetstyle_p.h - ${CMAKE_CURRENT_SOURCE_DIR}/styles/qplastiquestyle.h - ${CMAKE_CURRENT_SOURCE_DIR}/styles/qmotifstyle.h ${CMAKE_CURRENT_SOURCE_DIR}/styles/qwindowsstyle.h ${CMAKE_CURRENT_SOURCE_DIR}/styles/qcleanlooksstyle.h ${CMAKE_CURRENT_SOURCE_DIR}/styles/qcleanlooksstyle_p.h @@ -795,8 +791,6 @@ set(GUI_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/styles/qproxystyle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/styles/qstylesheetstyle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/styles/qstylesheetstyle_default.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/styles/qplastiquestyle.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/styles/qmotifstyle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/styles/qwindowsstyle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/styles/qcleanlooksstyle.cpp ${CMAKE_CURRENT_SOURCE_DIR}/styles/qstyle.qrc diff --git a/src/gui/kernel/qformlayout.cpp b/src/gui/kernel/qformlayout.cpp index c2efaf8e7..216c0fa9a 100644 --- a/src/gui/kernel/qformlayout.cpp +++ b/src/gui/kernel/qformlayout.cpp @@ -1017,38 +1017,7 @@ QStyle* QFormLayoutPrivate::getStyle() const \snippet doc/src/snippets/code/src_gui_kernel_qformlayout.cpp 1 \endlist - The table below shows the default appearance in different styles. - - \table - \header - \o QCommonStyle derived styles (except QPlastiqueStyle) - \o QPlastiqueStyle - \o Qt Extended styles - \row - \o \inlineimage qformlayout-win.png - \o \inlineimage qformlayout-mac.png - \o \inlineimage qformlayout-kde.png - \o \inlineimage qformlayout-qpe.png - \row - \o Traditional style used for Windows, GNOME, and earlier - versions of KDE. Labels are left aligned, and expanding - fields grow to fill the available space. (This normally - corresponds to what we would get using a two-column - QGridLayout.) - \o Style based on the - \l{Mac OS X Aqua} guidelines. Labels are right-aligned, - the fields don't grow beyond their size hint, and the - form is horizontally centered. - \o Recommended style for - \l{KDE applications}. Similar to MacStyle, except that the form - is left-aligned and all fields grow to fill the available - space. - \o Default style for Qt Extended styles. Labels are right-aligned, - expanding fields grow to fill the available space, and row - wrapping is enabled for long lines. - \endtable - - The form styles can be also be overridden individually by calling + The form styles can be be overridden individually by calling setLabelAlignment(), setFormAlignment(), setFieldGrowthPolicy(), and setRowWrapPolicy(). @@ -1725,9 +1694,8 @@ QFormLayout::RowWrapPolicy QFormLayout::rowWrapPolicy() const \brief the horizontal alignment of the labels The default value depends on the widget or application style. For - QCommonStyle derived styles, except for QPlastiqueStyle, the - default is Qt::AlignLeft; for the other styles, the default is - Qt::AlignRight. + QCommonStyle derived styles, the default is Qt::AlignLeft; for + the other styles, the default is Qt::AlignRight. \sa formAlignment */ diff --git a/src/gui/qguicommon_p.h b/src/gui/qguicommon_p.h index 4ea0693f5..885319401 100644 --- a/src/gui/qguicommon_p.h +++ b/src/gui/qguicommon_p.h @@ -146,176 +146,6 @@ inline static int lowest_bit(uint v) static const qreal inv_dist_to_plane = 1. / 1024.; -#ifndef QT_NO_XPM -// Message box icons, from page 210 of the Windows style guide. - -// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette. -// Thanks to TrueColor displays, it is slightly more efficient to have -// them duplicated. -/* XPM */ -static const char * const qt_information_xpm[]={ - "32 32 5 1", - ". c None", - "c c #000000", - "* c #999999", - "a c #ffffff", - "b c #0000ff", - "...........********.............", - "........***aaaaaaaa***..........", - "......**aaaaaaaaaaaaaa**........", - ".....*aaaaaaaaaaaaaaaaaa*.......", - "....*aaaaaaaabbbbaaaaaaaac......", - "...*aaaaaaaabbbbbbaaaaaaaac.....", - "..*aaaaaaaaabbbbbbaaaaaaaaac....", - ".*aaaaaaaaaaabbbbaaaaaaaaaaac...", - ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..", - "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.", - "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.", - "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", - "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", - "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", - "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", - "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", - ".*aaaaaaaaaaabbbbbaaaaaaaaaac***", - ".*aaaaaaaaaaabbbbbaaaaaaaaaac***", - "..*aaaaaaaaaabbbbbaaaaaaaaac***.", - "...caaaaaaabbbbbbbbbaaaaaac****.", - "....caaaaaaaaaaaaaaaaaaaac****..", - ".....caaaaaaaaaaaaaaaaaac****...", - "......ccaaaaaaaaaaaaaacc****....", - ".......*cccaaaaaaaaccc*****.....", - "........***cccaaaac*******......", - "..........****caaac*****........", - ".............*caaac**...........", - "...............caac**...........", - "................cac**...........", - ".................cc**...........", - "..................***...........", - "...................**..........."}; - -/* XPM */ -static const char* const qt_warning_xpm[]={ - "32 32 4 1", - ". c None", - "a c #ffff00", - "* c #000000", - "b c #999999", - ".............***................", - "............*aaa*...............", - "...........*aaaaa*b.............", - "...........*aaaaa*bb............", - "..........*aaaaaaa*bb...........", - "..........*aaaaaaa*bb...........", - ".........*aaaaaaaaa*bb..........", - ".........*aaaaaaaaa*bb..........", - "........*aaaaaaaaaaa*bb.........", - "........*aaaa***aaaa*bb.........", - ".......*aaaa*****aaaa*bb........", - ".......*aaaa*****aaaa*bb........", - "......*aaaaa*****aaaaa*bb.......", - "......*aaaaa*****aaaaa*bb.......", - ".....*aaaaaa*****aaaaaa*bb......", - ".....*aaaaaa*****aaaaaa*bb......", - "....*aaaaaaaa***aaaaaaaa*bb.....", - "....*aaaaaaaa***aaaaaaaa*bb.....", - "...*aaaaaaaaa***aaaaaaaaa*bb....", - "...*aaaaaaaaaa*aaaaaaaaaa*bb....", - "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...", - "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...", - ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..", - ".*aaaaaaaaaaa****aaaaaaaaaa*bb..", - "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.", - "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.", - "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", - "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", - ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb", - "..*************************bbbbb", - "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.", - ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."}; - -/* XPM */ -static const char* const qt_critical_xpm[]={ - "32 32 4 1", - ". c None", - "a c #999999", - "* c #ff0000", - "b c #ffffff", - "...........********.............", - ".........************...........", - ".......****************.........", - "......******************........", - ".....********************a......", - "....**********************a.....", - "...************************a....", - "..*******b**********b*******a...", - "..******bbb********bbb******a...", - ".******bbbbb******bbbbb******a..", - ".*******bbbbb****bbbbb*******a..", - "*********bbbbb**bbbbb*********a.", - "**********bbbbbbbbbb**********a.", - "***********bbbbbbbb***********aa", - "************bbbbbb************aa", - "************bbbbbb************aa", - "***********bbbbbbbb***********aa", - "**********bbbbbbbbbb**********aa", - "*********bbbbb**bbbbb*********aa", - ".*******bbbbb****bbbbb*******aa.", - ".******bbbbb******bbbbb******aa.", - "..******bbb********bbb******aaa.", - "..*******b**********b*******aa..", - "...************************aaa..", - "....**********************aaa...", - "....a********************aaa....", - ".....a******************aaa.....", - "......a****************aaa......", - ".......aa************aaaa.......", - ".........aa********aaaaa........", - "...........aaaaaaaaaaa..........", - ".............aaaaaaa............"}; - -/* XPM */ -static const char *const qt_question_xpm[] = { - "32 32 5 1", - ". c None", - "c c #000000", - "* c #999999", - "a c #ffffff", - "b c #0000ff", - "...........********.............", - "........***aaaaaaaa***..........", - "......**aaaaaaaaaaaaaa**........", - ".....*aaaaaaaaaaaaaaaaaa*.......", - "....*aaaaaaaaaaaaaaaaaaaac......", - "...*aaaaaaaabbbbbbaaaaaaaac.....", - "..*aaaaaaaabaaabbbbaaaaaaaac....", - ".*aaaaaaaabbaaaabbbbaaaaaaaac...", - ".*aaaaaaaabbbbaabbbbaaaaaaaac*..", - "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.", - "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.", - "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**", - "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**", - "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**", - "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**", - "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**", - ".*aaaaaaaaaaaabbaaaaaaaaaaaac***", - ".*aaaaaaaaaaabbbbaaaaaaaaaaac***", - "..*aaaaaaaaaabbbbaaaaaaaaaac***.", - "...caaaaaaaaaabbaaaaaaaaaac****.", - "....caaaaaaaaaaaaaaaaaaaac****..", - ".....caaaaaaaaaaaaaaaaaac****...", - "......ccaaaaaaaaaaaaaacc****....", - ".......*cccaaaaaaaaccc*****.....", - "........***cccaaaac*******......", - "..........****caaac*****........", - ".............*caaac**...........", - "...............caac**...........", - "................cac**...........", - ".................cc**...........", - "..................***...........", - "...................**...........", -}; -#endif - // use the same rounding as in qrasterizer.cpp (6 bit fixed point) static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 33f5b2770..73aff473f 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -564,8 +564,7 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi that closely resembles the Clearlooks style, introduced by Richard Stellingwerff and Daniel Borgmann. - \sa {Cleanlooks Style Widget Gallery}, QWindowsStyle, QMotifStyle, - QPlastiqueStyle + \sa {Cleanlooks Style Widget Gallery}, QWindowsStyle */ /*! diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index b00a7ce59..2de5c11f9 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -195,7 +195,7 @@ static const char * const filedialog_end_xpm[]={ subElementRect() are documented here. \endomit - \sa QStyle, QMotifStyle, QWindowsStyle + \sa QStyle, QWindowsStyle */ /*! diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp deleted file mode 100644 index 197d539d3..000000000 --- a/src/gui/styles/qmotifstyle.cpp +++ /dev/null @@ -1,2349 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmotifstyle.h" - -#if !defined(QT_NO_STYLE_MOTIF) - -#include "qmenu.h" -#include "qapplication.h" -#include "qpainter.h" -#include "qdrawutil.h" -#include "qpixmap.h" -#include "qpalette.h" -#include "qwidget.h" -#include "qpushbutton.h" -#include "qscrollbar.h" -#include "qtabbar.h" -#include "qtabwidget.h" -#include "qlistview.h" -#include "qsplitter.h" -#include "qslider.h" -#include "qcombobox.h" -#include "qlineedit.h" -#include "qprogressbar.h" -#include "qimage.h" -#include "qfocusframe.h" -#include "qdebug.h" -#include "qpainterpath.h" -#include "qmotifstyle_p.h" -#include "qdialogbuttonbox.h" -#include "qformlayout.h" -#include "qgraphicsproxywidget.h" -#include "qgraphicsview.h" -#include "qguicommon_p.h" - -#ifdef Q_WS_X11 -#include "qx11info_x11.h" -#endif - -#include - -QT_BEGIN_NAMESPACE - -// old constants that might still be useful... -static const int motifItemFrame = 2; // menu item frame width -static const int motifSepHeight = 2; // separator item height -static const int motifItemHMargin = 3; // menu item hor text margin -static const int motifItemVMargin = 2; // menu item ver text margin -static const int motifArrowHMargin = 6; // arrow horizontal margin -static const int motifTabSpacing = 12; // space between text and tab -static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark -static const int motifCheckMarkSpace = 16; - - -/*! - \class QMotifStyle - \brief The QMotifStyle class provides Motif look and feel. - - \ingroup appearance - - This class implements the Motif look and feel. It closely - resembles the original Motif look as defined by the Open Group, - but with some minor improvements. The Motif style is Qt's default - GUI style on Unix platforms. - - \img qmotifstyle.png - \sa QWindowsStyle, QPlastiqueStyle -*/ - -/*! - \variable QMotifStyle::focus - \internal -*/ - -/*! - Constructs a QMotifStyle. - - If \a useHighlightCols is false (the default), the style will - polish the application's color palette to emulate the Motif way of - highlighting, which is a simple inversion between the base and the - text color. -*/ -QMotifStyle::QMotifStyle(bool useHighlightCols) - : QCommonStyle(*new QMotifStylePrivate(useHighlightCols)) -{ - setObjectName(QLatin1String("Motif")); -} - - -/*! - \internal -*/ -QMotifStyle::QMotifStyle(QMotifStylePrivate &dd) - : QCommonStyle(dd) -{ - setObjectName(QLatin1String("Motif")); -} - -/*! - \internal - Animate indeterminate progress bars only when visible -*/ -bool QMotifStyle::eventFilter(QObject *o, QEvent *e) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QMotifStyle); - switch(e->type()) { - case QEvent::StyleChange: - case QEvent::Show: - if (QProgressBar *bar = qobject_cast(o)) { - d->bars << bar; - if (d->bars.size() == 1) { - Q_ASSERT(d->animationFps> 0); - d->animateTimer = startTimer(1000 / d->animationFps); - } - } - break; - case QEvent::Destroy: - case QEvent::Hide: - // reinterpret_cast because there is no type info when getting - // the destroy event. We know that it is a QProgressBar. - if (QProgressBar *bar = reinterpret_cast(o)) { - d->bars.removeAll(bar); - if (d->bars.isEmpty() && d->animateTimer) { - killTimer(d->animateTimer); - d->animateTimer = 0; - } - } - default: - break; - } -#endif // QT_NO_PROGRESSBAR - return QCommonStyle::eventFilter(o, e); -} - -/*! - \reimp -*/ -void QMotifStyle::timerEvent(QTimerEvent *event) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QMotifStyle); - if (event->timerId() == d->animateTimer) { - Q_ASSERT(d->animationFps > 0); - d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps); - foreach (QProgressBar *bar, d->bars) { - if ((bar->minimum() == 0 && bar->maximum() == 0)) - bar->update(); - } - } -#endif // QT_NO_PROGRESSBAR - QCommonStyle::timerEvent(event); -} - -QMotifStylePrivate::QMotifStylePrivate(bool useHighlightCols) - : QCommonStylePrivate(), - focus(nullptr), - highlightCols(useHighlightCols), -#ifndef QT_NO_PROGRESSBAR - animationFps(25), animateTimer(0), animateStep(0) -#endif -{ -} - -QMotifStylePrivate::~QMotifStylePrivate() -{ - delete focus; -} - -/*! - If \a arg is false, the style will polish the application's color - palette to emulate the Motif way of highlighting, which is a - simple inversion between the base and the text color. - - The effect will show up the next time an application palette is - set via QApplication::setPalette(). The current color palette of - the application remains unchanged. - - \sa QStyle::polish() -*/ -void QMotifStyle::setUseHighlightColors(bool arg) -{ - Q_D(QMotifStyle); - d->highlightCols = arg; -} - -/*! - Returns true if the style treats the highlight colors of the - palette in a Motif-like manner, which is a simple inversion - between the base and the text color; otherwise returns false. The - default is false. -*/ -bool QMotifStyle::useHighlightColors() const -{ - Q_D(const QMotifStyle); - return d->highlightCols; -} - -/*! \reimp */ - -void QMotifStyle::polish(QPalette& pal) -{ - Q_D(const QMotifStyle); - if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) { - QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108); - pal.setColor(QPalette::Active, QPalette::Light, nlight) ; - pal.setColor(QPalette::Disabled, QPalette::Light, nlight) ; - pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ; - } - - if (d->highlightCols) - return; - - // force the ugly motif way of highlighting *sigh* - pal.setColor(QPalette::Active, QPalette::Highlight, - pal.color(QPalette::Active, QPalette::Text)); - pal.setColor(QPalette::Active, QPalette::HighlightedText, - pal.color(QPalette::Active, QPalette::Base)); - pal.setColor(QPalette::Disabled, QPalette::Highlight, - pal.color(QPalette::Disabled, QPalette::Text)); - pal.setColor(QPalette::Disabled, QPalette::HighlightedText, - pal.color(QPalette::Disabled, QPalette::Base)); - pal.setColor(QPalette::Inactive, QPalette::Highlight, - pal.color(QPalette::Active, QPalette::Text)); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, - pal.color(QPalette::Active, QPalette::Base)); -} - -/*! - \reimp - \internal - Keep QStyle::polish() visible. -*/ -void QMotifStyle::polish(QWidget* widget) -{ - QCommonStyle::polish(widget); -#ifndef QT_NO_PROGRESSBAR - if (qobject_cast(widget)) - widget->installEventFilter(this); -#endif -} - -/*! - \reimp - \internal - Keep QStyle::polish() visible. -*/ -void QMotifStyle::unpolish(QWidget* widget) -{ - QCommonStyle::unpolish(widget); -#ifndef QT_NO_PROGRESSBAR - if (qobject_cast(widget)) { - Q_D(QMotifStyle); - widget->removeEventFilter(this); - d->bars.removeAll(static_cast(widget)); - } -#endif -} - - -/*! - \reimp - \internal - Keep QStyle::polish() visible. -*/ -void QMotifStyle::polish(QApplication* a) -{ - QCommonStyle::polish(a); -} - - -/*! - \reimp - \internal - Keep QStyle::polish() visible. -*/ -void QMotifStyle::unpolish(QApplication* a) -{ - QCommonStyle::unpolish(a); -} - -static void rot(QPolygon& a, int n) -{ - QPolygon r(a.size()); - for (int i = 0; i < (int)a.size(); i++) { - switch (n) { - case 1: r.setPoint(i,-a[i].y(),a[i].x()); break; - case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break; - case 3: r.setPoint(i,a[i].y(),-a[i].x()); break; - } - } - a = r; -} - - -/*! - \reimp -*/ -void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w) const -{ - Q_D(const QMotifStyle); - switch(pe) { - - case PE_FrameTabWidget: - case PE_FrameWindow: - qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, proxy()->pixelMetric(PM_DefaultFrameWidth)); - break; - case PE_FrameFocusRect: - if (const QStyleOptionFocusRect *fropt = qstyleoption_cast(opt)) { - if ((fropt->state & State_HasFocus) && d->focus && d->focus->isVisible() - && !(fropt->state & QStyle::State_Item)) - break; - QCommonStyle::drawPrimitive(pe, opt, p, w); - } - break; - - case PE_IndicatorToolBarHandle: { - p->save(); - p->translate(opt->rect.x(), opt->rect.y()); - - QColor dark(opt->palette.dark().color()); - QColor light(opt->palette.light().color()); - int i; - if (opt->state & State_Horizontal) { - int h = opt->rect.height(); - if (h > 6) { - if (opt->state & State_On) - p->fillRect(1, 1, 8, h - 2, opt->palette.highlight()); - QPolygon a(2 * ((h-6)/3)); - int y = 3 + (h%3)/2; - p->setPen(dark); - p->drawLine(8, 1, 8, h-2); - for (i=0; 2*i < a.size(); ++i) { - a.setPoint(2*i, 5, y+1+3*i); - a.setPoint(2*i+1, 2, y+2+3*i); - } - p->drawPoints(a); - p->setPen(light); - p->drawLine(9, 1, 9, h-2); - for (i=0; 2*i < a.size(); i++) { - a.setPoint(2*i, 4, y+3*i); - a.setPoint(2*i+1, 1, y+1+3*i); - } - p->drawPoints(a); - // if (drawBorder) { - // p->setPen(QPen(Qt::darkGray)); - // p->drawLine(0, opt->rect.height() - 1, - // tbExtent, opt->rect.height() - 1); - // } - } - } else { - int w = opt->rect.width(); - if (w > 6) { - if (opt->state & State_On) - p->fillRect(1, 1, w - 2, 9, opt->palette.highlight()); - QPolygon a(2 * ((w-6)/3)); - - int x = 3 + (w%3)/2; - p->setPen(dark); - p->drawLine(1, 8, w-2, 8); - for (i=0; 2*i < a.size(); ++i) { - a.setPoint(2*i, x+1+3*i, 6); - a.setPoint(2*i+1, x+2+3*i, 3); - } - p->drawPoints(a); - p->setPen(light); - p->drawLine(1, 9, w-2, 9); - for (i=0; 2*i < a.size(); ++i) { - a.setPoint(2*i, x+3*i, 5); - a.setPoint(2*i+1, x+1+3*i, 2); - } - p->drawPoints(a); - // if (drawBorder) { - // p->setPen(QPen(Qt::darkGray)); - // p->drawLine(opt->rect.width() - 1, 0, - // opt->rect.width() - 1, tbExtent); - // } - } - } - p->restore(); - break; } - - case PE_PanelButtonCommand: - case PE_PanelButtonBevel: - case PE_PanelButtonTool: { - QBrush fill; - if (opt->state & State_Sunken) - fill = opt->palette.brush(QPalette::Mid); - else if ((opt->state & State_On) && (opt->state & State_Enabled)) - fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern); - else - fill = opt->palette.brush(QPalette::Button); - if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise)) - qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)), - proxy()->pixelMetric(PM_DefaultFrameWidth), &fill); - break; } - - case PE_IndicatorCheckBox: { - bool on = opt->state & State_On; - bool down = opt->state & State_Sunken; - bool showUp = !(down ^ on); - QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid); - if (opt->state & State_NoChange) { - qDrawPlainRect(p, opt->rect, opt->palette.text().color(), - 1, &fill); - p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(), - opt->rect.x(), opt->rect.y() + opt->rect.height() - 1); - } else { - qDrawShadePanel(p, opt->rect, opt->palette, !showUp, - proxy()->pixelMetric(PM_DefaultFrameWidth), &fill); - } - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); - break; } - - case PE_IndicatorRadioButton: { -#define INTARRLEN(x) sizeof(x)/(sizeof(int)*2) - int inner_pts[] = { // used for filling diamond - 2,opt->rect.height()/2, - opt->rect.width()/2,2, - opt->rect.width()-3,opt->rect.height()/2, - opt->rect.width()/2,opt->rect.height()-3 - }; - int top_pts[] = { // top (^) of diamond - 0,opt->rect.height()/2, - opt->rect.width()/2,0, - opt->rect.width()-2,opt->rect.height()/2-1, - opt->rect.width()-3,opt->rect.height()/2-1, - opt->rect.width()/2,1, - 1,opt->rect.height()/2, - 2,opt->rect.height()/2, - opt->rect.width()/2,2, - opt->rect.width()-4,opt->rect.height()/2-1 - }; - int bottom_pts[] = { // bottom (v) of diamond - 1,opt->rect.height()/2+1, - opt->rect.width()/2,opt->rect.height()-1, - opt->rect.width()-1,opt->rect.height()/2, - opt->rect.width()-2,opt->rect.height()/2, - opt->rect.width()/2,opt->rect.height()-2, - 2,opt->rect.height()/2+1, - 3,opt->rect.height()/2+1, - opt->rect.width()/2,opt->rect.height()-3, - opt->rect.width()-3,opt->rect.height()/2 - }; - bool on = opt->state & State_On; - bool down = opt->state & State_Sunken; - bool showUp = !(down ^ on); - QPen oldPen = p->pen(); - QBrush oldBrush = p->brush(); - QPolygon a(INTARRLEN(inner_pts), inner_pts); - p->setPen(Qt::NoPen); - p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid)); - a.translate(opt->rect.x(), opt->rect.y()); - p->drawPolygon(a); - p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color()); - p->setBrush(Qt::NoBrush); - a.setPoints(INTARRLEN(top_pts), top_pts); - a.translate(opt->rect.x(), opt->rect.y()); - p->drawPolyline(a); - p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color()); - a.setPoints(INTARRLEN(bottom_pts), bottom_pts); - a.translate(opt->rect.x(), opt->rect.y()); - p->drawPolyline(a); - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); - p->setPen(oldPen); - p->setBrush(oldBrush); - break; } - - case PE_IndicatorSpinUp: - case PE_IndicatorSpinPlus: - case PE_IndicatorSpinDown: - case PE_IndicatorSpinMinus: - case PE_IndicatorArrowUp: - case PE_IndicatorArrowDown: - case PE_IndicatorArrowRight: - case PE_IndicatorArrowLeft: { - QRect rect = opt->rect; - QPolygon bFill; - QPolygon bTop; - QPolygon bBot; - QPolygon bLeft; - if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp) - pe = PE_IndicatorArrowUp; - else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown) - pe = PE_IndicatorArrowDown; - bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown; - bool horizontal = !vertical; - int dim = rect.width() < rect.height() ? rect.width() : rect.height(); - int colspec = 0x0000; - - if (!(opt->state & State_Enabled)) - dim -= 2; - if(dim < 2) - break; - - // adjust size and center (to fix rotation below) - if (rect.width() > dim) { - rect.setX(rect.x() + ((rect.width() - dim) / 2)); - rect.setWidth(dim); - } - if (rect.height() > dim) { - rect.setY(rect.y() + ((rect.height() - dim) / 2)); - rect.setHeight(dim); - } - - if (dim > 3) { - if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style - bFill.resize( dim & 1 ? 3 : 4 ); - bTop.resize( 2 ); - bBot.resize( 2 ); - bLeft.resize( 2 ); - bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 ); - bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 ); - bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 ); - - if ( dim > 6 ) { // dim>6: must fill interior - bFill.putPoints( 0, 2, 0, dim-1, 0, 0 ); - if ( dim & 1 ) // if size is an odd number - bFill.setPoint( 2, dim - 1, dim / 2 ); - else - bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 ); - } - } else { - if (dim > 6) - bFill.resize(dim & 1 ? 3 : 4); - bTop.resize((dim/2)*2); - bBot.resize(dim & 1 ? dim + 1 : dim); - bLeft.resize(dim > 4 ? 4 : 2); - bLeft.putPoints(0, 2, 0,0, 0,dim-1); - if (dim > 4) - bLeft.putPoints(2, 2, 1,2, 1,dim-3); - bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1); - bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2); - - for(int i=0; i 6) { // dim>6: must fill interior - bFill.putPoints(0, 2, 1,dim-3, 1,2); - if (dim & 1) // if size is an odd number - bFill.setPoint(2, dim - 3, dim / 2); - else - bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2); - } - } - } else { - if (dim == 3) { // 3x3 arrow pattern - bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1); - bTop .setPoints(2, 1,0, 1,0); - bBot .setPoints(2, 1,2, 2,1); - } - else { // 2x2 arrow pattern - bLeft.setPoints(2, 0,0, 0,1); - bTop .setPoints(2, 1,0, 1,0); - bBot .setPoints(2, 1,1, 1,1); - } - } - - // We use rot() and translate() as it is more efficient that - // matrix transformations on the painter, and because it still - // works with QT_NO_TRANSFORMATIONS defined. - - if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) { - if (vertical) { - rot(bFill,3); - rot(bLeft,3); - rot(bTop,3); - rot(bBot,3); - bFill.translate(0, rect.height() - 1); - bLeft.translate(0, rect.height() - 1); - bTop.translate(0, rect.height() - 1); - bBot.translate(0, rect.height() - 1); - } else { - rot(bFill,2); - rot(bLeft,2); - rot(bTop,2); - rot(bBot,2); - bFill.translate(rect.width() - 1, rect.height() - 1); - bLeft.translate(rect.width() - 1, rect.height() - 1); - bTop.translate(rect.width() - 1, rect.height() - 1); - bBot.translate(rect.width() - 1, rect.height() - 1); - } - if (opt->state & State_Sunken) - colspec = horizontal ? 0x2334 : 0x2343; - else - colspec = horizontal ? 0x1443 : 0x1434; - } else { - if (vertical) { - rot(bFill,1); - rot(bLeft,1); - rot(bTop,1); - rot(bBot,1); - bFill.translate(rect.width() - 1, 0); - bLeft.translate(rect.width() - 1, 0); - bTop.translate(rect.width() - 1, 0); - bBot.translate(rect.width() - 1, 0); - } - if (opt->state & State_Sunken) - colspec = horizontal ? 0x2443 : 0x2434; - else - colspec = horizontal ? 0x1334 : 0x1343; - } - bFill.translate(rect.x(), rect.y()); - bLeft.translate(rect.x(), rect.y()); - bTop.translate(rect.x(), rect.y()); - bBot.translate(rect.x(), rect.y()); - - const QColor *cols[5]; - if (opt->state & State_Enabled) { - cols[0] = 0; - cols[1] = &opt->palette.button().color(); - cols[2] = &opt->palette.mid().color(); - cols[3] = &opt->palette.light().color(); - cols[4] = &opt->palette.dark().color(); - } else { - cols[0] = 0; - cols[1] = &opt->palette.mid().color(); - cols[2] = &opt->palette.mid().color(); - cols[3] = &opt->palette.mid().color(); - cols[4] = &opt->palette.mid().color(); - } - -#define CLEFT *cols[(colspec>>8) & 0xf] -#define CTOP *cols[(colspec>>4) & 0xf] -#define CBOT *cols[colspec & 0xf] - - QPen savePen = p->pen(); - QBrush saveBrush = p->brush(); - QPen pen(Qt::NoPen); - QBrush brush = opt->palette.brush((opt->state & State_Enabled) ? - QPalette::Button : QPalette::Mid); - p->setPen(pen); - p->setBrush(brush); - p->drawPolygon(bFill); - p->setBrush(Qt::NoBrush); - - p->setPen(CLEFT); - p->drawPolyline(bLeft); - p->setPen(CTOP); - p->drawPolyline(bTop); - p->setPen(CBOT); - p->drawPolyline(bBot); - - p->setBrush(saveBrush); - p->setPen(savePen); -#undef CLEFT -#undef CTOP -#undef CBOT - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); - break; } - - case PE_IndicatorDockWidgetResizeHandle: { - const int motifOffset = 10; - int sw = proxy()->pixelMetric(PM_SplitterWidth); - if (opt->state & State_Horizontal) { - int yPos = opt->rect.y() + opt->rect.height() / 2; - int kPos = opt->rect.right() - motifOffset - sw; - int kSize = sw - 2; - - qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette); - qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize, - opt->palette, false, 1, &opt->palette.brush(QPalette::Button)); - qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette); - } else { - int xPos = opt->rect.x() + opt->rect.width() / 2; - int kPos = motifOffset; - int kSize = sw - 2; - - qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette); - qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette, - false, 1, &opt->palette.brush(QPalette::Button)); - qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette); - } - break; } - - case PE_IndicatorMenuCheckMark: { - const int markW = 6; - const int markH = 6; - int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1; - int posY = opt->rect.y() + (opt->rect.height() - markH) / 2; - int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth); - - if (dfw < 2) { - // Could do with some optimizing/caching... - QPolygon a(7*2); - int i, xx, yy; - xx = posX; - yy = 3 + posY; - for (i=0; i<3; i++) { - a.setPoint(2*i, xx, yy); - a.setPoint(2*i+1, xx, yy+2); - xx++; yy++; - } - yy -= 2; - for (i=3; i<7; i++) { - a.setPoint(2*i, xx, yy); - a.setPoint(2*i+1, xx, yy+2); - xx++; yy--; - } - if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) { - int pnt; - p->setPen(opt->palette.highlightedText().color()); - QPoint offset(1,1); - for (pnt = 0; pnt < (int)a.size(); pnt++) - a[pnt] += offset; - p->drawPolyline(a); - for (pnt = 0; pnt < (int)a.size(); pnt++) - a[pnt] -= offset; - } - p->setPen(opt->palette.text().color()); - p->drawPolyline(a); - - qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw); - } else - qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw, - &opt->palette.brush(QPalette::Mid)); - - break; } - - case PE_IndicatorProgressChunk: - { - bool vertical = false; - if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast(opt)) - vertical = (pb2->orientation == Qt::Vertical); - if (!vertical) { - p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), - opt->rect.height(), opt->palette.brush(QPalette::Highlight)); - } else { - p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(), - opt->palette.brush(QPalette::Highlight)); - } - } - break; - - default: - QCommonStyle::drawPrimitive(pe, opt, p, w); - break; - } -} - - -/*! - \reimp -*/ -void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *widget) const -{ - Q_D(const QMotifStyle); - switch(element) { - case CE_Splitter: { - QStyleOption handleOpt = *opt; - if (handleOpt.state & State_Horizontal) - handleOpt.state &= ~State_Horizontal; - else - handleOpt.state |= State_Horizontal; - proxy()->drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget); - break; } - - case CE_ScrollBarSubLine: - case CE_ScrollBarAddLine:{ - PrimitiveElement pe; - if (element == CE_ScrollBarAddLine) - pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft) : PE_IndicatorArrowDown; - else - pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp; - QStyleOption arrowOpt = *opt; - arrowOpt.state |= State_Enabled; - proxy()->drawPrimitive(pe, &arrowOpt, p, widget); - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) { - int fw = proxy()->pixelMetric(PM_DefaultFrameWidth); - p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern)); - } - }break; - - case CE_ScrollBarSubPage: - case CE_ScrollBarAddPage: - p->fillRect(opt->rect, opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); - break; - - case CE_ScrollBarSlider: { - QStyleOption bevelOpt = *opt; - bevelOpt.state |= State_Raised; - bevelOpt.state &= ~(State_Sunken | State_On); - p->save(); - p->setBrushOrigin(bevelOpt.rect.topLeft()); - proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); - p->restore(); - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); - break; } - - case CE_RadioButton: - case CE_CheckBox: - if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { - bool isRadio = (element == CE_RadioButton); - QStyleOptionButton subopt = *btn; - subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator - : SE_CheckBoxIndicator, btn, widget); - proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, - &subopt, p, widget); - subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents - : SE_CheckBoxContents, btn, widget); - proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); - if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*btn); - fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect - : SE_CheckBoxFocusRect, btn, widget); - proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); - } - } - break; - case CE_PushButton: - if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { - proxy()->drawControl(CE_PushButtonBevel, btn, p, widget); - QStyleOptionButton subopt = *btn; - subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); - proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget); - if ((btn->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*btn); - fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); - proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); - } - } - break; - case CE_PushButtonBevel: - if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { - int diw, x1, y1, x2, y2; - p->setPen(opt->palette.foreground().color()); - p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush)); - diw = proxy()->pixelMetric(PM_ButtonDefaultIndicator); - opt->rect.getCoords(&x1, &y1, &x2, &y2); - if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) { - x1 += diw; - y1 += diw; - x2 -= diw; - y2 -= diw; - } - if (btn->features & QStyleOptionButton::DefaultButton) { - if (diw == 0) { - QPolygon a; - a.setPoints(9, - x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, - x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1); - p->setPen(opt->palette.shadow().color()); - p->drawPolygon(a); - x1 += 2; - y1 += 2; - x2 -= 2; - y2 -= 2; - } else { - qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true); - } - } - if (!(btn->features & QStyleOptionButton::Flat) || - (btn->state & (State_Sunken | State_On))) { - QStyleOptionButton newOpt = *btn; - newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1); - p->setBrushOrigin(p->brushOrigin()); - proxy()->drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget); - } - if (btn->features & QStyleOptionButton::HasMenu) { - int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); - QRect ir = btn->rect; - QStyleOptionButton newBtn = *btn; - newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8); - proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); - } - break; - } - -#ifndef QT_NO_TABBAR - case CE_TabBarTabShape: - if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { - const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget); - const int frame_offset = (default_frame > 1) ? 1 : 0; - - if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast || - tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) { - p->save(); - QRect tabRect = opt->rect; - QColor tabLight = opt->palette.light().color(); - QColor tabDark = opt->palette.dark().color(); - - p->fillRect(opt->rect.adjusted(default_frame, default_frame, - -default_frame, -default_frame), - tab->palette.background()); - - if(tab->shape == QTabBar::RoundedWest) { - tabDark = opt->palette.light().color(); - tabLight = opt->palette.dark().color(); - tabRect = QRect(0, 0, tabRect.height(), tabRect.width()); - p->translate(opt->rect.left(), opt->rect.bottom()); - p->rotate(-90); - } else if(tab->shape == QTabBar::RoundedSouth) { - tabDark = opt->palette.light().color(); - tabLight = opt->palette.dark().color(); - tabRect = QRect(0, 0, tabRect.width(), tabRect.height()); - p->translate(opt->rect.right(), opt->rect.bottom()); - p->rotate(180); - } else if(tab->shape == QTabBar::RoundedEast) { - tabRect = QRect(0, 0, tabRect.height(), tabRect.width()); - p->translate(opt->rect.right(), opt->rect.top()); - p->rotate(90); - } - - if (default_frame > 1) { - p->setPen(tabLight); - p->drawLine(tabRect.left(), tabRect.bottom(), - tabRect.right(), tabRect.bottom()); - p->setPen(tabLight); - p->drawLine(tabRect.left(), tabRect.bottom()-1, - tabRect.right(), tabRect.bottom()-1); - if (tabRect.left() == 0) - p->drawPoint(tabRect.bottomLeft()); - } else { - p->setPen(tabLight); - p->drawLine(tabRect.left(), tabRect.bottom(), - tabRect.right(), tabRect.bottom()); - } - - if (opt->state & State_Selected) { - p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset, - tabRect.width()-3, 2), - tab->palette.brush(QPalette::Active, QPalette::Background)); - p->setPen(tab->palette.background().color()); - p->drawLine(tabRect.left()+1, tabRect.bottom(), - tabRect.left()+1, tabRect.top()+2); - p->setPen(tabLight); - } else { - p->setPen(tabLight); - } - p->drawLine(tabRect.left(), tabRect.bottom()-1, - tabRect.left(), tabRect.top() + 2); - p->drawPoint(tabRect.left()+1, tabRect.top() + 1); - p->drawLine(tabRect.left()+2, tabRect.top(), - tabRect.right() - 2, tabRect.top()); - p->drawPoint(tabRect.left(), tabRect.bottom()); - - if (default_frame > 1) { - p->drawLine(tabRect.left()+1, tabRect.bottom(), - tabRect.left()+1, tabRect.top() + 2); - p->drawLine(tabRect.left()+2, tabRect.top()+1, - tabRect.right() - 2, tabRect.top()+1); - } - - p->setPen(tabDark); - p->drawLine(tabRect.right() - 1, tabRect.top() + 2, - tabRect.right() - 1, tabRect.bottom() - 1 + - ((opt->state & State_Selected) ? frame_offset : -frame_offset)); - if (default_frame > 1) { - p->drawPoint(tabRect.right() - 1, tabRect.top() + 1); - p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(), - tabRect.bottom() - - ((opt->state & State_Selected) ? - ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset)); - p->drawPoint(tabRect.right() - 1, tabRect.top() + 1); - } - p->restore(); - } else { - QCommonStyle::drawControl(element, opt, p, widget); - } - break; } -#endif // QT_NO_TABBAR - case CE_ProgressBarGroove: - qDrawShadePanel(p, opt->rect, opt->palette, true, 2); - break; - - case CE_ProgressBarLabel: - if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { - QTransform oldMatrix = p->transform(); - QRect rect = pb->rect; - bool vertical = (pb->orientation == Qt::Vertical); - bool invert = pb->invertedAppearance; - bool bottomToTop = pb->bottomToTop; - - if (vertical) { - QTransform m; - rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - if (bottomToTop) { - m.translate(0.0, rect.width()); - m.rotate(-90); - } else { - m.translate(rect.height(), 0.0); - m.rotate(90); - } - p->setTransform(m, true); - } - const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget); - int u = rect.width() / unit_width; - int p_v = pb->progress - pb->minimum; - int t_s = qMax(0, pb->maximum - pb->minimum); - if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) { - // scale down to something usable. - p_v /= u; - t_s /= u; - } - if (pb->textVisible && t_s) { - int nu = (u * p_v + t_s/2) / t_s; - int x = unit_width * nu; - QRect left(rect.x(), rect.y(), x, rect.height()); - QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height()); - Qt::LayoutDirection dir; - dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction; - if (invert) - dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight; - const QRect highlighted = visualRect(dir, rect, left); - const QRect background = visualRect(dir, rect, right); - p->setPen(opt->palette.highlightedText().color()); - p->setClipRect(highlighted); - p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text); - - if (pb->progress != pb->maximum) { - p->setClipRect(background); - p->setPen(opt->palette.highlight().color()); - p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text); - } - } - p->setTransform(oldMatrix, false); - break; - } - - case CE_MenuTearoff: { - if(opt->state & State_Selected) { - if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1) - qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), - opt->rect.height(), opt->palette, false, motifItemFrame, - &opt->palette.brush(QPalette::Button)); - else - qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2, - opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button)); - } else { - p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); - } - p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine)); - p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4, - opt->rect.y()+opt->rect.height()/2-1); - p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine)); - p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4, - opt->rect.y()+opt->rect.height()/2); - break; } - - case CE_MenuItem: - if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(opt)) { - int maxpmw = menuitem->maxIconWidth; - if(menuitem->menuHasCheckableItems) - maxpmw = qMax(maxpmw, motifCheckMarkSpace); - - int x, y, w, h; - opt->rect.getRect(&x, &y, &w, &h); - - if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator - int textWidth = 0; - if (!menuitem->text.isEmpty()) { - QFont oldFont = p->font(); - p->setFont(menuitem->font); - p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button)); - proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, - menuitem->palette, menuitem->state & State_Enabled, menuitem->text, - QPalette::Text); - textWidth = menuitem->fontMetrics.width(menuitem->text) + 10; - y += menuitem->fontMetrics.height() / 2; - p->setFont(oldFont); - } - p->setPen(opt->palette.dark().color()); - p->drawLine(x, y, x + 5, y); - p->drawLine(x + 5 + textWidth, y, x+w, y); - p->setPen(opt->palette.light().color()); - p->drawLine(x, y + 1, x + 5, y + 1); - p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1); - return; - } - - int pw = motifItemFrame; - if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame - if(pixelMetric(PM_MenuPanelWidth, opt) > 1) - qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw, - &opt->palette.brush(QPalette::Button)); - else - qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1, - &opt->palette.brush(QPalette::Button)); - } else { // incognito frame - p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button)); - } - - QRect vrect = visualRect(opt->direction, opt->rect, - QRect(x+motifItemFrame, y+motifItemFrame, maxpmw, - h-2*motifItemFrame)); - int xvis = vrect.x(); - if (menuitem->checked) { - if(!menuitem->icon.isNull()) - qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame, - opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight)); - } else if (!(opt->state & State_Selected)) { - p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame, - opt->palette.brush(QPalette::Button)); - } - - if(!menuitem->icon.isNull()) { // draw icon - QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif - if ((opt->state & State_Selected) && !!(opt->state & State_Enabled)) - mode = QIcon::Active; - QPixmap pixmap; - if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked) - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On); - else - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode); - - int pixw = pixmap.width(); - int pixh = pixmap.height(); - QRect pmr(0, 0, pixw, pixh); - pmr.moveCenter(vrect.center()); - p->setPen(opt->palette.text().color()); - p->drawPixmap(pmr.topLeft(), pixmap); - - } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"... - int mh = h - 2*motifItemFrame; - - QStyleOptionButton newMenuItem; - newMenuItem.state = menuitem->checked ? State_On : State_None; - if (opt->state & State_Enabled) { - newMenuItem.state |= State_Enabled; - if (menuitem->state & State_Sunken) - newMenuItem.state |= State_Sunken; - } - if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) { - newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11); - proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget); - } else { - newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9); - proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget); - } - } - - p->setPen(opt->palette.buttonText().color()); - - QColor discol; - if (!(opt->state & State_Enabled)) { - discol = opt->palette.text().color(); - p->setPen(discol); - } - - int xm = motifItemFrame + maxpmw + motifItemHMargin; - - vrect = visualRect(opt->direction, opt->rect, - QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth, - h-2*motifItemVMargin)); - xvis = vrect.x(); - - QString s = menuitem->text; - if (!s.isNull()) { // draw text - int t = s.indexOf(QLatin1Char('\t')); - int m = motifItemVMargin; - int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - text_flags |= Qt::AlignLeft; - QFont oldFont = p->font(); - p->setFont(menuitem->font); - if (t >= 0) { // draw tab text - QRect vr = visualRect(opt->direction, opt->rect, - QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame, - y+motifItemVMargin, menuitem->tabWidth, - h-2*motifItemVMargin)); - int xv = vr.x(); - QRect tr(xv, y+m, menuitem->tabWidth, h-2*m); - p->drawText(tr, text_flags, s.mid(t+1)); - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); - s = s.left(t); - } - QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m); - p->drawText(tr, text_flags, s.left(t)); - p->setFont(oldFont); - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); - } - if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow - int dim = (h-2*motifItemFrame) / 2; - QStyle::PrimitiveElement arrow = (opt->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight); - QStyleOption arrowOpt = *opt; - arrowOpt.rect = visualRect(opt->direction, opt->rect, - QRect(x+w - motifArrowHMargin - motifItemFrame - dim, - y+h/2-dim/2, dim, dim)); - if ((opt->state & State_Selected)) - arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None)); - else - arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None); - proxy()->drawPrimitive(arrow, &arrowOpt, p, widget); - } - break; } - - case CE_MenuBarItem: - if (opt->state & State_Selected) // active item - qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame, - &opt->palette.brush(QPalette::Button)); - else // other item - p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); - QCommonStyle::drawControl(element, opt, p, widget); - break; - - case CE_HeaderSection: - p->save(); - p->setBrushOrigin(opt->rect.topLeft()); - qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)), - proxy()->pixelMetric(PM_DefaultFrameWidth), - &opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button)); - p->restore(); - break; - case CE_RubberBand: { - QPixmap tiledPixmap(16, 16); - QPainter pixmapPainter(&tiledPixmap); - pixmapPainter.setPen(Qt::NoPen); - pixmapPainter.setBrush(Qt::Dense4Pattern); - pixmapPainter.setBackground(QBrush(opt->palette.base())); - pixmapPainter.setBackgroundMode(Qt::OpaqueMode); - pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height()); - pixmapPainter.end(); - // ### workaround for borked XRENDER - tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage()); - - p->save(); - QRect r = opt->rect; - QStyleHintReturnMask mask; - if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) - p->setClipRegion(mask.region); - p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); - p->restore(); - } - break; -#ifndef QT_NO_PROGRESSBAR - case CE_ProgressBarContents: - if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { - QRect rect = pb->rect; - // Get extra style options if version 2 - bool vertical = (pb->orientation == Qt::Vertical); - bool inverted = pb->invertedAppearance; - - QTransform m; - if (vertical) { - rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - m.rotate(90); - m.translate(0, -(rect.height() + rect.y()*2)); - } - - QPalette pal2 = pb->palette; - // Correct the highlight color if it is the same as the background - if (pal2.highlight() == pal2.background()) - pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active, - QPalette::Highlight)); - bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical); - if (inverted) - reverse = !reverse; - int w = rect.width(); - if (pb->minimum == 0 && pb->maximum == 0) { - QRect progressBar; - Q_D(const QMotifStyle); - // draw busy indicator - int x = (d->animateStep*8)% (w * 2); - if (x > w) - x = 2 * w - x; - x = reverse ? rect.right() - x : x + rect.x(); - p->setTransform(m, true); - p->setPen(QPen(pal2.highlight().color(), 4)); - p->drawLine(x, rect.y(), x, rect.height()); - - } else - QCommonStyle::drawControl(element, opt, p, widget); - } - break; -#endif // QT_NO_PROGRESSBAR - default: - QCommonStyle::drawControl(element, opt, p, widget); - break; } -} - -static int get_combo_extra_width(int h, int w, int *return_awh=0) -{ - int awh, - tmp; - if (h < 8) { - awh = 6; - } else if (h < 14) { - awh = h - 2; - } else { - awh = h/2; - } - tmp = (awh * 3) / 2; - if (tmp > w / 2) { - awh = w / 2 - 3; - tmp = w / 2 + 3; - } - - if (return_awh) - *return_awh = awh; - - return tmp; -} - -static void get_combo_parameters(const QRect &r, - int &ew, int &awh, int &ax, - int &ay, int &sh, int &dh, - int &sy) -{ - ew = get_combo_extra_width(r.height(), r.width(), &awh); - - sh = (awh+3)/4; - if (sh < 3) - sh = 3; - dh = sh/2 + 1; - - ay = r.y() + (r.height()-awh-sh-dh)/2; - if (ay < 0) { - //panic mode - ay = 0; - sy = r.height(); - } else { - sy = ay+awh+dh; - } - ax = r.x() + r.width() - ew; - ax += (ew-awh)/2; -} - -/*! - \reimp -*/ -void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *widget) const -{ - Q_D(const QMotifStyle); - switch (cc) { - case CC_ToolButton: - if (const QStyleOptionToolButton *toolbutton - = qstyleoption_cast(opt)) { - QRect button, menuarea; - button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); - menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); - - State bflags = toolbutton->state & ~State_Sunken; - if (bflags & State_AutoRaise) { - if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { - bflags &= ~State_Raised; - } - } - State mflags = bflags; - if (toolbutton->state & State_Sunken) { - if (toolbutton->activeSubControls & SC_ToolButton) - bflags |= State_Sunken; - mflags |= State_Sunken; - } - - QStyleOption tool(0); - tool.palette = toolbutton->palette; - if (toolbutton->subControls & SC_ToolButton) { - if (bflags & (State_Sunken | State_On | State_Raised)) { - tool.rect = button; - tool.state = bflags; - proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); - } - } - - if ((toolbutton->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) { - QStyleOptionFocusRect fr; - fr.QStyleOption::operator=(*toolbutton); - fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3); - proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); - } - QStyleOptionToolButton label = *toolbutton; - label.state = bflags; - int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); - label.rect = button.adjusted(fw, fw, -fw, -fw); - proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); - - if (toolbutton->subControls & SC_ToolButtonMenu) { - tool.rect = menuarea; - tool.state = mflags; - if (mflags & (State_Sunken | State_On | State_Raised)) - proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); - proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); - } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { - int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); - QRect ir = toolbutton->rect; - QStyleOptionToolButton newBtn = *toolbutton; - newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6); - proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); - } - } - break; -#ifndef QT_NO_SPINBOX - case CC_SpinBox: - if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { - QStyleOptionSpinBox copy = *spinbox; - PrimitiveElement pe; - - if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) { - QRect r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget); - qDrawShadePanel(p, r, opt->palette, false, proxy()->pixelMetric(PM_SpinBoxFrameWidth)); - - int fw = proxy()->pixelMetric(QStyle::PM_DefaultFrameWidth); - r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw); - QStyleOptionFrame lineOpt; - lineOpt.QStyleOption::operator=(*opt); - lineOpt.rect = r; - lineOpt.lineWidth = fw; - lineOpt.midLineWidth = 0; - lineOpt.state |= QStyle::State_Sunken; - proxy()->drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget); - } - - if (spinbox->subControls & SC_SpinBoxUp) { - copy.subControls = SC_SpinBoxUp; - QPalette pal2 = spinbox->palette; - if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { - pal2.setCurrentColorGroup(QPalette::Disabled); - copy.state &= ~State_Enabled; - } - - copy.palette = pal2; - - if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) { - copy.state |= State_On; - copy.state |= State_Sunken; - } else { - copy.state |= State_Raised; - copy.state &= ~State_Sunken; - } - pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus - : PE_IndicatorSpinUp); - - copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget); - proxy()->drawPrimitive(pe, ©, p, widget); - } - - if (spinbox->subControls & SC_SpinBoxDown) { - copy.subControls = SC_SpinBoxDown; - copy.state = spinbox->state; - QPalette pal2 = spinbox->palette; - if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { - pal2.setCurrentColorGroup(QPalette::Disabled); - copy.state &= ~State_Enabled; - } - copy.palette = pal2; - - if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) { - copy.state |= State_On; - copy.state |= State_Sunken; - } else { - copy.state |= State_Raised; - copy.state &= ~State_Sunken; - } - pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus - : PE_IndicatorSpinDown); - - copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget); - proxy()->drawPrimitive(pe, ©, p, widget); - } - } - break; -#endif // QT_NO_SPINBOX -#ifndef QT_NO_SLIDER - case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { - QRect groove = proxy()->subControlRect(CC_Slider, opt, SC_SliderGroove, widget), - handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget); - - if ((opt->subControls & SC_SliderGroove) && groove.isValid()) { - qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth), - &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); - if ((opt->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) { - QStyleOption focusOpt = *opt; - focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget); - proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget); - } - } - - if ((opt->subControls & SC_SliderHandle) && handle.isValid()) { - QStyleOption bevelOpt = *opt; - bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken; - bevelOpt.rect = handle; - p->save(); - p->setBrushOrigin(bevelOpt.rect.topLeft()); - proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); - p->restore(); - - if (slider->orientation == Qt::Horizontal) { - int mid = handle.x() + handle.width() / 2; - qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2, - opt->palette, true, 1); - } else { - int mid = handle.y() + handle.height() / 2; - qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette, - true, 1); - } - if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) - p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern)); - } - - if (slider->subControls & SC_SliderTickmarks) { - QStyleOptionSlider tmpSlider = *slider; - tmpSlider.subControls = SC_SliderTickmarks; - int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); - tmpSlider.rect.translate(frameWidth - 1, 0); - QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget); - } - } - break; -#endif // QT_NO_SLIDER - case CC_ComboBox: - if (const QStyleOptionComboBox *cb = qstyleoption_cast(opt)) { - if (opt->subControls & SC_ComboBoxArrow) { - int awh, ax, ay, sh, sy, dh, ew; - int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; - - if (cb->frame) { - QStyleOptionButton btn; - btn.QStyleOption::operator=(*cb); - btn.state |= QStyle::State_Raised; - proxy()->drawPrimitive(PE_PanelButtonCommand, &btn, p, widget); - } else { - p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); - } - - QRect tr = opt->rect; - tr.adjust(fw, fw, -fw, -fw); - get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy); - - QRect ar = QCommonStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh)); - - QStyleOption arrowOpt = *opt; - arrowOpt.rect = ar; - arrowOpt.state |= State_Enabled; - proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); - - - // draws the shaded line under the arrow - p->setPen(opt->palette.light().color()); - p->drawLine(ar.x(), sy, ar.x()+awh-1, sy); - p->drawLine(ar.x(), sy, ar.x(), sy+sh-1); - p->setPen(opt->palette.dark().color()); - p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1); - p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1); - - if ((cb->state & State_HasFocus) && (!d->focus || !d->focus->isVisible())) { - QStyleOptionFocusRect focusRect; - focusRect.QStyleOption::operator=(*opt); - focusRect.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget); - focusRect.backgroundColor = opt->palette.button().color(); - proxy()->drawPrimitive(PE_FrameFocusRect, &focusRect, p, widget); - } - } - - if (opt->subControls & SC_ComboBoxEditField) { - if (cb->editable) { - QRect er = proxy()->subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget); - er.adjust(-1, -1, 1, 1); - qDrawShadePanel(p, er, opt->palette, true, 1, - &opt->palette.brush(QPalette::Base)); - } - } - p->setPen(opt->palette.buttonText().color()); - } - break; - -#ifndef QT_NO_SCROLLBAR - case CC_ScrollBar: { - if (opt->subControls & SC_ScrollBarGroove) - qDrawShadePanel(p, opt->rect, opt->palette, true, - proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget), - &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); - - if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { - QStyleOptionSlider newScrollbar = *scrollbar; - if (scrollbar->minimum == scrollbar->maximum) - newScrollbar.state |= State_Enabled; // make sure that the slider is drawn. - QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget); - } - break; } -#endif - - default: - QCommonStyle::drawComplexControl(cc, opt, p, widget); - break; - } -} - - -/*! \reimp */ -int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, - const QWidget *widget) const -{ - int ret = 0; - - switch(pm) { - case PM_ButtonDefaultIndicator: - ret = 5; - break; - - case PM_CheckBoxLabelSpacing: - case PM_RadioButtonLabelSpacing: - ret = 10; - break; - - case PM_ToolBarFrameWidth: - ret = proxy()->pixelMetric(PM_DefaultFrameWidth); - break; - - case PM_ToolBarItemMargin: - ret = 1; - break; - - case PM_ButtonShiftHorizontal: - case PM_ButtonShiftVertical: - ret = 0; - break; - - case PM_SplitterWidth: - ret = qMax(10, QApplication::globalStrut().width()); - break; - - case PM_SliderLength: - ret = 30; - break; - - case PM_SliderThickness: - ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth); - break; -#ifndef QT_NO_SLIDER - case PM_SliderControlThickness: - if (const QStyleOptionSlider *sl = qstyleoption_cast(opt)) { - int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width(); - int ticks = sl->tickPosition; - int n = 0; - if (ticks & QSlider::TicksAbove) - n++; - if (ticks & QSlider::TicksBelow) - n++; - if (!n) { - ret = space; - break; - } - - int thick = 6; // Magic constant to get 5 + 16 + 5 - - space -= thick; - //### the two sides may be unequal in size - if (space > 0) - thick += (space * 2) / (n + 2); - ret = thick; - } - break; - - case PM_SliderSpaceAvailable: - if (const QStyleOptionSlider *sl = qstyleoption_cast(opt)) { - if (sl->orientation == Qt::Horizontal) - ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); - else - ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); - } - break; -#endif // QT_NO_SLIDER - case PM_DockWidgetFrameWidth: - ret = 2; - break; - - case PM_DockWidgetHandleExtent: - ret = 9; - break; - - case PM_ProgressBarChunkWidth: - ret = 1; - break; - - case PM_ExclusiveIndicatorWidth: - case PM_ExclusiveIndicatorHeight: - ret = 13; - break; - - case PM_MenuBarHMargin: - ret = 2; // really ugly, but Motif - break; - - case PM_MenuButtonIndicator: - if (!opt) - ret = 12; - else - ret = qMax(12, (opt->rect.height() - 4) / 3); - break; - default: - ret = QCommonStyle::pixelMetric(pm, opt, widget); - break; - } - return ret; -} - - -/*! - \reimp -*/ -QRect -QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget) const -{ - switch (cc) { -#ifndef QT_NO_SPINBOX - case CC_SpinBox: - if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { - int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; - QSize bs; - bs.setHeight(opt->rect.height()/2 - fw); - bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean - bs = bs.expandedTo(QApplication::globalStrut()); - int y = fw + spinbox->rect.y(); - int x, lx, rx; - x = spinbox->rect.x() + opt->rect.width() - fw - bs.width(); - lx = fw; - rx = x - fw * 2; - const int margin = spinbox->frame ? 4 : 0; - switch (sc) { - case SC_SpinBoxUp: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - return visualRect(spinbox->direction, spinbox->rect, - QRect(x, y, bs.width(), bs.height() - 1)); - case SC_SpinBoxDown: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - return visualRect(spinbox->direction, spinbox->rect, - QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1)); - case SC_SpinBoxEditField: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - return visualRect(spinbox->direction, spinbox->rect, - QRect(lx + margin, y + margin, - spinbox->rect.width() - 2*fw - 2*margin, - spinbox->rect.height() - 2*fw - 2*margin)); - - return visualRect(spinbox->direction, spinbox->rect, - QRect(lx + margin, y + margin, rx - margin, - spinbox->rect.height() - 2*fw - 2 * margin)); - case SC_SpinBoxFrame: - return visualRect(spinbox->direction, spinbox->rect, spinbox->rect); - default: - break; - } - break; } -#endif // QT_NO_SPINBOX -#ifndef QT_NO_SLIDER - case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { - if (sc == SC_SliderHandle) { - int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget); - int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget); - bool horizontal = slider->orientation == Qt::Horizontal; - int len = proxy()->pixelMetric(PM_SliderLength, opt, widget); - int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth); - int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, - horizontal ? slider->rect.width() - len - 2 * motifBorder - : slider->rect.height() - len - 2 * motifBorder, - slider->upsideDown); - if (horizontal) - return visualRect(slider->direction, slider->rect, - QRect(sliderPos + motifBorder, tickOffset + motifBorder, len, - thickness - 2 * motifBorder)); - return visualRect(slider->direction, slider->rect, - QRect(tickOffset + motifBorder, sliderPos + motifBorder, - thickness - 2 * motifBorder, len)); - } - } - break; -#endif // QT_NO_SLIDER -#ifndef QT_NO_SCROLLBAR - case CC_ScrollBar: - if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { - int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth); - QRect rect = visualRect(scrollbar->direction, scrollbar->rect, - QCommonStyle::subControlRect(cc, scrollbar, sc, widget)); - if (sc == SC_ScrollBarSlider) { - if (scrollbar->orientation == Qt::Horizontal) - rect.adjust(-dfw, dfw, dfw, -dfw); - else - rect.adjust(dfw, -dfw, -dfw, dfw); - } else if (sc != SC_ScrollBarGroove) { - if (scrollbar->orientation == Qt::Horizontal) - rect.adjust(0, dfw, 0, -dfw); - else - rect.adjust(dfw, 0, -dfw, 0); - } - return visualRect(scrollbar->direction, scrollbar->rect, rect); - } - break; -#endif // QT_NO_SCROLLBAR -#ifndef QT_NO_COMBOBOX - case CC_ComboBox: - if (const QStyleOptionComboBox *cb = qstyleoption_cast(opt)) { - switch (sc) { - case SC_ComboBoxArrow: { - int ew, awh, sh, dh, ax, ay, sy; - int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; - QRect cr = opt->rect; - cr.adjust(fw, fw, -fw, -fw); - get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy); - return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight())); - } - - case SC_ComboBoxEditField: { - int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; - QRect rect = opt->rect; - rect.adjust(fw, fw, -fw, -fw); - int ew = get_combo_extra_width(rect.height(), rect.width()); - rect.adjust(1, 1, -1-ew, -1); - return visualRect(cb->direction, cb->rect, rect); - } - - default: - break; - } - } - break; -#endif // QT_NO_SCROLLBAR - default: - break; - } - return QCommonStyle::subControlRect(cc, opt, sc, widget); -} - -/*! - \reimp -*/ -QSize -QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget) const -{ - QSize sz(contentsSize); - - switch(ct) { - case CT_RadioButton: - case CT_CheckBox: - sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); - sz.rwidth() += motifItemFrame; - break; - - case CT_PushButton: - if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { - sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); - if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton))) - sz.setWidth(qMax(75, sz.width())); - sz += QSize(0, 1); // magical extra pixel - } - break; - - case CT_MenuBarItem: { - if (!sz.isEmpty()) - sz += QSize(5*motifItemHMargin+1, 2*motifItemVMargin + motifItemFrame); - break; - } - - case CT_MenuItem: - if (const QStyleOptionMenuItem *mi = qstyleoption_cast(opt)) { - sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget); - int w = sz.width(), h = sz.height(); - - if (mi->menuItemType == QStyleOptionMenuItem::Separator) { - w = 10; - h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height(); - } - - // a little bit of border can never harm - w += 2*motifItemHMargin + 2*motifItemFrame; - - if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0) - // string contains tab - w += motifTabSpacing; - else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu) - // submenu indicator needs some room if we don't have a tab column - w += motifArrowHMargin + 4*motifItemFrame; - - int checkColumn = mi->maxIconWidth; - if (mi->menuHasCheckableItems) - checkColumn = qMax(checkColumn, motifCheckMarkSpace); - if (checkColumn > 0) - w += checkColumn + motifCheckMarkHMargin; - - sz = QSize(w, h); - } - break; - - - default: - sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); - break; - } - - return sz; -} - -/*! - \reimp -*/ -QRect -QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const -{ - QRect rect; - - switch (sr) { - case SE_SliderFocusRect: - rect = QCommonStyle::subElementRect(sr, opt, widget); - rect.adjust(2, 2, -2, -2); - break; - - case SE_CheckBoxIndicator: - case SE_RadioButtonIndicator: - { - rect = visualRect(opt->direction, opt->rect, - QCommonStyle::subElementRect(sr, opt, widget)); - rect.adjust(motifItemFrame,0, motifItemFrame,0); - rect = visualRect(opt->direction, opt->rect, rect); - } - break; - - case SE_ComboBoxFocusRect: - { - int awh, ax, ay, sh, sy, dh, ew; - int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); - QRect tr = opt->rect; - - tr.adjust(fw, fw, -fw, -fw); - get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy); - rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4); - break; - } - - case SE_ProgressBarLabel: - case SE_ProgressBarGroove: - case SE_ProgressBarContents: - if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { - int textw = 0; - if (pb->textVisible) - textw = pb->fontMetrics.width(QLatin1String("100%")) + 6; - - if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) { - rect = opt->rect; - } else { - if(sr == SE_ProgressBarLabel) - rect.setCoords(opt->rect.right() - textw, opt->rect.top(), - opt->rect.right(), opt->rect.bottom()); - else - rect.setCoords(opt->rect.left(), opt->rect.top(), - opt->rect.right() - textw, opt->rect.bottom()); - } - if (sr == SE_ProgressBarContents) - rect.adjust(2, 2, -2, -2); - rect = visualRect(pb->direction, pb->rect, rect); - } - break; - case SE_CheckBoxClickRect: - case SE_RadioButtonClickRect: - rect = visualRect(opt->direction, opt->rect, opt->rect); - break; - - default: - rect = QCommonStyle::subElementRect(sr, opt, widget); - } - return rect; -} - -#ifndef QT_NO_XPM -/* XPM */ -static const char * const qt_motif_menu_xpm[] = { -"16 16 11 1", -" c #000000", -", c #336600", -". c #99CC00", -"X c #666600", -"o c #999933", -"+ c #333300", -"@ c #669900", -"# c #999900", -"$ c #336633", -"% c #666633", -"& c #99CC33", -"................", -"................", -".....#,++X#.....", -"....X X....", -"...X Xo#% X&..", -"..# o..&@o o..", -".., X..#+ @X X..", -"..+ o.o+ +o# +..", -"..+ #o+ +## +..", -".., %@ ++ +, X..", -"..# o@oo+ #..", -"...X X##$ o..", -"....X X..", -"....&oX++X#oX...", -"................", -"................"}; - -/* XPM */ -static const char * const qt_motif_close_xpm[] = { - "12 12 2 1", - " s None c None", - ". c black", - " ", - " ", - " . . ", - " ... ... ", - " ...... ", - " .... ", - " .... ", - " ...... ", - " ... ... ", - " . . ", - " ", - " "}; - -/* XPM */ -static const char * const qt_motif_maximize_xpm[] = { - "12 12 2 1", - " s None c None", - ". c black", - " ", - " ", - " ", - " . ", - " ... ", - " ..... ", - " ....... ", - " ......... ", - " ", - " ", - " ", - " "}; - -/* XPM */ -static const char * const qt_motif_minimize_xpm[] = { - "12 12 2 1", - " s None c None", - ". c black", - " ", - " ", - " ", - " ", - " ......... ", - " ....... ", - " ..... ", - " ... ", - " . ", - " ", - " ", - " "}; - -#if 0 // ### not used??? -/* XPM */ -static const char * const qt_motif_normalize_xpm[] = { - "12 12 2 1", - " s None c None", - ". c black", - " ", - " ", - " . ", - " .. ", - " ... ", - " .... ", - " ..... ", - " ...... ", - " ....... ", - " ", - " ", - " "}; -#endif - -/* XPM */ -static const char * const qt_motif_normalizeup_xpm[] = { - "12 12 2 1", - " s None c None", - ". c black", - " ", - " ", - " ", - " ....... ", - " ...... ", - " ..... ", - " .... ", - " ... ", - " .. ", - " . ", - " ", - " "}; - -/* XPM */ -static const char * const qt_motif_shade_xpm[] = { - "12 12 2 1", - "# c #000000", - ". c None", - "............", - "............", - ".#########..", - ".#########..", - "............", - "............", - "............", - "............", - "............", - "............", - "............", - "............"}; - -/* XPM */ -static const char * const qt_motif_unshade_xpm[] = { - "12 12 2 1", - "# c #000000", - ". c None", - "............", - "............", - ".#########..", - ".#########..", - ".#.......#..", - ".#.......#..", - ".#.......#..", - ".#.......#..", - ".#.......#..", - ".#########..", - "............", - "............"}; - -/* XPM */ -static const char * qt_motif_dock_window_close_xpm[] = { - "8 8 2 1", - "# c #000000", - ". c None", - "##....##", - ".##..##.", - "..####..", - "...##...", - "..####..", - ".##..##.", - "##....##", - "........"}; -#endif - -/*! - \reimp -*/ -QPixmap -QMotifStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget) const -{ -#ifndef QT_NO_XPM - switch (standardPixmap) { - case SP_TitleBarMenuButton: - return QPixmap(qt_motif_menu_xpm); - case SP_TitleBarShadeButton: - return QPixmap(qt_motif_shade_xpm); - case SP_TitleBarUnshadeButton: - return QPixmap(qt_motif_unshade_xpm); - case SP_TitleBarNormalButton: - return QPixmap(qt_motif_normalizeup_xpm); - case SP_TitleBarMinButton: - return QPixmap(qt_motif_minimize_xpm); - case SP_TitleBarMaxButton: - return QPixmap(qt_motif_maximize_xpm); - case SP_TitleBarCloseButton: - return QPixmap(qt_motif_close_xpm); - case SP_DockWidgetCloseButton: - return QPixmap(qt_motif_dock_window_close_xpm); - - case SP_MessageBoxInformation: { - // All that color looks ugly in Motif - const QPalette &pal = QApplication::palette(); - QImage image((const char **) qt_information_xpm); - QMap imagecolors; - imagecolors.insert(4288256409, pal.color(QPalette::Active, QPalette::Dark).rgba()); - imagecolors.insert(4294967295, pal.color(QPalette::Active, QPalette::Base).rgba()); - imagecolors.insert(4278190335, pal.color(QPalette::Active, QPalette::Text).rgba()); - image = replaceColors(image, imagecolors); - return QPixmap::fromImage(image); - } - case SP_MessageBoxWarning: { - const QPalette &pal = QApplication::palette(); - QImage image((const char **) qt_warning_xpm); - QMap imagecolors; - imagecolors.insert(4294967040, pal.color(QPalette::Active, QPalette::Base).rgba()); - imagecolors.insert(4278190080, pal.color(QPalette::Active, QPalette::Text).rgba()); - imagecolors.insert(4288256409, pal.color(QPalette::Active, QPalette::Dark).rgba()); - image = replaceColors(image, imagecolors); - return QPixmap::fromImage(image); - } - case SP_MessageBoxCritical: { - const QPalette &pal = QApplication::palette(); - QImage image((const char **) qt_critical_xpm); - QMap imagecolors; - imagecolors.insert(4288256409, pal.color(QPalette::Active, QPalette::Dark).rgba()); - imagecolors.insert(4294901760, pal.color(QPalette::Active, QPalette::Text).rgba()); - imagecolors.insert(4294967295, pal.color(QPalette::Active, QPalette::Base).rgba()); - image = replaceColors(image, imagecolors); - return QPixmap::fromImage(image); - } - case SP_MessageBoxQuestion: { - const QPalette &pal = QApplication::palette(); - QImage image((const char **) qt_question_xpm); - QMap imagecolors; - imagecolors.insert(4288256409, pal.color(QPalette::Active, QPalette::Dark).rgba()); - imagecolors.insert(4294967295, pal.color(QPalette::Active, QPalette::Base).rgba()); - imagecolors.insert(4278190335, pal.color(QPalette::Active, QPalette::Text).rgba()); - image = replaceColors(image, imagecolors); - return QPixmap::fromImage(image); - } - default: - break; - } -#endif - - return QCommonStyle::standardPixmap(standardPixmap, opt, widget); -} - -/*! \reimp */ -bool QMotifStyle::event(QEvent *e) -{ - Q_D(QMotifStyle); - if(e->type() == QEvent::FocusIn) { - if (QWidget *focusWidget = QApplication::focusWidget()) { -#ifndef QT_NO_GRAPHICSVIEW - if (QGraphicsView *graphicsView = qobject_cast(focusWidget)) { - QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0; - if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) { - QGraphicsProxyWidget *proxy = static_cast(focusItem); - if (proxy->widget()) - focusWidget = proxy->widget()->focusWidget(); - } - } -#endif - if (!d->focus) - d->focus = new QFocusFrame(focusWidget); - d->focus->setWidget(focusWidget); - } else { - if (d->focus) - d->focus->setWidget(0); - } - } else if (e->type() == QEvent::FocusOut && d->focus) { - d->focus->setWidget(0); - } - return QCommonStyle::event(e); -} - - -/*! \reimp */ -int -QMotifStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, - QStyleHintReturn *returnData) const -{ - int ret; - - switch (hint) { - case SH_DrawMenuBarSeparator: - ret = true; - break; - - case SH_ScrollBar_MiddleClickAbsolutePosition: - case SH_Slider_SloppyKeyEvents: - case SH_ProgressDialog_CenterCancelButton: - case SH_Menu_SpaceActivatesItem: - case SH_ScrollView_FrameOnlyAroundContents: - case SH_DitherDisabledText: - ret = 1; - break; - - case SH_Menu_SubMenuPopupDelay: - ret = 96; - break; - - case SH_ProgressDialog_TextLabelAlignment: - ret = Qt::AlignLeft | Qt::AlignVCenter; - break; - - case SH_ItemView_ChangeHighlightOnFocus: - ret = 0; - break; - - case SH_MessageBox_UseBorderForButtonSpacing: - ret = 1; - break; - - case SH_Dial_BackgroundRole: - ret = QPalette::Mid; - break; - - case SH_LineEdit_PasswordCharacter: - ret = '*'; - break; - case SH_DialogButtonBox_ButtonsHaveIcons: - ret = 0; - break; - default: - ret = QCommonStyle::styleHint(hint, opt, widget, returnData); - break; - } - - return ret; -} - -/*! \reimp */ -QPalette QMotifStyle::standardPalette() const -{ - QColor background(0xcf, 0xcf, 0xcf); -#ifdef Q_WS_X11 - if (QX11Info::appDepth() <= 8) - background = QColor(0xc0, 0xc0, 0xc0); -#endif - - QColor light = background.lighter(); - QColor mid = QColor(0xa6, 0xa6, 0xa6); - QColor dark = QColor(0x79, 0x7d, 0x79); - QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); - palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark); - palette.setBrush(QPalette::Disabled, QPalette::Text, dark); - palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark); - palette.setBrush(QPalette::Disabled, QPalette::Base, background); - return palette; -} - -QT_END_NAMESPACE - - -#include "moc_qmotifstyle.h" - -#endif // !defined(QT_NO_STYLE_MOTIF) diff --git a/src/gui/styles/qmotifstyle.h b/src/gui/styles/qmotifstyle.h deleted file mode 100644 index 45f9f1f44..000000000 --- a/src/gui/styles/qmotifstyle.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMOTIFSTYLE_H -#define QMOTIFSTYLE_H - -#include - - -QT_BEGIN_NAMESPACE - - -#if !defined(QT_NO_STYLE_MOTIF) - -class QPalette; -class QFocusFrame; - -class QMotifStylePrivate; -class Q_GUI_EXPORT QMotifStyle : public QCommonStyle -{ - Q_OBJECT -public: - explicit QMotifStyle(bool useHighlightCols = false); - - void setUseHighlightColors(bool); - bool useHighlightColors() const; - - void polish(QPalette&); - void polish(QWidget*); - void unpolish(QWidget*); - void polish(QApplication*); - void unpolish(QApplication*); - - void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = nullptr) const; - - void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = nullptr) const; - - void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = nullptr) const; - - QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget = nullptr) const; - - int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, - const QWidget *widget = nullptr) const; - - QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = nullptr) const; - - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const; - - QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = nullptr) const; - - int styleHint(StyleHint hint, const QStyleOption *opt = nullptr, const QWidget *widget = nullptr, - QStyleHintReturn *returnData = nullptr) const; - - bool event(QEvent *); - QPalette standardPalette() const; - -protected: - QMotifStyle(QMotifStylePrivate &dd); - void timerEvent(QTimerEvent *event); - bool eventFilter(QObject *o, QEvent *e); - -private: - Q_DECLARE_PRIVATE(QMotifStyle) - Q_DISABLE_COPY(QMotifStyle) -}; - -#endif // QT_NO_STYLE_MOTIF - -QT_END_NAMESPACE - - -#endif // QMOTIFSTYLE_H diff --git a/src/gui/styles/qmotifstyle_p.h b/src/gui/styles/qmotifstyle_p.h deleted file mode 100644 index 7d2d9f723..000000000 --- a/src/gui/styles/qmotifstyle_p.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMOTIFSTYLE_P_H -#define QMOTIFSTYLE_P_H -#include "qlist.h" -#include "qdatetime.h" -#include "qprogressbar.h" -#include "qmotifstyle.h" -#include "qcommonstyle_p.h" - -QT_BEGIN_NAMESPACE - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Katie API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -// Private class -class QMotifStylePrivate : public QCommonStylePrivate -{ - Q_DECLARE_PUBLIC(QMotifStyle) -public: - explicit QMotifStylePrivate(bool useHighlightCols = false); - ~QMotifStylePrivate(); - -public: - QPointer focus; - bool highlightCols; - -#ifndef QT_NO_PROGRESSBAR - QList bars; - int animationFps; - int animateTimer; - QTime startTime; - int animateStep; -#endif // QT_NO_PROGRESSBAR -}; - -QT_END_NAMESPACE - -#endif //QMOTIFSTYLE_P_H diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp deleted file mode 100644 index 29735c4f7..000000000 --- a/src/gui/styles/qplastiquestyle.cpp +++ /dev/null @@ -1,5819 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qplastiquestyle.h" - -#if !defined(QT_NO_STYLE_PLASTIQUE) - -static const bool AnimateBusyProgressBar = true; -static const bool AnimateProgressBar = false; -// #define QPlastique_MaskButtons -static const int ProgressBarFps = 25; -static const int blueFrameWidth = 2; // with of line edit focus frame - -#include "qwindowsstyle_p.h" -#include "qapplication.h" -#include "qbitmap.h" -#include "qabstractitemview.h" -#include "qcheckbox.h" -#include "qcombobox.h" -#include "qdebug.h" -#include "qdialogbuttonbox.h" -#include "qformlayout.h" -#include "qgroupbox.h" -#include "qimage.h" -#include "qlineedit.h" -#include "qmainwindow.h" -#include "qmenu.h" -#include "qmenubar.h" -#include "qpainter.h" -#include "qpaintengine.h" -#include "qpainterpath.h" -#include "qpalette.h" -#include "qpen.h" -#include "qpixmap.h" -#include "qpixmapcache.h" -#include "qprogressbar.h" -#include "qpushbutton.h" -#include "qradiobutton.h" -#include "qscrollbar.h" -#include "qspinbox.h" -#include "qsplitter.h" -#include "qstyleoption.h" -#include "qtextedit.h" -#include "qelapsedtimer.h" -#include "qtoolbar.h" -#include "qtoolbox.h" -#include "qtoolbutton.h" -#include "qworkspace.h" -#include "qvarlengtharray.h" -#include "qstylehelper_p.h" -#include "qguicommon_p.h" - -#include - -QT_BEGIN_NAMESPACE - -// from windows style -static const int plastiqueWindowsItemFrame = 2; // menu item frame width -static const int plastiqueWindowsItemHMargin = 3; // menu item hor text margin -static const int plastiqueWindowsItemVMargin = 2; // menu item ver text margin -static const int plastiqueWindowsRightBorder = 15; // right border on windows - -/* XPM */ -static const char * const qt_plastique_slider_verticalhandle[] = { - "15 11 6 1", - " c None", - "+ c #979797", - "@ c #C9C9C9", - "$ c #C1C1C1", - "b c #FAFAFA", - "d c #AFAFAF", - " $++++++++$ ", - "$+bbbbbbbb+$ ", - "+b $$ +$ ", - "+b $@ +$ ", - "+b +$", - "+b d+", - "+b d+$", - "+b $$ d+$ ", - "+b $@ d+$ ", - "$+dddddddd+$ ", - " $++++++++$ "}; - -/* XPM */ -static const char * const qt_plastique_slider_verticalhandle_left[] = { - "15 11 6 1", - " c None", - "+ c #979797", - "@ c #C9C9C9", - "$ c #C1C1C1", - "b c #FAFAFA", - "d c #AFAFAF", - " $++++++++$ ", - " $+bbbbbbbb+$", - " $+b $$ d+", - " $+b $@ d+", - "$+b d+", - "+b d+", - "$+ d+", - " $+ $$ d+", - " $+ $@ d+", - " $+dddddddd+$", - " $++++++++$ "}; - -/* XPM */ -static const char * const qt_plastique_slider_horizontalhandle[] = { - "11 15 6 1", - " c None", - "+ c #979797", - "@ c #C9C9C9", - "$ c #C1C1C1", - "b c #FAFAFA", - "d c #AFAFAF", - " $+++++++$ ", - "$+bbbbbbb+$", - "+b d+", - "+b$$ $$d+", - "+b$@ $@d+", - "+b d+", - "+b d+", - "+b d+", - "+b d+", - "+b d+", - "$+ d+$", - " $+ d+$ ", - " $+ d+$ ", - " $+d+$ ", - " $+$ "}; - -/* XPM */ -static const char * const qt_plastique_slider_horizontalhandle_up[] = { - "11 15 6 1", - " c None", - "+ c #979797", - "@ c #C9C9C9", - "$ c #C1C1C1", - "b c #FAFAFA", - "d c #AFAFAF", - " $+$ ", - " $+b+$ ", - " $+b +$ ", - " $+b +$ ", - "$+b +$", - "+b d+", - "+b d+", - "+b d+", - "+b d+", - "+b d+", - "+b$$ $$d+", - "+b$@ $@d+", - "+b d+", - "$+ddddddd+$", - " $+++++++$ "}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_arrow_left[] = { - "4 7 2 1", - " c None", - "* c #BFBFBF", - " *", - " **", - " ***", - "****", - " ***", - " **", - " *"}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_arrow_right[] = { - "4 7 2 1", - " c None", - "* c #BFBFBF", - "* ", - "** ", - "*** ", - "****", - "*** ", - "** ", - "* "}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_arrow_up[] = { - "7 4 2 1", - " c None", - "* c #BFBFBF", - " * ", - " *** ", - " ***** ", - "*******"}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_arrow_down[] = { - "7 4 2 1", - " c None", - "* c #BFBFBF", - "*******", - " ***** ", - " *** ", - " * "}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_left[] = { - "16 16 5 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - "# c #FAFAFA", - "< c #AFAFAF", - " .+++++++++++++.", - ".+#############+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - ".+<<<<<<<<<<<<<+", - " .+++++++++++++."}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_right[] = { - "16 16 5 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - "# c #FAFAFA", - "< c #AFAFAF", - ".+++++++++++++. ", - "+#############+.", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+<<<<<<<<<<<<<+.", - ".+++++++++++++. "}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_up[] = { - "16 16 5 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - "# c #FAFAFA", - "< c #AFAFAF", - " .++++++++++++. ", - ".+############+.", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+<<<<<<<<<<<<<<+", - ".++++++++++++++."}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_button_down[] = { - "16 16 5 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - "# c #FAFAFA", - "< c #AFAFAF", - "++++++++++++++++", - "+##############+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - "+# <+", - ".+<<<<<<<<<<<<+.", - " .++++++++++++. "}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_slider_pattern_vertical[] = { - "10 18 3 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - ".. .. ..", - ".+ .+ .+", - " ", - " ", - ".. .. ..", - ".+ .+ .+", - " ", - " ", - ".. .. ..", - ".+ .+ .+", - " ", - " ", - ".. .. ..", - ".+ .+ .+", - " ", - " ", - ".. .. ..", - ".+ .+ .+"}; - -/* XPM */ -static const char * const qt_plastique_scrollbar_slider_pattern_horizontal[] = { - "18 10 3 1", - " c None", - ". c #BFBFBF", - "+ c #979797", - ".. .. .. .. ..", - ".+ .+ .+ .+ .+", - " ", - " ", - ".. .. .. .. ..", - ".+ .+ .+ .+ .+", - " ", - " ", - ".. .. .. .. ..", - ".+ .+ .+ .+ .+"}; - -/* XPM */ -static const char * const qt_plastique_toolbarhandle[] = { - "6 6 4 1", - " c None", - ". c #C5C5C5", - "+ c #EEEEEE", - "@ c #FAFAFA", - ".. ", - ".+@ ", - " @@ ", - " .. ", - " .+@", - " @@"}; - -/* XPM */ -static const char * const qt_plastique_simple_toolbarhandle[] = { - "3 3 4 1", - " c None", - ". c #C5C5C5", - "+ c #EEEEEE", - "@ c #FAFAFA", - ".. ", - ".+@", - " @@"}; - -/* XPM */ -static const char * const qt_plastique_titlebar_context_help[] = { -"27 27 5 1", -" c None", -". c #0A0C12", -"+ c #1B202D", -"@ c #293144", -"# c #3C435D", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" +@##@+ ", -" .@@@.+@@.. ", -" .##+ +@@+. ", -" .##@ @#@+. ", -" .... +@+.. ", -" .@+@@.. ", -" +#@@+ ", -" .##. ", -" .++. ", -" .++. ", -" +##+ ", -" .@@. ", -" ", -" ", -" ", -" ", -" ", -" ", -" "}; - -static QLinearGradient qMapGradientToRect(const QLinearGradient &gradient, const QRectF &rect) -{ - QLinearGradient tmpGrad(rect.center().x(), rect.top(), - rect.center().x(), rect.bottom()); - tmpGrad.setStops(gradient.stops()); - return tmpGrad; -} - -static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect) -{ - if (!brush.gradient()) - return brush; - - // ### Ugly assumption that it's a linear gradient - QBrush tmp(qMapGradientToRect(*static_cast(brush.gradient()), rect)); - return tmp; -} - -static void qBrushSetAlphaF(QBrush *brush, qreal alpha) -{ - if (const QGradient *gradient = brush->gradient()) { - // Use the gradient. Call QColor::setAlphaF() on all color stops. - QGradientStops stops = gradient->stops(); - QMutableVectorIterator it(stops); - QColor tmpColor; - while (it.hasNext()) { - it.next(); - tmpColor = it.value().second; - tmpColor.setAlphaF(alpha * tmpColor.alphaF()); - it.setValue(QPair(it.value().first, tmpColor)); - } - - switch (gradient->type()) { - case QGradient::RadialGradient: { - QRadialGradient grad = *static_cast(gradient); - grad.setStops(stops); - *brush = QBrush(grad); - break; - } - default: - qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type" - " - falling back to QLinearGradient"); - case QGradient::LinearGradient: { - QLinearGradient grad = *static_cast(gradient); - grad.setStops(stops); - *brush = QBrush(grad); - break; - } - } - } else if (!brush->texture().isNull()) { - // Modify the texture - ridiculously expensive. - QPixmap texture = brush->texture(); - QPixmap pixmap; - QString name = QLatin1String("qbrushtexture-alpha") - + HexString(alpha) - + HexString(texture.cacheKey()); - if (!QPixmapCache::find(name, pixmap)) { - QImage image = texture.toImage(); - QRgb *rgb = reinterpret_cast(image.bits()); - int pixels = image.width() * image.height(); - QColor tmpColor; - while (pixels--) { - tmpColor.setRgb(*rgb); - tmpColor.setAlphaF(alpha * tmpColor.alphaF()); - *rgb++ = tmpColor.rgba(); - } - pixmap = QPixmap::fromImage(image); - QPixmapCache::insert(name, pixmap); - } - brush->setTexture(pixmap); - } else { - // Use the color - QColor tmpColor = brush->color(); - tmpColor.setAlphaF(alpha * tmpColor.alphaF()); - brush->setColor(tmpColor); - } -} - -static QBrush qBrushLight(QBrush brush, int light) -{ - if (const QGradient *gradient = brush.gradient()) { - // Use the gradient. Call QColor::lighter() on all color stops. - QGradientStops stops = gradient->stops(); - QMutableVectorIterator it(stops); - while (it.hasNext()) { - it.next(); - it.setValue(QPair(it.value().first, it.value().second.lighter(light))); - } - - switch (gradient->type()) { - case QGradient::RadialGradient: { - QRadialGradient grad = *static_cast(gradient); - grad.setStops(stops); - brush = QBrush(grad); - break; - } - default: - qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type" - " - falling back to QLinearGradient"); - case QGradient::LinearGradient: { - QLinearGradient grad = *static_cast(gradient); - grad.setStops(stops); - brush = QBrush(grad); - break; - } - } - } else if (!brush.texture().isNull()) { - // Modify the texture - ridiculously expensive. - QPixmap texture = brush.texture(); - QPixmap pixmap; - QString name = QLatin1String("qbrushtexture-light") - + HexString(light) - + HexString(texture.cacheKey()); - - if (!QPixmapCache::find(name, pixmap)) { - QImage image = texture.toImage(); - QRgb *rgb = reinterpret_cast(image.bits()); - int pixels = image.width() * image.height(); - QColor tmpColor; - while (pixels--) { - tmpColor.setRgb(*rgb); - *rgb++ = tmpColor.lighter(light).rgba(); - } - pixmap = QPixmap::fromImage(image); - QPixmapCache::insert(name, pixmap); - } - brush.setTexture(pixmap); - } else { - // Use the color - brush.setColor(brush.color().lighter(light)); - } - return brush; -} - -static QBrush qBrushDark(QBrush brush, int dark) -{ - if (const QGradient *gradient = brush.gradient()) { - // Use the gradient. Call QColor::darker() on all color stops. - QGradientStops stops = gradient->stops(); - QMutableVectorIterator it(stops); - while (it.hasNext()) { - it.next(); - it.setValue(QPair(it.value().first, it.value().second.darker(dark))); - } - - switch (gradient->type()) { - case QGradient::RadialGradient: { - QRadialGradient grad = *static_cast(gradient); - grad.setStops(stops); - brush = QBrush(grad); - break; - } - default: - qWarning("QPlastiqueStyle::qBrushDark() - unknown gradient type" - " - falling back to QLinearGradient"); - case QGradient::LinearGradient: { - QLinearGradient grad = *static_cast(gradient); - grad.setStops(stops); - brush = QBrush(grad); - break; - } - } - } else if (!brush.texture().isNull()) { - // Modify the texture - ridiculously expensive. - QPixmap texture = brush.texture(); - QPixmap pixmap; - QString name = QLatin1String("qbrushtexture-dark") - + HexString(dark) - + HexString(texture.cacheKey()); - - if (!QPixmapCache::find(name, pixmap)) { - QImage image = texture.toImage(); - QRgb *rgb = reinterpret_cast(image.bits()); - int pixels = image.width() * image.height(); - QColor tmpColor; - while (pixels--) { - tmpColor.setRgb(*rgb); - *rgb++ = tmpColor.darker(dark).rgba(); - } - pixmap = QPixmap::fromImage(image); - QPixmapCache::insert(name, pixmap); - } - brush.setTexture(pixmap); - } else { - // Use the color - brush.setColor(brush.color().darker(dark)); - } - return brush; -} - -/* - Draws a rounded frame using the provided brush for 1, and adds 0.5 alpha - for 0. - - 0111111110 - 01 10 - 1 1 - 1 1 - 1 1 - 01 10 - 0111111110 -*/ -static void qt_plastique_draw_frame(QPainter *painter, const QRect &rect, const QStyleOption *option, - QFrame::Shadow shadow = QFrame::Plain) -{ - QPen oldPen = painter->pen(); - QBrush border; - QBrush corner; - QBrush innerTopLeft; - QBrush innerBottomRight; - - if (shadow != QFrame::Plain && (option->state & QStyle::State_HasFocus)) { - border = option->palette.highlight(); - qBrushSetAlphaF(&border, qreal(0.8)); - corner = option->palette.highlight(); - qBrushSetAlphaF(&corner, 0.5); - innerTopLeft = qBrushDark(option->palette.highlight(), 125); - innerBottomRight = option->palette.highlight(); - qBrushSetAlphaF(&innerBottomRight, qreal(0.65)); - } else { - border = option->palette.shadow(); - qBrushSetAlphaF(&border, qreal(0.4)); - corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, 0.25); - innerTopLeft = option->palette.shadow(); - innerBottomRight = option->palette.shadow(); - if (shadow == QFrame::Sunken) { - qBrushSetAlphaF(&innerTopLeft, qreal(0.23)); - qBrushSetAlphaF(&innerBottomRight, qreal(0.075)); - } else { - qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); - qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); - } - } - - QLine lines[4]; - QPoint points[8]; - - // Opaque corner lines - painter->setPen(QPen(border, 0)); - lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); - lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); - lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 4); - - // Opaque corner dots - points[0] = QPoint(rect.left() + 1, rect.top() + 1); - points[1] = QPoint(rect.left() + 1, rect.bottom() - 1); - points[2] = QPoint(rect.right() - 1, rect.top() + 1); - points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 4); - - // Shaded corner dots - painter->setPen(QPen(corner, 0)); - points[0] = QPoint(rect.left(), rect.top() + 1); - points[1] = QPoint(rect.left(), rect.bottom() - 1); - points[2] = QPoint(rect.left() + 1, rect.top()); - points[3] = QPoint(rect.left() + 1, rect.bottom()); - points[4] = QPoint(rect.right(), rect.top() + 1); - points[5] = QPoint(rect.right(), rect.bottom() - 1); - points[6] = QPoint(rect.right() - 1, rect.top()); - points[7] = QPoint(rect.right() - 1, rect.bottom()); - painter->drawPoints(points, 8); - - // Shadows - if (shadow != QFrame::Plain) { - painter->setPen(QPen(innerTopLeft, 0)); - lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - painter->setPen(QPen(innerBottomRight, 0)); - lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); - lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - } - - painter->setPen(oldPen); -} - -static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, - const QColor &gradientStop) -{ - QString gradientName = QLatin1String("qplastique-g") - + HexString(rect.width()) - + HexString(rect.height()) - + HexString(gradientStart.rgba()) - + HexString(gradientStop.rgba()); - - QPixmap cache; - QPainter *p = painter; - QRect r = rect; - - bool doPixmapCache = painter->deviceTransform().isIdentity() - && painter->worldMatrix().isIdentity(); - if (doPixmapCache && QPixmapCache::find(gradientName, cache)) { - painter->drawPixmap(rect, cache); - } else { - if (doPixmapCache) { - cache = QPixmap(rect.size()); - cache.fill(Qt::transparent); - p = new QPainter(&cache); - r = QRect(0, 0, rect.width(), rect.height()); - } - - int x = r.center().x(); - QLinearGradient gradient(x, r.top(), x, r.bottom()); - gradient.setColorAt(0, gradientStart); - gradient.setColorAt(1, gradientStop); - p->fillRect(r, gradient); - - if (doPixmapCache) { - p->end(); - delete p; - painter->drawPixmap(rect, cache); - QPixmapCache::insert(gradientName, cache); - } - } -} - -static void qt_plastique_drawFrame(QPainter *painter, const QStyleOption *option, const QWidget *widget) -{ - QRect rect = option->rect; - QPen oldPen = painter->pen(); - - QColor borderColor = option->palette.background().color().darker(178); - QColor gradientStartColor = option->palette.button().color().lighter(104); - QColor gradientStopColor = option->palette.button().color().darker(105); - QColor alphaCornerColor; - if (widget) { - // ### backgroundrole/foregroundrole should be part of the style option - alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); - } else { - alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); - } - - QLine lines[4]; - QPoint points[8]; - - // outline / border - painter->setPen(borderColor); - lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); - lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); - lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 4); - - points[0] = QPoint(rect.left() + 1, rect.top() + 1); - points[1] = QPoint(rect.right() - 1, rect.top() + 1); - points[2] = QPoint(rect.left() + 1, rect.bottom() - 1); - points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 4); - - painter->setPen(alphaCornerColor); - - points[0] = QPoint(rect.left() + 1, rect.top()); - points[1] = QPoint(rect.right() - 1, rect.top()); - points[2] = QPoint(rect.left() + 1, rect.bottom()); - points[3] = QPoint(rect.right() - 1, rect.bottom()); - points[4] = QPoint(rect.left(), rect.top() + 1); - points[5] = QPoint(rect.right(), rect.top() + 1); - points[6] = QPoint(rect.left(), rect.bottom() - 1); - points[7] = QPoint(rect.right(), rect.bottom() - 1); - painter->drawPoints(points, 8); - - // inner border - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) - painter->setPen(option->palette.button().color().darker(118)); - else - painter->setPen(gradientStartColor); - - lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, option->rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, option->rect.bottom() - 2); - painter->drawLines(lines, 2); - - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) - painter->setPen(option->palette.button().color().darker(110)); - else - painter->setPen(gradientStopColor.darker(102)); - - lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); - lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - - painter->setPen(oldPen); -} - -static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *option, bool base, - const QWidget *widget) -{ - QRect rect = option->rect; - QPen oldPen = painter->pen(); - - QColor gradientStartColor = option->palette.button().color().lighter(104); - QColor gradientStopColor = option->palette.button().color().darker(105); - - // gradient fill - if ((option->state & QStyle::State_Enabled) || !(option->state & QStyle::State_AutoRaise)) { - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) { - qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1), - option->palette.button().color().darker(114), - option->palette.button().color().darker(106)); - } else { - qt_plastique_draw_gradient(painter, rect.adjusted(1, 1, -1, -1), - base ? option->palette.background().color().lighter(105) : gradientStartColor, - base ? option->palette.background().color().darker(102) : gradientStopColor); - } - } - - qt_plastique_drawFrame(painter, option, widget); - - painter->setPen(oldPen); -} - -static void qt_plastique_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken) -{ - if (tmp.isNull()) - return; - bool active = (option->titleBarState & QStyle::State_Active); - - // ### use palette colors instead - QColor mdiButtonGradientStartColor; - QColor mdiButtonGradientStopColor; - if (active) { - mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x7d8bb1 : 0x55689a); - mdiButtonGradientStopColor = QColor((hover || sunken) ? 0x939ebe : 0x7381ab); - } else { - mdiButtonGradientStartColor = QColor((hover || sunken) ? 0x9e9e9e : 0x818181); - mdiButtonGradientStopColor = QColor((hover || sunken) ? 0xababab : 0x929292); - } - - qt_plastique_draw_gradient(painter, tmp.adjusted(1, 1, -1, -1), - mdiButtonGradientStartColor, mdiButtonGradientStopColor); - - QColor mdiButtonBorderColor; - if (active) { - mdiButtonBorderColor = (hover || sunken) ? QColor(0x627097) : QColor(0x324577); - } else { - mdiButtonBorderColor = (hover || sunken) ? QColor(0x838383) : QColor(0x5e5e5e); - } - painter->setPen(QPen(mdiButtonBorderColor, 1)); - - const QLine lines[4] = { - QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), - QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), - QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), - QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) }; - painter->drawLines(lines, 4); - - const QPoint points[4] = { - QPoint(tmp.left() + 1, tmp.top() + 1), - QPoint(tmp.right() - 1, tmp.top() + 1), - QPoint(tmp.left() + 1, tmp.bottom() - 1), - QPoint(tmp.right() - 1, tmp.bottom() - 1) }; - painter->drawPoints(points, 4); -} - -#ifndef QT_NO_DOCKWIDGET -static QString elliditide(const QString &text, const QFontMetrics &fontMetrics, const QRect &rect, int *textWidth = 0) -{ - // Chop and insert ellide into title if text is too wide - QString title = text; - int width = textWidth ? *textWidth : fontMetrics.width(text); - QString ellipsis = QLatin1String("..."); - if (width > rect.width()) { - QString leftHalf = title.left(title.size() / 2); - QString rightHalf = title.mid(leftHalf.size() + 1); - while (!leftHalf.isEmpty() && !rightHalf.isEmpty()) { - leftHalf.chop(1); - int fontwidth = fontMetrics.width(leftHalf + ellipsis + rightHalf); - if (fontwidth < rect.width()) { - title = leftHalf + ellipsis + rightHalf; - width = fontwidth; - break; - } - rightHalf.remove(0, 1); - fontwidth = fontMetrics.width(leftHalf + ellipsis + rightHalf); - if (fontwidth < rect.width()) { - title = leftHalf + ellipsis + rightHalf; - width = fontwidth; - break; - } - } - } - if (textWidth) - *textWidth = width; - return title; -} -#endif - -#if !defined(QT_NO_DOCKWIDGET) || !defined(QT_NO_SPLITTER) -static void qt_plastique_draw_handle(QPainter *painter, const QStyleOption *option, - const QRect &rect, Qt::Orientation orientation, - const QWidget *widget) -{ - QColor borderColor = option->palette.background().color().darker(178); - QColor alphaCornerColor; - if (widget) { - // ### backgroundrole/foregroundrole should be part of the style option - alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); - } else { - alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); - } - QImage handle(qt_plastique_simple_toolbarhandle); - QMap handlecolors; - alphaCornerColor.setAlpha(170); - handlecolors.insert(4291151301, alphaCornerColor.rgba()); - handlecolors.insert(4293848814, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); - handlecolors.insert(4294638330, option->palette.light().color().rgba()); - handle = replaceColors(handle, handlecolors); - - const int spacing = 2; - - if (orientation == Qt::Vertical) { - int nchunks = rect.width() / (handle.width() + spacing); - for (int i = 0; i < nchunks; ++i) - painter->drawImage(QPoint(rect.left() + i * (handle.width() + spacing), rect.top()), handle); - } else { - int nchunks = rect.height() / (handle.height() + spacing); - for (int i = 0; i < nchunks; ++i) - painter->drawImage(QPoint(rect.left(), rect.top() + i * (handle.height() + spacing)), handle); - } -} -#endif - -class QPlastiqueStylePrivate : public QWindowsStylePrivate -{ - Q_DECLARE_PUBLIC(QPlastiqueStyle) -public: - QPlastiqueStylePrivate(); - virtual ~QPlastiqueStylePrivate(); - void drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option, - const QRect &rect, const QWidget *widget) const; - -#ifndef QT_NO_PROGRESSBAR - QList bars; - int progressBarAnimateTimer; - QElapsedTimer timer; -#endif -}; - -/*! - \internal - */ -QPlastiqueStylePrivate::QPlastiqueStylePrivate() : - QWindowsStylePrivate() -#ifndef QT_NO_PROGRESSBAR - , progressBarAnimateTimer(0) -#endif -{ -} - -/*! - \internal - */ -QPlastiqueStylePrivate::~QPlastiqueStylePrivate() -{ -} - -/*! - \class QPlastiqueStyle - \brief The QPlastiqueStyle class provides a widget style similar to the - Plastik style available in KDE. - - The Plastique style provides a default look and feel for widgets on X11 - that closely resembles the Plastik style, introduced by Sandro Giessl in - KDE 3.2. - - \img qplastiquestyle.png - \sa QWindowsStyle, QMotifStyle -*/ - -/*! - Constructs a QPlastiqueStyle object. -*/ -QPlastiqueStyle::QPlastiqueStyle() - : QWindowsStyle(*new QPlastiqueStylePrivate) -{ - setObjectName(QLatin1String("Plastique")); -} - -/* - Used by spin- and combo box. - Draws a rounded frame around rect but omits the right hand edge -*/ -void QPlastiqueStylePrivate::drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option, - const QRect &rect, const QWidget *widget) const -{ - Q_Q(const QPlastiqueStyle); - bool reverse = option->direction == Qt::RightToLeft; - QStyleOptionFrame frameOpt; -#ifndef QT_NO_LINEEDIT - if (QLineEdit *lineedit = widget->findChild()) - frameOpt.initFrom(lineedit); -#else - Q_UNUSED(widget) -#endif // QT_NO_LINEEDIT - - frameOpt.rect = rect; - painter->save(); - frameOpt.rect.adjust(-blueFrameWidth + (reverse ? 1 : 0), -blueFrameWidth, - blueFrameWidth + (reverse ? 0 : -1), blueFrameWidth); - painter->setClipRect(frameOpt.rect); - frameOpt.rect.adjust(reverse ? -2 : 0, 0, reverse ? 0 : 2, 0); - frameOpt.lineWidth = q->pixelMetric(QStyle::PM_DefaultFrameWidth); - frameOpt.midLineWidth = 0; - frameOpt.state = option->state | QStyle::State_Sunken; - frameOpt.palette = option->palette; - q->drawPrimitive(QStyle::PE_PanelLineEdit, &frameOpt, painter, widget); - painter->restore(); - - // Draw a two pixel highlight on the flat edge - if (option->state & QStyle::State_HasFocus) { - painter->setPen(QPen(option->palette.highlight(), 0)); - QBrush focusBorder = option->palette.highlight(); - qBrushSetAlphaF(&focusBorder, qreal(0.65)); - if (!reverse) { - painter->drawLine(rect.topRight() + QPoint(1, -1), - rect.bottomRight() + QPoint(1, 1)); - painter->setPen(QPen(focusBorder, 0)); - painter->drawLine(rect.topRight(), - rect.bottomRight()); - } - else { - painter->drawLine(rect.topLeft() + QPoint(-1, -1), - rect.bottomLeft() + QPoint(-1, 1)); - painter->setPen(QPen(focusBorder, 0)); - painter->drawLine(rect.topLeft(), - rect.bottomLeft()); - } - } -} - -/*! - \reimp -*/ -void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const -{ - Q_ASSERT(option); - - QColor borderColor = option->palette.background().color().darker(178); - QColor alphaCornerColor; - if (widget) { - // ### backgroundrole/foregroundrole should be part of the style option - alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); - } else { - alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); - } - QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color()); - - switch (element) { - case PE_IndicatorButtonDropDown: - proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget); - break; - case PE_FrameDefaultButton: { - if (!(option->state & QStyle::State_Enabled)) - break; - painter->setPen(QPen(QColor(0, 0, 0, 127), 0)); - const QLine lines[4] = { - QLine(option->rect.left() + 2, option->rect.top(), - option->rect.right() - 2, option->rect.top()), - QLine(option->rect.left() + 2, option->rect.bottom(), - option->rect.right() - 2, option->rect.bottom()), - QLine(option->rect.left(), option->rect.top() + 2, - option->rect.left(), option->rect.bottom() - 2), - QLine(option->rect.right(), option->rect.top() + 2, - option->rect.right(), option->rect.bottom() - 2) }; - painter->drawLines(lines, 4); - - QPoint points[8]; - points[0] = QPoint(option->rect.left() + 1, option->rect.top() + 1); - points[1] = QPoint(option->rect.right() - 1, option->rect.top() + 1); - points[2] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1); - points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1); - painter->drawPoints(points, 4); - - painter->setPen(QPen(QColor(0, 0, 0, 63), 0)); - points[0] = QPoint(option->rect.left() + 1, option->rect.top()); - points[1] = QPoint(option->rect.right() - 1, option->rect.top()); - points[2] = QPoint(option->rect.left(), option->rect.top() + 1); - points[3] = QPoint(option->rect.right(), option->rect.top() + 1); - points[4] = QPoint(option->rect.left() + 1, option->rect.bottom()); - points[5] = QPoint(option->rect.right() - 1, option->rect.bottom()); - points[6] = QPoint(option->rect.left(), option->rect.bottom() - 1); - points[7] = QPoint(option->rect.right(), option->rect.bottom() - 1); - painter->drawPoints(points, 8); - - break; - } -#ifndef QT_NO_TABWIDGET - case PE_FrameTabWidget: - if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(option)) { - if (twf->shape != QTabBar::RoundedNorth && twf->shape != QTabBar::RoundedWest && - twf->shape != QTabBar::RoundedSouth && twf->shape != QTabBar::RoundedEast) { - QWindowsStyle::drawPrimitive(element, option, painter, widget); - break; - } - - int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); - bool reverse = (twf->direction == Qt::RightToLeft); - - painter->save(); - - // Start by filling the contents of the tab widget frame (which is - // actually a panel). - painter->fillRect(option->rect.adjusted(1, 1, -1, -1), option->palette.window()); - - QRect tabBarRect; - switch (twf->shape) { - case QTabBar::RoundedNorth: - if (reverse) - tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, twf->rect.top(), twf->tabBarSize.width(), borderThickness); - else - tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), twf->rect.top(), twf->tabBarSize.width(), borderThickness); - break ; - case QTabBar::RoundedWest: - tabBarRect = QRect(twf->rect.left(), twf->rect.top() + twf->leftCornerWidgetSize.height(), borderThickness, twf->tabBarSize.height()); - break ; - case QTabBar::RoundedEast: - tabBarRect = QRect(twf->rect.right() - borderThickness + 1, twf->rect.top() + twf->leftCornerWidgetSize.height(), - borderThickness, twf->tabBarSize.height()); - break ; - case QTabBar::RoundedSouth: - if (reverse) - tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, - twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness); - else - tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), - twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness); - break ; - default: - break; - } - - QRegion region(twf->rect); - region -= tabBarRect; - painter->setClipRegion(region); - - // Outer border - QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2)); - QLine rightLine = QLine(twf->rect.topRight() + QPoint(0, 2), twf->rect.bottomRight() - QPoint(0, 2)); - QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0)); - QLine topLine = QLine(twf->rect.topLeft() + QPoint(2, 0), twf->rect.topRight() - QPoint(2, 0)); - - QBrush border = option->palette.shadow(); - qBrushSetAlphaF(&border, qreal(0.4)); - painter->setPen(QPen(border, 0)); - - QVarLengthArray lines; - QVarLengthArray points; - - lines.append(topLine); - - // Inner border - QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0)); - QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, 0), rightLine.p2() - QPoint(1, 0)); - QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1)); - QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(0, 1)); - - // Rounded Corner - QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1)); - QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1)); - QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0)); - QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1)); - QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1)); - QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0)); - QPoint rightTopOuterCorner = QPoint(innerRightLine.p1() - QPoint(0, 1)); - QPoint rightTopInnerCorner1 = QPoint(rightLine.p1() - QPoint(0, 1)); - QPoint rightTopInnerCorner2 = QPoint(topLine.p2() + QPoint(1, 0)); - QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1)); - QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1)); - QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0)); - - lines.append(leftLine); - lines.append(rightLine); - lines.append(bottomLine); - - painter->drawLines(lines.constData(), lines.size()); - lines.clear(); - - points.append(leftBottomOuterCorner); - points.append(rightBottomOuterCorner); - points.append(rightTopOuterCorner); - points.append(leftTopOuterCorner); - - painter->drawPoints(points.constData(), points.size()); - points.clear(); - - QBrush innerTopLeft = option->palette.shadow(); - qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); - painter->setPen(QPen(innerTopLeft, 0)); - - lines.append(innerLeftLine); - lines.append(innerTopLine); - painter->drawLines(lines.constData(), lines.size()); - lines.clear(); - - QBrush innerBottomRight = option->palette.shadow(); - qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); - painter->setPen(QPen(innerBottomRight, 0)); - lines.append(innerRightLine); - lines.append(innerBottomLine); - painter->drawLines(lines.constData(), lines.size()); - lines.clear(); - - QBrush corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, 0.25); - painter->setPen(QPen(corner, 0)); - points.append(leftBottomInnerCorner1); - points.append(leftBottomInnerCorner2); - points.append(rightBottomInnerCorner1); - points.append(rightBottomInnerCorner2); - points.append(rightTopInnerCorner1); - points.append(rightTopInnerCorner2); - points.append(leftTopInnerCorner1); - points.append(leftTopInnerCorner2); - painter->drawPoints(points.constData(), points.size()); - points.clear(); - - painter->restore(); - } - break ; -#endif // QT_NO_TABWIDGET -#ifndef QT_NO_TABBAR - case PE_FrameTabBarBase: - if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast(option)) { - if (tbb->shape != QTabBar::RoundedNorth && tbb->shape != QTabBar::RoundedWest && - tbb->shape != QTabBar::RoundedSouth && tbb->shape != QTabBar::RoundedEast) { - QWindowsStyle::drawPrimitive(element, option, painter, widget); - break; - } - - painter->save(); - - QRegion region(tbb->rect); - region -= tbb->tabBarRect; - painter->setClipRegion(region); - - QLine topLine = QLine(tbb->rect.bottomLeft() - QPoint(0, 1), tbb->rect.bottomRight() - QPoint(0, 1)); - QLine bottomLine = QLine(tbb->rect.bottomLeft(), tbb->rect.bottomRight()); - - QBrush border = option->palette.shadow(); - qBrushSetAlphaF(&border, qreal(0.4)); - QBrush innerTopLeft = option->palette.shadow(); - qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); - QBrush innerBottomRight = option->palette.shadow(); - qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); - QBrush corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, 0.25); - - if (tbb->shape == QTabBar::RoundedSouth) - painter->setPen(QPen(corner, 0)); - else - painter->setPen(QPen(border, 0)); - painter->drawLine(topLine); - - if (tbb->shape != QTabBar::RoundedSouth) - painter->setPen(QPen(innerTopLeft, 0)); - else - painter->setPen(QPen(border, 0)); - painter->drawLine(bottomLine); - - painter->restore(); - } - break ; -#endif // QT_NO_TABBAR -#ifndef QT_NO_GROUPBOX - case PE_FrameGroupBox: - if (const QStyleOptionFrame *frame = qstyleoption_cast(option)) { - QStyleOptionFrameV2 frameV2(*frame); - if (frameV2.features & QStyleOptionFrameV2::Flat) { - QPen oldPen = painter->pen(); - painter->setPen(borderColor); - painter->drawLine(frameV2.rect.topLeft(), frameV2.rect.topRight()); - painter->setPen(oldPen); - } else { - frameV2.state &= ~(State_Sunken | State_HasFocus); - proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget); - } - } - break; -#endif // QT_NO_GROUPBOX - case PE_Frame: { - QFrame::Shadow shadow = QFrame::Plain; - if (option->state & State_Sunken) - shadow = QFrame::Sunken; - else if (option->state & State_Raised) - shadow = QFrame::Raised; - qt_plastique_draw_frame(painter, option->rect, option, shadow); - break; - } -#ifndef QT_NO_LINEEDIT - case PE_FrameLineEdit: - qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); - break; - case PE_PanelLineEdit: - if (const QStyleOptionFrame *lineEdit = qstyleoption_cast(option)) { - // Panel of a line edit inside combo box or spin box is drawn in CC_ComboBox and CC_SpinBox - if (widget) { -#ifndef QT_NO_SPINBOX - // Spinbox doesn't need a separate palette for the lineedit - if (qobject_cast(widget->parentWidget())) - break; -#endif - } - - painter->save(); - - // Fill the line edit insides - QRect filledRect = lineEdit->rect.adjusted(1, 1, -1, -1); - QBrush baseBrush = qMapBrushToRect(lineEdit->palette.base(), filledRect); - painter->setBrushOrigin(filledRect.topLeft()); - painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush); - - painter->setPen(QPen(baseBrush, 0)); - const QLine lines[4] = { - QLine(filledRect.left(), filledRect.top() + 1, - filledRect.left(), filledRect.bottom() - 1), - QLine(filledRect.right(), filledRect.top() + 1, - filledRect.right(), filledRect.bottom() - 1), - QLine(filledRect.left() + 1, filledRect.top(), - filledRect.right() - 1, filledRect.top()), - QLine(filledRect.left() + 1, filledRect.bottom(), - filledRect.right() - 1, filledRect.bottom()) }; - painter->drawLines(lines, 4); - - if (lineEdit->lineWidth != 0) - qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); - - painter->restore(); - break; - } -#endif // QT_NO_LINEEDIT - case PE_FrameDockWidget: - case PE_FrameMenu: - case PE_FrameStatusBarItem: { - // Draws the frame around a popup menu. - QPen oldPen = painter->pen(); - painter->setPen(borderColor); - painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); - painter->setPen(alphaCornerColor); - const QPoint points[4] = { - QPoint(option->rect.topLeft()), - QPoint(option->rect.topRight()), - QPoint(option->rect.bottomLeft()), - QPoint(option->rect.bottomRight()) }; - painter->drawPoints(points, 4); - painter->setPen(oldPen); - break; - } -#ifndef QT_NO_MAINWINDOW - case PE_PanelMenuBar: - if ((widget && qobject_cast(widget->parentWidget())) - ) { - // Draws the light line above and the dark line below menu bars and - // tool bars. - QPen oldPen = painter->pen(); - if (element == PE_PanelMenuBar || (option->state & State_Horizontal)) { - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.left(), option->rect.bottom(), - option->rect.right(), option->rect.bottom()); - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.left(), option->rect.top(), - option->rect.right(), option->rect.top()); - } else { - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.left(), option->rect.top(), - option->rect.left(), option->rect.bottom()); - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.right(), option->rect.top(), - option->rect.right(), option->rect.bottom()); - } - painter->setPen(oldPen); - } - break; -#endif // QT_NO_MAINWINDOW - case PE_IndicatorHeaderArrow: { - QWindowsStyle::drawPrimitive(element, option, painter, widget); - break; - } - case PE_PanelButtonTool: - // Draws a tool button (f.ex., in QToolBar and QTabBar) - if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) - qt_plastique_drawShadedPanel(painter, option, true, widget); - break; -#ifndef QT_NO_TOOLBAR - case PE_IndicatorToolBarHandle: { - QPixmap cache; - QRect rect = option->rect; - QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); - if (!QPixmapCache::find(pixmapName, cache)) { - cache = QPixmap(rect.size()); - cache.fill(Qt::transparent); - QPainter cachePainter(&cache); - QRect cacheRect(QPoint(0, 0), rect.size()); - if (widget) - cachePainter.fillRect(cacheRect, option->palette.brush(widget->backgroundRole())); - else - cachePainter.fillRect(cacheRect, option->palette.background()); - - QImage handle(qt_plastique_toolbarhandle); - QMap handlecolors; - alphaCornerColor.setAlpha(170); - handlecolors.insert(4291151301, alphaCornerColor.rgba()); - handlecolors.insert(4293848814, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); - handlecolors.insert(4294638330, option->palette.light().color().rgba()); - handle = replaceColors(handle, handlecolors); - - if (option->state & State_Horizontal) { - int nchunks = cacheRect.height() / handle.height(); - int indent = (cacheRect.height() - (nchunks * handle.height())) / 2; - for (int i = 0; i < nchunks; ++i) - cachePainter.drawImage(QPoint(cacheRect.left() + 3, cacheRect.top() + indent + i * handle.height()), - handle); - } else { - int nchunks = cacheRect.width() / handle.width(); - int indent = (cacheRect.width() - (nchunks * handle.width())) / 2; - for (int i = 0; i < nchunks; ++i) - cachePainter.drawImage(QPoint(cacheRect.left() + indent + i * handle.width(), cacheRect.top() + 3), - handle); - } - cachePainter.end(); - QPixmapCache::insert(pixmapName, cache); - } - painter->drawPixmap(rect.topLeft(), cache); - break; - } - case PE_IndicatorToolBarSeparator: { - QPen oldPen = painter->pen(); - painter->setPen(alphaCornerColor); - if (option->state & State_Horizontal) { - painter->drawLine(option->rect.left(), option->rect.top() + 1, option->rect.left(), option->rect.bottom() - 2); - painter->setPen(option->palette.base().color()); - painter->drawLine(option->rect.right(), option->rect.top() + 1, option->rect.right(), option->rect.bottom() - 2); - } else { - painter->drawLine(option->rect.left() + 1, option->rect.top(), option->rect.right() - 2, option->rect.top()); - painter->setPen(option->palette.base().color()); - painter->drawLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 2, option->rect.bottom()); - } - painter->setPen(oldPen); - break; - } -#endif // QT_NO_TOOLBAR - case PE_PanelButtonCommand: - if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - bool sunken = (button->state & State_Sunken) || (button->state & State_On); - if ((button->features & QStyleOptionButton::Flat) && !sunken) - break; - - bool defaultButton = (button->features & (QStyleOptionButton::DefaultButton - | QStyleOptionButton::AutoDefaultButton)); - - BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(defaultButton)) - - QPen oldPen = p->pen(); - bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver); - - // Give the painter a different brush origin for sunken buttons - if (sunken) { - // ### No such function - // p->setPenOrigin(rect.left() + 1, rect.top() + 1); - p->setBrushOrigin(rect.left() + 1, rect.top() + 1); - } - - // Draw border - qt_plastique_draw_frame(p, rect, option); - - // Fill the panel - QRectF fillRect = rect.adjusted(2, 2, -2, -2); - - // Button colors - QBrush alphaCornerBrush = qMapBrushToRect(qBrushDark(option->palette.button(), 165), rect); - qBrushSetAlphaF(&alphaCornerBrush, 0.5); - QBrush buttonGradientBrush; - QBrush leftLineGradientBrush; - QBrush rightLineGradientBrush; - QBrush sunkenButtonGradientBrush; - QBrush sunkenLeftLineGradientBrush; - QBrush sunkenRightLineGradientBrush; - QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); - if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { - buttonGradientBrush = buttonBrush; - sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108); - leftLineGradientBrush = qBrushLight(buttonBrush, 105); - rightLineGradientBrush = qBrushDark(buttonBrush, 105); - sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110); - sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106); - } else { - // Generate gradients - QLinearGradient buttonGradient(rect.topLeft(), rect.bottomLeft()); - if (hover) { - buttonGradient.setColorAt(0.0, mergedColors(option->palette.highlight().color(), - buttonBrush.color().lighter(104), 6)); - buttonGradient.setColorAt(1.0, mergedColors(option->palette.highlight().color(), - buttonBrush.color().darker(110), 6)); - } else { - buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); - buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); - } - buttonGradientBrush = QBrush(buttonGradient); - - QLinearGradient buttonGradient2(rect.topLeft(), rect.bottomLeft()); - buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113)); - buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103)); - sunkenButtonGradientBrush = QBrush(buttonGradient2); - - QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft()); - buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); - buttonGradient3.setColorAt(1.0, buttonBrush.color()); - leftLineGradientBrush = QBrush(buttonGradient3); - - QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft()); - buttonGradient4.setColorAt(0.0, buttonBrush.color()); - buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); - rightLineGradientBrush = QBrush(buttonGradient4); - - QLinearGradient buttonGradient5(rect.topLeft(), rect.bottomLeft()); - buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113)); - buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107)); - sunkenLeftLineGradientBrush = QBrush(buttonGradient5); - - QLinearGradient buttonGradient6(rect.topLeft(), rect.bottomLeft()); - buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108)); - buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103)); - sunkenRightLineGradientBrush = QBrush(buttonGradient6); - } - - // Main fill - p->fillRect(fillRect, - qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, rect)); - - // Top line - p->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, rect), 105), 0)); - p->drawLine(QPointF(rect.left() + 2, rect.top() + 1), - QPointF(rect.right() - 2, rect.top() + 1)); - - // Bottom line - p->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, rect), 105), 0)); - p->drawLine(QPointF(rect.left() + 2, rect.bottom() - 1), - QPointF(rect.right() - 2, rect.bottom() - 1)); - - // Left line - p->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush - : leftLineGradientBrush, rect), 1)); - p->drawLine(QPointF(rect.left() + 1, rect.top() + 2), - QPointF(rect.left() + 1, rect.bottom() - 2)); - - // Right line - p->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush - : rightLineGradientBrush, rect), 1)); - p->drawLine(QPointF(rect.right() - 1, rect.top() + 2), - QPointF(rect.right() - 1, rect.bottom() - 2)); - - // Hovering - if (hover && !sunken) { - QBrush hover = qMapBrushToRect(option->palette.highlight(), rect); - QBrush hoverOuter = hover; - qBrushSetAlphaF(&hoverOuter, qreal(0.7)); - - QLine lines[2]; - - p->setPen(QPen(hoverOuter, 0)); - lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1); - p->drawLines(lines, 2); - - QBrush hoverInner = hover; - qBrushSetAlphaF(&hoverInner, qreal(0.45)); - p->setPen(QPen(hoverInner, 0)); - lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.right() - 1, rect.top() + 2); - lines[1] = QLine(rect.left() + 1, rect.bottom() - 2, rect.right() - 1, rect.bottom() - 2); - p->drawLines(lines, 2); - - QBrush hoverSide = hover; - qBrushSetAlphaF(&hoverSide, qreal(0.075)); - p->setPen(QPen(hoverSide, 0)); - lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); - lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - p->drawLines(lines, 2); - } - - p->setPen(oldPen); - - END_STYLE_PIXMAPCACHE - } - break; - case PE_IndicatorCheckBox: - if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - BEGIN_STYLE_PIXMAPCACHE(QLatin1String("checkbox")) - - p->save(); - - // Outline - QBrush border = option->palette.shadow(); - qBrushSetAlphaF(&border, qreal(0.4)); - p->setPen(QPen(border, 0)); - const QLine lines[4] = { - QLine(rect.left() + 1, rect.top(), rect.right() - 1, rect.top()), - QLine(rect.left() + 1, rect.bottom(), rect.right() - 1, rect.bottom()), - QLine(rect.left(), rect.top() + 1, rect.left(), rect.bottom() - 1), - QLine(rect.right(), rect.top() + 1, rect.right(), rect.bottom() - 1) }; - p->drawLines(lines, 4); - - QBrush corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, qreal(0.2)); - p->setPen(QPen(corner, 0)); - const QPoint points[4] = { - rect.topLeft(), rect.topRight(), - rect.bottomLeft(), rect.bottomRight() }; - p->drawPoints(points, 4); - - // Fill - QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect); - if (!baseBrush.gradient() && baseBrush.texture().isNull()) { - QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom()); - gradient.setColorAt(0, baseBrush.color()); - gradient.setColorAt(1, baseBrush.color().darker(105)); - baseBrush = gradient; - } - p->fillRect(rect.adjusted(1, 1, -1, -1), baseBrush); - - // Hover - if ((button->state & State_Enabled) && (button->state & State_MouseOver)) { - QBrush pen = qMapBrushToRect(button->palette.highlight(), rect); - qBrushSetAlphaF(&pen, qreal(0.8)); - p->setPen(QPen(pen, 0)); - p->drawRect(rect.adjusted(1, 1, -2, -2)); - qBrushSetAlphaF(&pen, 0.5); - p->setPen(QPen(pen, 0)); - p->drawRect(rect.adjusted(2, 2, -3, -3)); - - qBrushSetAlphaF(&pen, qreal(0.2)); - p->setBrush(pen); - p->drawRect(rect.adjusted(2, 2, -3, -3)); - } - - // Indicator - bool on = button->state & State_On; - bool sunken = button->state & State_Sunken; - bool unchanged = button->state & State_NoChange; - bool enabled = button->state & State_Enabled; - if (on || (enabled && sunken) || unchanged) { - QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect); - if (sunken) - qBrushSetAlphaF(&pointBrush, qreal(0.5)); - else if (unchanged) - qBrushSetAlphaF(&pointBrush, qreal(0.3)); - p->setPen(QPen(pointBrush, 3)); - const QLine lines[2] = { - QLine(rect.left() + 4, rect.top() + 4, rect.right() - 3, rect.bottom() - 3), - QLine(rect.right() - 3, rect.top() + 4, rect.left() + 4, rect.bottom() - 3) }; - p->drawLines(lines, 2); - } - - p->restore(); - END_STYLE_PIXMAPCACHE - } - break; - case PE_IndicatorRadioButton: - if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - BEGIN_STYLE_PIXMAPCACHE(QLatin1String("radiobutton")) - - p->save(); - - // The the filled ellipse - QBrush border = qMapBrushToRect(option->palette.shadow(), rect); - qBrushSetAlphaF(&border, qreal(0.51)); - p->setPen(QPen(border, 0)); - - QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect); - if (!baseBrush.gradient() && baseBrush.texture().isNull()) { - QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom()); - gradient.setColorAt(0, baseBrush.color()); - gradient.setColorAt(1, baseBrush.color().darker(105)); - baseBrush = gradient; - } - p->setBrush(baseBrush); - p->drawEllipse(QRectF(rect).adjusted(1, 1, -1, -1)); - - // Hover - if ((button->state & State_Enabled) && (button->state & State_MouseOver)) { - QBrush pen = qMapBrushToRect(button->palette.highlight(), rect); - qBrushSetAlphaF(&pen, qreal(0.8)); - p->setPen(QPen(pen, 0)); - qBrushSetAlphaF(&pen, qreal(0.2)); - p->setBrush(pen); - p->drawEllipse(QRectF(rect).adjusted(2, 2, -2, -2)); - } - - // Indicator - bool on = button->state & State_On; - bool sunken = button->state & State_Sunken; - bool enabled = button->state & State_Enabled; - if (on || (enabled && sunken)) { - p->setPen(Qt::NoPen); - QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect); - if (sunken) - qBrushSetAlphaF(&pointBrush, 0.5); - p->setBrush(pointBrush); - p->drawEllipse(QRectF(rect).adjusted(3, 3, -3, -3)); - } - - p->restore(); - END_STYLE_PIXMAPCACHE - } - break; -#ifndef QT_NO_DOCKWIDGET - case PE_IndicatorDockWidgetResizeHandle: - if ((option->state & State_Enabled) && (option->state & State_MouseOver)) - painter->fillRect(option->rect, QColor(255, 255, 255, 128)); - if (option->state & State_Horizontal) { - int width = option->rect.width() / 3; - QRect rect(option->rect.center().x() - width / 2, - option->rect.top() + (option->rect.height() / 2) - 1, width, 3); - qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget); - } else { - int height = option->rect.height() / 3; - QRect rect(option->rect.left() + (option->rect.width() / 2 - 1), - option->rect.center().y() - height / 2, 3, height); - qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget); - } - break; -#endif // QT_NO_DOCKWIDGET - case PE_IndicatorViewItemCheck: { - QStyleOptionButton button; - button.QStyleOption::operator=(*option); - button.state &= ~State_MouseOver; - proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); - break; - } - case PE_FrameWindow: { - painter->save(); - bool active = (option->state & State_Active); - int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget); - - QPalette palette = option->palette; - if (!active) - palette.setCurrentColorGroup(QPalette::Disabled); - - // Frame and rounded corners - painter->setPen(mergedColors(palette.highlight().color(), Qt::black, 50)); - - QLine lines[3]; - QPoint points[4]; - - // bottom border line - lines[0] = QLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 1, option->rect.bottom()); - - // bottom left and right side border lines - lines[1] = QLine(option->rect.left(), titleBarStop, option->rect.left(), option->rect.bottom() - 1); - lines[2] = QLine(option->rect.right(), titleBarStop, option->rect.right(), option->rect.bottom() - 1); - painter->drawLines(lines, 3); - points[0] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1); - points[1] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1); - painter->drawPoints(points, 2); - - - // alpha corners - painter->setPen(mergedColors(palette.highlight().color(), palette.background().color(), 55)); - points[0] = QPoint(option->rect.left() + 2, option->rect.bottom() - 1); - points[1] = QPoint(option->rect.left() + 1, option->rect.bottom() - 2); - points[2] = QPoint(option->rect.right() - 2, option->rect.bottom() - 1); - points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 2); - painter->drawPoints(points, 4); - - - // upper and lower left inner - painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color()) : palette.background().color().darker(120)); - painter->drawLine(option->rect.left() + 1, titleBarStop, option->rect.left() + 1, option->rect.bottom() - 2); - - - painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color(), 57) : palette.background().color().darker(130)); - lines[0] = QLine(option->rect.right() - 1, titleBarStop, option->rect.right() - 1, option->rect.bottom() - 2); - lines[1] = QLine(option->rect.left() + 1, option->rect.bottom() - 1, option->rect.right() - 1, option->rect.bottom() - 1); - painter->drawLines(lines, 2); - - painter->restore(); - } - break; - case PE_IndicatorBranch: { - int mid_h = option->rect.x() + option->rect.width() / 2; - int mid_v = option->rect.y() + option->rect.height() / 2; - int bef_h = mid_h; - int bef_v = mid_v; - int aft_h = mid_h; - int aft_v = mid_v; - QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern); - if (option->state & State_Item) { - if (option->direction == Qt::RightToLeft) - painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush); - else - painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush); - } - if (option->state & State_Sibling) - painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush); - if (option->state & (State_Open | State_Children | State_Item | State_Sibling)) - painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush); - - if (option->state & State_Children) { - painter->save(); - QPoint center = option->rect.center(); - // border - QRect fullRect(center.x() - 4, center.y() - 4, 9, 9); - painter->setPen(borderColor); - - const QLine lines[4] = { - QLine(fullRect.left() + 1, fullRect.top(), - fullRect.right() - 1, fullRect.top()), - QLine(fullRect.left() + 1, fullRect.bottom(), - fullRect.right() - 1, fullRect.bottom()), - QLine(fullRect.left(), fullRect.top() + 1, - fullRect.left(), fullRect.bottom() - 1), - QLine(fullRect.right(), fullRect.top() + 1, - fullRect.right(), fullRect.bottom() - 1) }; - painter->drawLines(lines, 4); - - // "antialiased" corners - painter->setPen(alphaCornerColor); - const QPoint points[4] = { - fullRect.topLeft(), - fullRect.topRight(), - fullRect.bottomLeft(), - fullRect.bottomRight() }; - painter->drawPoints(points, 4); - - // fill - QRect adjustedRect = fullRect; - QRect gradientRect(adjustedRect.left() + 1, adjustedRect.top() + 1, - adjustedRect.right() - adjustedRect.left() - 1, - adjustedRect.bottom() - adjustedRect.top() - 1); - if (option->palette.base().style() == Qt::SolidPattern) { - QColor baseGradientStartColor = option->palette.base().color().darker(101); - QColor baseGradientStopColor = option->palette.base().color().darker(106); - qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor); - } else { - painter->fillRect(gradientRect, option->palette.base()); - } - // draw "+" or "-" - painter->setPen(alphaTextColor); - painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); - if (!(option->state & State_Open)) - painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2); - painter->restore(); - } - } - break; - default: - QWindowsStyle::drawPrimitive(element, option, painter, widget); - break; - } -} - -/*! - \reimp -*/ -void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const -{ - QColor borderColor = option->palette.background().color().darker(178); - QColor alphaCornerColor; - if (widget) { - // ### backgroundrole/foregroundrole should be part of the style option - alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); - } else { - alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); - } - - QColor gradientStartColor = option->palette.button().color().lighter(104); - QColor gradientStopColor = option->palette.button().color().darker(105); - - QColor highlightedGradientStartColor = option->palette.button().color().lighter(101); - QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85); - - QColor lightShadowGradientStartColor = highlightedGradientStartColor.lighter(105); - QColor lightShadowGradientStopColor = highlightedGradientStopColor.lighter(105); - - QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35); - QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58); - - QColor alphaInnerColor = mergedColors(highlightedDarkInnerBorderColor, option->palette.base().color()); - - switch (element) { -#ifndef QT_NO_TABBAR - case CE_TabBarTabShape: - if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { - - if (tab->shape != QTabBar::RoundedNorth && tab->shape != QTabBar::RoundedWest && - tab->shape != QTabBar::RoundedSouth && tab->shape != QTabBar::RoundedEast) { - QWindowsStyle::drawControl(element, option, painter, widget); - break; - } - - painter->save(); - - // Set up some convenience variables - bool disabled = !(tab->state & State_Enabled); - bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab; - bool selected = tab->state & State_Selected; - bool mouseOver = (tab->state & State_MouseOver) && !selected && !disabled; - bool previousSelected = tab->selectedPosition == QStyleOptionTab::PreviousIsSelected; - bool nextSelected = tab->selectedPosition == QStyleOptionTab::NextIsSelected; - bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget); - bool reverse = (tab->direction == Qt::RightToLeft); - - int lowerTop = selected ? 0 : 3; // to make the selected tab bigger than the rest - bool atEnd = (tab->position == QStyleOptionTab::End) || onlyTab; - bool atBeginning = ((tab->position == QStyleOptionTab::Beginning) || onlyTab) - && !leftCornerWidget; - bool reverseShadow = false; - - int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); - int marginLeft = 0; - if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) { - marginLeft = 1; - } - - // I've set the names based on the natural coordinate system. Vectors are used to rotate everything - // if the orientation of the tab bare is different than north. - { - // Coordinates of corners of rectangle for transformation - QPoint topLeft; - QPoint topRight; - QPoint bottomLeft; - QPoint bottomRight; - - // Fill with normalized vectors in the direction of the coordinate system - // (down and right should be complement of up and left, or it will look odd) - QPoint vectorUp; - QPoint vectorDown; - QPoint vectorLeft; - QPoint vectorRight; - - QBrush border = option->palette.shadow(); - qBrushSetAlphaF(&border, qreal(0.4)); - QBrush innerTopLeft = option->palette.shadow(); - qBrushSetAlphaF(&innerTopLeft, qreal(0.075)); - QBrush innerBottomRight = option->palette.shadow(); - qBrushSetAlphaF(&innerBottomRight, qreal(0.23)); - QBrush corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, qreal(0.25)); - - QBrush baseColor1; - QBrush baseColor2; - - switch (tab->shape) { - case QTabBar::RoundedNorth: - vectorUp = QPoint(0, -1); - vectorDown = QPoint(0, 1); - - if (reverse) { - vectorLeft = QPoint(1, 0); - vectorRight = QPoint(-1, 0); - reverseShadow = true; - } else { - vectorLeft = QPoint(-1, 0); - vectorRight = QPoint(1, 0); - } - - if (reverse) { - topLeft = tab->rect.topRight(); - topRight = tab->rect.topLeft(); - bottomLeft = tab->rect.bottomRight(); - bottomRight = tab->rect.bottomLeft(); - } else { - topLeft = tab->rect.topLeft(); - topRight = tab->rect.topRight(); - bottomLeft = tab->rect.bottomLeft(); - bottomRight = tab->rect.bottomRight(); - } - - - baseColor1 = border; - baseColor2 = innerTopLeft; - break ; - case QTabBar::RoundedWest: - vectorUp = QPoint(-1, 0); - vectorDown = QPoint(1, 0); - vectorLeft = QPoint(0, -1); - vectorRight = QPoint(0, 1); - - topLeft = tab->rect.topLeft(); - topRight = tab->rect.bottomLeft(); - bottomLeft = tab->rect.topRight(); - bottomRight = tab->rect.bottomRight(); - - baseColor1 = border; - baseColor2 = innerTopLeft; - break ; - case QTabBar::RoundedEast: - vectorUp = QPoint(1, 0); - vectorDown = QPoint(-1, 0); - vectorLeft = QPoint(0, -1); - vectorRight = QPoint(0, 1); - - topLeft = tab->rect.topRight(); - topRight = tab->rect.bottomRight(); - bottomLeft = tab->rect.topLeft(); - bottomRight = tab->rect.bottomLeft(); - - baseColor1 = border; - baseColor2 = innerBottomRight; - break ; - case QTabBar::RoundedSouth: - vectorUp = QPoint(0, 1); - vectorDown = QPoint(0, -1); - - if (reverse) { - vectorLeft = QPoint(1, 0); - vectorRight = QPoint(-1, 0); - reverseShadow = true; - - topLeft = tab->rect.bottomRight(); - topRight = tab->rect.bottomLeft(); - bottomLeft = tab->rect.topRight(); - bottomRight = tab->rect.topLeft(); - } else { - vectorLeft = QPoint(-1, 0); - vectorRight = QPoint(1, 0); - - topLeft = tab->rect.bottomLeft(); - topRight = tab->rect.bottomRight(); - bottomLeft = tab->rect.topLeft(); - bottomRight = tab->rect.topRight(); - } - - baseColor1 = border; - baseColor2 = innerBottomRight; - break ; - default: - break; - } - - // Make the tab smaller when it's at the end, so that we are able to draw the corner - if (atEnd) { - topRight += vectorLeft; - bottomRight += vectorLeft; - } - - { - // Outer border - QLine topLine; - { - QPoint adjustTopLineLeft = (vectorRight * (marginLeft + (previousSelected ? 0 : 1))) + - (vectorDown * lowerTop); - QPoint adjustTopLineRight = (vectorDown * lowerTop); - if (atBeginning || selected) - adjustTopLineLeft += vectorRight; - if (atEnd || selected) - adjustTopLineRight += 2 * vectorLeft; - - topLine = QLine(topLeft + adjustTopLineLeft, topRight + adjustTopLineRight); - } - - QLine leftLine; - { - QPoint adjustLeftLineTop = (vectorRight * marginLeft) + (vectorDown * (lowerTop + 1)); - QPoint adjustLeftLineBottom = (vectorRight * marginLeft) + (vectorUp * borderThickness); - if (atBeginning || selected) - adjustLeftLineTop += vectorDown; // Make place for rounded corner - if (atBeginning && selected) - adjustLeftLineBottom += borderThickness * vectorDown; - else if (selected) - adjustLeftLineBottom += vectorUp; - - leftLine = QLine(topLeft + adjustLeftLineTop, bottomLeft + adjustLeftLineBottom); - } - - QLine rightLine; - { - QPoint adjustRightLineTop = vectorDown * (2 + lowerTop); - QPoint adjustRightLineBottom = vectorUp * borderThickness; - if (selected) - adjustRightLineBottom += vectorUp; - - rightLine = QLine(topRight + adjustRightLineTop, bottomRight + adjustRightLineBottom); - } - - // Background - QPoint startPoint = topLine.p1() + vectorDown + vectorLeft; - if (mouseOver) - startPoint += vectorDown; - QPoint endPoint = rightLine.p2(); - - if (tab->state & State_Enabled) { - QRect fillRect = QRect(startPoint, endPoint).normalized(); - if (fillRect.isValid()) { - if (selected) { - fillRect = QRect(startPoint, endPoint + vectorLeft + vectorDown * 3).normalized(); - painter->fillRect(fillRect, option->palette.window()); - - // Connect to the base - painter->setPen(QPen(option->palette.window(), 0)); - QVarLengthArray points; - points.append(rightLine.p2() + vectorDown); - points.append(rightLine.p2() + vectorDown + vectorDown); - points.append(rightLine.p2() + vectorDown + vectorDown + vectorRight); - if (tab->position != QStyleOptionTab::Beginning) { - points.append(leftLine.p2() + vectorDown); - points.append(leftLine.p2() + vectorDown + vectorDown); - points.append(leftLine.p2() + vectorDown + vectorDown + vectorLeft); - } - painter->drawPoints(points.constData(), points.size()); - } else { - QBrush buttonGradientBrush; - QBrush buttonBrush = qMapBrushToRect(option->palette.button(), fillRect); - if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { - buttonGradientBrush = buttonBrush; - } else { - // Generate gradients - QLinearGradient buttonGradient(fillRect.topLeft(), fillRect.bottomLeft()); - buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); - buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); - buttonGradientBrush = QBrush(buttonGradient); - } - - painter->fillRect(fillRect, buttonGradientBrush); - } - } - } - - QPoint rightCornerDot = topRight + vectorLeft + (lowerTop + 1)*vectorDown; - QPoint leftCornerDot = topLeft + (marginLeft + 1)*vectorRight + (lowerTop + 1)*vectorDown; - QPoint bottomRightConnectToBase = rightLine.p2() + vectorRight + vectorDown; - QPoint bottomLeftConnectToBase = leftLine.p2() + vectorLeft + vectorDown; - - painter->setPen(QPen(border, 0)); - - QVarLengthArray lines; - QVarLengthArray points; - - lines.append(topLine); - - if (mouseOver) { - painter->drawLines(lines.constData(), lines.count()); - lines.clear(); - - QLine secondHoverLine = QLine(topLine.p1() + vectorDown * 2 + vectorLeft, topLine.p2() + vectorDown * 2 + vectorRight); - painter->setPen(highlightedLightInnerBorderColor); - painter->drawLine(secondHoverLine); - } - - if (mouseOver) - painter->setPen(QPen(border, 0)); - - if (!previousSelected) - lines.append(leftLine); - if (atEnd || selected) { - lines.append(rightLine); - points.append(rightCornerDot); - } - if (atBeginning || selected) - points.append(leftCornerDot); - if (selected) { - points.append(bottomRightConnectToBase); - points.append(bottomLeftConnectToBase); - } - if (lines.size() > 0) { - painter->drawLines(lines.constData(), lines.size()); - lines.clear(); - } - if (points.size() > 0) { - painter->drawPoints(points.constData(), points.size()); - points.clear(); - } - - // Antialiasing - painter->setPen(QPen(corner, 0)); - if (atBeginning || selected) - points.append(topLine.p1() + vectorLeft); - if (!previousSelected) - points.append(leftLine.p1() + vectorUp); - if (atEnd || selected) { - points.append(topLine.p2() + vectorRight); - points.append(rightLine.p1() + vectorUp); - } - - if (selected) { - points.append(bottomRightConnectToBase + vectorLeft); - if (!atBeginning) { - points.append(bottomLeftConnectToBase + vectorRight); - - if (((tab->position == QStyleOptionTab::Beginning) || onlyTab) && leftCornerWidget) { - // A special case: When the first tab is selected and - // has a left corner widget, it needs to do more work - // to connect to the base - QPoint p1 = bottomLeftConnectToBase + vectorDown; - - points.append(p1); - } - } - } - if (points.size() > 0) { - painter->drawPoints(points.constData(), points.size()); - points.clear(); - } - - // Inner border - QLine innerTopLine = QLine(topLine.p1() + vectorDown, topLine.p2() + vectorDown); - if (!selected) { - QLinearGradient topLineGradient(innerTopLine.p1(),innerTopLine.p2()); - topLineGradient.setColorAt(0, lightShadowGradientStartColor); - topLineGradient.setColorAt(1, lightShadowGradientStopColor); - painter->setPen(QPen(mouseOver ? QBrush(highlightedDarkInnerBorderColor) : QBrush(topLineGradient), 1)); - } else { - painter->setPen(QPen(innerTopLeft, 0)); - } - painter->drawLine(innerTopLine); - - QLine innerLeftLine = QLine(leftLine.p1() + vectorRight + vectorDown, leftLine.p2() + vectorRight); - QLine innerRightLine = QLine(rightLine.p1() + vectorLeft + vectorDown, rightLine.p2() + vectorLeft); - - if (selected) { - innerRightLine = QLine(innerRightLine.p1() + vectorUp, innerRightLine.p2()); - innerLeftLine = QLine(innerLeftLine.p1() + vectorUp, innerLeftLine.p2()); - } - - if (selected || atBeginning) { - QBrush leftLineGradientBrush; - QRect rect = QRect(innerLeftLine.p1(), innerLeftLine.p2()).normalized(); - QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); - if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { - leftLineGradientBrush = qBrushLight(buttonBrush, 105); - } else { - QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft()); - buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); - buttonGradient3.setColorAt(1.0, buttonBrush.color()); - leftLineGradientBrush = QBrush(buttonGradient3); - } - - if (!selected) - painter->setPen(QPen(leftLineGradientBrush, 0)); - - // Assume the sun is on the same side in Right-To-Left layouts and draw the - // light shadow on the left side always (the right line is on the left side in - // reverse layouts for north and south) - if (reverseShadow) - painter->drawLine(innerRightLine); - else - painter->drawLine(innerLeftLine); - } - - if (atEnd || selected) { - if (!selected) { - QBrush rightLineGradientBrush; - QRect rect = QRect(innerRightLine.p1(), innerRightLine.p2()).normalized(); - QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect); - if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { - rightLineGradientBrush = qBrushDark(buttonBrush, 105); - } else { - QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft()); - buttonGradient4.setColorAt(0.0, buttonBrush.color()); - buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); - rightLineGradientBrush = QBrush(buttonGradient4); - } - - painter->setPen(QPen(rightLineGradientBrush, 0)); - } else { - painter->setPen(QPen(innerBottomRight, 0)); - } - - if (reverseShadow) - painter->drawLine(innerLeftLine); - else - painter->drawLine(innerRightLine); - } - - - // Base - QLine baseLine = QLine(bottomLeft + marginLeft * 2 * vectorRight, bottomRight); - { - - QPoint adjustedLeft; - QPoint adjustedRight; - - if (atEnd && !selected) { - baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorRight); - } - - if (nextSelected) { - adjustedRight += vectorLeft; - baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorLeft); - } - if (previousSelected) { - adjustedLeft += vectorRight; - baseLine = QLine(baseLine.p1() + vectorRight, baseLine.p2()); - } - if (atBeginning) - adjustedLeft += vectorRight; - - painter->setPen(QPen(baseColor2, 0)); - if (!selected) - painter->drawLine(baseLine); - - if (atEnd && !selected) - painter->drawPoint(baseLine.p2() + vectorRight); - - if (atBeginning && !selected) - adjustedLeft = vectorRight; - else - adjustedLeft = QPoint(0, 0); - painter->setPen(QPen(baseColor1, 0)); - if (!selected) - painter->drawLine(bottomLeft + vectorUp + adjustedLeft, baseLine.p2() + vectorUp); - - QPoint endPoint = bottomRight + vectorUp; - if (atEnd && !selected) - painter->drawPoint(endPoint); - - // For drawing a lower left "fake" corner on the base when the first tab is unselected - if (atBeginning && !selected) { - painter->drawPoint(baseLine.p1() + vectorLeft); - } - - painter->setPen(QPen(corner, 0)); - if (nextSelected) - painter->drawPoint(endPoint); - else if (selected) - painter->drawPoint(endPoint + vectorRight); - - // For drawing a lower left "fake" corner on the base when the first tab is unselected - if (atBeginning && !selected) { - painter->drawPoint(baseLine.p1() + 2 * vectorLeft); - } - } - } - } - - // Yay we're done - - painter->restore(); - } - break; -#endif // QT_NO_TABBAR -#ifndef QT_NO_PROGRESSBAR - case CE_ProgressBarGroove: - if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { - QRect rect = bar->rect; - QPen oldPen = painter->pen(); - - QLine lines[4]; - - // outline - painter->setPen(borderColor); - lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); - lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); - lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 4); - - QPoint points[8]; - points[0] = QPoint(rect.left() + 1, rect.top() + 1); - points[1] = QPoint(rect.right() - 1, rect.top() + 1); - points[2] = QPoint(rect.left() + 1, rect.bottom() - 1); - points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 4); - - // alpha corners - painter->setPen(alphaCornerColor); - points[0] = QPoint(rect.left(), rect.top() + 1); - points[1] = QPoint(rect.left() + 1, rect.top()); - points[2] = QPoint(rect.right(), rect.top() + 1); - points[3] = QPoint(rect.right() - 1, rect.top()); - points[4] = QPoint(rect.left(), rect.bottom() - 1); - points[5] = QPoint(rect.left() + 1, rect.bottom()); - points[6] = QPoint(rect.right(), rect.bottom() - 1); - points[7] = QPoint(rect.right() - 1, rect.bottom()); - painter->drawPoints(points, 8); - - // inner outline, north-west - painter->setPen(gradientStartColor.darker(105)); - lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - - // base of the groove - painter->setPen(QPen()); - painter->fillRect(rect.adjusted(2, 2, -2, -1), QBrush(bar->palette.base().color())); - painter->setPen(bar->palette.base().color()); - painter->drawLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - - painter->setPen(oldPen); - } - break; - case CE_ProgressBarLabel: - if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { - // The busy indicator doesn't draw a label - if (bar->minimum == 0 && bar->maximum == 0) - return; - - painter->save(); - - QRect rect = bar->rect; - QRect leftRect; - - QFont font; - font.setBold(true); - painter->setFont(font); - painter->setPen(bar->palette.text().color()); - - // Get extra style options if version 2 - bool vertical = (bar->orientation == Qt::Vertical); - bool inverted = bar->invertedAppearance; - bool bottomToTop = bar->bottomToTop; - - if (vertical) { - rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - QTransform m; - if (bottomToTop) { - m.translate(0.0, rect.width()); - m.rotate(-90); - } else { - m.translate(rect.height(), 0.0); - m.rotate(90); - } - painter->setTransform(m, true); - } - - int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width(); - - bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) - || ((bar->direction == Qt::LeftToRight) && inverted))) || (vertical && ((!inverted && !bottomToTop) || (inverted && bottomToTop))); - if (flip) { - int indicatorPos = rect.width() - progressIndicatorPos; - if (indicatorPos >= 0 && indicatorPos <= rect.width()) { - painter->setPen(bar->palette.base().color()); - leftRect = QRect(rect.left(), rect.top(), indicatorPos, rect.height()); - } else if (indicatorPos > rect.width()) { - painter->setPen(bar->palette.text().color()); - } else { - painter->setPen(bar->palette.base().color()); - } - } else { - if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) { - leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); - } else if (progressIndicatorPos > rect.width()) { - painter->setPen(bar->palette.base().color()); - } else { - painter->setPen(bar->palette.text().color()); - } - } - - QRegion rightRect = rect; - rightRect = rightRect.subtracted(leftRect); - painter->setClipRegion(rightRect); - painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); - if (!leftRect.isNull()) { - painter->setPen(flip ? bar->palette.text().color() : bar->palette.base().color()); - painter->setClipRect(leftRect); - painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); - } - - painter->restore(); - } - break; - case CE_ProgressBarContents: - if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { - Q_D(const QPlastiqueStyle); - QRect rect = bar->rect; - bool vertical = false; - bool inverted = false; - bool indeterminate = (bar->minimum == 0 && bar->maximum == 0); - if (!indeterminate && bar->progress == -1) - break; - - painter->save(); - - // Get extra style options if version 2 - if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast(option)) { - vertical = (bar2->orientation == Qt::Vertical); - inverted = bar2->invertedAppearance; - } - - // If the orientation is vertical, we use a transform to rotate - // the progress bar 90 degrees clockwise. This way we can use the - // same rendering code for both orientations. - if (vertical) { - rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - QTransform m = QTransform::fromTranslate(rect.height()-1, 0); - m.rotate(90.0); - painter->setTransform(m, true); - } - - int maxWidth = rect.width() - 4; - int minWidth = 4; - qint64 progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth); - int width = indeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth); - bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; - if (inverted) - reverse = !reverse; - - QRect progressBar; - if (!indeterminate) { - if (!reverse) { - progressBar.setRect(rect.left() + 2, rect.top() + 2, width, rect.height() - 4); - } else { - progressBar.setRect(rect.right() - 1 - width, rect.top() + 2, width, rect.height() - 4); - } - } else { - int slideWidth = ((rect.width() - 4) * 2) / 3; - int step = ((d->animateStep * slideWidth) / ProgressBarFps) % slideWidth; - if ((((d->animateStep * slideWidth) / ProgressBarFps) % (2 * slideWidth)) >= slideWidth) - step = slideWidth - step; - progressBar.setRect(rect.left() + 2 + step, rect.top() + 2, - slideWidth / 2, rect.height() - 4); - } - - // outline - painter->setPen(highlightedDarkInnerBorderColor); - - QVarLengthArray lines; - QVarLengthArray points; - if (!reverse) { - if (width == minWidth) { - points.append(QPoint(progressBar.left() + 1, progressBar.top())); - points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); - } else { - if (indeterminate) { - lines.append(QLine(progressBar.left() + 2, progressBar.top(), - progressBar.right() - 2, progressBar.top())); - lines.append(QLine(progressBar.left() + 2, progressBar.bottom(), - progressBar.right() - 2, progressBar.bottom())); - } else { - lines.append(QLine(progressBar.left() + 1, progressBar.top(), - progressBar.right() - 2, progressBar.top())); - lines.append(QLine(progressBar.left() + 1, progressBar.bottom(), - progressBar.right() - 2, progressBar.bottom())); - } - } - - if (indeterminate) { - lines.append(QLine(progressBar.left(), progressBar.top() + 2, - progressBar.left(), progressBar.bottom() - 2)); - } else { - lines.append(QLine(progressBar.left(), progressBar.top() + 1, - progressBar.left(), progressBar.bottom() - 1)); - } - lines.append(QLine(progressBar.right(), progressBar.top() + 2, - progressBar.right(), progressBar.bottom() - 2)); - } else { - if (width == minWidth) { - points.append(QPoint(progressBar.right() - 1, progressBar.top())); - points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); - } else { - if (indeterminate) { - lines.append(QLine(progressBar.right() - 2, progressBar.top(), - progressBar.left() + 2, progressBar.top())); - lines.append(QLine(progressBar.right() - 2, progressBar.bottom(), - progressBar.left() + 2, progressBar.bottom())); - } else { - lines.append(QLine(progressBar.right() - 1, progressBar.top(), - progressBar.left() + 2, progressBar.top())); - lines.append(QLine(progressBar.right() - 1, progressBar.bottom(), - progressBar.left() + 2, progressBar.bottom())); - } - } - if (indeterminate) { - lines.append(QLine(progressBar.right(), progressBar.top() + 2, - progressBar.right(), progressBar.bottom() - 2)); - } else { - lines.append(QLine(progressBar.right(), progressBar.top() + 1, - progressBar.right(), progressBar.bottom() - 1)); - } - lines.append(QLine(progressBar.left(), progressBar.top() + 2, - progressBar.left(), progressBar.bottom() - 2)); - } - - if (points.size() > 0) { - painter->drawPoints(points.constData(), points.size()); - points.clear(); - } - painter->drawLines(lines.constData(), lines.size()); - lines.clear(); - - // alpha corners - painter->setPen(alphaInnerColor); - if (!reverse) { - if (indeterminate) { - points.append(QPoint(progressBar.left() + 1, progressBar.top())); - points.append(QPoint(progressBar.left(), progressBar.top() + 1)); - points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); - points.append(QPoint(progressBar.left(), progressBar.bottom() - 1)); - } else { - points.append(QPoint(progressBar.left(), progressBar.top())); - points.append(QPoint(progressBar.left(), progressBar.bottom())); - } - points.append(QPoint(progressBar.right() - 1, progressBar.top())); - points.append(QPoint(progressBar.right(), progressBar.top() + 1)); - points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); - points.append(QPoint(progressBar.right(), progressBar.bottom() - 1)); - } else { - if (indeterminate) { - points.append(QPoint(progressBar.right() - 1, progressBar.top())); - points.append(QPoint(progressBar.right(), progressBar.top() + 1)); - points.append(QPoint(progressBar.right() - 1, progressBar.bottom())); - points.append(QPoint(progressBar.right(), progressBar.bottom() - 1)); - } else { - points.append(QPoint(progressBar.right(), progressBar.top())); - points.append(QPoint(progressBar.right(), progressBar.bottom())); - } - points.append(QPoint(progressBar.left() + 1, progressBar.top())); - points.append(QPoint(progressBar.left(), progressBar.top() + 1)); - points.append(QPoint(progressBar.left() + 1, progressBar.bottom())); - points.append(QPoint(progressBar.left(), progressBar.bottom() - 1)); - } - - painter->drawPoints(points.constData(), points.size()); - points.clear(); - - // contents - painter->setPen(QPen()); - - QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"), - option, rect.size()); - QPixmap cache; - if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { - QSize size = rect.size(); - cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6)); - cache.fill(Qt::white); - QPainter cachePainter(&cache); - QRect pixmapRect(0, 0, cache.width(), cache.height()); - - int leftEdge = 0; - bool flip = false; - while (leftEdge < cache.width() + 1) { - QColor rectColor = option->palette.highlight().color(); - QColor lineColor = option->palette.highlight().color(); - if (flip) { - flip = false; - rectColor = rectColor.lighter(105); - lineColor = lineColor.lighter(105); - } else { - flip = true; - } - - cachePainter.setPen(lineColor); - const QLine cacheLines[2] = { - QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.top(), - pixmapRect.left() + leftEdge + 9, pixmapRect.top()), - QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.bottom(), - pixmapRect.left() + leftEdge + 9, pixmapRect.bottom()) }; - cachePainter.drawLines(cacheLines, 2); - cachePainter.fillRect(QRect(pixmapRect.left() + leftEdge, pixmapRect.top(), - 10, pixmapRect.height()), rectColor); - - leftEdge += 10; - } - - QPixmapCache::insert(progressBarName, cache); - } - painter->setClipRect(progressBar.adjusted(1, 0, -1, -1)); - - if (!vertical) - progressBar.adjust(0, 1, 0, 1); - if (!indeterminate) { - int step = (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) ? (d->animateStep % 20) : 0; - if (reverse) - painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache); - else - painter->drawPixmap(progressBar.left() - 25 - step + width % 20, progressBar.top(), cache); - } else { - painter->drawPixmap(progressBar.left(), progressBar.top(), cache); - } - - painter->restore(); - } - break; -#endif // QT_NO_PROGRESSBAR - case CE_HeaderSection: - // Draws the header in tables. - if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { - QPixmap cache; - QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); - pixmapName += QString::number(- int(header->position)); - pixmapName += QString::number(- int(header->orientation)); - - if (!QPixmapCache::find(pixmapName, cache)) { - cache = QPixmap(option->rect.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); - QPainter cachePainter(&cache); - - bool sunken = (header->state & State_Enabled) && (header->state & State_Sunken); - - QColor headerGradientStart = sunken ? option->palette.background().color().darker(114) : gradientStartColor; - QColor headerGradientStop = sunken ? option->palette.background().color().darker(106) : gradientStopColor; - - QColor lightLine = sunken ? option->palette.background().color().darker(118) : gradientStartColor; - QColor darkLine = sunken ? option->palette.background().color().darker(110) : gradientStopColor.darker(105); - - qt_plastique_draw_gradient(&cachePainter, pixmapRect, - headerGradientStart, headerGradientStop); - - cachePainter.setPen(borderColor); - cachePainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1)); - cachePainter.setPen(alphaCornerColor); - - const QPoint points[4] = { - pixmapRect.topLeft(), pixmapRect.topRight(), - pixmapRect.bottomLeft(), pixmapRect.bottomRight() }; - cachePainter.drawPoints(points, 4); - - QLine lines[2]; - - // inner lines - cachePainter.setPen(lightLine); - lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.top() + 1, - pixmapRect.right() - 2, pixmapRect.top() + 1); - lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2, - pixmapRect.left() + 1, pixmapRect.bottom() - 2); - cachePainter.drawLines(lines, 2); - - cachePainter.setPen(darkLine); - lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.bottom() - 1, - pixmapRect.right() - 2, pixmapRect.bottom() - 1); - lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.bottom() - 2, - pixmapRect.right() - 1, pixmapRect.top() + 2); - cachePainter.drawLines(lines, 2); - - cachePainter.end(); - QPixmapCache::insert(pixmapName, cache); - } - painter->drawPixmap(option->rect.topLeft(), cache); - - } - break; -#ifndef QT_NO_MENU - case CE_MenuItem: - // Draws one item in a popup menu. - if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - painter->save(); - QBrush textBrush; - if (option->palette.resolve() & (1 << QPalette::ButtonText)) - textBrush = option->palette.buttonText(); - else - textBrush = option->palette.windowText(); // KDE uses windowText rather than buttonText for menus - - if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { - painter->fillRect(menuItem->rect, option->palette.background().color().lighter(103)); - - int w = 0; - if (!menuItem->text.isEmpty()) { - painter->setFont(menuItem->font); - proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, - menuItem->palette, menuItem->state & State_Enabled, menuItem->text, - QPalette::Text); - w = menuItem->fontMetrics.width(menuItem->text) + 5; - } - - painter->setPen(alphaCornerColor); - bool reverse = menuItem->direction == Qt::RightToLeft; - painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(), - menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y()); - - painter->restore(); - break; - } - - bool selected = menuItem->state & State_Selected; - bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; - bool checked = menuItem->checked; - - if (selected) { - qt_plastique_draw_gradient(painter, menuItem->rect, - option->palette.highlight().color().lighter(105), - option->palette.highlight().color().darker(110)); - - painter->setPen(option->palette.highlight().color().lighter(110)); - painter->drawLine(option->rect.topLeft(), option->rect.topRight()); - painter->setPen(option->palette.highlight().color().darker(115)); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - } else { - painter->fillRect(option->rect, option->palette.background().color().lighter(103)); - } - - // Check - QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13); - checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); - if (checkable) { - if ((menuItem->checkType & QStyleOptionMenuItem::Exclusive) && menuItem->icon.isNull()) { - QStyleOptionButton button; - button.rect = checkRect; - button.state = menuItem->state; - if (checked) - button.state |= State_On; - button.palette = menuItem->palette; - proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget); - } else { - if (menuItem->icon.isNull()) { - QStyleOptionButton button; - button.rect = checkRect; - button.state = menuItem->state; - if (checked) - button.state |= State_On; - button.palette = menuItem->palette; - proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); - } else if (checked) { - int iconSize = qMax(menuItem->maxIconWidth, 20); - QRect sunkenRect(option->rect.left() + 1, - option->rect.top() + (option->rect.height() - iconSize) / 2 + 1, - iconSize, iconSize); - sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect); - - QStyleOption opt = *option; - opt.state |= State_Sunken; - opt.rect = sunkenRect; - qt_plastique_drawShadedPanel(painter, &opt, false, widget); - } - } - } - - // Text and icon, ripped from windows style - bool dis = !(menuItem->state & State_Enabled); - bool act = menuItem->state & State_Selected; - const QStyleOption *opt = option; - const QStyleOptionMenuItem *menuitem = menuItem; - int checkcol = qMax(menuitem->maxIconWidth, 20); - QPainter *p = painter; - QRect vCheckRect = visualRect(opt->direction, menuitem->rect, - QRect(menuitem->rect.x(), menuitem->rect.y(), - checkcol, menuitem->rect.height())); - if (!menuItem->icon.isNull()) { - QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; - if (act && !dis) - mode = QIcon::Active; - QPixmap pixmap; - if (checked) - pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On); - else - pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode); - int pixw = pixmap.width(); - int pixh = pixmap.height(); - - QRect pmr(0, 0, pixw, pixh); - pmr.moveCenter(vCheckRect.center()); - painter->setPen(textBrush.color()); - if (checkable && checked) - painter->drawPixmap(QPoint(pmr.left() + 1, pmr.top() + 1), pixmap); - else - painter->drawPixmap(pmr.topLeft(), pixmap); - } - - if (selected) { - painter->setPen(menuItem->palette.highlightedText().color()); - } else { - painter->setPen(textBrush.color()); - } - int x, y, w, h; - menuitem->rect.getRect(&x, &y, &w, &h); - int tab = menuitem->tabWidth; - QColor discol; - if (dis) { - discol = textBrush.color(); - p->setPen(discol); - } - int xm = plastiqueWindowsItemFrame + checkcol + plastiqueWindowsItemHMargin; - int xpos = menuitem->rect.x() + xm; - QRect textRect(xpos, y + plastiqueWindowsItemVMargin, w - xm - plastiqueWindowsRightBorder - tab + 1, h - 2 * plastiqueWindowsItemVMargin); - QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); - QString s = menuitem->text; - if (!s.isEmpty()) { // draw text - p->save(); - int t = s.indexOf(QLatin1Char('\t')); - int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) - text_flags |= Qt::TextHideMnemonic; - text_flags |= Qt::AlignLeft; - if (t >= 0) { - QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, - QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { - p->setPen(menuitem->palette.light().color()); - p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); - p->setPen(discol); - } - p->drawText(vShortcutRect, text_flags, s.mid(t + 1)); - s = s.left(t); - } - QFont font = menuitem->font; - if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) - font.setBold(true); - p->setFont(font); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { - p->setPen(menuitem->palette.light().color()); - p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); - p->setPen(discol); - } - p->drawText(vTextRect, text_flags, s.left(t)); - p->restore(); - } - - // Arrow - if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow - int dim = (menuItem->rect.height() - 4) / 2; - PrimitiveElement arrow; - arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; - int xpos = menuItem->rect.left() + menuItem->rect.width() - 6 - 2 - dim; - QRect vSubMenuRect = visualRect(option->direction, menuItem->rect, - QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim)); - QStyleOptionMenuItem newMI = *menuItem; - newMI.rect = vSubMenuRect; - newMI.state = option->state & State_Enabled; - if (selected) - newMI.palette.setColor(QPalette::ButtonText, - newMI.palette.highlightedText().color()); - else - newMI.palette.setColor(QPalette::ButtonText, textBrush.color()); - proxy()->drawPrimitive(arrow, &newMI, painter, widget); - } - - painter->restore(); - } - break; -#endif // QT_NO_MENU -#ifndef QT_NO_MENUBAR - case CE_MenuBarItem: - // Draws a menu bar item; File, Edit, Help etc.. - if ((option->state & State_Selected)) { - QPixmap cache; - QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); - if (!QPixmapCache::find(pixmapName, cache)) { - cache = QPixmap(option->rect.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); - QPainter cachePainter(&cache); - - QRect rect = pixmapRect; - - // gradient fill - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) { - qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1), - option->palette.button().color().darker(114), - option->palette.button().color().darker(106)); - } else { - qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1), - option->palette.background().color().lighter(105), - option->palette.background().color().darker(102)); - } - - // outer border and corners - cachePainter.setPen(borderColor); - cachePainter.drawRect(rect.adjusted(0, 0, -1, -1)); - cachePainter.setPen(alphaCornerColor); - - const QPoint points[4] = { - rect.topLeft(), - rect.topRight(), - rect.bottomLeft(), - rect.bottomRight() }; - cachePainter.drawPoints(points, 4); - - // inner border - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) - cachePainter.setPen(option->palette.button().color().darker(118)); - else - cachePainter.setPen(gradientStartColor); - - QLine lines[2]; - lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); - cachePainter.drawLines(lines, 2); - - if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) - cachePainter.setPen(option->palette.button().color().darker(114)); - else - cachePainter.setPen(gradientStopColor.darker(102)); - lines[0] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1); - lines[1] = QLine(rect.right() - 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 2); - cachePainter.drawLines(lines, 2); - cachePainter.end(); - QPixmapCache::insert(pixmapName, cache); - } - painter->drawPixmap(option->rect.topLeft(), cache); - } else { - painter->fillRect(option->rect, option->palette.background()); - } - - if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) { - QStyleOptionMenuItem newMI = *mbi; - if (!(option->palette.resolve() & (1 << QPalette::ButtonText))) //KDE uses windowText rather than buttonText for menus - newMI.palette.setColor(QPalette::ButtonText, newMI.palette.windowText().color()); - QCommonStyle::drawControl(element, &newMI, painter, widget); - } - break; - -#ifndef QT_NO_MAINWINDOW - case CE_MenuBarEmptyArea: - if (widget && qobject_cast(widget->parentWidget())) { - painter->fillRect(option->rect, option->palette.window()); - QPen oldPen = painter->pen(); - painter->setPen(QPen(option->palette.dark().color())); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - painter->setPen(oldPen); - } - break; -#endif // QT_NO_MAINWINDOW - -#endif // QT_NO_MENUBAR - -#ifndef QT_NO_TOOLBOX - case CE_ToolBoxTabShape: - if (const QStyleOptionToolBox *toolBox = qstyleoption_cast(option)) { - painter->save(); - - int width = toolBox->rect.width(); - int diag = toolBox->rect.height() - 2; - - // The essential points - QPoint rightMost; - QPoint rightEdge; - QPoint leftEdge; - QPoint leftMost; - QPoint leftOne; - QPoint rightOne; - QPoint upOne(0, -1); - QPoint downOne(0, 1); - - if (toolBox->direction != Qt::RightToLeft) { - rightMost = QPoint(toolBox->rect.right(), toolBox->rect.bottom() - 2); - rightEdge = QPoint(toolBox->rect.right() - width / 10, toolBox->rect.bottom() - 2); - leftEdge = QPoint(toolBox->rect.right() - width / 10 - diag, toolBox->rect.top()); - leftMost = QPoint(toolBox->rect.left(), toolBox->rect.top()); - leftOne = QPoint(-1, 0); - rightOne = QPoint(1, 0); - } else { - rightMost = QPoint(toolBox->rect.left(), toolBox->rect.bottom() - 2); - rightEdge = QPoint(toolBox->rect.left() + width / 10, toolBox->rect.bottom() - 2); - leftEdge = QPoint(toolBox->rect.left() + width / 10 + diag, toolBox->rect.top()); - leftMost = QPoint(toolBox->rect.right(), toolBox->rect.top()); - leftOne = QPoint(1, 0); - rightOne = QPoint(-1, 0); - } - - QLine lines[3]; - - // Draw the outline - painter->setPen(borderColor); - lines[0] = QLine(rightMost, rightEdge); - lines[1] = QLine(rightEdge + leftOne, leftEdge); - lines[2] = QLine(leftEdge + leftOne, leftMost); - painter->drawLines(lines, 3); - painter->setPen(toolBox->palette.base().color()); - lines[0] = QLine(rightMost + downOne, rightEdge + downOne); - lines[1] = QLine(rightEdge + leftOne + downOne, leftEdge + downOne); - lines[2] = QLine(leftEdge + leftOne + downOne, leftMost + downOne); - painter->drawLines(lines, 3); - - painter->restore(); - } - break; -#endif // QT_NO_TOOLBOX -#ifndef QT_NO_SPLITTER - case CE_Splitter: - if ((option->state & State_Enabled) && (option->state & State_MouseOver)) - painter->fillRect(option->rect, QColor(255, 255, 255, 128)); - if (option->state & State_Horizontal) { - int height = option->rect.height() / 3; - QRect rect(option->rect.left() + (option->rect.width() / 2 - 1), - option->rect.center().y() - height / 2, 3, height); - qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget); - } else { - int width = option->rect.width() / 3; - QRect rect(option->rect.center().x() - width / 2, - option->rect.top() + (option->rect.height() / 2) - 1, width, 3); - qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget); - } - break; -#endif // QT_NO_SPLITTER -#ifndef QT_NO_DOCKWIDGET - case CE_DockWidgetTitle: - if (const QStyleOptionDockWidget *dockWidget = qstyleoption_cast(option)) { - painter->save(); - - bool verticalTitleBar = dockWidget->verticalTitleBar; - - // Find text width and title rect - int textWidth = option->fontMetrics.width(dockWidget->title); - int margin = 4; - QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget); - QRect rect = dockWidget->rect; - - if (verticalTitleBar) { - QRect r = rect; - QSize s = r.size(); - s.transpose(); - r.setSize(s); - - titleRect = QRect(r.left() + rect.bottom() - - titleRect.bottom(), - r.top() + titleRect.left() - rect.left(), - titleRect.height(), titleRect.width()); - - painter->translate(r.left(), r.top() + r.width()); - painter->rotate(-90); - painter->translate(-r.left(), -r.top()); - - rect = r; - } - - // Chop and insert ellide into title if text is too wide - QString title = elliditide(dockWidget->title, dockWidget->fontMetrics, titleRect, &textWidth); - - // Draw the toolbar handle pattern to the left and right of the text - QImage handle(qt_plastique_toolbarhandle); - QMap handlecolors; - alphaCornerColor.setAlpha(170); - handlecolors.insert(4291151301, alphaCornerColor.rgba()); - handlecolors.insert(4293848814, mergedColors(alphaCornerColor, option->palette.light().color()).rgba()); - handlecolors.insert(4294638330, option->palette.light().color().rgba()); - handle = replaceColors(handle, handlecolors); - - if (title.isEmpty()) { - // Joint handle if there's no title - QRect r; - r.setRect(titleRect.left(), titleRect.top(), titleRect.width(), titleRect.bottom()); - int nchunks = (r.width() / handle.width()) - 1; - int indent = (r.width() - (nchunks * handle.width())) / 2; - for (int i = 0; i < nchunks; ++i) { - painter->drawImage(QPoint(r.left() + indent + i * handle.width(), - r.center().y() - handle.height() / 2), - handle); - } - } else { - // Handle pattern to the left of the title - QRect leftSide(titleRect.left(), titleRect.top(), - titleRect.width() / 2 - textWidth / 2 - margin, titleRect.bottom()); - int nchunks = leftSide.width() / handle.width(); - int indent = (leftSide.width() - (nchunks * handle.width())) / 2; - for (int i = 0; i < nchunks; ++i) { - painter->drawImage(QPoint(leftSide.left() + indent - + i * handle.width(), - leftSide.center().y() - - handle.height() / 2), - handle); - } - - // Handle pattern to the right of the title - QRect rightSide = titleRect.adjusted(titleRect.width() / 2 + textWidth / 2 + margin, 0, 0, 0); - nchunks = rightSide.width() / handle.width(); - indent = (rightSide.width() - (nchunks * handle.width())) / 2; - for (int j = 0; j < nchunks; ++j) { - painter->drawImage(QPoint(rightSide.left() + indent + j * handle.width(), - rightSide.center().y() - handle.height() / 2), - handle); - } - } - - // Draw the text centered - QFont font = painter->font(); - font.setPointSize(QFontInfo(font).pointSize() - 1); - painter->setFont(font); - painter->setPen(dockWidget->palette.windowText().color()); - painter->drawText(titleRect, - int(Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextShowMnemonic), - title); - - painter->restore(); - } - - break; -#endif // QT_NO_DOCKWIDGET -#ifndef QT_NO_TOOLBAR - case CE_ToolBar: - if (const QStyleOptionToolBar *toolBar = qstyleoption_cast(option)) { - // Draws the light line above and the dark line below menu bars and - // tool bars. - QPen oldPen = painter->pen(); - if (toolBar->toolBarArea == Qt::TopToolBarArea) { - if (toolBar->positionOfLine == QStyleOptionToolBar::End - || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { - // The end and onlyone top toolbar lines draw a double - // line at the bottom to blend with the central - // widget. - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.left(), option->rect.bottom() - 1, - option->rect.right(), option->rect.bottom() - 1); - } else { - // All others draw a single dark line at the bottom. - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - } - // All top toolbar lines draw a light line at the top. - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.topLeft(), option->rect.topRight()); - } else if (toolBar->toolBarArea == Qt::BottomToolBarArea) { - if (toolBar->positionOfLine == QStyleOptionToolBar::End - || toolBar->positionOfLine == QStyleOptionToolBar::Middle) { - // The end and middle bottom tool bar lines draw a dark - // line at the bottom. - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - } - if (toolBar->positionOfLine == QStyleOptionToolBar::Beginning - || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { - // The beginning and only one tool bar lines draw a - // double line at the bottom to blend with the - // status bar. - // ### The styleoption could contain whether the - // main window has a menu bar and a status bar, and - // possibly dock widgets. - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.left(), option->rect.bottom() - 1, - option->rect.right(), option->rect.bottom() - 1); - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - } - if (toolBar->positionOfLine == QStyleOptionToolBar::End) { - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.topLeft(), option->rect.topRight()); - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.left(), option->rect.top() + 1, - option->rect.right(), option->rect.top() + 1); - - } else { - // All other bottom toolbars draw a light line at the top. - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.topLeft(), option->rect.topRight()); - } - } - if (toolBar->toolBarArea == Qt::LeftToolBarArea) { - if (toolBar->positionOfLine == QStyleOptionToolBar::Middle - || toolBar->positionOfLine == QStyleOptionToolBar::End) { - // The middle and left end toolbar lines draw a light - // line to the left. - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); - } - if (toolBar->positionOfLine == QStyleOptionToolBar::End) { - // All other left toolbar lines draw a dark line to the right - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.right() - 1, option->rect.top(), - option->rect.right() - 1, option->rect.bottom()); - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); - } else { - // All other left toolbar lines draw a dark line to the right - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); - } - } else if (toolBar->toolBarArea == Qt::RightToolBarArea) { - if (toolBar->positionOfLine == QStyleOptionToolBar::Middle - || toolBar->positionOfLine == QStyleOptionToolBar::End) { - // Right middle and end toolbar lines draw the dark right line - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.topRight(), option->rect.bottomRight()); - } - if (toolBar->positionOfLine == QStyleOptionToolBar::End - || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) { - // The right end and single toolbar draws the dark - // line on its left edge - painter->setPen(alphaCornerColor); - painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); - // And a light line next to it - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.left() + 1, option->rect.top(), - option->rect.left() + 1, option->rect.bottom()); - } else { - // Other right toolbars draw a light line on its left edge - painter->setPen(option->palette.background().color().lighter(104)); - painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft()); - } - } - painter->setPen(oldPen); - } - break; -#endif // QT_NO_TOOLBAR -#ifndef QT_NO_SCROLLBAR - case CE_ScrollBarAddLine: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool reverse = scrollBar->direction == Qt::RightToLeft; - bool sunken = scrollBar->state & State_Sunken; - - QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); - QPixmap cache; - if (!QPixmapCache::find(addLinePixmapName, cache)) { - cache = QPixmap(option->rect.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, cache.width(), cache.height()); - QPainter addLinePainter(&cache); - addLinePainter.fillRect(pixmapRect, option->palette.background()); - - if (option->state & State_Enabled) { - // Gradient - QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top() + 2, - pixmapRect.center().x(), pixmapRect.bottom() - 2); - if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) { - gradient.setColorAt(0, gradientStopColor); - gradient.setColorAt(1, gradientStopColor); - } else { - gradient.setColorAt(0, gradientStartColor.lighter(105)); - gradient.setColorAt(1, gradientStopColor); - } - addLinePainter.fillRect(pixmapRect.left() + 2, pixmapRect.top() + 2, - pixmapRect.right() - 3, pixmapRect.bottom() - 3, - gradient); - } - - // Details - QImage addButton; - QMap addButtonMap; - if (horizontal) { - addButton = QImage(reverse ? qt_plastique_scrollbar_button_left : qt_plastique_scrollbar_button_right); - } else { - addButton = QImage(qt_plastique_scrollbar_button_down); - } - addButtonMap.insert(4290756543, alphaCornerColor.rgba()); - addButtonMap.insert(4288124823, borderColor.rgba()); - if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) { - addButtonMap.insert(4294638330, gradientStopColor.rgba()); - addButtonMap.insert(4289703855, gradientStopColor.rgba()); - } else { - addButtonMap.insert(4294638330, gradientStartColor.lighter(105).rgba()); - addButtonMap.insert(4289703855, gradientStopColor.rgba()); - } - addButton = replaceColors(addButton, addButtonMap); - addLinePainter.drawImage(pixmapRect, addButton); - - // Arrow - if (horizontal) { - QImage arrow(reverse ? qt_plastique_scrollbar_button_arrow_left : qt_plastique_scrollbar_button_arrow_right); - QMap arrowcolors; - arrowcolors.insert(4290756543, scrollBar->palette.foreground().color().rgba()); - arrow = replaceColors(arrow, arrowcolors); - - if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) - addLinePainter.translate(1, 1); - addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow); - } else { - QImage arrow(qt_plastique_scrollbar_button_arrow_down); - QMap arrowcolors; - arrowcolors.insert(4290756543, scrollBar->palette.foreground().color().rgba()); - arrow = replaceColors(arrow, arrowcolors); - - if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) - addLinePainter.translate(1, 1); - addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); - } - addLinePainter.end(); - QPixmapCache::insert(addLinePixmapName, cache); - } - painter->drawPixmap(option->rect.topLeft(), cache); - } - break; - case CE_ScrollBarSubPage: - case CE_ScrollBarAddPage: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - bool sunken = scrollBar->state & State_Sunken; - bool horizontal = scrollBar->orientation == Qt::Horizontal; - - QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); - if (sunken) - groovePixmapName += QLatin1String("-sunken"); - if (element == CE_ScrollBarAddPage) - groovePixmapName += QLatin1String("-addpage"); - - QPixmap cache; - if (!QPixmapCache::find(groovePixmapName, cache)) { - cache = QPixmap(option->rect.size()); - cache.fill(option->palette.background().color()); - QPainter groovePainter(&cache); - QRect pixmapRect = QRect(0, 0, option->rect.width(), option->rect.height()); - QColor color = scrollBar->palette.base().color().darker(sunken ? 125 : 100); - groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 0, - (element == CE_ScrollBarAddPage) ? pixmapRect.height() : 0); - groovePainter.fillRect(pixmapRect, QBrush(color, Qt::Dense4Pattern)); - - QColor edgeColor = scrollBar->palette.base().color().darker(125); - if (horizontal) { - groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 1, 0); - groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(pixmapRect.width(), 1)), - QBrush(edgeColor, Qt::Dense4Pattern)); - groovePainter.fillRect(QRect(pixmapRect.bottomLeft(), QSize(pixmapRect.width(), 1)), - QBrush(edgeColor, Qt::Dense4Pattern)); - } else { - groovePainter.setBrushOrigin(0, (element == CE_ScrollBarAddPage) ? pixmapRect.height() : 1); - groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(1, pixmapRect.height())), - QBrush(edgeColor, Qt::Dense4Pattern)); - groovePainter.fillRect(QRect(pixmapRect.topRight(), QSize(1, pixmapRect.height())), - QBrush(edgeColor, Qt::Dense4Pattern)); - } - - groovePainter.end(); - QPixmapCache::insert(groovePixmapName, cache); - } - painter->drawPixmap(option->rect.topLeft(), cache); - } - break; - case CE_ScrollBarSubLine: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - QRect scrollBarSubLine = scrollBar->rect; - - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool isEnabled = scrollBar->state & State_Enabled; - bool reverse = scrollBar->direction == Qt::RightToLeft; - bool sunken = scrollBar->state & State_Sunken; - - // The SubLine (up/left) buttons - QRect button1; - QRect button2; - int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); - if (horizontal) { - button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); - button2.setRect(scrollBarSubLine.right() - (scrollBarExtent - 1), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); - } else { - button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarSubLine.width(), scrollBarExtent); - button2.setRect(scrollBarSubLine.left(), scrollBarSubLine.bottom() - (scrollBarExtent - 1), scrollBarSubLine.width(), scrollBarExtent); - } - - QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); - QPixmap cache; - if (!QPixmapCache::find(subLinePixmapName, cache)) { - cache = QPixmap(button1.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, cache.width(), cache.height()); - QPainter subLinePainter(&cache); - subLinePainter.fillRect(pixmapRect, option->palette.background()); - - if (isEnabled) { - // Gradients - if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) { - qt_plastique_draw_gradient(&subLinePainter, - QRect(pixmapRect.left() + 2, pixmapRect.top() + 2, - pixmapRect.right() - 3, pixmapRect.bottom() - 3), - gradientStopColor, - gradientStopColor); - } else { - qt_plastique_draw_gradient(&subLinePainter, - QRect(pixmapRect.left() + 2, pixmapRect.top() + 2, - pixmapRect.right() - 3, pixmapRect.bottom() - 3), - gradientStartColor.lighter(105), - gradientStopColor); - } - } - - // Details - QImage subButton; - QMap subButtonMap; - if (horizontal) { - subButton = QImage(reverse ? qt_plastique_scrollbar_button_right : qt_plastique_scrollbar_button_left); - } else { - subButton = QImage(qt_plastique_scrollbar_button_up); - } - subButtonMap.insert(4290756543, alphaCornerColor.rgba()); - subButtonMap.insert(4288124823, borderColor.rgba()); - if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) { - subButtonMap.insert(4294638330, gradientStopColor.rgba()); - subButtonMap.insert(4289703855, gradientStopColor.rgba()); - } else { - subButtonMap.insert(4294638330, gradientStartColor.lighter(105).rgba()); - subButtonMap.insert(4289703855, gradientStopColor.rgba()); - } - subButton = replaceColors(subButton, subButtonMap); - subLinePainter.drawImage(pixmapRect, subButton); - - // Arrows - if (horizontal) { - QImage arrow(reverse ? qt_plastique_scrollbar_button_arrow_right : qt_plastique_scrollbar_button_arrow_left); - QMap arrowcolors; - arrowcolors.insert(4290756543, scrollBar->palette.foreground().color().rgba()); - arrow = replaceColors(arrow, arrowcolors); - - if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) - subLinePainter.translate(1, 1); - subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow); - } else { - QImage arrow(qt_plastique_scrollbar_button_arrow_up); - QMap arrowcolors; - arrowcolors.insert(4290756543, scrollBar->palette.foreground().color().rgba()); - arrow = replaceColors(arrow, arrowcolors); - - if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) - subLinePainter.translate(1, 1); - subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); - } - subLinePainter.end(); - QPixmapCache::insert(subLinePixmapName, cache); - } - painter->drawPixmap(button1.topLeft(), cache); - painter->drawPixmap(button2.topLeft(), cache); - } - break; - case CE_ScrollBarSlider: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - bool horizontal = scrollBar->orientation == Qt::Horizontal; - bool isEnabled = scrollBar->state & State_Enabled; - - // The slider - if (option->rect.isValid()) { - QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); - if (horizontal) - sliderPixmapName += QLatin1String("-horizontal"); - - QPixmap cache; - if (!QPixmapCache::find(sliderPixmapName, cache)) { - cache = QPixmap(option->rect.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, cache.width(), cache.height()); - QPainter sliderPainter(&cache); - bool sunken = (scrollBar->state & State_Sunken); - - if (isEnabled) { - QLinearGradient gradient(pixmapRect.left(), pixmapRect.center().y(), - pixmapRect.right(), pixmapRect.center().y()); - if (horizontal) - gradient = QLinearGradient(pixmapRect.center().x(), pixmapRect.top(), - pixmapRect.center().x(), pixmapRect.bottom()); - - if (sunken) { - gradient.setColorAt(0, gradientStartColor.lighter(110)); - gradient.setColorAt(1, gradientStopColor.lighter(105)); - } else { - gradient.setColorAt(0, gradientStartColor.lighter(105)); - gradient.setColorAt(1, gradientStopColor); - } - sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), gradient); - } else { - sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), option->palette.background()); - } - - sliderPainter.setPen(borderColor); - sliderPainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1)); - sliderPainter.setPen(alphaCornerColor); - QPoint points[4] = { - QPoint(pixmapRect.left(), pixmapRect.top()), - QPoint(pixmapRect.left(), pixmapRect.bottom()), - QPoint(pixmapRect.right(), pixmapRect.top()), - QPoint(pixmapRect.right(), pixmapRect.bottom()) }; - sliderPainter.drawPoints(points, 4); - - QLine lines[2]; - sliderPainter.setPen(sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105)); - lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 1, - pixmapRect.right() - 1, pixmapRect.top() + 1); - lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2, - pixmapRect.left() + 1, pixmapRect.bottom() - 2); - sliderPainter.drawLines(lines, 2); - - sliderPainter.setPen(sunken ? gradientStopColor.lighter(105) : gradientStopColor); - lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.bottom() - 1, - pixmapRect.right() - 1, pixmapRect.bottom() - 1); - lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.top() + 2, - pixmapRect.right() - 1, pixmapRect.bottom() - 1); - sliderPainter.drawLines(lines, 2); - - int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); - if ((horizontal && scrollBar->rect.width() > sliderMinLength) - || (!horizontal && scrollBar->rect.height() > sliderMinLength)) { - QImage pattern(horizontal ? qt_plastique_scrollbar_slider_pattern_horizontal - : qt_plastique_scrollbar_slider_pattern_vertical); - QMap patterncolors; - patterncolors.insert(4290756543, alphaCornerColor.rgba()); - patterncolors.insert(4288124823, (sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105)).rgba()); - pattern = replaceColors(pattern, patterncolors); - - if (horizontal) { - sliderPainter.drawImage(pixmapRect.center().x() - pattern.width() / 2 + 1, - pixmapRect.center().y() - 4, - pattern); - } else { - sliderPainter.drawImage(pixmapRect.center().x() - 4, - pixmapRect.center().y() - pattern.height() / 2 + 1, - pattern); - } - } - sliderPainter.end(); - // insert the slider into the cache - QPixmapCache::insert(sliderPixmapName, cache); - } - painter->drawPixmap(option->rect.topLeft(), cache); - } - } - break; -#endif -#ifndef QT_NO_COMBOBOX - case CE_ComboBoxLabel: - if (const QStyleOptionComboBox *comboBox = qstyleoption_cast(option)) { - painter->save(); - if (!comboBox->editable) { - // Plastique's non-editable combo box is drawn as a button, so - // we need the label to be drawn using ButtonText where it - // would usually use Text. - painter->setPen(QPen(comboBox->palette.buttonText(), 0)); - QWindowsStyle::drawControl(element, option, painter, widget); - } else if (!comboBox->currentIcon.isNull()) { - { - QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); - if (comboBox->direction == Qt::RightToLeft) - editRect.adjust(0, 2, -2, -2); - else - editRect.adjust(2, 2, 0, -2); - painter->save(); - painter->setClipRect(editRect); - if (!comboBox->currentIcon.isNull()) { - QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal - : QIcon::Disabled; - QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); - QRect iconRect(editRect); - iconRect.setWidth(comboBox->iconSize.width() + 5); - iconRect = alignedRect(comboBox->direction, - Qt::AlignLeft | Qt::AlignVCenter, - iconRect.size(), editRect); - painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); - proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); - } - painter->restore(); - } - } else { - QWindowsStyle::drawControl(element, option, painter, widget); - } - - painter->restore(); - } - break; -#endif - default: - QWindowsStyle::drawControl(element, option, painter, widget); - break; - } -} - -/*! - \reimp -*/ -void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const -{ - QColor borderColor = option->palette.background().color().darker(178); - QColor alphaCornerColor; - if (widget) { - // ### backgroundrole/foregroundrole should be part of the style option - alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); - } else { - alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); - } - QColor gradientStartColor = option->palette.button().color().lighter(104); - QColor gradientStopColor = option->palette.button().color().darker(105); - - switch (control) { -#ifndef QT_NO_SLIDER - case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); - QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); - bool horizontal = slider->orientation == Qt::Horizontal; - bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; - bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; - - QRect groove; - //The clickable region is 5 px wider than the visible groove for improved usability - if (grooveRegion.isValid()) - groove = horizontal ? grooveRegion.adjusted(0, 5, 0, -5) : grooveRegion.adjusted(5, 0, -5, 0); - - - QPixmap cache; - - if ((option->subControls & SC_SliderGroove) && groove.isValid()) { - BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("slider_groove-%0-%1").arg(ticksAbove).arg(ticksBelow)) - p->fillRect(groove, option->palette.background()); - - // draw groove - if (horizontal) { - p->setPen(borderColor); - const QLine lines[4] = { - QLine(groove.left() + 1, groove.top(), - groove.right() - 1, groove.top()), - QLine(groove.left() + 1, groove.bottom(), - groove.right() - 1, groove.bottom()), - QLine(groove.left(), groove.top() + 1, - groove.left(), groove.bottom() - 1), - QLine(groove.right(), groove.top() + 1, - groove.right(), groove.bottom() - 1) }; - p->drawLines(lines, 4); - - p->setPen(alphaCornerColor); - const QPoint points[4] = { - QPoint(groove.left(), groove.top()), - QPoint(groove.left(), groove.bottom()), - QPoint(groove.right(), groove.top()), - QPoint(groove.right(), groove.bottom()) }; - p->drawPoints(points, 4); - } else { - p->setPen(borderColor); - const QLine lines[4] = { - QLine(groove.left() + 1, groove.top(), - groove.right() - 1, groove.top()), - QLine(groove.left() + 1, groove.bottom(), - groove.right() - 1, groove.bottom()), - QLine(groove.left(), groove.top() + 1, - groove.left(), groove.bottom() - 1), - QLine(groove.right(), groove.top() + 1, - groove.right(), groove.bottom() - 1) }; - p->drawLines(lines, 4); - - p->setPen(alphaCornerColor); - const QPoint points[4] = { - QPoint(groove.left(), groove.top()), - QPoint(groove.right(), groove.top()), - QPoint(groove.left(), groove.bottom()), - QPoint(groove.right(), groove.bottom()) }; - p->drawPoints(points, 4); - } - END_STYLE_PIXMAPCACHE - } - - if ((option->subControls & SC_SliderHandle) && handle.isValid()) { - QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); - if (ticksAbove && !ticksBelow) - handlePixmapName += QLatin1String("-flipped"); - if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) - handlePixmapName += QLatin1String("-sunken"); - - if (!QPixmapCache::find(handlePixmapName, cache)) { - cache = QPixmap(handle.size()); - cache.fill(Qt::white); - QRect pixmapRect(0, 0, handle.width(), handle.height()); - QPainter handlePainter(&cache); - handlePainter.fillRect(pixmapRect, option->palette.background()); - - // draw handle - if (horizontal) { - QPainterPath path; - if (ticksAbove && !ticksBelow) { - path.moveTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom() - 10)); - path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.bottom() - 14)); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom() - 10)); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); - } else { - path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 10)); - path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.top() + 14)); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 10)); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); - } - if (slider->state & State_Enabled) { - QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(), - pixmapRect.center().x(), pixmapRect.bottom()); - if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) { - gradient.setColorAt(0, gradientStartColor.lighter(110)); - gradient.setColorAt(1, gradientStopColor.lighter(110)); - } else { - gradient.setColorAt(0, gradientStartColor); - gradient.setColorAt(1, gradientStopColor); - } - handlePainter.fillPath(path, gradient); - } else { - handlePainter.fillPath(path, slider->palette.background()); - } - } else { - QPainterPath path; - if (ticksAbove && !ticksBelow) { - path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.right() - 14, pixmapRect.top() + 5)); - path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1)); - } else { - path.moveTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.top() + 1)); - path.lineTo(QPoint(pixmapRect.left() + 14, pixmapRect.top() + 5)); - path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom())); - path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1)); - } - if (slider->state & State_Enabled) { - QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(), - pixmapRect.center().x(), pixmapRect.bottom()); - gradient.setColorAt(0, gradientStartColor); - gradient.setColorAt(1, gradientStopColor); - handlePainter.fillPath(path, gradient); - } else { - handlePainter.fillPath(path, slider->palette.background()); - } - } - - QImage image; - QMap imagecolors; - if (horizontal) { - image = QImage((ticksAbove && !ticksBelow) ? qt_plastique_slider_horizontalhandle_up : qt_plastique_slider_horizontalhandle); - } else { - image = QImage((ticksAbove && !ticksBelow) ? qt_plastique_slider_verticalhandle_left : qt_plastique_slider_verticalhandle); - } - imagecolors.insert(4288124823, borderColor.rgba()); - imagecolors.insert(4291414473, gradientStartColor.rgba()); - imagecolors.insert(4290888129, alphaCornerColor.rgba()); - if (option->state & State_Enabled) { - imagecolors.insert(4294638330, 0x80ffffff); - imagecolors.insert(4289703855, 0x25000000); - } else { - imagecolors.insert(4294638330, qt_transparentrgba); - imagecolors.insert(4289703855, qt_transparentrgba); - } - image = replaceColors(image, imagecolors); - handlePainter.drawImage(pixmapRect, image); - handlePainter.end(); - QPixmapCache::insert(handlePixmapName, cache); - } - - painter->drawPixmap(handle.topLeft(), cache); - - if (slider->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*slider); - fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); - proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } - } - - if (option->subControls & SC_SliderTickmarks) { - QPen oldPen = painter->pen(); - painter->setPen(borderColor); - int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); - int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); - int interval = slider->tickInterval; - if (interval <= 0) { - interval = slider->singleStep; - if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, - available) - - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, - 0, available) < 3) - interval = slider->pageStep; - } - if (interval <= 0) - interval = 1; - - int v = slider->minimum; - int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); - QVarLengthArray lines; - while (v <= slider->maximum + 1) { - if (v == slider->maximum + 1 && interval == 1) - break; - const int v_ = qMin(v, slider->maximum); - int pos = sliderPositionFromValue(slider->minimum, slider->maximum, - v_, (horizontal - ? slider->rect.width() - : slider->rect.height()) - len, - slider->upsideDown) + len / 2; - - int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0); - - if (horizontal) { - if (ticksAbove) { - lines.append(QLine(pos, slider->rect.top() + extra, - pos, slider->rect.top() + tickSize)); - } - if (ticksBelow) { - lines.append(QLine(pos, slider->rect.bottom() - extra, - pos, slider->rect.bottom() - tickSize)); - } - } else { - if (ticksAbove) { - lines.append(QLine(slider->rect.left() + extra, pos, - slider->rect.left() + tickSize, pos)); - } - if (ticksBelow) { - lines.append(QLine(slider->rect.right() - extra, pos, - slider->rect.right() - tickSize, pos)); - } - } - - // in the case where maximum is max int - int nextInterval = v + interval; - if (nextInterval < v) - break; - v = nextInterval; - } - painter->drawLines(lines.constData(), lines.size()); - painter->setPen(oldPen); - } - } - break; -#endif // QT_NO_SLIDER -#ifndef QT_NO_SPINBOX - case CC_SpinBox: - if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - painter->save(); - bool upSunken = (spinBox->activeSubControls & SC_SpinBoxUp) && (spinBox->state & (State_Sunken | State_On)); - bool downSunken = (spinBox->activeSubControls & SC_SpinBoxDown) && (spinBox->state & (State_Sunken | State_On)); - bool reverse = (spinBox->direction == Qt::RightToLeft); - - // Rects - QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); - QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); - QRect buttonRect = upRect | downRect; - - // Brushes - QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); - qBrushSetAlphaF(&corner, qreal(0.25)); - QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect); - qBrushSetAlphaF(&border, qreal(0.4)); - - QVarLengthArray points; - - Q_D(const QPlastiqueStyle); - if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) { - QRect filledRect = option->rect.adjusted(1, 1, -1, -1); - QBrush baseBrush = qMapBrushToRect(option->palette.base(), filledRect); - painter->setBrushOrigin(filledRect.topLeft()); - painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush); - qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken); - } else { - d->drawPartialFrame(painter, - option, - proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget), - widget); - } - // Paint buttons - if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) { - painter->restore(); - break; - } - // Button outlines - painter->setPen(QPen(border, 0)); - if (!reverse) - painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1)); - else - painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1)); - - if (!reverse) { - const QLine lines[4] = { - QLine(upRect.left(), upRect.top(), upRect.right() - 2, upRect.top()), - QLine(upRect.left() + 1, upRect.bottom(), upRect.right() - 1, upRect.bottom()), - QLine(downRect.left(), downRect.bottom(), downRect.right() - 2, downRect.bottom()), - QLine(buttonRect.right(), buttonRect.top() + 2, buttonRect.right(), buttonRect.bottom() - 2) }; - painter->drawLines(lines, 4); - - points.append(QPoint(upRect.right() - 1, upRect.top() + 1)); - points.append(QPoint(downRect.right() - 1, downRect.bottom() - 1)); - painter->drawPoints(points.constData(), points.size()); - points.clear(); - painter->setPen(QPen(corner, 0)); - points.append(QPoint(upRect.right() - 1, upRect.top())); - points.append(QPoint(upRect.right(), upRect.top() + 1)); - points.append(QPoint(upRect.right(), downRect.bottom() - 1)); - points.append(QPoint(upRect.right() - 1, downRect.bottom())); - } else { - const QLine lines[4] = { - QLine(upRect.right(), upRect.top(), upRect.left() + 2, upRect.top()), - QLine(upRect.right() - 1, upRect.bottom(), upRect.left() + 1, upRect.bottom()), - QLine(downRect.right(), downRect.bottom(), downRect.left() + 2, downRect.bottom()), - QLine(buttonRect.left(), buttonRect.top() + 2, buttonRect.left(), buttonRect.bottom() - 2) }; - painter->drawLines(lines, 4); - - points.append(QPoint(upRect.left() + 1, upRect.top() + 1)); - points.append(QPoint(downRect.left() + 1, downRect.bottom() - 1)); - painter->drawPoints(points.constData(), points.size()); - points.clear(); - painter->setPen(QPen(corner, 0)); - points.append(QPoint(upRect.left() + 1, upRect.top())); - points.append(QPoint(upRect.left(), upRect.top() + 1)); - points.append(QPoint(upRect.left(), downRect.bottom() - 1)); - points.append(QPoint(upRect.left() + 1, downRect.bottom())); - } - painter->drawPoints(points.constData(), points.size()); - points.clear(); - - // Button colors - QBrush buttonGradientBrush; - QBrush leftLineGradientBrush; - QBrush rightLineGradientBrush; - QBrush sunkenButtonGradientBrush; - QBrush sunkenLeftLineGradientBrush; - QBrush sunkenRightLineGradientBrush; - QBrush buttonBrush = qMapBrushToRect(option->palette.button(), buttonRect); - if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) { - buttonGradientBrush = buttonBrush; - sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108); - leftLineGradientBrush = qBrushLight(buttonBrush, 105); - rightLineGradientBrush = qBrushDark(buttonBrush, 105); - sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110); - sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106); - } else { - // Generate gradients - QLinearGradient buttonGradient(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104)); - buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110)); - buttonGradientBrush = QBrush(buttonGradient); - - QLinearGradient buttonGradient2(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113)); - buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103)); - sunkenButtonGradientBrush = QBrush(buttonGradient2); - - QLinearGradient buttonGradient3(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105)); - buttonGradient3.setColorAt(1.0, buttonBrush.color()); - leftLineGradientBrush = QBrush(buttonGradient3); - - QLinearGradient buttonGradient4(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient4.setColorAt(0.0, buttonBrush.color()); - buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110)); - rightLineGradientBrush = QBrush(buttonGradient4); - - QLinearGradient buttonGradient5(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113)); - buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107)); - sunkenLeftLineGradientBrush = QBrush(buttonGradient5); - - QLinearGradient buttonGradient6(buttonRect.topLeft(), buttonRect.bottomLeft()); - buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108)); - buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103)); - sunkenRightLineGradientBrush = QBrush(buttonGradient6); - } - - // Main fill - painter->fillRect(upRect.adjusted(2, 2, -2, -2), - qMapBrushToRect(upSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, upRect)); - painter->fillRect(downRect.adjusted(2, 2, -2, -2), - qMapBrushToRect(downSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, downRect)); - - // Top line - painter->setPen(QPen(qBrushLight(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, upRect), 105), 0)); - if (!reverse) { - painter->drawLine(upRect.left() + 1, upRect.top() + 1, - upRect.right() - 2, upRect.top() + 1); - } else { - painter->drawLine(upRect.right() - 1, upRect.top() + 1, - upRect.left() + 2, upRect.top() + 1); - } - painter->setPen(QPen(qBrushLight(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, downRect), 105), 0)); - if (!reverse) { - painter->drawLine(downRect.left() + 1, downRect.top() + 1, - downRect.right() - 1, downRect.top() + 1); - } else { - painter->drawLine(downRect.right() - 1, downRect.top() + 1, - downRect.left() + 1, downRect.top() + 1); - } - - // Left line - painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenLeftLineGradientBrush - : leftLineGradientBrush, upRect), 1)); - if (!reverse) { - painter->drawLine(upRect.left() + 1, upRect.top() + 2, - upRect.left() + 1, upRect.bottom() - 1); - } else { - painter->drawLine(upRect.left() + 1, upRect.top() + 2, - upRect.left() + 1, upRect.bottom() - 1); - } - painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenLeftLineGradientBrush - : leftLineGradientBrush, downRect), 1)); - if (!reverse) { - painter->drawLine(downRect.left() + 1, downRect.top() + 2, - downRect.left() + 1, downRect.bottom() - 1); - } else { - painter->drawLine(downRect.left() + 1, downRect.top() + 1, - downRect.left() + 1, downRect.bottom() - 2); - } - - // Bottom line - painter->setPen(QPen(qBrushDark(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, upRect), 105), 0)); - if (!reverse) { - painter->drawLine(upRect.left() + 2, upRect.bottom() - 1, - upRect.right() - 1, upRect.bottom() - 1); - } else { - painter->drawLine(upRect.right() - 2, upRect.bottom() - 1, - upRect.left() + 1, upRect.bottom() - 1); - } - painter->setPen(QPen(qBrushDark(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush - : buttonGradientBrush, downRect), 105), 0)); - if (!reverse) { - painter->drawLine(downRect.left() + 2, downRect.bottom() - 1, - downRect.right() - 2, downRect.bottom() - 1); - } else { - painter->drawLine(downRect.right() - 2, downRect.bottom() - 1, - downRect.left() + 2, downRect.bottom() - 1); - } - - // Right line - painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenRightLineGradientBrush - : rightLineGradientBrush, upRect), 1)); - if (!reverse) { - painter->drawLine(upRect.right() - 1, upRect.top() + 2, - upRect.right() - 1, upRect.bottom() - 1); - } else { - painter->drawLine(upRect.right() - 1, upRect.top() + 2, - upRect.right() - 1, upRect.bottom() - 1); - } - painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenRightLineGradientBrush - : rightLineGradientBrush, downRect), 1)); - if (!reverse) { - painter->drawLine(downRect.right() - 1, downRect.top() + 1, - downRect.right() - 1, downRect.bottom() - 2); - } else { - painter->drawLine(downRect.right() - 1, downRect.top() + 2, - downRect.right() - 1, downRect.bottom() - 1); - } - - QBrush indicatorBrush = qMapBrushToRect(option->palette.buttonText(), buttonRect); - painter->setPen(QPen(indicatorBrush, 0)); - if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) { - QPoint center; - if (spinBox->subControls & SC_SpinBoxUp) { - // ....... - // ...X... - // ...X... - // .XXXXX. - // ...X... - // ...X... - // ....... - center = upRect.center(); - if (upSunken) { - ++center.rx(); - ++center.ry(); - } - painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2); - painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); - } - if (spinBox->subControls & SC_SpinBoxDown) { - // ....... - // ....... - // ....... - // .XXXXX. - // ....... - // ....... - // ....... - center = downRect.center(); - if (downSunken) { - ++center.rx(); - ++center.ry(); - } - painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y()); - } - } else { - int offset; - int centerX; - if (spinBox->subControls & SC_SpinBoxUp) { - // ........... - // .....X..... - // ....XXX.... - // ...XXXXX... - // ..XXXXXXX.. - // ........... - offset = upSunken ? 1 : 0; - QRect upArrowRect(upRect.center().x() - 3 + offset, upRect.center().y() - 2 + offset, 7, 4); - centerX = upArrowRect.center().x(); - painter->drawPoint(centerX, upArrowRect.top()); - const QLine lines[3] = { - QLine(centerX - 1, upArrowRect.top() + 1, centerX + 1, upArrowRect.top() + 1), - QLine(centerX - 2, upArrowRect.top() + 2, centerX + 2, upArrowRect.top() + 2), - QLine(centerX - 3, upArrowRect.top() + 3, centerX + 3, upArrowRect.top() + 3) }; - painter->drawLines(lines, 3); - } - if (spinBox->subControls & SC_SpinBoxDown) { - // ........... - // ..XXXXXXX.. - // ...XXXXX... - // ....XXX.... - // .....X..... - // ........... - offset = downSunken ? 1 : 0; - QRect downArrowRect(downRect.center().x() - 3 + offset, downRect.center().y() - 2 + offset + 1, 7, 4); - centerX = downArrowRect.center().x(); - const QLine lines[3] = { - QLine(centerX - 3, downArrowRect.top(), centerX + 3, downArrowRect.top()), - QLine(centerX - 2, downArrowRect.top() + 1, centerX + 2, downArrowRect.top() + 1), - QLine(centerX - 1, downArrowRect.top() + 2, centerX + 1, downArrowRect.top() + 2) }; - painter->drawLines(lines, 3); - painter->drawPoint(centerX, downArrowRect.top() + 3); - } - } - painter->restore(); - } - break; -#endif // QT_NO_SPINBOX -#ifndef QT_NO_COMBOBOX - case CC_ComboBox: - if (const QStyleOptionComboBox *comboBox = qstyleoption_cast(option)) { - bool sunken = comboBox->state & State_On; // play dead if combobox has no items - bool reverse = comboBox->direction == Qt::RightToLeft; - int menuButtonWidth = 16; - int xoffset = sunken ? (reverse ? -1 : 1) : 0; - int yoffset = sunken ? 1 : 0; - QRect rect = comboBox->rect; - QPen oldPen = painter->pen(); - - // Fill - if (comboBox->editable) { - // Button colors - QBrush alphaCornerBrush = qBrushDark(option->palette.button(), 165); - qBrushSetAlphaF(&alphaCornerBrush, 0.5); - QBrush buttonGradientBrush; - QBrush leftLineGradientBrush; - QBrush rightLineGradientBrush; - QBrush sunkenButtonGradientBrush; - QBrush sunkenLeftLineGradientBrush; - QBrush sunkenRightLineGradientBrush; - QBrush button = option->palette.button(); - if (button.gradient() || !button.texture().isNull()) { - buttonGradientBrush = button; - sunkenButtonGradientBrush = qBrushDark(button, 108); - leftLineGradientBrush = qBrushLight(button, 105); - rightLineGradientBrush = qBrushDark(button, 105); - sunkenLeftLineGradientBrush = qBrushDark(button, 110); - sunkenRightLineGradientBrush = qBrushDark(button, 106); - } else { - // Generate gradients - QLinearGradient buttonGradient(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient.setColorAt(0.0, button.color().lighter(104)); - buttonGradient.setColorAt(1.0, button.color().darker(110)); - buttonGradientBrush = QBrush(buttonGradient); - - QLinearGradient buttonGradient2(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient2.setColorAt(0.0, button.color().darker(113)); - buttonGradient2.setColorAt(1.0, button.color().darker(103)); - sunkenButtonGradientBrush = QBrush(buttonGradient2); - - QLinearGradient buttonGradient3(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient3.setColorAt(0.0, button.color().lighter(105)); - buttonGradient3.setColorAt(1.0, button.color()); - leftLineGradientBrush = QBrush(buttonGradient3); - - QLinearGradient buttonGradient4(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient4.setColorAt(0.0, button.color()); - buttonGradient4.setColorAt(1.0, button.color().darker(110)); - rightLineGradientBrush = QBrush(buttonGradient4); - - QLinearGradient buttonGradient5(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient5.setColorAt(0.0, button.color().darker(113)); - buttonGradient5.setColorAt(1.0, button.color().darker(107)); - sunkenLeftLineGradientBrush = QBrush(buttonGradient5); - - QLinearGradient buttonGradient6(option->rect.topLeft(), option->rect.bottomLeft()); - buttonGradient6.setColorAt(0.0, button.color().darker(108)); - buttonGradient6.setColorAt(1.0, button.color().darker(103)); - sunkenRightLineGradientBrush = QBrush(buttonGradient6); - } - - // ComboBox starts with a lineedit in place already. - QRect buttonRect; - if (!reverse) { - buttonRect.setRect(rect.right() - menuButtonWidth, rect.top(), menuButtonWidth + 1, rect.height()); - } else { - buttonRect.setRect(rect.left(), rect.top(), menuButtonWidth + 1, rect.height()); - } - - Q_D(const QPlastiqueStyle); - d->drawPartialFrame(painter, - option, - proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget), - widget); - - QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect); - qBrushSetAlphaF(&border, qreal(0.4)); - painter->setPen(QPen(border, 0)); - if (!reverse) - painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1)); - else - painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1)); - - // Outline the button border - if (!reverse) { - const QLine lines[3] = { - QLine(buttonRect.left(), buttonRect.top(), - buttonRect.right() - 2, buttonRect.top()), - QLine(buttonRect.right(), buttonRect.top() + 2, - buttonRect.right(), buttonRect.bottom() - 2), - QLine(buttonRect.left(), buttonRect.bottom(), - buttonRect.right() - 2, buttonRect.bottom()) }; - painter->drawLines(lines, 3); - { - const QPoint points[2] = { - QPoint(buttonRect.right() - 1, buttonRect.top() + 1), - QPoint(buttonRect.right() - 1, buttonRect.bottom() - 1) }; - painter->drawPoints(points, 2); - } - - QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); - qBrushSetAlphaF(&corner, qreal(0.16)); - painter->setPen(QPen(corner, 0)); - { - const QPoint points[4] = { - QPoint(buttonRect.right() - 1, buttonRect.top()), - QPoint(buttonRect.right() - 1, buttonRect.bottom()), - QPoint(buttonRect.right(), buttonRect.top() + 1), - QPoint(buttonRect.right(), buttonRect.bottom() - 1) }; - painter->drawPoints(points, 4); - } - } else { - const QLine lines[3] = { - QLine(buttonRect.right(), buttonRect.top(), - buttonRect.left() + 2, buttonRect.top()), - QLine(buttonRect.left(), buttonRect.top() + 2, - buttonRect.left(), buttonRect.bottom() - 2), - QLine(buttonRect.right(), buttonRect.bottom(), - buttonRect.left() + 2, buttonRect.bottom()) }; - painter->drawLines(lines, 3); - { - const QPoint points[2] = { - QPoint(buttonRect.left() + 1, buttonRect.top() + 1), - QPoint(buttonRect.left() + 1, buttonRect.bottom() - 1) }; - painter->drawPoints(points, 2); - } - - QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect); - qBrushSetAlphaF(&corner, qreal(0.16)); - painter->setPen(QPen(corner, 0)); - { - const QPoint points[4] = { - QPoint(buttonRect.left() + 1, buttonRect.top()), - QPoint(buttonRect.left() + 1, buttonRect.bottom()), - QPoint(buttonRect.left(), buttonRect.top() + 1), - QPoint(buttonRect.left(), buttonRect.bottom() - 1) }; - painter->drawPoints(points, 4); - } - } - - QRect fillRect = buttonRect.adjusted(2, 2, -2, -2); - // Main fill - painter->fillRect(fillRect, - qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, option->rect)); - - // Top line - painter->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, option->rect), 105), 0)); - if (!reverse) { - painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 1), - QPointF(buttonRect.right() - 2, buttonRect.top() + 1)); - } else { - painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 1), - QPointF(buttonRect.left() + 2, buttonRect.top() + 1)); - } - - // Bottom line - painter->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush - : buttonGradientBrush, option->rect), 105), 0)); - if (!reverse) { - painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.bottom() - 1), - QPointF(buttonRect.right() - 2, buttonRect.bottom() - 1)); - } else { - painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.bottom() - 1), - QPointF(buttonRect.left() + 2, buttonRect.bottom() - 1)); - } - - // Left line - painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush - : leftLineGradientBrush, option->rect), 1)); - if (!reverse) { - painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2), - QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2)); - } else { - painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2), - QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2)); - } - - // Right line - painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush - : rightLineGradientBrush, option->rect), 1)); - if (!reverse) { - painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2), - QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2)); - } else { - painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2), - QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2)); - } - } else { - // Start with a standard panel button fill - QStyleOptionButton buttonOption; - buttonOption.QStyleOption::operator=(*comboBox); - if (!sunken) { - buttonOption.state &= ~State_Sunken; - } - proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); - - // Draw the menu button separator line - QBrush border = qMapBrushToRect(option->palette.shadow(), rect); - qBrushSetAlphaF(&border, qreal(0.35)); - painter->setPen(QPen(border, 0)); - if (!reverse) { - painter->drawLine(rect.right() - menuButtonWidth + xoffset, rect.top() + 1, - rect.right() - menuButtonWidth + xoffset, rect.bottom() - 1); - } else { - painter->drawLine(rect.left() + menuButtonWidth + xoffset, rect.top() + 1, - rect.left() + menuButtonWidth + xoffset, rect.bottom() - 1); - } - } - - // Draw the little arrow - if (comboBox->subControls & SC_ComboBoxArrow) { - int left = !reverse ? rect.right() - menuButtonWidth : rect.left(); - int right = !reverse ? rect.right() : rect.left() + menuButtonWidth; - QRect arrowRect((left + right) / 2 - 3 + xoffset, - rect.center().y() - 1 + yoffset, 7, 4); - painter->setPen(QPen(qMapBrushToRect(option->palette.buttonText(), rect), 0)); - const QLine lines[3] = { - QLine(arrowRect.topLeft(), arrowRect.topRight()), - QLine(arrowRect.left() + 1, arrowRect.top() + 1, - arrowRect.right() - 1, arrowRect.top() + 1), - QLine(arrowRect.left() + 2, arrowRect.top() + 2, - arrowRect.right() - 2, arrowRect.top() + 2) }; - painter->drawLines(lines, 3); - painter->drawPoint(arrowRect.center().x(), arrowRect.bottom()); - } - - // Draw the focus rect - if ((option->state & State_HasFocus) && !comboBox->editable - && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { - QStyleOptionFocusRect focus; - focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) - .adjusted(-2, 0, 2, 0); - proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); - } - - painter->setPen(oldPen); - } - break; -#endif // QT_NO_COMBOBOX - case CC_TitleBar: - if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast(option)) { - painter->save(); - bool active = (titleBar->titleBarState & State_Active); - QRect fullRect = titleBar->rect; - - // ### use palette colors instead - QColor titleBarGradientStart(active ? 0x3b508a : 0x6e6e6e); - QColor titleBarGradientStop(active ? 0x5d6e9e : 0x818181); - QColor titleBarFrameBorder(0x393939); - QColor titleBarAlphaCorner(active ? 0x4b5e7f : 0x6a6a6a); - QColor titleBarInnerTopLine(active ? 0x8e98ba : 0xa4a4a4); - QColor titleBarInnerInnerTopLine(active ? 0x57699b : 0x808080); - QColor leftCorner(active ? 0x6f7ea8 : 0x8e8e8e); - QColor rightCorner(active ? 0x44537d : 0x676767); - QColor textColor(active ? 0x282e40 : 0x282e40); - QColor textAlphaColor(active ? 0x3f4862 : 0x3f4862); - - - { - // Fill title bar gradient - qt_plastique_draw_gradient(painter, option->rect.adjusted(1, 1, -1, 0), - titleBarGradientStart, - titleBarGradientStop); - - // Frame and rounded corners - painter->setPen(titleBarFrameBorder); - - // top border line - { - const QLine lines[3] = { - QLine(fullRect.left() + 2, fullRect.top(), fullRect.right() - 2, fullRect.top()), - QLine(fullRect.left(), fullRect.top() + 2, fullRect.left(), fullRect.bottom()), - QLine(fullRect.right(), fullRect.top() + 2, fullRect.right(), fullRect.bottom()) }; - painter->drawLines(lines, 3); - const QPoint points[2] = { - QPoint(fullRect.left() + 1, fullRect.top() + 1), - QPoint(fullRect.right() - 1, fullRect.top() + 1) }; - painter->drawPoints(points, 2); - } - - // alpha corners - painter->setPen(titleBarAlphaCorner); - { - const QPoint points[4] = { - QPoint(fullRect.left() + 2, fullRect.top() + 1), - QPoint(fullRect.left() + 1, fullRect.top() + 2), - QPoint(fullRect.right() - 2, fullRect.top() + 1), - QPoint(fullRect.right() - 1, fullRect.top() + 2) }; - painter->drawPoints(points, 4); - } - - // inner top line - painter->setPen(titleBarInnerTopLine); - painter->drawLine(fullRect.left() + 3, fullRect.top() + 1, fullRect.right() - 3, fullRect.top() + 1); - - // inner inner top line - painter->setPen(titleBarInnerInnerTopLine); - painter->drawLine(fullRect.left() + 2, fullRect.top() + 2, fullRect.right() - 2, fullRect.top() + 2); - - // left and right inner - painter->setPen(leftCorner); - painter->drawLine(fullRect.left() + 1, fullRect.top() + 3, fullRect.left() + 1, fullRect.bottom()); - painter->setPen(rightCorner); - painter->drawLine(fullRect.right() - 1, fullRect.top() + 3, fullRect.right() - 1, fullRect.bottom()); - - if (titleBar->titleBarState & Qt::WindowMinimized) { - painter->setPen(titleBarFrameBorder); - painter->drawLine(fullRect.left() + 2, fullRect.bottom(), fullRect.right() - 2, fullRect.bottom()); - { - const QPoint points[2] = { - QPoint(fullRect.left() + 1, fullRect.bottom() - 1), - QPoint(fullRect.right() - 1, fullRect.bottom() - 1) }; - painter->drawPoints(points, 2); - } - painter->setPen(rightCorner); - painter->drawLine(fullRect.left() + 2, fullRect.bottom() - 1, fullRect.right() - 2, fullRect.bottom() - 1); - painter->setPen(titleBarAlphaCorner); - { - const QPoint points[4] = { - QPoint(fullRect.left() + 1, fullRect.bottom() - 2), - QPoint(fullRect.left() + 2, fullRect.bottom() - 1), - QPoint(fullRect.right() - 1, fullRect.bottom() - 2), - QPoint(fullRect.right() - 2, fullRect.bottom() - 1) }; - painter->drawPoints(points, 4); - } - } - // draw title - QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); - - QFont font = painter->font(); - font.setBold(true); - painter->setFont(font); - painter->setPen(titleBar->palette.text().color()); - - // Attempt to align left if there is not enough room for the title - // text. Otherwise, align center. QWorkspace does elliding for us, - // and it doesn't know about the bold title, so we need to work - // around some of the width mismatches. - bool tooWide = (QFontMetrics(font).width(titleBar->text) > textRect.width()); - QTextOption option((tooWide ? Qt::AlignLeft : Qt::AlignHCenter) | Qt::AlignVCenter); - option.setWrapMode(QTextOption::NoWrap); - - painter->drawText(textRect.adjusted(1, 1, 1, 1), titleBar->text, option); - painter->setPen(titleBar->palette.highlightedText().color()); - painter->drawText(textRect, titleBar->text, option); - } - - // min button - if ((titleBar->subControls & SC_TitleBarMinButton) - && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) - && !(titleBar->titleBarState & Qt::WindowMinimized)) { - bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); - - QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); - - int xoffset = minButtonRect.width() / 3; - int yoffset = minButtonRect.height() / 3; - - QRect minButtonIconRect(minButtonRect.left() + xoffset, minButtonRect.top() + yoffset, - minButtonRect.width() - xoffset * 2, minButtonRect.height() - yoffset * 2); - - painter->setPen(textColor); - { - const QLine lines[2] = { - QLine(minButtonIconRect.center().x() - 2, - minButtonIconRect.center().y() + 3, - minButtonIconRect.center().x() + 3, - minButtonIconRect.center().y() + 3), - QLine(minButtonIconRect.center().x() - 2, - minButtonIconRect.center().y() + 4, - minButtonIconRect.center().x() + 3, - minButtonIconRect.center().y() + 4) }; - painter->drawLines(lines, 2); - } - painter->setPen(textAlphaColor); - { - const QLine lines[2] = { - QLine(minButtonIconRect.center().x() - 3, - minButtonIconRect.center().y() + 3, - minButtonIconRect.center().x() - 3, - minButtonIconRect.center().y() + 4), - QLine(minButtonIconRect.center().x() + 4, - minButtonIconRect.center().y() + 3, - minButtonIconRect.center().x() + 4, - minButtonIconRect.center().y() + 4) }; - painter->drawLines(lines, 2); - } - } - - // max button - if ((titleBar->subControls & SC_TitleBarMaxButton) - && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) - && !(titleBar->titleBarState & Qt::WindowMaximized)) { - bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); - - QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); - - int xoffset = maxButtonRect.width() / 3; - int yoffset = maxButtonRect.height() / 3; - - QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset, - maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2); - - painter->setPen(textColor); - painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); - painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, - maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); - painter->setPen(textAlphaColor); - const QPoint points[4] = { - maxButtonIconRect.topLeft(), maxButtonIconRect.topRight(), - maxButtonIconRect.bottomLeft(), maxButtonIconRect.bottomRight() }; - painter->drawPoints(points, 4); - } - - // close button - if (titleBar->subControls & SC_TitleBarCloseButton && titleBar->titleBarFlags & Qt::WindowSystemMenuHint) { - bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); - - QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); - - int xoffset = closeButtonRect.width() / 3; - int yoffset = closeButtonRect.height() / 3; - - QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset, - closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2); - - painter->setPen(textAlphaColor); - { - const QLine lines[4] = { - QLine(closeIconRect.left() + 1, closeIconRect.top(), - closeIconRect.right(), closeIconRect.bottom() - 1), - QLine(closeIconRect.left(), closeIconRect.top() + 1, - closeIconRect.right() - 1, closeIconRect.bottom()), - QLine(closeIconRect.right() - 1, closeIconRect.top(), - closeIconRect.left(), closeIconRect.bottom() - 1), - QLine(closeIconRect.right(), closeIconRect.top() + 1, - closeIconRect.left() + 1, closeIconRect.bottom()) }; - painter->drawLines(lines, 4); - const QPoint points[4] = { - closeIconRect.topLeft(), closeIconRect.topRight(), - closeIconRect.bottomLeft(), closeIconRect.bottomRight() }; - painter->drawPoints(points, 4); - } - painter->setPen(textColor); - { - const QLine lines[2] = { - QLine(closeIconRect.left() + 1, closeIconRect.top() + 1, - closeIconRect.right() - 1, closeIconRect.bottom() - 1), - QLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, - closeIconRect.right() - 1, closeIconRect.top() + 1) }; - painter->drawLines(lines, 2); - } - } - - // normalize button - if ((titleBar->subControls & SC_TitleBarNormalButton) && - (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && - (titleBar->titleBarState & Qt::WindowMinimized)) || - ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && - (titleBar->titleBarState & Qt::WindowMaximized)))) { - bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); - - QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); - int xoffset = int(normalButtonRect.width() / 3.5); - int yoffset = int(normalButtonRect.height() / 3.5); - - QRect normalButtonIconRect(normalButtonRect.left() + xoffset, normalButtonRect.top() + yoffset, - normalButtonRect.width() - xoffset * 2, normalButtonRect.height() - yoffset * 2); - - QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0); - painter->setPen(textColor); - painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1)); - painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1, - frontWindowRect.right() - 1, frontWindowRect.top() + 1); - painter->setPen(textAlphaColor); - { - const QPoint points[4] = { - frontWindowRect.topLeft(), frontWindowRect.topRight(), - frontWindowRect.bottomLeft(), frontWindowRect.bottomRight() }; - painter->drawPoints(points, 4); - } - - QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); - QRegion clipRegion = backWindowRect; - clipRegion -= frontWindowRect; - painter->save(); - painter->setClipRegion(clipRegion); - painter->setPen(textColor); - painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1)); - painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1, - backWindowRect.right() - 1, backWindowRect.top() + 1); - painter->setPen(textAlphaColor); - { - const QPoint points[4] = { - backWindowRect.topLeft(), backWindowRect.topRight(), - backWindowRect.bottomLeft(), backWindowRect.bottomRight() }; - painter->drawPoints(points, 4); - } - painter->restore(); - } - - // context help button - if (titleBar->subControls & SC_TitleBarContextHelpButton - && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { - bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); - - QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); - - qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); - - QColor blend; - // ### Use palette colors - if (active) { - blend = mergedColors(QColor(hover ? 0x7d8bb1 : 0x55689a), - QColor(hover ? 0x939ebe : 0x7381ab)); - } else { - blend = mergedColors(QColor(hover ? 0x9e9e9e : 0x818181), - QColor(hover ? 0xababab : 0x929292)); - } - QImage image(qt_plastique_titlebar_context_help); - QMap imagecolors; - imagecolors.insert(4282139485, textColor.rgba()); - imagecolors.insert(4280889668, mergedColors(blend, textColor, 30).rgba()); - imagecolors.insert(4279967789, mergedColors(blend, textColor, 70).rgba()); - imagecolors.insert(4278848530, mergedColors(blend, textColor, 90).rgba()); - image = replaceColors(image, imagecolors); - - painter->drawImage(contextHelpButtonRect, image); - } - - // shade button - if (titleBar->subControls & SC_TitleBarShadeButton) { - bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); - - QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); - - int xoffset = shadeButtonRect.width() / 3; - int yoffset = shadeButtonRect.height() / 3; - - QRect shadeButtonIconRect(shadeButtonRect.left() + xoffset, shadeButtonRect.top() + yoffset, - shadeButtonRect.width() - xoffset * 2, shadeButtonRect.height() - yoffset * 2); - - QPainterPath path(shadeButtonIconRect.bottomLeft()); - path.lineTo(shadeButtonIconRect.center().x(), shadeButtonIconRect.bottom() - shadeButtonIconRect.height() / 2); - path.lineTo(shadeButtonIconRect.bottomRight()); - path.lineTo(shadeButtonIconRect.bottomLeft()); - - painter->setPen(textAlphaColor); - painter->setBrush(textColor); - painter->drawPath(path); - } - - // unshade button - if (titleBar->subControls & SC_TitleBarUnshadeButton) { - bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); - - QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); - qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); - - int xoffset = unshadeButtonRect.width() / 3; - int yoffset = unshadeButtonRect.height() / 3; - - QRect unshadeButtonIconRect(unshadeButtonRect.left() + xoffset, unshadeButtonRect.top() + yoffset, - unshadeButtonRect.width() - xoffset * 2, unshadeButtonRect.height() - yoffset * 2); - - int midY = unshadeButtonIconRect.bottom() - unshadeButtonIconRect.height() / 2; - QPainterPath path(QPoint(unshadeButtonIconRect.left(), midY)); - path.lineTo(unshadeButtonIconRect.right(), midY); - path.lineTo(unshadeButtonIconRect.center().x(), unshadeButtonIconRect.bottom()); - path.lineTo(unshadeButtonIconRect.left(), midY); - - painter->setPen(textAlphaColor); - painter->setBrush(textColor); - painter->drawPath(path); - } - - // from qwindowsstyle.cpp - if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { - bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver); - bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); - - QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); - if (hover) - qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); - - if (!titleBar->icon.isNull()) { - titleBar->icon.paint(painter, iconRect); - } else { - QStyleOption tool(0); - tool.palette = titleBar->palette; - QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget); - tool.rect = iconRect; - painter->save(); - proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); - painter->restore(); - } - } - painter->restore(); - } - break; -#ifndef QT_NO_DIAL - case CC_Dial: - if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) - QStyleHelper::drawDial(dial, painter); - break; -#endif // QT_NO_DIAL - default: - QWindowsStyle::drawComplexControl(control, option, painter, widget); - break; - } -} - -/*! - \reimp -*/ -QSize QPlastiqueStyle::sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const -{ - QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); - - switch (type) { - case CT_RadioButton: - ++newSize.rheight(); - ++newSize.rwidth(); - break; -#ifndef QT_NO_SLIDER - case CT_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); - if (slider->tickPosition & QSlider::TicksBelow) { - if (slider->orientation == Qt::Horizontal) - newSize.rheight() += tickSize; - else - newSize.rwidth() += tickSize; - } - if (slider->tickPosition & QSlider::TicksAbove) { - if (slider->orientation == Qt::Horizontal) - newSize.rheight() += tickSize; - else - newSize.rwidth() += tickSize; - } - } - break; -#endif // QT_NO_SLIDER -#ifndef QT_NO_SCROLLBAR - case CT_ScrollBar: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); - int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget); - if (scrollBar->orientation == Qt::Horizontal) { - newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent); - } else { - newSize = QSize(scrollBarExtent, scrollBarExtent * 3 + scrollBarSliderMinimum); - } - } - break; -#endif // QT_NO_SCROLLBAR -#ifndef QT_NO_SPINBOX - case CT_SpinBox: - // Make sure the size is odd - newSize.setHeight(sizeFromContents(CT_LineEdit, option, size, widget).height()); - newSize.rheight() -= ((1 - newSize.rheight()) & 1); - break; -#endif -#ifndef QT_NO_TOOLBUTTON - case CT_ToolButton: - newSize.rheight() += 3; - newSize.rwidth() += 3; - break; -#endif -#ifndef QT_NO_COMBOBOX - case CT_ComboBox: - newSize = sizeFromContents(CT_PushButton, option, size, widget); - newSize.rwidth() += 30; // Make room for drop-down indicator - newSize.rheight() += 4; - break; -#endif - case CT_MenuItem: - if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) - newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height()); - } - break; - case CT_MenuBarItem: - newSize.setHeight(newSize.height()); - break; - default: - break; - } - - return newSize; -} - -/*! - \reimp -*/ -QRect QPlastiqueStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const -{ - QRect rect; - switch (element) { - case SE_RadioButtonIndicator: - rect = visualRect(option->direction, option->rect, - QWindowsStyle::subElementRect(element, option, widget)).adjusted(0, 0, 1, 1); - break; -#ifndef QT_NO_PROGRESSBAR - case SE_ProgressBarLabel: - case SE_ProgressBarContents: - case SE_ProgressBarGroove: - return option->rect; -#endif // QT_NO_PROGRESSBAR - default: - return QWindowsStyle::subElementRect(element, option, widget); - } - - return visualRect(option->direction, option->rect, rect); -} - -/*! - \reimp -*/ -QRect QPlastiqueStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, - SubControl subControl, const QWidget *widget) const -{ - QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget); - - switch (control) { -#ifndef QT_NO_SLIDER - case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); - - switch (subControl) { - case SC_SliderHandle: - if (slider->orientation == Qt::Horizontal) { - rect.setWidth(11); - rect.setHeight(15); - int centerY = slider->rect.center().y() - rect.height() / 2; - if (slider->tickPosition & QSlider::TicksAbove) - centerY += tickSize; - if (slider->tickPosition & QSlider::TicksBelow) - centerY -= tickSize; - rect.moveTop(centerY); - } else { - rect.setWidth(15); - rect.setHeight(11); - int centerX = slider->rect.center().x() - rect.width() / 2; - if (slider->tickPosition & QSlider::TicksAbove) - centerX += tickSize; - if (slider->tickPosition & QSlider::TicksBelow) - centerX -= tickSize; - rect.moveLeft(centerX); - } - break; - case SC_SliderGroove: { - QPoint grooveCenter = slider->rect.center(); - if (slider->orientation == Qt::Horizontal) { - rect.setHeight(14); - --grooveCenter.ry(); - if (slider->tickPosition & QSlider::TicksAbove) - grooveCenter.ry() += tickSize; - if (slider->tickPosition & QSlider::TicksBelow) - grooveCenter.ry() -= tickSize; - } else { - rect.setWidth(14); - --grooveCenter.rx(); - if (slider->tickPosition & QSlider::TicksAbove) - grooveCenter.rx() += tickSize; - if (slider->tickPosition & QSlider::TicksBelow) - grooveCenter.rx() -= tickSize; - } - rect.moveCenter(grooveCenter); - break; - } - default: - break; - } - } - break; -#endif // QT_NO_SLIDER -#ifndef QT_NO_SCROLLBAR - case CC_ScrollBar: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget); - int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ? - scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3); - int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); - int sliderLength; - - // calculate slider length - if (scrollBar->maximum != scrollBar->minimum) { - uint valueRange = scrollBar->maximum - scrollBar->minimum; - sliderLength = (scrollBar->pageStep * sliderMaxLength) / (valueRange + scrollBar->pageStep); - - if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2) - sliderLength = sliderMinLength; - if (sliderLength > sliderMaxLength) - sliderLength = sliderMaxLength; - } else { - sliderLength = sliderMaxLength; - } - - int sliderStart = scrollBarExtent + sliderPositionFromValue(scrollBar->minimum, - scrollBar->maximum, - scrollBar->sliderPosition, - sliderMaxLength - sliderLength, - scrollBar->upsideDown); - - QRect scrollBarRect = scrollBar->rect; - - switch (subControl) { - case SC_ScrollBarSubLine: // top/left button - if (scrollBar->orientation == Qt::Horizontal) { - rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width() - scrollBarExtent, scrollBarRect.height()); - } else { - rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width(), scrollBarRect.height() - scrollBarExtent); - } - break; - case SC_ScrollBarAddLine: // bottom/right button - if (scrollBar->orientation == Qt::Horizontal) { - rect.setRect(scrollBarRect.right() - (scrollBarExtent - 1), scrollBarRect.top(), scrollBarExtent, scrollBarRect.height()); - } else { - rect.setRect(scrollBarRect.left(), scrollBarRect.bottom() - (scrollBarExtent - 1), scrollBarRect.width(), scrollBarExtent); - } - break; - case SC_ScrollBarSubPage: - if (scrollBar->orientation == Qt::Horizontal) { - rect.setRect(scrollBarRect.left() + scrollBarExtent, scrollBarRect.top(), - sliderStart - (scrollBarRect.left() + scrollBarExtent), scrollBarRect.height()); - } else { - rect.setRect(scrollBarRect.left(), scrollBarRect.top() + scrollBarExtent, - scrollBarRect.width(), sliderStart - (scrollBarRect.left() + scrollBarExtent)); - } - break; - case SC_ScrollBarAddPage: - if (scrollBar->orientation == Qt::Horizontal) - rect.setRect(sliderStart + sliderLength, 0, - sliderMaxLength - sliderStart - sliderLength + scrollBarExtent, scrollBarRect.height()); - else - rect.setRect(0, sliderStart + sliderLength, - scrollBarRect.width(), sliderMaxLength - sliderStart - sliderLength + scrollBarExtent); - break; - case SC_ScrollBarGroove: - if (scrollBar->orientation == Qt::Horizontal) { - rect = scrollBarRect.adjusted(scrollBarExtent, 0, -2 * scrollBarExtent, 0); - } else { - rect = scrollBarRect.adjusted(0, scrollBarExtent, 0, -2 * scrollBarExtent); - } - break; - case SC_ScrollBarSlider: - if (scrollBar->orientation == Qt::Horizontal) { - rect.setRect(sliderStart, 0, sliderLength, scrollBarRect.height()); - } else { - rect.setRect(0, sliderStart, scrollBarRect.width(), sliderLength); - } - break; - default: - break; - } - rect = visualRect(scrollBar->direction, scrollBarRect, rect); - } - break; -#endif // QT_NO_SCROLLBAR -#ifndef QT_NO_SPINBOX - case CC_SpinBox: - if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - int center = spinBox->rect.height() / 2; - switch (subControl) { - case SC_SpinBoxUp: - if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - rect = visualRect(spinBox->direction, spinBox->rect, rect); - rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top(), 17, center + 1); - rect = visualRect(spinBox->direction, spinBox->rect, rect); - break; - case SC_SpinBoxDown: - if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - rect = visualRect(spinBox->direction, spinBox->rect, rect); - rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top() + center, 17, spinBox->rect.height() - center); - rect = visualRect(spinBox->direction, spinBox->rect, rect); - break; - case SC_SpinBoxEditField: - if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) { - rect = spinBox->rect.adjusted(0, 0, -16, 0); - } else { - rect = spinBox->rect; - } - rect.adjust(blueFrameWidth, blueFrameWidth, -blueFrameWidth, -blueFrameWidth); - rect = visualRect(spinBox->direction, spinBox->rect, rect); - break; - default: - break; - } - } - break; -#endif // QT_NO_SPINBOX -#ifndef QT_NO_COMBOBOX - case CC_ComboBox: - switch (subControl) { - case SC_ComboBoxArrow: - rect = visualRect(option->direction, option->rect, rect); - rect.setRect(rect.right() - 17, rect.top() - 2, - 19, rect.height() + 4); - rect = visualRect(option->direction, option->rect, rect); - break; - case SC_ComboBoxEditField: { - if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { - int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); - rect = visualRect(option->direction, option->rect, rect); - - if (box->editable) { - rect = box->rect.adjusted(blueFrameWidth, blueFrameWidth, -blueFrameWidth, -blueFrameWidth); - rect.setRight(rect.right() - 16); // Overlaps the combobox button by 2 pixels - } else { - rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, - option->rect.width() - 16 - 2 * frameWidth, - option->rect.height() - 2 * frameWidth); - rect.setLeft(rect.left() + 2); - rect.setRight(rect.right() - 2); - if (box->state & (State_Sunken | State_On)) - rect.translate(1, 1); - } - rect = visualRect(option->direction, option->rect, rect); - } - break; - } - default: - break; - } - break; -#endif // QT_NO_COMBOBOX - case CC_TitleBar: - if (const QStyleOptionTitleBar *tb = qstyleoption_cast(option)) { - SubControl sc = subControl; - QRect &ret = rect; - const int indent = 3; - const int controlTopMargin = 4; - const int controlBottomMargin = 3; - const int controlWidthMargin = 1; - const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin; - const int delta = controlHeight + controlWidthMargin; - int offset = 0; - - bool isMinimized = tb->titleBarState & Qt::WindowMinimized; - bool isMaximized = tb->titleBarState & Qt::WindowMaximized; - - switch (sc) { - case SC_TitleBarLabel: - if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) { - ret = tb->rect; - if (tb->titleBarFlags & Qt::WindowSystemMenuHint) - ret.adjust(delta, 0, -delta, 0); - if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) - ret.adjust(0, 0, -delta, 0); - if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) - ret.adjust(0, 0, -delta, 0); - if (tb->titleBarFlags & Qt::WindowShadeButtonHint) - ret.adjust(0, 0, -delta, 0); - if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) - ret.adjust(0, 0, -delta, 0); - ret.adjusted(indent, 0, -indent, 0); - } - break; - case SC_TitleBarContextHelpButton: - if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) - offset += delta; - case SC_TitleBarMinButton: - if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) - offset += delta; - else if (sc == SC_TitleBarMinButton) - break; - case SC_TitleBarNormalButton: - if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) - offset += delta; - else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) - offset += delta; - else if (sc == SC_TitleBarNormalButton) - break; - case SC_TitleBarMaxButton: - if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) - offset += delta; - else if (sc == SC_TitleBarMaxButton) - break; - case SC_TitleBarShadeButton: - if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) - offset += delta; - else if (sc == SC_TitleBarShadeButton) - break; - case SC_TitleBarUnshadeButton: - if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) - offset += delta; - else if (sc == SC_TitleBarUnshadeButton) - break; - case SC_TitleBarCloseButton: - if (tb->titleBarFlags & Qt::WindowSystemMenuHint) - offset += delta; - else if (sc == SC_TitleBarCloseButton) - break; - ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin, - controlHeight, controlHeight); - break; - case SC_TitleBarSysMenu: - if (tb->titleBarFlags & Qt::WindowSystemMenuHint) { - ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin, - controlHeight, controlHeight); - } - break; - default: - break; - } - ret = visualRect(tb->direction, tb->rect, ret); - } - break; - default: - break; - } - - return rect; -} - -/*! - \reimp -*/ -int QPlastiqueStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, - QStyleHintReturn *returnData) const -{ - int ret = 0; - switch (hint) { - case SH_WindowFrame_Mask: - ret = 1; - if (QStyleHintReturnMask *mask = qstyleoption_cast(returnData)) { - mask->region = option->rect; - mask->region -= QRect(option->rect.left(), option->rect.top(), 2, 1); - mask->region -= QRect(option->rect.right() - 1, option->rect.top(), 2, 1); - mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 1, 1); - mask->region -= QRect(option->rect.right(), option->rect.top() + 1, 1, 1); - - const QStyleOptionTitleBar *titleBar = qstyleoption_cast(option); - if (titleBar && (titleBar->titleBarState & Qt::WindowMinimized)) { - mask->region -= QRect(option->rect.left(), option->rect.bottom(), 2, 1); - mask->region -= QRect(option->rect.right() - 1, option->rect.bottom(), 2, 1); - mask->region -= QRect(option->rect.left(), option->rect.bottom() - 1, 1, 1); - mask->region -= QRect(option->rect.right(), option->rect.bottom() - 1, 1, 1); - } else { - mask->region -= QRect(option->rect.bottomLeft(), QSize(1, 1)); - mask->region -= QRect(option->rect.bottomRight(), QSize(1, 1)); - } - } - break; - case SH_TitleBar_NoBorder: - ret = 1; - break; - case SH_TitleBar_AutoRaise: - ret = 1; - break; - case SH_ItemView_ShowDecorationSelected: - ret = true; - break; - case SH_ToolBox_SelectedPageTitleBold: - case SH_ScrollBar_MiddleClickAbsolutePosition: - ret = true; - break; - case SH_MainWindow_SpaceBelowMenuBar: - ret = 0; - break; - case SH_FormLayoutWrapPolicy: - ret = QFormLayout::DontWrapRows; - break; - case SH_FormLayoutFieldGrowthPolicy: - ret = QFormLayout::ExpandingFieldsGrow; - break; - case SH_FormLayoutFormAlignment: - ret = Qt::AlignLeft | Qt::AlignTop; - break; - case SH_FormLayoutLabelAlignment: - ret = Qt::AlignRight; - break; - case SH_MessageBox_TextInteractionFlags: - ret = Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; - break; - case SH_LineEdit_PasswordCharacter: - ret = QCommonStyle::styleHint(hint, option, widget, returnData); - break; - case SH_ItemView_ArrowKeysNavigateIntoChildren: - ret = true; - break; - case SH_Menu_SubMenuPopupDelay: - ret = 96; // from Plastik - break; -#ifdef Q_WS_X11 - case SH_DialogButtonBox_ButtonsHaveIcons: - ret = true; - break; -#endif - case SH_Menu_AllowActiveAndDisabled: - ret = false; - break; - default: - ret = QWindowsStyle::styleHint(hint, option, widget, returnData); - break; - } - return ret; -} - -/*! - \reimp -*/ -QStyle::SubControl QPlastiqueStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, - const QPoint &pos, const QWidget *widget) const -{ - SubControl ret = SC_None; - switch (control) { -#ifndef QT_NO_SCROLLBAR - case CC_ScrollBar: - if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); - if (slider.contains(pos)) { - ret = SC_ScrollBarSlider; - break; - } - - QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); - if (scrollBarAddLine.contains(pos)) { - ret = SC_ScrollBarAddLine; - break; - } - - QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget); - if (scrollBarSubPage.contains(pos)) { - ret = SC_ScrollBarSubPage; - break; - } - - QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget); - if (scrollBarAddPage.contains(pos)) { - ret = SC_ScrollBarAddPage; - break; - } - - QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); - if (scrollBarSubLine.contains(pos)) { - ret = SC_ScrollBarSubLine; - break; - } - } - break; -#endif // QT_NO_SCROLLBAR - default: - break; - } - - return ret != SC_None ? ret : QWindowsStyle::hitTestComplexControl(control, option, pos, widget); -} - -/*! - \reimp -*/ -int QPlastiqueStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const -{ - int ret = -1; - switch (metric) { - case PM_MenuVMargin: - case PM_MenuHMargin: - ret = 0; - break; - case PM_ButtonShiftHorizontal: - case PM_ButtonShiftVertical: - ret = 1; - break; - case PM_ButtonDefaultIndicator: - ret = 0; - break; -#ifndef QT_NO_SLIDER - case PM_SliderThickness: - ret = 15; - break; - case PM_SliderLength: - case PM_SliderControlThickness: - ret = 11; - break; - case PM_SliderTickmarkOffset: - ret = 5; - break; - case PM_SliderSpaceAvailable: - if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - int size = 15; - if (slider->tickPosition & QSlider::TicksBelow) - ++size; - if (slider->tickPosition & QSlider::TicksAbove) - ++size; - ret = size; - break; - } -#endif // QT_NO_SLIDER - case PM_ScrollBarExtent: - ret = 16; - break; - case PM_ScrollBarSliderMin: - ret = 26; - break; - case PM_ProgressBarChunkWidth: - ret = 1; - break; - case PM_MenuBarItemSpacing: - ret = 3; - break; - case PM_MenuBarVMargin: - ret = 2; - break; - case PM_MenuBarHMargin: - ret = 0; - break; - case PM_MenuBarPanelWidth: - ret = 1; - break; - case PM_ToolBarHandleExtent: - ret = 9; - break; - case PM_ToolBarSeparatorExtent: - ret = 2; - break; - case PM_ToolBarItemSpacing: - ret = 1; - break; - case PM_ToolBarItemMargin: - ret = 1; - break; - case PM_ToolBarFrameWidth: - ret = 2; - break; - case PM_SplitterWidth: - ret = 6; - break; - case PM_DockWidgetSeparatorExtent: - ret = 6; - break; - case PM_DockWidgetHandleExtent: - ret = 20; - break; - case PM_DefaultFrameWidth: -#ifndef QT_NO_MENU - if (qobject_cast(widget)) { - ret = 1; - break; - } -#endif - ret = 2; - break; - case PM_MdiSubWindowFrameWidth: - ret = 4; - break; - case PM_TitleBarHeight: - ret = qMax(widget ? widget->fontMetrics().height() : - (option ? option->fontMetrics.height() : 0), 30); - break; - case PM_MaximumDragDistance: - return -1; - case PM_DockWidgetTitleMargin: - return 2; - case PM_LayoutHorizontalSpacing: - case PM_LayoutVerticalSpacing: - return -1; // rely on layoutHorizontalSpacing() - case PM_LayoutLeftMargin: - case PM_LayoutTopMargin: - case PM_LayoutRightMargin: - case PM_LayoutBottomMargin: - { - bool isWindow = false; - if (option) { - isWindow = (option->state & State_Window); - } else if (widget) { - isWindow = widget->isWindow(); - } - - if (isWindow) { - ret = 11; - } else { - ret = 9; - } - } - default: - break; - } - - return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget); -} - -/*! - \reimp -*/ -QPalette QPlastiqueStyle::standardPalette() const -{ - QPalette palette; - - palette.setBrush(QPalette::Disabled, QPalette::WindowText, QColor(QRgb(0xff808080))); - palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(QRgb(0xffdddfe4))); - palette.setBrush(QPalette::Disabled, QPalette::Light, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Disabled, QPalette::Midlight, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Disabled, QPalette::Dark, QColor(QRgb(0xff555555))); - palette.setBrush(QPalette::Disabled, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); - palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(QRgb(0xffc7c7c7))); - palette.setBrush(QPalette::Disabled, QPalette::BrightText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Disabled, QPalette::ButtonText, QColor(QRgb(0xff808080))); - palette.setBrush(QPalette::Disabled, QPalette::Base, QColor(QRgb(0xffefefef))); - palette.setBrush(QPalette::Disabled, QPalette::AlternateBase, palette.color(QPalette::Disabled, QPalette::Base).darker(110)); - palette.setBrush(QPalette::Disabled, QPalette::Window, QColor(QRgb(0xffefefef))); - palette.setBrush(QPalette::Disabled, QPalette::Shadow, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(QRgb(0xff567594))); - palette.setBrush(QPalette::Disabled, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Disabled, QPalette::Link, QColor(QRgb(0xff0000ee))); - palette.setBrush(QPalette::Disabled, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); - palette.setBrush(QPalette::Active, QPalette::WindowText, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Active, QPalette::Button, QColor(QRgb(0xffdddfe4))); - palette.setBrush(QPalette::Active, QPalette::Light, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Active, QPalette::Dark, QColor(QRgb(0xff555555))); - palette.setBrush(QPalette::Active, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); - palette.setBrush(QPalette::Active, QPalette::Text, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Active, QPalette::BrightText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Active, QPalette::ButtonText, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Active, QPalette::Base, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Active, QPalette::AlternateBase, palette.color(QPalette::Active, QPalette::Base).darker(110)); - palette.setBrush(QPalette::Active, QPalette::Window, QColor(QRgb(0xffefefef))); - palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(QRgb(0xff678db2))); - palette.setBrush(QPalette::Active, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Active, QPalette::Link, QColor(QRgb(0xff0000ee))); - palette.setBrush(QPalette::Active, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); - palette.setBrush(QPalette::Inactive, QPalette::WindowText, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(QRgb(0xffdddfe4))); - palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Inactive, QPalette::Dark, QColor(QRgb(0xff555555))); - palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(QRgb(0xffc7c7c7))); - palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Inactive, QPalette::BrightText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Inactive, QPalette::ButtonText, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Inactive, QPalette::Base, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Inactive, QPalette::AlternateBase, palette.color(QPalette::Inactive, QPalette::Base).darker(110)); - palette.setBrush(QPalette::Inactive, QPalette::Window, QColor(QRgb(0xffefefef))); - palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(QRgb(0xff000000))); - palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(QRgb(0xff678db2))); - palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, QColor(QRgb(0xffffffff))); - palette.setBrush(QPalette::Inactive, QPalette::Link, QColor(QRgb(0xff0000ee))); - palette.setBrush(QPalette::Inactive, QPalette::LinkVisited, QColor(QRgb(0xff52188b))); - return palette; -} - -/*! - \reimp -*/ -void QPlastiqueStyle::polish(QWidget *widget) -{ - if (qobject_cast(widget) -#ifndef QT_NO_COMBOBOX - || qobject_cast(widget) -#endif -#ifndef QT_NO_SPINBOX - || qobject_cast(widget) -#endif - || qobject_cast(widget) -#ifndef QT_NO_GROUPBOX - || qobject_cast(widget) -#endif - || qobject_cast(widget) -#ifndef QT_NO_SPLITTER - || qobject_cast(widget) -#endif -#ifndef QT_NO_TABBAR - || qobject_cast(widget) -#endif - ) { - widget->setAttribute(Qt::WA_Hover); - } - - if (widget->inherits("QWorkspaceTitleBar")) { - widget->setAttribute(Qt::WA_Hover); - } - - if (false // to simplify the #ifdefs -#ifndef QT_NO_MENUBAR - || qobject_cast(widget) -#endif -#ifndef QT_NO_TOOLBAR - || qobject_cast(widget) - || (widget && qobject_cast(widget->parent())) -#endif - ) { - widget->setBackgroundRole(QPalette::Window); - } - -#ifndef QT_NO_PROGRESSBAR - if (AnimateBusyProgressBar && qobject_cast(widget)) - widget->installEventFilter(this); -#endif - -#if defined QPlastique_MaskButtons - if (qobject_cast(widget) || qobject_cast(widget)) - widget->installEventFilter(this); -#endif -} - -/*! - \reimp -*/ -void QPlastiqueStyle::unpolish(QWidget *widget) -{ - if (qobject_cast(widget) -#ifndef QT_NO_COMBOBOX - || qobject_cast(widget) -#endif -#ifndef QT_NO_SPINBOX - || qobject_cast(widget) -#endif - || qobject_cast(widget) -#ifndef QT_NO_GROUPBOX - || qobject_cast(widget) -#endif -#ifndef QT_NO_SPLITTER - || qobject_cast(widget) -#endif -#ifndef QT_NO_TABBAR - || qobject_cast(widget) -#endif - || qobject_cast(widget)) { - widget->setAttribute(Qt::WA_Hover, false); - } - - if (widget->inherits("QWorkspaceTitleBar")) { - widget->setAttribute(Qt::WA_Hover, false); - } - - if (false // to simplify the #ifdefs -#ifndef QT_NO_MENUBAR - || qobject_cast(widget) -#endif -#ifndef QT_NO_TOOLBOX - || qobject_cast(widget) -#endif -#ifndef QT_NO_TOOLBAR - || qobject_cast(widget) - || (widget && qobject_cast(widget->parent())) -#endif - ) { - widget->setBackgroundRole(QPalette::Button); - } - -#ifndef QT_NO_PROGRESSBAR - if (AnimateBusyProgressBar && qobject_cast(widget)) { - Q_D(QPlastiqueStyle); - widget->removeEventFilter(this); - d->bars.removeAll(static_cast(widget)); - } -#endif - -#if defined QPlastique_MaskButtons - if (qobject_cast(widget) || qobject_cast(widget)) - widget->removeEventFilter(this); -#endif -} - -// this works as long as we have at most 16 different control types -#define CT1(c) CT2(c, c) -#define CT2(c1, c2) (((uint)c1 << 16) | (uint)c2) - -/*! - \internal -*/ -int QPlastiqueStyle::layoutSpacing(QSizePolicy::ControlType control1, - QSizePolicy::ControlType control2, - Qt::Orientation orientation, - const QStyleOption * /* option */, - const QWidget * /* widget */) const -{ - const int ButtonMask = QSizePolicy::ButtonBox | QSizePolicy::PushButton; - - if (control2 == QSizePolicy::ButtonBox) - return 11; - - if ((control1 | control2) & ButtonMask) - return (orientation == Qt::Horizontal) ? 10 : 9; - - switch (CT2(control1, control2)) { - case CT1(QSizePolicy::Label): - case CT2(QSizePolicy::Label, QSizePolicy::DefaultType): - case CT2(QSizePolicy::Label, QSizePolicy::CheckBox): - case CT2(QSizePolicy::Label, QSizePolicy::ComboBox): - case CT2(QSizePolicy::Label, QSizePolicy::LineEdit): - case CT2(QSizePolicy::Label, QSizePolicy::RadioButton): - case CT2(QSizePolicy::Label, QSizePolicy::Slider): - case CT2(QSizePolicy::Label, QSizePolicy::SpinBox): - case CT2(QSizePolicy::Label, QSizePolicy::ToolButton): - return 5; - case CT2(QSizePolicy::CheckBox, QSizePolicy::RadioButton): - case CT2(QSizePolicy::RadioButton, QSizePolicy::CheckBox): - case CT1(QSizePolicy::CheckBox): - if (orientation == Qt::Vertical) - return 2; - case CT1(QSizePolicy::RadioButton): - if (orientation == Qt::Vertical) - return 1; - } - - if (orientation == Qt::Horizontal - && (control2 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton))) - return 8; - - if ((control1 | control2) & (QSizePolicy::Frame - | QSizePolicy::GroupBox - | QSizePolicy::TabWidget)) { - return 11; - } - - if ((control1 | control2) & (QSizePolicy::Line | QSizePolicy::Slider - | QSizePolicy::LineEdit | QSizePolicy::ComboBox - | QSizePolicy::SpinBox)) - return 7; - - return 6; -} - -/*! - \reimp -*/ -bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QPlastiqueStyle); - - switch (event->type()) { - case QEvent::Show: - if (QProgressBar *bar = qobject_cast(watched)) { - d->bars.append(bar); - if (d->bars.size() == 1) { - Q_ASSERT(ProgressBarFps > 0); - d->timer.start(); - d->progressBarAnimateTimer = startTimer(1000 / ProgressBarFps); - } - } - break; - case QEvent::Destroy: - case QEvent::Hide: - if(!d->bars.isEmpty()) { - d->bars.removeAll(reinterpret_cast(watched)); - if (d->bars.isEmpty()) { - killTimer(d->progressBarAnimateTimer); - d->progressBarAnimateTimer = 0; - } - } - break; -#if defined QPlastique_MaskButtons - case QEvent::Resize: - if (qobject_cast(watched) || qobject_cast(watched)) { - QWidget *widget = qobject_cast(watched); - QRect rect = widget->rect(); - QRegion region(rect); - region -= QRect(rect.left(), rect.top(), 2, 1); - region -= QRect(rect.left(), rect.top() + 1, 1, 1); - region -= QRect(rect.left(), rect.bottom(), 2, 1); - region -= QRect(rect.left(), rect.bottom() - 1, 1, 1); - region -= QRect(rect.right() - 1, rect.top(), 2, 1); - region -= QRect(rect.right(), rect.top() + 1, 1, 1); - region -= QRect(rect.right() - 1, rect.bottom(), 2, 1); - region -= QRect(rect.right(), rect.bottom() - 1, 1, 1); - widget->setMask(region); - } - break; -#endif - default: - break; - } -#endif // QT_NO_PROGRESSBAR - - return QWindowsStyle::eventFilter(watched, event); -} - -/*! - \reimp -*/ -void QPlastiqueStyle::timerEvent(QTimerEvent *event) -{ -#ifndef QT_NO_PROGRESSBAR - Q_D(QPlastiqueStyle); - - if (event->timerId() == d->progressBarAnimateTimer) { - Q_ASSERT(ProgressBarFps > 0); - d->animateStep = d->timer.elapsed() / (1000 / ProgressBarFps); - foreach (QProgressBar *bar, d->bars) { - if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0)) - bar->update(); - } - } -#endif // QT_NO_PROGRESSBAR - event->ignore(); -} - -QT_END_NAMESPACE - - -#include "moc_qplastiquestyle.h" - -#endif // !defined(QT_NO_STYLE_PLASTIQUE) diff --git a/src/gui/styles/qplastiquestyle.h b/src/gui/styles/qplastiquestyle.h deleted file mode 100644 index 3e10f0350..000000000 --- a/src/gui/styles/qplastiquestyle.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLASTIQUESTYLE_H -#define QPLASTIQUESTYLE_H - -#include - - -QT_BEGIN_NAMESPACE - - -#if !defined(QT_NO_STYLE_PLASTIQUE) - -class QPlastiqueStylePrivate; -class Q_GUI_EXPORT QPlastiqueStyle : public QWindowsStyle -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QPlastiqueStyle) -public: - QPlastiqueStyle(); - - void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget = nullptr) const; - void drawControl(ControlElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const; - void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const; - QSize sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const; - - QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; - QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, - SubControl sc, const QWidget *widget) const; - - int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, - QStyleHintReturn *returnData = nullptr) const; - SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, - const QPoint &pos, const QWidget *widget = nullptr) const; - - int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const; - - void polish(QWidget *widget); - void unpolish(QWidget *widget); - - QPalette standardPalette() const; - - int layoutSpacing(QSizePolicy::ControlType control1, - QSizePolicy::ControlType control2, - Qt::Orientation orientation, - const QStyleOption *option = nullptr, - const QWidget *widget = nullptr) const; - -protected: - bool eventFilter(QObject *watched, QEvent *event); - void timerEvent(QTimerEvent *event); - -private: - Q_DISABLE_COPY(QPlastiqueStyle) -}; - -#endif // QT_NO_STYLE_PLASTIQUE - -QT_END_NAMESPACE - - -#endif // QPLASTIQUESTYLE_H diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 62dcc38d7..d91ceedfe 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -65,12 +65,11 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C \ingroup appearance - Qt contains a set of QStyle subclasses that emulate the styles of - the different platforms supported by Qt (QWindowsStyle, - QMotifStyle, etc.). By default, these styles are built into the - QtGui library. Styles can also be made available as plugins. + Katie contains a set of QStyle subclasses that emulate the styles of + the different platforms supported by Katie (QWindowsStyle, etc.). + By default, these styles are built into the QtGui library. - Qt's built-in widgets use QStyle to perform nearly all of their + Katie's built-in widgets use QStyle to perform nearly all of their drawing, ensuring that they look exactly like the equivalent native widgets. The diagram below shows a QComboBox in eight different styles. diff --git a/src/gui/styles/qstylefactory.cpp b/src/gui/styles/qstylefactory.cpp index 04f07ac6e..dc3ad1df6 100644 --- a/src/gui/styles/qstylefactory.cpp +++ b/src/gui/styles/qstylefactory.cpp @@ -25,10 +25,6 @@ #include "qapplication.h" #include "qwindowsstyle.h" -#include "qmotifstyle.h" -#ifndef QT_NO_STYLE_PLASTIQUE -#include "qplastiquestyle.h" -#endif #ifndef QT_NO_STYLE_CLEANLOOKS #include "qcleanlooksstyle.h" #endif @@ -74,20 +70,14 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, stylesloader, QStyle *QStyleFactory::create(const QString& key) { #ifndef QT_NO_STYLE_WINDOWS - if (key.compare(QLatin1String("Windows"), Qt::CaseInsensitive) == 0) + if (key.compare(QLatin1String("Windows"), Qt::CaseInsensitive) == 0) { return new QWindowsStyle(); -#endif -#ifndef QT_NO_STYLE_MOTIF - if (key.compare(QLatin1String("Motif"), Qt::CaseInsensitive) == 0) - return new QMotifStyle(); -#endif -#ifndef QT_NO_STYLE_PLASTIQUE - if (key.compare(QLatin1String("Plastique"), Qt::CaseInsensitive) == 0) - return new QPlastiqueStyle(); + } #endif #ifndef QT_NO_STYLE_CLEANLOOKS - if (key.compare(QLatin1String("Cleanlooks"), Qt::CaseInsensitive) == 0) + if (key.compare(QLatin1String("Cleanlooks"), Qt::CaseInsensitive) == 0) { return new QCleanlooksStyle(); + } #endif #if !defined(QT_NO_LIBRARY) if (QStyleFactoryInterface *factory = qobject_cast(stylesloader()->instance(key))) { @@ -120,12 +110,6 @@ QStringList QStyleFactory::keys() #ifndef QT_NO_STYLE_WINDOWS list << QLatin1String("Windows"); #endif -#ifndef QT_NO_STYLE_MOTIF - list << QLatin1String("Motif"); -#endif -#ifndef QT_NO_STYLE_PLASTIQUE - list << QLatin1String("Plastique"); -#endif #ifndef QT_NO_STYLE_CLEANLOOKS list << QLatin1String("Cleanlooks"); #endif @@ -133,7 +117,3 @@ QStringList QStyleFactory::keys() } QT_END_NAMESPACE - - - - diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index a92d71fdc..7377b9943 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -38,7 +38,6 @@ #include "qlineedit.h" #include "qwindowsstyle.h" #include "qcombobox.h" -#include "qplastiquestyle.h" #include "qabstractscrollarea.h" #include "qtooltip.h" #include "qshareddata.h" @@ -1342,8 +1341,8 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded) { if (bg && bg->brush.style() != Qt::NoBrush) { - p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp - p->setBrush(cg, QPalette::Button, bg->brush); // for plastique + p->setBrush(cg, QPalette::Base, bg->brush); // for windows + p->setBrush(cg, QPalette::Button, bg->brush); p->setBrush(cg, w->backgroundRole(), bg->brush); p->setBrush(cg, QPalette::Window, bg->brush); } diff --git a/src/gui/styles/qstylesheetstyle_default.cpp b/src/gui/styles/qstylesheetstyle_default.cpp index f3c1498d7..6361141f6 100644 --- a/src/gui/styles/qstylesheetstyle_default.cpp +++ b/src/gui/styles/qstylesheetstyle_default.cpp @@ -303,12 +303,13 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const ADD_STYLE_RULE; } - /*QComboBox[style="QPlastiqueStyle"][readOnly="true"], +/* QComboBox[style="QCleanlooksStyle"][readOnly="true"] { -qt-background-role: button; - }*/ - if (baseStyle()->inherits("QPlastiqueStyle") || baseStyle()->inherits("QCleanlooksStyle")) + } +*/ + if (baseStyle()->inherits("QCleanlooksStyle")) { SET_ELEMENT_NAME(QLatin1String("QComboBox")); ADD_ATTRIBUTE_SELECTOR(QLatin1String("readOnly"), QLatin1String("true"), AttributeSelector::MatchEqual); diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index ea7e6671e..c1f567ba2 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -145,7 +145,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) \ingroup appearance \img qwindowsstyle.png - \sa QPlastiqueStyle, QMotifStyle + \sa QCleanlooksStyle */ /*! @@ -555,6 +555,174 @@ static const char * qt_windows_dock_widget_close_xpm[] = { ".##..##.", "........", "........"}; + +// Message box icons, from page 210 of the Windows style guide. + +// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette. +// Thanks to TrueColor displays, it is slightly more efficient to have +// them duplicated. +/* XPM */ +static const char * const qt_information_xpm[]={ + "32 32 5 1", + ". c None", + "c c #000000", + "* c #999999", + "a c #ffffff", + "b c #0000ff", + "...........********.............", + "........***aaaaaaaa***..........", + "......**aaaaaaaaaaaaaa**........", + ".....*aaaaaaaaaaaaaaaaaa*.......", + "....*aaaaaaaabbbbaaaaaaaac......", + "...*aaaaaaaabbbbbbaaaaaaaac.....", + "..*aaaaaaaaabbbbbbaaaaaaaaac....", + ".*aaaaaaaaaaabbbbaaaaaaaaaaac...", + ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..", + "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.", + "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.", + "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", + "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", + "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", + "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", + "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", + ".*aaaaaaaaaaabbbbbaaaaaaaaaac***", + ".*aaaaaaaaaaabbbbbaaaaaaaaaac***", + "..*aaaaaaaaaabbbbbaaaaaaaaac***.", + "...caaaaaaabbbbbbbbbaaaaaac****.", + "....caaaaaaaaaaaaaaaaaaaac****..", + ".....caaaaaaaaaaaaaaaaaac****...", + "......ccaaaaaaaaaaaaaacc****....", + ".......*cccaaaaaaaaccc*****.....", + "........***cccaaaac*******......", + "..........****caaac*****........", + ".............*caaac**...........", + "...............caac**...........", + "................cac**...........", + ".................cc**...........", + "..................***...........", + "...................**..........."}; + +/* XPM */ +static const char* const qt_warning_xpm[]={ + "32 32 4 1", + ". c None", + "a c #ffff00", + "* c #000000", + "b c #999999", + ".............***................", + "............*aaa*...............", + "...........*aaaaa*b.............", + "...........*aaaaa*bb............", + "..........*aaaaaaa*bb...........", + "..........*aaaaaaa*bb...........", + ".........*aaaaaaaaa*bb..........", + ".........*aaaaaaaaa*bb..........", + "........*aaaaaaaaaaa*bb.........", + "........*aaaa***aaaa*bb.........", + ".......*aaaa*****aaaa*bb........", + ".......*aaaa*****aaaa*bb........", + "......*aaaaa*****aaaaa*bb.......", + "......*aaaaa*****aaaaa*bb.......", + ".....*aaaaaa*****aaaaaa*bb......", + ".....*aaaaaa*****aaaaaa*bb......", + "....*aaaaaaaa***aaaaaaaa*bb.....", + "....*aaaaaaaa***aaaaaaaa*bb.....", + "...*aaaaaaaaa***aaaaaaaaa*bb....", + "...*aaaaaaaaaa*aaaaaaaaaa*bb....", + "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...", + "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...", + ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..", + ".*aaaaaaaaaaa****aaaaaaaaaa*bb..", + "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.", + "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.", + "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", + "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", + ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb", + "..*************************bbbbb", + "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.", + ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."}; + +/* XPM */ +static const char* const qt_critical_xpm[]={ + "32 32 4 1", + ". c None", + "a c #999999", + "* c #ff0000", + "b c #ffffff", + "...........********.............", + ".........************...........", + ".......****************.........", + "......******************........", + ".....********************a......", + "....**********************a.....", + "...************************a....", + "..*******b**********b*******a...", + "..******bbb********bbb******a...", + ".******bbbbb******bbbbb******a..", + ".*******bbbbb****bbbbb*******a..", + "*********bbbbb**bbbbb*********a.", + "**********bbbbbbbbbb**********a.", + "***********bbbbbbbb***********aa", + "************bbbbbb************aa", + "************bbbbbb************aa", + "***********bbbbbbbb***********aa", + "**********bbbbbbbbbb**********aa", + "*********bbbbb**bbbbb*********aa", + ".*******bbbbb****bbbbb*******aa.", + ".******bbbbb******bbbbb******aa.", + "..******bbb********bbb******aaa.", + "..*******b**********b*******aa..", + "...************************aaa..", + "....**********************aaa...", + "....a********************aaa....", + ".....a******************aaa.....", + "......a****************aaa......", + ".......aa************aaaa.......", + ".........aa********aaaaa........", + "...........aaaaaaaaaaa..........", + ".............aaaaaaa............"}; + +/* XPM */ +static const char *const qt_question_xpm[] = { + "32 32 5 1", + ". c None", + "c c #000000", + "* c #999999", + "a c #ffffff", + "b c #0000ff", + "...........********.............", + "........***aaaaaaaa***..........", + "......**aaaaaaaaaaaaaa**........", + ".....*aaaaaaaaaaaaaaaaaa*.......", + "....*aaaaaaaaaaaaaaaaaaaac......", + "...*aaaaaaaabbbbbbaaaaaaaac.....", + "..*aaaaaaaabaaabbbbaaaaaaaac....", + ".*aaaaaaaabbaaaabbbbaaaaaaaac...", + ".*aaaaaaaabbbbaabbbbaaaaaaaac*..", + "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.", + "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.", + "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**", + "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**", + "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**", + "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**", + "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**", + ".*aaaaaaaaaaaabbaaaaaaaaaaaac***", + ".*aaaaaaaaaaabbbbaaaaaaaaaaac***", + "..*aaaaaaaaaabbbbaaaaaaaaaac***.", + "...caaaaaaaaaabbaaaaaaaaaac****.", + "....caaaaaaaaaaaaaaaaaaaac****..", + ".....caaaaaaaaaaaaaaaaaac****...", + "......ccaaaaaaaaaaaaaacc****....", + ".......*cccaaaaaaaaccc*****.....", + "........***cccaaaac*******......", + "..........****caaac*****........", + ".............*caaac**...........", + "...............caac**...........", + "................cac**...........", + ".................cc**...........", + "..................***...........", + "...................**...........", +}; #endif //QT_NO_XPM /*! diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index b95b4388a..60c92ec83 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -576,94 +576,6 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti class to hold them. These actions can then be inserted into menus in the usual way; see the QMenu documentation for more details. - \section1 Platform Dependent Look and Feel - - Different platforms have different requirements for the appearance - of menu bars and their behavior when the user interacts with them. - For example, Windows systems are often configured so that the - underlined character mnemonics that indicate keyboard shortcuts - for items in the menu bar are only shown when the \gui{Alt} key is - pressed. - - \table - - \row \o \inlineimage plastique-menubar.png A menu bar shown in the - Plastique widget style. - - \o The \l{QPlastiqueStyle}{Plastique widget style}, like most - other styles, handles the \gui{Help} menu in the same way as it - handles any other menu. - - \row \o \inlineimage motif-menubar.png A menu bar shown in the - Motif widget style. - - \o The \l{QMotifStyle}{Motif widget style} treats \gui{Help} menus - in a special way, placing them at right-hand end of the menu bar. - - \endtable - - \section1 QMenuBar on Mac OS X - - QMenuBar on Mac OS X is a wrapper for using the system-wide menu bar. - If you have multiple menu bars in one dialog the outermost menu bar - (normally inside a widget with widget flag Qt::Window) will - be used for the system-wide menu bar. - - Qt for Mac OS X also provides a menu bar merging feature to make - QMenuBar conform more closely to accepted Mac OS X menu bar layout. - The merging functionality is based on string matching the title of - a QMenu entry. These strings are translated (using QObject::tr()) - in the "QMenuBar" context. If an entry is moved its slots will still - fire as if it was in the original place. The table below outlines - the strings looked for and where the entry is placed if matched: - - \table - \header \i String matches \i Placement \i Notes - \row \i about.* - \i Application Menu | About - \i The application name is fetched from the \c {Info.plist} file - (see note below). If this entry is not found no About item - will appear in the Application Menu. - \row \i config, options, setup, settings or preferences - \i Application Menu | Preferences - \i If this entry is not found the Settings item will be disabled - \row \i quit or exit - \i Application Menu | Quit - \i If this entry is not found a default Quit item will be - created to call QApplication::quit() - \endtable - - You can override this behavior by using the QAction::menuRole() - property. - - If you want all windows in a Mac application to share one menu - bar, you must create a menu bar that does not have a parent. - Create a parent-less menu bar this way: - - \snippet doc/src/snippets/code/src_gui_widgets_qmenubar.cpp 1 - - \bold{Note:} Do \e{not} call QMainWindow::menuBar() to create the - shared menu bar, because that menu bar will have the QMainWindow - as its parent. That menu bar would only be displayed for the - parent QMainWindow. - - \bold{Note:} The text used for the application name in the menu - bar is obtained from the value set in the \c{Info.plist} file in - the application's bundle. See \l{Deploying an Application on - Mac OS X} for more information. - - \section1 QMenuBar on Windows CE - - QMenuBar on Windows CE is a wrapper for using the system-wide menu bar, - similar to the Mac. This feature is activated for Windows Mobile - and integrates QMenuBar with the native soft keys. The left soft - key can be controlled with QMenuBar::setDefaultAction() and the - right soft key can be used to access the menu bar. - - The hovered() signal is not supported for the native menu - integration. Also, it is not possible to display an icon in a - native menu on Windows Mobile. - \section1 Examples The \l{mainwindows/menus}{Menus} example shows how to use QMenuBar diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 9af02cee3..753d36e6e 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -408,7 +408,6 @@ static const struct ClassTblData { { QLatin1String("QMetaType"), QLatin1String("QtCore/qmetatype.h") }, { QLatin1String("QMimeData"), QLatin1String("QtCore/qmimedata.h") }, { QLatin1String("QModelIndex"), QLatin1String("QtCore/qabstractitemmodel.h") }, - { QLatin1String("QMotifStyle"), QLatin1String("QtGui/qmotifstyle.h") }, { QLatin1String("QMouseEvent"), QLatin1String("QtGui/qevent.h") }, { QLatin1String("QMoveEvent"), QLatin1String("QtGui/qevent.h") }, { QLatin1String("QMovie"), QLatin1String("QtGui/qmovie.h") }, @@ -447,7 +446,6 @@ static const struct ClassTblData { { QLatin1String("QPixmapCache"), QLatin1String("QtGui/qpixmapcache.h") }, { QLatin1String("QPlainTextDocumentLayout"), QLatin1String("QtGui/qplaintextedit.h") }, { QLatin1String("QPlainTextEdit"), QLatin1String("QtGui/qplaintextedit.h") }, - { QLatin1String("QPlastiqueStyle"), QLatin1String("QtGui/qplastiquestyle.h") }, { QLatin1String("QPluginLoader"), QLatin1String("QtCore/qpluginloader.h") }, { QLatin1String("QPoint"), QLatin1String("QtCore/qpoint.h") }, { QLatin1String("QPointF"), QLatin1String("QtCore/qpoint.h") }, @@ -708,11 +706,7 @@ static const struct ClassTblData { { QLatin1String("QXmlStreamWriter"), QLatin1String("QtXml/qxmlstream.h") }, { QLatin1String("ResultIteratorBase"), QLatin1String("QtCore/qtconcurrentresultstore.h") }, { QLatin1String("ResultStoreBase"), QLatin1String("QtCore/qtconcurrentresultstore.h") }, - { QLatin1String("SignalSlotEditor"), QLatin1String("QtDesigner/signalsloteditor.h") }, - { QLatin1String("SignalSlotEditorPlugin"), QLatin1String("QtDesigner/signalsloteditor_plugin.h") }, - { QLatin1String("SignalSlotEditorTool"), QLatin1String("QtDesigner/signalsloteditor_tool.h") }, { QLatin1String("StringListEditorButton"), QLatin1String("QtDesigner/stringlisteditorbutton.h") }, - { QLatin1String("Tab"), QLatin1String("QtGui/qtextoption.h") }, { QLatin1String("TabOrderEditor"), QLatin1String("QtDesigner/tabordereditor.h") }, { QLatin1String("TabOrderEditorPlugin"), QLatin1String("QtDesigner/tabordereditor_plugin.h") }, { QLatin1String("TabOrderEditorTool"), QLatin1String("QtDesigner/tabordereditor_tool.h") }, diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp index 48e65cf89..0fb13a57f 100644 --- a/tests/auto/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/qformlayout/tst_qformlayout.cpp @@ -386,15 +386,6 @@ void tst_QFormLayout::setFormStyle() QFormLayout layout; widget.setLayout(&layout); -#ifndef QT_NO_STYLE_PLASTIQUE - widget.setStyle(new QPlastiqueStyle()); - - QVERIFY(layout.labelAlignment() == Qt::AlignRight); - QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); - QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::ExpandingFieldsGrow); - QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows); -#endif - widget.setStyle(new QWindowsStyle()); QVERIFY(layout.labelAlignment() == Qt::AlignLeft); diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index f0c331a73..0ec60f33a 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -1553,7 +1553,7 @@ void tst_QListWidget::task199503_crashWhenCleared() void tst_QListWidget::task217070_scrollbarsAdjusted() { - //This task was mailing for style using SH_ScrollView_FrameOnlyAroundContents such as QMotifStyle + //This task was mailing for style using SH_ScrollView_FrameOnlyAroundContents QListWidget v; for (int i = 0; i<200;i++) v.addItem(QString::number(i)); diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index 9453ffb3b..61281b1cf 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -33,9 +33,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -53,7 +51,7 @@ #include //TESTED_CLASS= -//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp gui/styles/qs60style.cpp +//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qwindowsstyle.cpp // Make a widget frameless to prevent size constraints of title bars // from interfering (Windows). @@ -80,14 +78,11 @@ private slots: void cleanupTestCase(); void init(); void cleanup(); - void testMotifStyle(); - void testPlastiqueStyle(); void testWindowsStyle(); void testCleanlooksStyle(); void testStyleFactory(); void testProxyStyle(); void pixelMetric(); - void progressBarChangeStyle(); void defaultFont(); void testDrawingShortcuts(); private: @@ -135,15 +130,9 @@ void tst_QStyle::cleanupTestCase() void tst_QStyle::testStyleFactory() { QStringList keys = QStyleFactory::keys(); -#ifndef QT_NO_STYLE_MOTIF - QVERIFY(keys.contains("Motif")); -#endif #ifndef QT_NO_STYLE_CLEANLOOKS QVERIFY(keys.contains("Cleanlooks")); #endif -#ifndef QT_NO_STYLE_PLASTIQUE - QVERIFY(keys.contains("Plastique")); -#endif #ifndef QT_NO_STYLE_WINDOWS QVERIFY(keys.contains("Windows")); #endif @@ -299,17 +288,6 @@ void tst_QStyle::testScrollBarSubControls(QStyle* style) } } -void tst_QStyle::testPlastiqueStyle() -{ -#if !defined(QT_NO_STYLE_PLASTIQUE) - QPlastiqueStyle pstyle; - testAllFunctions(&pstyle); - lineUpLayoutTest(&pstyle); -#else - QSKIP("No Plastique style", SkipAll); -#endif -} - void tst_QStyle::testCleanlooksStyle() { #if !defined(QT_NO_STYLE_CLEANLOOKS) @@ -358,16 +336,6 @@ void comparePixmap(const QString &filename, const QPixmap &pixmap) writeImage(filename, pixmap.toImage()); } -void tst_QStyle::testMotifStyle() -{ -#if !defined(QT_NO_STYLE_MOTIF) - QMotifStyle mstyle; - testAllFunctions(&mstyle); -#else - QSKIP("No Motif style", SkipAll); -#endif -} - // Helper class... MyWidget::MyWidget( QWidget* parent, const char* name ) @@ -449,53 +417,6 @@ void tst_QStyle::pixelMetric() delete style; } -void tst_QStyle::progressBarChangeStyle() -{ -#if !defined(QT_NO_STYLE_PLASTIQUE) && !defined(QT_NO_STYLE_WINDOWS) - //test a crashing situation (task 143530) - //where changing the styles and deleting a progressbar would crash - - QWindowsStyle style1; - QPlastiqueStyle style2; - - QProgressBar *progress=new QProgressBar; - progress->setStyle(&style1); - - progress->show(); - - progress->setStyle(&style2); - - QTest::qWait(100); - delete progress; - - QTest::qWait(100); - - //before the correction, there would be a crash here -#elif !defined(QT_NO_STYLE_S60) && !defined(QT_NO_STYLE_WINDOWS) - //test a crashing situation (task 143530) - //where changing the styles and deleting a progressbar would crash - - QWindowsStyle style1; - QS60Style style2; - - QProgressBar *progress=new QProgressBar; - progress->setStyle(&style1); - - progress->show(); - - progress->setStyle(&style2); - - QTest::qWait(100); - delete progress; - - QTest::qWait(100); - - //before the correction, there would be a crash here -#else - QSKIP("Either style Plastique or Windows or S60 missing", SkipAll); -#endif -} - void tst_QStyle::lineUpLayoutTest(QStyle *style) { QWidget widget; diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 123b3e57b..57faa05ec 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -704,7 +704,7 @@ void tst_QStyleSheetStyle::focusColors() int styleCount = 2; QStyle *styles[2]; - styles[0] = new QPlastiqueStyle; + styles[0] = new QCleanlooksStyle; styles[1] = new QWindowsStyle; for (int i = 0; i < styleCount; ++i) { @@ -1554,7 +1554,7 @@ class ChangeEventWidget : public QWidget if (!recurse) { recurse = true; - QStyle *style = new QMotifStyle; + QStyle *style = new QWindowsStyle(); style->setParent(this); setStyle(style); recurse = false; -- 2.11.0