| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 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 documentation 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 | /*!
|
|---|
| 44 | \class QMacStyle
|
|---|
| 45 | \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager.
|
|---|
| 46 |
|
|---|
| 47 | \ingroup appearance
|
|---|
| 48 |
|
|---|
| 49 | This class is implemented as a wrapper to the HITheme
|
|---|
| 50 | APIs, allowing applications to be styled according to the current
|
|---|
| 51 | theme in use on Mac OS X. This is done by having primitives
|
|---|
| 52 | in QStyle implemented in terms of what Mac OS X would normally theme.
|
|---|
| 53 |
|
|---|
| 54 | \warning This style is only available on Mac OS X because it relies on the
|
|---|
| 55 | HITheme APIs.
|
|---|
| 56 |
|
|---|
| 57 | There are additional issues that should be taken
|
|---|
| 58 | into consideration to make an application compatible with the
|
|---|
| 59 | \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html
|
|---|
| 60 | Apple Human Interface Guidelines \endlink. Some of these issues are outlined
|
|---|
| 61 | below.
|
|---|
| 62 |
|
|---|
| 63 | \list
|
|---|
| 64 |
|
|---|
| 65 | \i Layout - The restrictions on window layout are such that some
|
|---|
| 66 | aspects of layout that are style-dependent cannot be achieved
|
|---|
| 67 | using QLayout. Changes are being considered (and feedback would be
|
|---|
| 68 | appreciated) to make layouts QStyle-able. Some of the restrictions
|
|---|
| 69 | involve horizontal and vertical widget alignment and widget size
|
|---|
| 70 | (covered below).
|
|---|
| 71 |
|
|---|
| 72 | \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt
|
|---|
| 73 | does not fully implement this behavior so as to maintain cross-platform
|
|---|
| 74 | compatibility. As a result some widgets sizes may be inappropriate (and
|
|---|
| 75 | subsequently not rendered correctly by the HITheme APIs).The
|
|---|
| 76 | QWidget::sizeHint() will return the appropriate size for many
|
|---|
| 77 | managed widgets (widgets enumerated in \l QStyle::ContentsType).
|
|---|
| 78 |
|
|---|
| 79 | \i Effects - QMacStyle uses HITheme for performing most of the drawing, but
|
|---|
| 80 | also uses emulation in a few cases where HITheme does not provide the
|
|---|
| 81 | required functionality (for example, tab bars on Panther, the toolbar
|
|---|
| 82 | separator, etc). We tried to make the emulation as close to the original as
|
|---|
| 83 | possible. Please report any issues you see in effects or non-standard
|
|---|
| 84 | widgets.
|
|---|
| 85 |
|
|---|
| 86 | \endlist
|
|---|
| 87 |
|
|---|
| 88 | There are other issues that need to be considered in the feel of
|
|---|
| 89 | your application (including the general color scheme to match the
|
|---|
| 90 | Aqua colors). The Guidelines mentioned above will remain current
|
|---|
| 91 | with new advances and design suggestions for Mac OS X.
|
|---|
| 92 |
|
|---|
| 93 | Note that the functions provided by QMacStyle are
|
|---|
| 94 | reimplementations of QStyle functions; see QStyle for their
|
|---|
| 95 | documentation.
|
|---|
| 96 |
|
|---|
| 97 | \img qmacstyle.png
|
|---|
| 98 | \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | /*!
|
|---|
| 103 | \enum QMacStyle::WidgetSizePolicy
|
|---|
| 104 |
|
|---|
| 105 | \value SizeSmall
|
|---|
| 106 | \value SizeLarge
|
|---|
| 107 | \value SizeMini
|
|---|
| 108 | \value SizeDefault
|
|---|
| 109 | \omitvalue SizeNone
|
|---|
| 110 | */
|
|---|
| 111 |
|
|---|
| 112 | /*! \fn QMacStyle::QMacStyle()
|
|---|
| 113 | Constructs a QMacStyle object.
|
|---|
| 114 | */
|
|---|
| 115 |
|
|---|
| 116 | /*! \fn QMacStyle::~QMacStyle()
|
|---|
| 117 | Destructs a QMacStyle object.
|
|---|
| 118 | */
|
|---|
| 119 |
|
|---|
| 120 | /*! \fn void QMacStyle::polish(QPalette &pal)
|
|---|
| 121 | \reimp
|
|---|
| 122 | */
|
|---|
| 123 |
|
|---|
| 124 | /*! \fn void QMacStyle::polish(QApplication *)
|
|---|
| 125 | \reimp
|
|---|
| 126 | */
|
|---|
| 127 |
|
|---|
| 128 | /*! \fn void QMacStyle::unpolish(QApplication *)
|
|---|
| 129 | \reimp
|
|---|
| 130 | */
|
|---|
| 131 |
|
|---|
| 132 | /*! \fn void QMacStyle::polish(QWidget* w)
|
|---|
| 133 | \reimp
|
|---|
| 134 | */
|
|---|
| 135 |
|
|---|
| 136 | /*! \fn void QMacStyle::unpolish(QWidget* w)
|
|---|
| 137 | \reimp
|
|---|
| 138 | */
|
|---|
| 139 |
|
|---|
| 140 | /*! \fn int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const
|
|---|
| 141 | \reimp
|
|---|
| 142 | */
|
|---|
| 143 |
|
|---|
| 144 | /*! \fn QPalette QMacStyle::standardPalette() const
|
|---|
| 145 | \reimp
|
|---|
| 146 | */
|
|---|
| 147 |
|
|---|
| 148 | /*! \fn int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const
|
|---|
| 149 | \reimp
|
|---|
| 150 | */
|
|---|
| 151 |
|
|---|
| 152 | /*! \fn QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
|
|---|
| 153 | \reimp
|
|---|
| 154 | */
|
|---|
| 155 |
|
|---|
| 156 | /*! \fn QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const
|
|---|
| 157 | \reimp
|
|---|
| 158 | */
|
|---|
| 159 |
|
|---|
| 160 | /*!
|
|---|
| 161 | \enum QMacStyle::FocusRectPolicy
|
|---|
| 162 |
|
|---|
| 163 | This type is used to signify a widget's focus rectangle policy.
|
|---|
| 164 |
|
|---|
| 165 | \value FocusEnabled show a focus rectangle when the widget has focus.
|
|---|
| 166 | \value FocusDisabled never show a focus rectangle for the widget.
|
|---|
| 167 | \value FocusDefault show a focus rectangle when the widget has
|
|---|
| 168 | focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit,
|
|---|
| 169 | QListBox, QListView, editable QTextEdit, or one of their
|
|---|
| 170 | subclasses.
|
|---|
| 171 | */
|
|---|
| 172 |
|
|---|
| 173 | /*! \fn void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
|
|---|
| 174 | \obsolete
|
|---|
| 175 | Sets the focus rectangle policy of \a w. The \a policy can be one of
|
|---|
| 176 | \l{QMacStyle::FocusRectPolicy}.
|
|---|
| 177 |
|
|---|
| 178 | This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the
|
|---|
| 179 | FocusDefault value does nothing anymore. If you want to set a widget back
|
|---|
| 180 | to its default value, you must save the old value of the attribute before
|
|---|
| 181 | you change it.
|
|---|
| 182 |
|
|---|
| 183 | \sa focusRectPolicy() QWidget::setAttribute()
|
|---|
| 184 | */
|
|---|
| 185 |
|
|---|
| 186 | /*! \fn QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w)
|
|---|
| 187 | \obsolete
|
|---|
| 188 | Returns the focus rectangle policy for the widget \a w.
|
|---|
| 189 |
|
|---|
| 190 | The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}.
|
|---|
| 191 |
|
|---|
| 192 | In 4.3 and up this function will simply test for the
|
|---|
| 193 | Qt::WA_MacShowFocusRect attribute and will never return
|
|---|
| 194 | QMacStyle::FocusDefault.
|
|---|
| 195 |
|
|---|
| 196 | \sa setFocusRectPolicy(), QWidget::testAttribute()
|
|---|
| 197 | */
|
|---|
| 198 |
|
|---|
| 199 | /*! \fn void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
|
|---|
| 200 |
|
|---|
| 201 | \obsolete
|
|---|
| 202 |
|
|---|
| 203 | Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
|
|---|
| 204 | or Qt::WA_MacNormalSize instead.
|
|---|
| 205 | */
|
|---|
| 206 |
|
|---|
| 207 | /*! \fn QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
|
|---|
| 208 | \obsolete
|
|---|
| 209 |
|
|---|
| 210 | Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
|
|---|
| 211 | or Qt::WA_MacNormalSize instead.
|
|---|
| 212 | */
|
|---|
| 213 |
|
|---|
| 214 | /*! \fn void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
|---|
| 215 |
|
|---|
| 216 | \reimp
|
|---|
| 217 | */
|
|---|
| 218 |
|
|---|
| 219 | /*! \fn void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
|---|
| 220 |
|
|---|
| 221 | \reimp
|
|---|
| 222 | */
|
|---|
| 223 |
|
|---|
| 224 | /*! \fn QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const
|
|---|
| 225 |
|
|---|
| 226 | \reimp
|
|---|
| 227 | */
|
|---|
| 228 |
|
|---|
| 229 | /*! \fn void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const
|
|---|
| 230 | \reimp
|
|---|
| 231 | */
|
|---|
| 232 |
|
|---|
| 233 | /*! \fn QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const
|
|---|
| 234 | \reimp
|
|---|
| 235 | */
|
|---|
| 236 |
|
|---|
| 237 | /*! \fn QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
|
|---|
| 238 | \reimp
|
|---|
| 239 | */
|
|---|
| 240 |
|
|---|
| 241 | /*! \fn QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const
|
|---|
| 242 | \reimp
|
|---|
| 243 | */
|
|---|
| 244 |
|
|---|
| 245 | /*! \fn void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const
|
|---|
| 246 | \reimp
|
|---|
| 247 | */
|
|---|
| 248 |
|
|---|
| 249 | /*! \fn bool QMacStyle::event(QEvent *e)
|
|---|
| 250 | \reimp
|
|---|
| 251 | */
|
|---|
| 252 |
|
|---|
| 253 | /*! \fn QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const
|
|---|
| 254 | \internal
|
|---|
| 255 | */
|
|---|
| 256 |
|
|---|
| 257 | /*! \fn int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const
|
|---|
| 258 |
|
|---|
| 259 | \internal
|
|---|
| 260 | */
|
|---|
| 261 |
|
|---|