diff options
Diffstat (limited to 'src/plugins/styles/mac/qmacstyle_mac.mm')
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 6266728c84..a6ece7632a 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -52,16 +52,22 @@ //#define DEBUG_SIZE_CONSTRAINT #include <private/qcore_mac_p.h> -#include <private/qcombobox_p.h> +#if QT_CONFIG(tabbar) #include <private/qtabbar_p.h> +#endif #include <private/qpainter_p.h> #include <qapplication.h> #include <qbitmap.h> +#if QT_CONFIG(combobox) +#include <private/qcombobox_p.h> #include <qcombobox.h> +#endif #if QT_CONFIG(dialogbuttonbox) #include <qdialogbuttonbox.h> #endif +#if QT_CONFIG(dockwidget) #include <qdockwidget.h> +#endif #include <qevent.h> #include <qfocusframe.h> #include <qformlayout.h> @@ -287,7 +293,7 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115); static const int closeButtonSize = 14; static const qreal closeButtonCornerRadius = 2.0; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast || shape == QTabBar::TriangularEast @@ -363,7 +369,7 @@ static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pres p->drawLine(margin, height - margin, width - margin, margin); } -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) { if (isVerticalTabs(shape)) { @@ -502,7 +508,7 @@ static inline bool isTreeView(const QWidget *widget) } #endif -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) { ThemeTabDirection ttd; @@ -771,7 +777,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg else if (qobject_cast<const QCheckBox *>(widg)) ct = QStyle::CT_CheckBox; #endif -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) else if (qobject_cast<const QComboBox *>(widg)) ct = QStyle::CT_ComboBox; #endif @@ -1017,7 +1023,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg break; } #endif -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) case QStyle::CT_LineEdit: if (!widg || !qobject_cast<QComboBox *>(widg->parentWidget())) { //should I take into account the font dimentions of the lineedit? -Sam @@ -1145,17 +1151,17 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRect &targetRect, int h NSBezierPath *focusRingPath; if (radius > 0) { const CGFloat roundedRectInset = -1.5; - focusRingPath = [NSBezierPath bezierPathWithRoundedRect:CGRectInset(focusRingRect, roundedRectInset, roundedRectInset) + focusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(CGRectInset(focusRingRect, roundedRectInset, roundedRectInset)) xRadius:radius yRadius:radius]; } else { const CGFloat outerClipInset = -focusRingWidth / 2; - NSBezierPath *focusRingClipPath = [NSBezierPath bezierPathWithRect:CGRectInset(focusRingRect, outerClipInset, outerClipInset)]; + NSBezierPath *focusRingClipPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(CGRectInset(focusRingRect, outerClipInset, outerClipInset))]; const CGFloat innerClipInset = 1; - NSBezierPath *focusRingInnerClipPath = [NSBezierPath bezierPathWithRect:CGRectInset(focusRingRect, innerClipInset, innerClipInset)]; + NSBezierPath *focusRingInnerClipPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(CGRectInset(focusRingRect, innerClipInset, innerClipInset))]; [focusRingClipPath appendBezierPath:focusRingInnerClipPath.bezierPathByReversingPath]; [focusRingClipPath setClip]; - focusRingPath = [NSBezierPath bezierPathWithRect:focusRingRect]; + focusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRingRect)]; focusRingPath.lineJoinStyle = NSRoundLineJoinStyle; } @@ -1200,7 +1206,7 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRect &targetRect, int h QRect(focusRingPixmap.width() - shCornerSize, svCornerSize, shCornerSize, focusRingPixmap.width() - 2 * svCornerSize)); } -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const { Q_ASSERT(textRect); @@ -1263,7 +1269,7 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg *textRect = tr; } -#endif //QT_NO_TABBAR +#endif // QT_CONFIG(tabbar) QStyleHelper::WidgetSizePolicy QMacStylePrivate::effectiveAquaSizeConstrain(const QStyleOption *option, const QWidget *widg, @@ -2357,7 +2363,7 @@ void QMacStyle::polish(QWidget* w) { #ifndef QT_NO_MENU if (qobject_cast<QMenu*>(w) -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) || qobject_cast<QComboBoxPrivateContainer *>(w) #endif ) { @@ -2382,7 +2388,7 @@ void QMacStyle::polish(QWidget* w) } #endif -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) if (QTabBar *tb = qobject_cast<QTabBar*>(w)) { if (tb->documentMode()) { w->setAttribute(Qt::WA_Hover); @@ -2424,7 +2430,7 @@ void QMacStyle::unpolish(QWidget* w) w->setWindowOpacity(1.0); } -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) if (QComboBox *combo = qobject_cast<QComboBox *>(w)) { if (!combo->isEditable()) { if (QWidget *widget = combo->findChild<QComboBoxPrivateContainer *>()) @@ -2433,7 +2439,7 @@ void QMacStyle::unpolish(QWidget* w) } #endif -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) if (qobject_cast<QTabBar*>(w)) { if (!w->testAttribute(Qt::WA_SetFont)) w->setFont(qApp->font(w)); @@ -2941,7 +2947,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = QEvent::MouseButtonRelease; break; case SH_TabBar_SelectMouseType: -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) if (const QStyleOptionTabBarBase *opt2 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { ret = opt2->documentMode ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; } else @@ -2966,7 +2972,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = Qt::AlignRight; break; case SH_TabBar_Alignment: { -#ifndef QT_NO_TABWIDGET +#if QT_CONFIG(tabwidget) if (const QTabWidget *tab = qobject_cast<const QTabWidget*>(w)) { if (tab->documentMode()) { ret = Qt::AlignLeft; @@ -2974,7 +2980,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w } } #endif -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) if (const QTabBar *tab = qobject_cast<const QTabBar*>(w)) { if (tab->documentMode()) { ret = Qt::AlignLeft; @@ -3151,7 +3157,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: ret = true; break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) case SH_TabBar_CloseButtonPosition: ret = QTabBar::LeftSide; break; @@ -3282,7 +3288,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->drawPath(path); p->restore(); break; } -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) case PE_FrameTabBarBase: if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { @@ -3598,7 +3604,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } break; -#ifndef QT_NO_TABWIDGET +#if QT_CONFIG(tabwidget) case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -4112,7 +4118,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w); } break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) case CE_TabBarTabShape: if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) { if (tabOpt->documentMode) { @@ -4261,7 +4267,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; #endif -#ifndef QT_NO_DOCKWIDGET +#if QT_CONFIG(dockwidget) case CE_DockWidgetTitle: if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(w)) { bool floating = dockWidget->isFloating(); @@ -4440,7 +4446,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // Always be normal or disabled to follow the Mac style. int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize); QSize iconSize(smallIconSize, smallIconSize); -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) { iconSize = comboBox->iconSize(); } @@ -4816,7 +4822,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, int(outRect.size.height)); break; } -#ifndef QT_NO_TABWIDGET +#if QT_CONFIG(tabwidget) case SE_TabWidgetLeftCorner: if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -4949,7 +4955,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, #endif case SE_LineEditContents: rect = QCommonStyle::subElementRect(sr, opt, widget); -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) if (widget && qobject_cast<const QComboBox*>(widget->parentWidget())) rect.adjust(-1, -2, 0, 0); else @@ -5093,7 +5099,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } rect.setBottom(rect.bottom() - 1); break; -#ifndef QT_NO_TABWIDGET +#if QT_CONFIG(tabwidget) case SE_TabWidgetLayoutItem: if (const QStyleOptionTabWidgetFrame *tabWidgetOpt = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -5108,7 +5114,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } break; #endif -#ifndef QT_NO_DOCKWIDGET +#if QT_CONFIG(dockwidget) case SE_DockWidgetCloseButton: case SE_DockWidgetFloatButton: case SE_DockWidgetTitleBarText: @@ -6411,7 +6417,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, * overlap is how much the pane should overlap the tab bar */ // then add the size between the stackwidget and the "contentsRect" -#ifndef QT_NO_TABWIDGET +#if QT_CONFIG(tabwidget) if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { QSize extra(0,0); @@ -6427,7 +6433,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } #endif break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabbar) case QStyle::CT_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { const QStyleHelper::WidgetSizePolicy AquaSize = d->aquaSizeConstrain(opt, widget); @@ -6510,7 +6516,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case QStyle::CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { int maxpmw = mi->maxIconWidth; -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) const QComboBox *comboBox = qobject_cast<const QComboBox *>(widget); #endif int w = sz.width(), @@ -6521,7 +6527,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } else { h = mi->fontMetrics.height() + 2; if (!mi->icon.isNull()) { -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) if (comboBox) { const QSize &iconSize = comboBox->iconSize(); h = qMax(h, iconSize.height() + 4); @@ -6542,7 +6548,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, w += maxpmw + 6; // add space for a check. All items have place for a check too. w += 20; -#ifndef QT_NO_COMBOBOX +#if QT_CONFIG(combobox) if (comboBox && comboBox->isVisible()) { QStyleOptionComboBox cmb; cmb.initFrom(comboBox); |