/**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** ** This file is part of the QtGui module of the Qt 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. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMACSTYLE_MAC_P_H #define QMACSTYLE_MAC_P_H #include #undef check #include "qmacstyle_mac.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // QT_BEGIN_NAMESPACE /* AHIG: Apple Human Interface Guidelines http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/ Builder: Apple Interface Builder v. 3.1.1 */ // 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)) enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2, QAquaSizeUnknown = -1 }; #define SIZE(large, small, mini) \ (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini)) // same as return SIZE(...) but optimized #define return_SIZE(large, small, mini) \ do { \ static const int sizes[] = { (large), (small), (mini) }; \ return sizes[controlSize]; \ } while (0) bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option); class QMacStylePrivate : public QObject { Q_OBJECT public: QMacStylePrivate(QMacStyle *style); // Ideally these wouldn't exist, but since they already exist we need some accessors. static const int PushButtonLeftOffset; static const int PushButtonTopOffset; static const int PushButtonRightOffset; static const int PushButtonBottomOffset; static const int MiniButtonH; static const int SmallButtonH; static const int BevelButtonW; static const int BevelButtonH; static const int PushButtonContentPadding; static const qreal ScrollBarFadeOutDuration; static const qreal ScrollBarFadeOutDelay; // Stuff from QAquaAnimate: bool addWidget(QWidget *); void removeWidget(QWidget *); enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar }; bool animatable(Animates, const QWidget *) const; void stopAnimate(Animates, QWidget *); void startAnimate(Animates, QWidget *); static ThemeDrawState getDrawState(QStyle::State flags); QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct = QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz = 0) const; void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe); bool doAnimate(Animates); inline int animateSpeed(Animates) const { return 33; } // Utility functions void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const; QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const; HIRect pushButtonContentBounds(const QStyleOptionButton *btn, const HIThemeButtonDrawInfo *bdi) const; void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, const QWidget *widget, const ThemeDrawState &tds); static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind); static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi); static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p); static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p); bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi, ThemeButtonKind buttonKindToCheck) const; void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const; QPixmap generateBackgroundPattern() const; protected: bool eventFilter(QObject *, QEvent *); void timerEvent(QTimerEvent *); private slots: void startAnimationTimer(); public: QPointer defaultButton; //default push buttons int timerID; QList > progressBars; //existing progress bars that need animation QList > scrollBars; //existing scroll bars that need animation struct OverlayScrollBarInfo { OverlayScrollBarInfo() : lastValue(-1), lastMinimum(-1), lastMaximum(-1), lastUpdate(QDateTime::currentDateTime()), hovered(false), lastHovered(QDateTime::fromTime_t(0)), cleared(false) {} int lastValue; int lastMinimum; int lastMaximum; QSize lastSize; QDateTime lastUpdate; bool hovered; QDateTime lastHovered; bool cleared; }; QMap scrollBarInfos; struct ButtonState { int frame; enum { ButtonDark, ButtonLight } dir; } buttonState; UInt8 progressFrame; QPointer focusWidget; CFAbsoluteTime defaultButtonStart; QMacStyle *q; bool mouseDown; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 void* receiver; void *nsscroller; #endif }; QT_END_NAMESPACE #endif // QMACSTYLE_MAC_P_H