Qt 4.8
qmacstyle_mac_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
111 
112 #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
113 enum {
117 };
118 
119 /* Search fields */
120 enum {
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 
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 
153 bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
154 
155 class QMacStylePrivate : public QObject
156 {
157  Q_OBJECT
158 
159 public:
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 
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,
185  QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
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 
196 
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;
216 protected:
217  bool eventFilter(QObject *, QEvent *);
218  void timerEvent(QTimerEvent *);
219 
220 private slots:
221  void startAnimationTimer();
222 
223 public:
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;
231  } buttonState;
234  CFAbsoluteTime defaultButtonStart;
236  bool mouseDown;
237 };
238 
240 
241 #endif // QMACSTYLE_MAC_P_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QPixmap generateBackgroundPattern() const
bool addWidget(QWidget *)
void startAnimate(Animates, QWidget *)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
ComplexControl
This enum describes the available complex controls.
Definition: qstyle.h:386
static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p)
bool doAnimate(Animates)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static const int PushButtonBottomOffset
static const int MiniButtonH
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
void removeWidget(QWidget *)
struct QMacStylePrivate::ButtonState buttonState
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static const int PushButtonLeftOffset
CFAbsoluteTime defaultButtonStart
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
ContentsType
This enum describes the available contents types.
Definition: qstyle.h:602
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
QAquaWidgetSize
static const int BevelButtonW
static const int SmallButtonH
static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p)
#define Q_OBJECT
Definition: qobjectdefs.h:157
bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi, ThemeButtonKind buttonKindToCheck) const
void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe)
bool animatable(Animates, const QWidget *) const
static const int PushButtonTopOffset
QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const
void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
State
Definition: qaudio.h:59
static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi)
void stopAnimate(Animates, QWidget *)
static const int BevelButtonH
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static const int PushButtonContentPadding
static ThemeDrawState getDrawState(QStyle::State flags)
QMacStylePrivate(QMacStyle *style)
QPointer< QFocusFrame > focusWidget
bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option)
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static const int PushButtonRightOffset
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int animateSpeed(Animates) const
QPointer< QPushButton > defaultButton
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const
QList< QPointer< QWidget > > progressBars
#define slots
Definition: qobjectdefs.h:68
void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, const QWidget *widget, const ThemeDrawState &tds)
HIRect pushButtonContentBounds(const QStyleOptionButton *btn, const HIThemeButtonDrawInfo *bdi) const
enum QMacStylePrivate::ButtonState::@260 dir
void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62