source: trunk/src/gui/styles/qmacstyle_mac_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 8.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42
43#ifndef QMACSTYLE_MAC_P_H
44#define QMACSTYLE_MAC_P_H
45
46#include <qmacstyle_mac.h>
47#include <private/qapplication_p.h>
48#include <private/qcombobox_p.h>
49#include <private/qmacstylepixmaps_mac_p.h>
50#include <private/qpaintengine_mac_p.h>
51#include <private/qpainter_p.h>
52#include <private/qprintengine_mac_p.h>
53#include <private/qstylehelper_p.h>
54#include <qapplication.h>
55#include <qbitmap.h>
56#include <qcheckbox.h>
57#include <qcombobox.h>
58#include <qdialogbuttonbox.h>
59#include <qdockwidget.h>
60#include <qevent.h>
61#include <qfocusframe.h>
62#include <qformlayout.h>
63#include <qgroupbox.h>
64#include <qhash.h>
65#include <qheaderview.h>
66#include <qlayout.h>
67#include <qlineedit.h>
68#include <qlistview.h>
69#include <qmainwindow.h>
70#include <qmap.h>
71#include <qmenubar.h>
72#include <qpaintdevice.h>
73#include <qpainter.h>
74#include <qpixmapcache.h>
75#include <qpointer.h>
76#include <qprogressbar.h>
77#include <qpushbutton.h>
78#include <qradiobutton.h>
79#include <qrubberband.h>
80#include <qsizegrip.h>
81#include <qspinbox.h>
82#include <qsplitter.h>
83#include <qstyleoption.h>
84#include <qtextedit.h>
85#include <qtextstream.h>
86#include <qtoolbar.h>
87#include <qtoolbutton.h>
88#include <qtreeview.h>
89#include <qtableview.h>
90#include <qwizard.h>
91#include <qdebug.h>
92#include <qlibrary.h>
93#include <qdatetimeedit.h>
94#include <qmath.h>
95#include <QtGui/qgraphicsproxywidget.h>
96#include <QtGui/qgraphicsview.h>
97#include <private/qt_cocoa_helpers_mac_p.h>
98
99//
100// W A R N I N G
101// -------------
102//
103// This file is not part of the Qt API. It exists purely as an
104// implementation detail. This header file may change from version to
105// version without notice, or even be removed.
106//
107// We mean it.
108//
109
110QT_BEGIN_NAMESPACE
111
112#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
113enum {
114 kThemePushButtonTextured = 31,
115 kThemePushButtonTexturedSmall = 32,
116 kThemePushButtonTexturedMini = 33
117};
118
119/* Search fields */
120enum {
121 kHIThemeFrameTextFieldRound = 1000,
122 kHIThemeFrameTextFieldRoundSmall = 1001,
123 kHIThemeFrameTextFieldRoundMini = 1002
124};
125#endif
126
127/*
128 AHIG:
129 Apple Human Interface Guidelines
130 http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
131
132 Builder:
133 Apple Interface Builder v. 3.1.1
134*/
135
136// this works as long as we have at most 16 different control types
137#define CT1(c) CT2(c, c)
138#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
139
140enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2,
141 QAquaSizeUnknown = -1 };
142
143#define SIZE(large, small, mini) \
144 (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))
145
146// same as return SIZE(...) but optimized
147#define return_SIZE(large, small, mini) \
148 do { \
149 static const int sizes[] = { (large), (small), (mini) }; \
150 return sizes[controlSize]; \
151 } while (0)
152
153bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
154
155class QMacStylePrivate : public QObject
156{
157 Q_OBJECT
158
159public:
160 QMacStylePrivate(QMacStyle *style);
161
162 // Ideally these wouldn't exist, but since they already exist we need some accessors.
163 static const int PushButtonLeftOffset;
164 static const int PushButtonTopOffset;
165 static const int PushButtonRightOffset;
166 static const int PushButtonBottomOffset;
167 static const int MiniButtonH;
168 static const int SmallButtonH;
169 static const int BevelButtonW;
170 static const int BevelButtonH;
171 static const int PushButtonContentPadding;
172
173
174 // Stuff from QAquaAnimate:
175 bool addWidget(QWidget *);
176 void removeWidget(QWidget *);
177
178 enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen };
179 bool animatable(Animates, const QWidget *) const;
180 void stopAnimate(Animates, QWidget *);
181 void startAnimate(Animates, QWidget *);
182 static ThemeDrawState getDrawState(QStyle::State flags);
183 QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
184 QStyle::ContentsType ct = QStyle::CT_CustomBase,
185 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
186 void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
187 HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe);
188 bool doAnimate(Animates);
189 inline int animateSpeed(Animates) const { return 33; }
190
191 // Utility functions
192 void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
193 QPainter *p, const QStyleOption *opt) const;
194
195 QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
196
197 HIRect pushButtonContentBounds(const QStyleOptionButton *btn,
198 const HIThemeButtonDrawInfo *bdi) const;
199
200 void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
201 const QWidget *widget, const ThemeDrawState &tds);
202
203 static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind);
204
205 static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);
206
207 static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);
208 static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,
209 const HIThemeButtonDrawInfo &bdi, QPainter *p);
210 bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,
211 ThemeButtonKind buttonKindToCheck) const;
212 void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
213 const ThemeDrawState tds,
214 HIThemeButtonDrawInfo *bdi) const;
215 QPixmap generateBackgroundPattern() const;
216protected:
217 bool eventFilter(QObject *, QEvent *);
218 void timerEvent(QTimerEvent *);
219
220private slots:
221 void startAnimationTimer();
222
223public:
224 QPointer<QPushButton> defaultButton; //default push buttons
225 int timerID;
226 QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation
227
228 struct ButtonState {
229 int frame;
230 enum { ButtonDark, ButtonLight } dir;
231 } buttonState;
232 UInt8 progressFrame;
233 QPointer<QFocusFrame> focusWidget;
234 CFAbsoluteTime defaultButtonStart;
235 QMacStyle *q;
236 bool mouseDown;
237};
238
239QT_END_NAMESPACE
240
241#endif // QMACSTYLE_MAC_P_H
Note: See TracBrowser for help on using the repository browser.