diff options
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qmacstyle_mac.h | 11 | ||||
-rw-r--r-- | src/gui/styles/qmacstyle_mac.mm | 181 | ||||
-rw-r--r-- | src/gui/styles/qmacstyle_mac_p.h | 22 | ||||
-rw-r--r-- | src/gui/styles/qmacstylepixmaps_mac_p.h | 5 | ||||
-rw-r--r-- | src/gui/styles/styles.pri | 3 |
5 files changed, 45 insertions, 177 deletions
diff --git a/src/gui/styles/qmacstyle_mac.h b/src/gui/styles/qmacstyle_mac.h index e594793..bcebb1d 100644 --- a/src/gui/styles/qmacstyle_mac.h +++ b/src/gui/styles/qmacstyle_mac.h @@ -120,17 +120,6 @@ public: bool event(QEvent *e); - // 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; - protected Q_SLOTS: QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0, const QWidget *widget = 0) const; diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index e82e638..9cffc1e 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -101,22 +101,21 @@ #include <QtGui/qgraphicsproxywidget.h> #include <QtGui/qgraphicsview.h> #include <private/qt_cocoa_helpers_mac_p.h> +#include "qmacstyle_mac_p.h" QT_BEGIN_NAMESPACE -extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp - // The following constants are used for adjusting the size // of push buttons so that they are drawn inside their bounds. -const int QMacStyle::PushButtonLeftOffset = 6; -const int QMacStyle::PushButtonTopOffset = 4; -const int QMacStyle::PushButtonRightOffset = 12; -const int QMacStyle::PushButtonBottomOffset = 12; -const int QMacStyle::MiniButtonH = 26; -const int QMacStyle::SmallButtonH = 30; -const int QMacStyle::BevelButtonW = 50; -const int QMacStyle::BevelButtonH = 22; -const int QMacStyle::PushButtonContentPadding = 6; +const int QMacStylePrivate::PushButtonLeftOffset = 6; +const int QMacStylePrivate::PushButtonTopOffset = 4; +const int QMacStylePrivate::PushButtonRightOffset = 12; +const int QMacStylePrivate::PushButtonBottomOffset = 12; +const int QMacStylePrivate::MiniButtonH = 26; +const int QMacStylePrivate::SmallButtonH = 30; +const int QMacStylePrivate::BevelButtonW = 50; +const int QMacStylePrivate::BevelButtonH = 22; +const int QMacStylePrivate::PushButtonContentPadding = 6; // These colors specify the titlebar gradient colors on // Leopard. Ideally we should get them from the system. @@ -134,25 +133,14 @@ static const QColor mainWindowGradientEnd(200, 200, 200); static const int DisclosureOffset = 4; -#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) -enum { - kThemePushButtonTextured = 31, - kThemePushButtonTexturedSmall = 32, - kThemePushButtonTexturedMini = 33 -}; - -/* Search fields */ -enum { - kHIThemeFrameTextFieldRound = 1000, - kHIThemeFrameTextFieldRoundSmall = 1001, - kHIThemeFrameTextFieldRoundMini = 1002 -}; -#endif - // Resolve these at run-time, since the functions was moved in Leopard. typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; +static int closeButtonSize = 12; + +extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp + static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast || shape == QTabBar::TriangularEast @@ -160,8 +148,6 @@ static bool isVerticalTabs(const QTabBar::Shape shape) { || shape == QTabBar::TriangularWest); } -static int closeButtonSize = 12; - void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected) { // draw background circle @@ -380,32 +366,6 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget p->drawLine(tabRect.x(), height - 1, width, height - 1); } -/* - 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) - static int getControlSize(const QStyleOption *option, const QWidget *widget) { if (option) { @@ -483,80 +443,9 @@ static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) return ttd; } -class QMacStylePrivate : public QObject -{ - Q_OBJECT - -public: - QMacStylePrivate(QMacStyle *style); - - // Stuff from QAquaAnimate: - bool addWidget(QWidget *); - void removeWidget(QWidget *); - - enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen }; - 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<QPushButton> defaultButton; //default push buttons - int timerID; - QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation - - struct ButtonState { - int frame; - enum { ButtonDark, ButtonLight } dir; - } buttonState; - UInt8 progressFrame; - QPointer<QFocusFrame> focusWidget; - CFAbsoluteTime defaultButtonStart; - QMacStyle *q; - bool mouseDown; -}; - QT_BEGIN_INCLUDE_NAMESPACE -#include "qmacstyle_mac.moc" +#include "moc_qmacstyle_mac.cpp" +#include "moc_qmacstyle_mac_p.cpp" QT_END_INCLUDE_NAMESPACE /***************************************************************************** @@ -1057,10 +946,10 @@ HIRect QMacStylePrivate::pushButtonContentBounds(const QStyleOptionButton *btn, // Adjust the bounds to correct for // carbon not calculating the content bounds fully correct if (bdi->kind == kThemePushButton || bdi->kind == kThemePushButtonSmall){ - outerBounds.origin.y += QMacStyle::PushButtonTopOffset; - outerBounds.size.height -= QMacStyle::PushButtonBottomOffset; + outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; + outerBounds.size.height -= QMacStylePrivate::PushButtonBottomOffset; } else if (bdi->kind == kThemePushButtonMini) { - outerBounds.origin.y += QMacStyle::PushButtonTopOffset; + outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; } HIRect contentBounds; @@ -1076,7 +965,7 @@ QSize QMacStylePrivate::pushButtonSizeFromContents(const QStyleOptionButton *btn { QSize csz(0, 0); QSize iconSize = btn->icon.isNull() ? QSize(0, 0) - : (btn->iconSize + QSize(QMacStyle::PushButtonContentPadding, 0)); + : (btn->iconSize + QSize(QMacStylePrivate::PushButtonContentPadding, 0)); QRect textRect = btn->text.isEmpty() ? QRect(0, 0, 1, 1) : btn->fontMetrics.boundingRect(QRect(), Qt::AlignCenter, btn->text); csz.setWidth(iconSize.width() + textRect.width() @@ -1151,12 +1040,12 @@ void QMacStylePrivate::initHIThemePushButton(const QStyleOptionButton *btn, // Choose the button kind that closest match the button rect, but at the // same time displays the button contents without clipping. bdi->kind = kThemeBevelButton; - if (btn->rect.width() >= QMacStyle::BevelButtonW && btn->rect.height() >= QMacStyle::BevelButtonH){ + if (btn->rect.width() >= QMacStylePrivate::BevelButtonW && btn->rect.height() >= QMacStylePrivate::BevelButtonH){ if (widget && widget->testAttribute(Qt::WA_MacVariableSize)) { - if (btn->rect.height() <= QMacStyle::MiniButtonH){ + if (btn->rect.height() <= QMacStylePrivate::MiniButtonH){ if (contentFitsInPushButton(btn, bdi, kThemePushButtonMini)) bdi->kind = kThemePushButtonMini; - } else if (btn->rect.height() <= QMacStyle::SmallButtonH){ + } else if (btn->rect.height() <= QMacStylePrivate::SmallButtonH){ if (contentFitsInPushButton(btn, bdi, kThemePushButtonSmall)) bdi->kind = kThemePushButtonSmall; } else if (contentFitsInPushButton(btn, bdi, kThemePushButton)) { @@ -3497,21 +3386,21 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // the focus 'shadow' will be inside. HIRect newRect = qt_hirectForQRect(btn->rect); if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) { - newRect.origin.x += PushButtonLeftOffset; - newRect.origin.y += PushButtonTopOffset; - newRect.size.width -= PushButtonRightOffset; - newRect.size.height -= PushButtonBottomOffset; + newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset; + newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; + newRect.size.width -= QMacStylePrivate::PushButtonRightOffset; + newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset; } else if (bdi.kind == kThemePushButtonMini) { - newRect.origin.x += PushButtonLeftOffset - 2; - newRect.origin.y += PushButtonTopOffset; - newRect.size.width -= PushButtonRightOffset - 4; + newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset - 2; + newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; + newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4; } HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); if (btn->features & QStyleOptionButton::HasMenu) { int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; - HIRect arrowRect = CGRectMake(ir.right() - mbi - PushButtonRightOffset, + HIRect arrowRect = CGRectMake(ir.right() - mbi - QMacStylePrivate::PushButtonRightOffset, ir.height() / 2 - 4, mbi, ir.height() / 2); bool drawColorless = btn->palette.currentColorGroup() == QPalette::Active; if (drawColorless && tds == kThemeStateInactive) @@ -3605,14 +3494,14 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (btn->state & State_On) state = QIcon::On; QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); - contentW += pixmap.width() + PushButtonContentPadding; + contentW += pixmap.width() + QMacStylePrivate::PushButtonContentPadding; int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2; int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2; QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height()); QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect); proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); int newOffset = iconDestRect.x() + iconDestRect.width() - + PushButtonContentPadding - textRect.x(); + + QMacStylePrivate::PushButtonContentPadding - textRect.x(); textRect.adjust(newOffset, 0, newOffset, 0); } // Draw the text: @@ -5708,8 +5597,8 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // By default, we fit the contents inside a normal rounded push button. // Do this by add enough space around the contents so that rounded // borders (including highlighting when active) will show. - sz.rwidth() += PushButtonLeftOffset + PushButtonRightOffset + 12; - sz.rheight() += PushButtonTopOffset + PushButtonBottomOffset; + sz.rwidth() += QMacStylePrivate::PushButtonLeftOffset + QMacStylePrivate::PushButtonRightOffset + 12; + sz.rheight() += QMacStylePrivate::PushButtonTopOffset + QMacStylePrivate::PushButtonBottomOffset; break; case QStyle::CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { diff --git a/src/gui/styles/qmacstyle_mac_p.h b/src/gui/styles/qmacstyle_mac_p.h index 7f8994e..5a0ba4c 100644 --- a/src/gui/styles/qmacstyle_mac_p.h +++ b/src/gui/styles/qmacstyle_mac_p.h @@ -107,19 +107,7 @@ // We mean it. // -// These colors specify the titlebar gradient colors on -// Leopard. Ideally we should get them from the system. -static const QColor titlebarGradientActiveBegin(220, 220, 220); -static const QColor titlebarGradientActiveEnd(151, 151, 151); -static const QColor titlebarSeparatorLineActive(111, 111, 111); -static const QColor titlebarGradientInactiveBegin(241, 241, 241); -static const QColor titlebarGradientInactiveEnd(207, 207, 207); -static const QColor titlebarSeparatorLineInactive(131, 131, 131); - -// Gradient colors used for the dock widget title bar and -// non-unifed tool bar bacground. -static const QColor mainWindowGradientBegin(240, 240, 240); -static const QColor mainWindowGradientEnd(200, 200, 200); +QT_BEGIN_NAMESPACE #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) enum { @@ -136,12 +124,6 @@ enum { }; #endif -// Resolve these at run-time, since the functions was moved in Leopard. -typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); -static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; - -static int closeButtonSize = 12; - /* AHIG: Apple Human Interface Guidelines @@ -252,4 +234,6 @@ public: bool mouseDown; }; +QT_END_NAMESPACE + #endif // QMACSTYLE_MAC_P_H diff --git a/src/gui/styles/qmacstylepixmaps_mac_p.h b/src/gui/styles/qmacstylepixmaps_mac_p.h index 6a5e0e6..58038c3 100644 --- a/src/gui/styles/qmacstylepixmaps_mac_p.h +++ b/src/gui/styles/qmacstylepixmaps_mac_p.h @@ -39,6 +39,9 @@ ** ****************************************************************************/ +#ifndef QMACSTYLEPIXMAPS_MAC_P_H +#define QMACSTYLEPIXMAPS_MAC_P_H + // // W A R N I N G // ------------- @@ -65,3 +68,5 @@ static const char * const qt_mac_toolbar_ext[]={ "aab###bb###baa", "ab###bb###baaa", ".###..###.aaaa"}; + +#endif // QMACSTYLEPIXMAPS_MAC_P_H diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index f920032..0a96272 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -46,7 +46,8 @@ x11{ contains( styles, mac ) { HEADERS += \ styles/qmacstyle_mac.h \ - styles/qmacstylepixmaps_mac_p.h + styles/qmacstylepixmaps_mac_p.h \ + styles/qmacstyle_mac_p.h OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm !contains( styles, windows ) { |