qmacstyle_mac.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QMACSTYLE_MAC_H
00043 #define QMACSTYLE_MAC_H
00044 
00045 #include <QtGui/qwindowsstyle.h>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Gui)
00052 
00053 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
00054 
00055 class QPalette;
00056 
00057 #if defined(QT_PLUGIN)
00058 #define Q_GUI_EXPORT_STYLE_MAC
00059 #else
00060 #define Q_GUI_EXPORT_STYLE_MAC Q_GUI_EXPORT
00061 #endif
00062 
00063 class QPushButton;
00064 class QStyleOptionButton;
00065 class QMacStylePrivate;
00066 class Q_GUI_EXPORT_STYLE_MAC QMacStyle : public QWindowsStyle
00067 {
00068     Q_OBJECT
00069 public:
00070     QMacStyle();
00071     virtual ~QMacStyle();
00072 
00073     void polish(QWidget *w);
00074     void unpolish(QWidget *w);
00075 
00076     void polish(QApplication*);
00077     void unpolish(QApplication*);
00078 
00079     void polish(QPalette &pal);
00080 
00081     void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
00082                        const QWidget *w = 0) const;
00083     void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
00084                      const QWidget *w = 0) const;
00085     QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
00086     void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
00087                             const QWidget *w = 0) const;
00088     SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
00089                                const QPoint &pt, const QWidget *w = 0) const;
00090     QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
00091                          const QWidget *w = 0) const;
00092     QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
00093                            const QSize &contentsSize, const QWidget *w = 0) const;
00094 
00095     int pixelMetric(PixelMetric pm, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
00096 
00097     QPalette standardPalette() const;
00098 
00099     virtual int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
00100                           QStyleHintReturn *shret = 0) const;
00101 
00102     enum FocusRectPolicy { FocusEnabled, FocusDisabled, FocusDefault };
00103     static void setFocusRectPolicy(QWidget *w, FocusRectPolicy policy);
00104     static FocusRectPolicy focusRectPolicy(const QWidget *w);
00105 
00106     enum WidgetSizePolicy { SizeSmall, SizeLarge, SizeMini, SizeDefault
00107 #ifdef QT3_SUPPORT
00108                             , SizeNone = SizeDefault
00109 #endif
00110     };
00111     static void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
00112     static WidgetSizePolicy widgetSizePolicy(const QWidget *w);
00113 
00114     QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt,
00115                            const QWidget *widget = 0) const;
00116 
00117     QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
00118                                 const QStyleOption *opt) const;
00119 
00120     virtual void drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
00121                               bool enabled, const QString &text, QPalette::ColorRole textRole  = QPalette::NoRole) const;
00122 
00123     bool event(QEvent *e);
00124 
00125 protected Q_SLOTS:
00126     QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
00127                                      const QWidget *widget = 0) const;
00128     int layoutSpacingImplementation(QSizePolicy::ControlType control1,
00129                                     QSizePolicy::ControlType control2, 
00130                                     Qt::Orientation orientation,
00131                                     const QStyleOption *option = 0, 
00132                                     const QWidget *widget = 0) const;
00133 
00134 private:
00135     Q_DISABLE_COPY(QMacStyle)
00136 
00137     QMacStylePrivate *d;
00138 
00139     friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
00140 };
00141 
00142 #endif // Q_WS_MAC
00143 
00144 QT_END_NAMESPACE
00145 
00146 QT_END_HEADER
00147 
00148 #endif // QMACSTYLE_H