Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qmacstyle_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
    4040****************************************************************************/
    4141
     42
     43
     44
     45
     46
    4247#include "qmacstyle_mac.h"
    4348
     
    4651//#define DEBUG_SIZE_CONSTRAINT
    4752
     53
    4854#include <private/qcombobox_p.h>
    4955#include <private/qmacstylepixmaps_mac_p.h>
     
    5157#include <private/qpainter_p.h>
    5258#include <private/qprintengine_mac_p.h>
     59
    5360#include <qapplication.h>
    5461#include <qbitmap.h>
     
    98105
    99106extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp
    100 extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp
    101107
    102108// The following constants are used for adjusting the size
     
    126132static const QColor mainWindowGradientEnd(200, 200, 200);
    127133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
    128148
    129149// Resolve these at run-time, since the functions was moved in Leopard.
     
    323343    }
    324344    p->setPen(borderHighlightTop);
    325     p->drawLine(0, 0, width, 0);
     345    p->drawLine(, 0, width, 0);
    326346    p->setPen(borderTop);
    327     p->drawLine(0, 1, width, 1);
     347    p->drawLine(, 1, width, 1);
    328348
    329349    // center block
    330     QRect centralRect(0, 2, width, height - 2);
     350    QRect centralRect(, 2, width, height - 2);
    331351    if (active) {
    332352        QColor mainColor = QColor(120, 120, 120);
     
    351371    }
    352372    p->setPen(borderHighlightBottom);
    353     p->drawLine(0, height - 2, width, height - 2);
     373    p->drawLine(, height - 2, width, height - 2);
    354374    p->setPen(borderBottom);
    355     p->drawLine(0, height - 1, width, height - 1);
     375    p->drawLine(, height - 1, width, height - 1);
    356376}
    357377
     
    487507                             QPainter *p, const QStyleOption *opt) const;
    488508
    489     void drawPantherTab(const QStyleOptionTab *tab, QPainter *p, const QWidget *w = 0) const;
    490 
    491509    QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
    492510
     
    541559 *****************************************************************************/
    542560extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp
    543 extern QPixmap qt_mac_convert_iconref(const IconRef, int, int); //qpixmap_mac.cpp
    544561extern QRegion qt_mac_convert_mac_region(HIShapeRef); //qregion_mac.cpp
    545562void qt_mac_dispose_rgn(RgnHandle r); //qregion_mac.cpp
     
    550567 *****************************************************************************/
    551568const int qt_mac_hitheme_version = 0; //the HITheme version we speak
    552 const int macSpinBoxSep        = 5;    // distance between spinwidget and the lineedit
    553569const int macItemFrame         = 2;    // menu item frame width
    554570const int macItemHMargin       = 3;    // menu item hor text margin
     
    563579static inline int qt_mac_hitheme_tab_version()
    564580{
    565 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    566     if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
    567         return 1;
    568 #endif
    569     return 0;
     581    return 1;
    570582}
    571583
     
    833845        break;
    834846    case QStyle::CT_HeaderSection:
    835         if (sz == QAquaSizeLarge && isTreeView(widg))
     847        if (isTreeView(widg))
    836848           ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight));
    837849        break;
     
    10331045    csz.setWidth(iconSize.width() + textRect.width()
    10341046             + ((btn->features & QStyleOptionButton::HasMenu)
    1035                             ? q->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, 0) : 0));
     1047                            ? q->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, 0) : 0));
    10361048    csz.setHeight(qMax(iconSize.height(), textRect.height()));
    10371049    return csz;
     
    14531465
    14541466    // Tiger broke reverse scroll bars so put them back and "fake it"
    1455     if (isScrollbar && (tdi->attributes & kThemeTrackRightToLeft)
    1456         && QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
     1467    if (isScrollbar && (tdi->attributes & kThemeTrackRightToLeft)) {
    14571468        tdi->attributes &= ~kThemeTrackRightToLeft;
    14581469        tdi->value = tdi->max - slider->sliderPosition;
     
    15351546    if ((defaultButton || !progressBars.isEmpty()) && timerID <= -1)
    15361547        timerID = startTimer(animateSpeed(AquaListViewItemOpen));
    1537 }
    1538 
    1539 enum { TabNormalLeft, TabNormalMid, TabNormalRight, TabSelectedActiveLeft,
    1540        TabSelectedActiveMid, TabSelectedActiveRight, TabSelectedInactiveLeft,
    1541        TabSelectedInactiveMid, TabSelectedInactiveRight, TabSelectedActiveGraphiteLeft,
    1542        TabSelectedActiveGraphiteMid, TabSelectedActiveGraphiteRight,
    1543        TabPressedLeft, TabPressedMid, TabPressedRight };
    1544 
    1545 static const char * const * const PantherTabXpms[] = {
    1546                                     qt_mac_tabnrm_left,
    1547                                     qt_mac_tabnrm_mid,
    1548                                     qt_mac_tabnrm_right,
    1549                                     qt_mac_tabselected_active_left,
    1550                                     qt_mac_tabselected_active_mid,
    1551                                     qt_mac_tabselected_active_right,
    1552                                     qt_mac_tabselected_inactive_left,
    1553                                     qt_mac_tabselected_inactive_mid,
    1554                                     qt_mac_tabselected_inactive_right,
    1555                                     qt_mac_tab_selected_active_graph_left,
    1556                                     qt_mac_tab_selected_active_graph_mid,
    1557                                     qt_mac_tab_selected_active_graph_right,
    1558                                     qt_mac_tab_press_left,
    1559                                     qt_mac_tab_press_mid,
    1560                                     qt_mac_tab_press_right};
    1561 
    1562 void QMacStylePrivate::drawPantherTab(const QStyleOptionTab *tabOpt, QPainter *p,
    1563                                       const QWidget *) const
    1564 {
    1565     QString tabKey = QLatin1String("$qt_mac_style_tab_");
    1566     int pantherTabStart;
    1567     int pantherTabMid;
    1568     int pantherTabEnd;
    1569 
    1570     ThemeTabDirection ttd = getTabDirection(tabOpt->shape);
    1571 
    1572     if (tabOpt->state & QStyle::State_Selected) {
    1573         if (!(tabOpt->state & QStyle::State_Active)) {
    1574             pantherTabStart = TabSelectedInactiveLeft;
    1575         } else {
    1576             // Draw into a pixmap to determine which version we use, Aqua or Graphite.
    1577             QPixmap tabPix(20, 20);
    1578             QPainter pixPainter(&tabPix);
    1579             HIThemeTabDrawInfo tdi;
    1580             tdi.version = 0;
    1581             tdi.style = kThemeTabFront;
    1582             tdi.direction = kThemeTabNorth;
    1583             tdi.size = kHIThemeTabSizeNormal;
    1584             tdi.adornment = kHIThemeTabAdornmentNone;
    1585             HIRect inRect = CGRectMake(0.0f, 0.0f, 20.0f, 20.0f);
    1586             HIThemeDrawTab(&inRect, &tdi, QMacCGContext(&pixPainter), kHIThemeOrientationNormal, 0);
    1587             pixPainter.end();
    1588             const QRgb GraphiteColor = 0xffa7b0ba;
    1589             QRgb pmColor = tabPix.toImage().pixel(10, 10);
    1590             if (qAbs(qRed(pmColor) - qRed(GraphiteColor)) < 3 &&
    1591                 qAbs(qGreen(pmColor) - qGreen(GraphiteColor)) < 3
    1592                 && qAbs(qBlue(pmColor) - qBlue(GraphiteColor)) < 3)
    1593                 pantherTabStart = TabSelectedActiveGraphiteLeft;
    1594             else
    1595                 pantherTabStart = TabSelectedActiveLeft;
    1596         }
    1597     } else if (tabOpt->state & QStyle::State_Sunken) {
    1598         pantherTabStart = TabPressedLeft;
    1599     } else {
    1600         pantherTabStart = TabNormalLeft;
    1601     }
    1602 
    1603 
    1604     bool doLine;
    1605     bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
    1606 
    1607     QStyleOptionTab::TabPosition tp = tabOpt->position;
    1608     if (ttd == kThemeTabWest
    1609         || ((ttd == kThemeTabNorth || ttd == kThemeTabSouth)
    1610             && tabOpt->direction == Qt::RightToLeft)) {
    1611         if (tp == QStyleOptionTab::Beginning)
    1612             tp = QStyleOptionTab::End;
    1613         else if (tp == QStyleOptionTab::End)
    1614             tp = QStyleOptionTab::Beginning;
    1615     }
    1616 
    1617     switch (tp) {
    1618     default:  // Stupid GCC, being overly pedantic
    1619     case QStyleOptionTab::Beginning:
    1620         doLine = false;
    1621         pantherTabMid = pantherTabEnd = pantherTabStart + 1;
    1622         break;
    1623     case QStyleOptionTab::Middle:
    1624         doLine = true;
    1625         pantherTabMid = pantherTabEnd = ++pantherTabStart;
    1626         break;
    1627     case QStyleOptionTab::End:
    1628         doLine = true;
    1629         pantherTabMid = ++pantherTabStart;
    1630         pantherTabEnd = pantherTabMid + 1;
    1631         break;
    1632     case QStyleOptionTab::OnlyOneTab:
    1633         doLine = false;
    1634         pantherTabMid = pantherTabStart + 1;
    1635         pantherTabEnd = pantherTabMid + 1;
    1636         break;
    1637     }
    1638 
    1639     QPixmap pmStart;
    1640     if (!QPixmapCache::find(tabKey + QString::number(pantherTabStart), pmStart)) {
    1641         pmStart = QPixmap(PantherTabXpms[pantherTabStart]);
    1642         QPixmapCache::insert(tabKey + QString::number(pantherTabStart), pmStart);
    1643     }
    1644 
    1645     QPixmap pmMid;
    1646     if (!QPixmapCache::find(tabKey + QString::number(pantherTabMid), pmMid)) {
    1647         pmMid = QPixmap(PantherTabXpms[pantherTabMid]);
    1648         QPixmapCache::insert(tabKey + QString::number(pantherTabMid), pmMid);
    1649     }
    1650 
    1651     QPixmap pmEnd;
    1652     if (!QPixmapCache::find(tabKey + QString::number(pantherTabEnd), pmEnd)) {
    1653         pmEnd = QPixmap(PantherTabXpms[pantherTabEnd]);
    1654         QPixmapCache::insert(tabKey + QString::number(pantherTabEnd), pmEnd);
    1655     }
    1656     QRect tr = tabOpt->rect;
    1657     if (verticalTabs) {
    1658         p->save();
    1659         int newX, newY, newRot;
    1660         if (tabOpt->shape == QTabBar::RoundedEast || tabOpt->shape == QTabBar::TriangularEast) {
    1661             newX = tr.width();
    1662             newY = tr.y();
    1663             newRot = 90;
    1664         } else {
    1665             newX = 0;
    1666             newY = tr.y() + tr.height();
    1667             newRot = -90;
    1668         }
    1669         tr.setRect(0, 0, tr.height(), tr.width());
    1670         QMatrix m;
    1671         if (ttd == kThemeTabEast) {
    1672             // It's lame but Apple inverts these on the East side.
    1673             m.scale(-1, 1);
    1674             m.translate(-tabOpt->rect.width(), 0);
    1675         }
    1676         m.translate(newX, newY);
    1677         m.rotate(newRot);
    1678         p->setMatrix(m, true);
    1679     }
    1680 
    1681     int x = tr.x();
    1682     int y = tr.y();
    1683     int endX = x + tr.width() - pmEnd.width();
    1684 
    1685     p->drawPixmap(x, y, pmStart.width(), tr.height(), pmStart);
    1686     if (doLine) {
    1687         QPen oldPen = p->pen();
    1688         p->setPen(QColor(0, 0, 0, 0x35));
    1689         p->drawLine(x, y + (verticalTabs ? 0 : 1), x, tr.height() - 2);
    1690     }
    1691 
    1692     for (x = x + pmStart.width(); x < endX; x += pmMid.width())
    1693         p->drawPixmap(x, y, pmMid.width(), tr.height(), pmMid);
    1694     p->drawPixmap(endX, y, pmEnd.width(), tr.height(), pmEnd);
    1695     if (verticalTabs)
    1696         p->restore();
    16971548}
    16981549
     
    19901841}
    19911842
    1992 /*!
    1993     \class QMacStyle
    1994     \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager.
    1995 
    1996     \ingroup appearance
    1997 
    1998     This class is implemented as a wrapper to the HITheme
    1999     APIs, allowing applications to be styled according to the current
    2000     theme in use on Mac OS X. This is done by having primitives
    2001     in QStyle implemented in terms of what Mac OS X would normally theme.
    2002 
    2003     \warning This style is only available on Mac OS X because it relies on the
    2004     HITheme APIs.
    2005 
    2006     There are additional issues that should be taken
    2007     into consideration to make an application compatible with the
    2008     \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html
    2009     Apple Human Interface Guidelines \endlink. Some of these issues are outlined
    2010     below.
    2011 
    2012     \list
    2013 
    2014     \i Layout - The restrictions on window layout are such that some
    2015     aspects of layout that are style-dependent cannot be achieved
    2016     using QLayout. Changes are being considered (and feedback would be
    2017     appreciated) to make layouts QStyle-able. Some of the restrictions
    2018     involve horizontal and vertical widget alignment and widget size
    2019     (covered below).
    2020 
    2021     \i Widget size - Mac OS X allows widgets to have specific fixed sizes.  Qt
    2022     does not fully implement this behavior so as to maintain cross-platform
    2023     compatibility. As a result some widgets sizes may be inappropriate (and
    2024     subsequently not rendered correctly by the HITheme APIs).The
    2025     QWidget::sizeHint() will return the appropriate size for many
    2026     managed widgets (widgets enumerated in \l QStyle::ContentsType).
    2027 
    2028     \i Effects - QMacStyle uses HITheme for performing most of the drawing, but
    2029     also uses emulation in a few cases where HITheme does not provide the
    2030     required functionality (for example, tab bars on Panther, the toolbar
    2031     separator, etc). We tried to make the emulation as close to the original as
    2032     possible. Please report any issues you see in effects or non-standard
    2033     widgets.
    2034 
    2035     \endlist
    2036 
    2037     There are other issues that need to be considered in the feel of
    2038     your application (including the general color scheme to match the
    2039     Aqua colors). The Guidelines mentioned above will remain current
    2040     with new advances and design suggestions for Mac OS X.
    2041 
    2042     Note that the functions provided by QMacStyle are
    2043     reimplementations of QStyle functions; see QStyle for their
    2044     documentation.
    2045 
    2046     \img qmacstyle.png
    2047     \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
    2048 */
    2049 
    2050 
    2051 /*!
    2052     \enum QMacStyle::WidgetSizePolicy
    2053 
    2054     \value SizeSmall
    2055     \value SizeLarge
    2056     \value SizeMini
    2057     \value SizeDefault
    2058     \omitvalue SizeNone
    2059 */
    2060 
    2061 /*!
    2062     Constructs a QMacStyle object.
    2063 */
    20641843QMacStyle::QMacStyle()
    20651844    : QWindowsStyle()
     
    20681847}
    20691848
    2070 /*!
    2071     Destructs a QMacStyle object.
    2072 */
    20731849QMacStyle::~QMacStyle()
    20741850{
     
    20841860{
    20851861    QPixmap px(4, 4);
    2086 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    2087     if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    2088         QMacCGContext cg(&px);
    2089         HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
    2090         const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height());
    2091         CGContextFillRect(cg, cgRect);
    2092     } else
    2093 #endif
    2094     {
    2095 #ifndef QT_MAC_NO_QUICKDRAW
    2096         QMacSavedPortInfo port(&px);
    2097         SetThemeBackground(kThemeBrushDialogBackgroundActive, px.depth(), true);
    2098         const Rect qdRect = { 0, 0, px.width(), px.height() };
    2099         EraseRect(&qdRect);
    2100 #endif
    2101     }
     1862    QMacCGContext cg(&px);
     1863    HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
     1864    const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height());
     1865    CGContextFillRect(cg, cgRect);
    21021866    return px;
    21031867}
     
    21071871    HIThemeSetFill us used directly if we are filling with the standard background.
    21081872*/
    2109 void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush)
    2110 {
    2111 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
     1873void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush)
     1874{
    21121875    QPoint dummy;
    21131876    const QPaintDevice *target = painter->device();
    21141877    const QPaintDevice *redirected = QPainter::redirected(target, &dummy);
    21151878    const bool usePainter = redirected && redirected != target;
    2116     const QRegion translated = rgn.translated(offset);
    2117 
    2118     if (!usePainter && QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 && qt_mac_backgroundPattern
     1879
     1880    if (!usePainter && qt_mac_backgroundPattern
    21191881        && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) {
    21201882
    2121         painter->setClipRegion(translated);
     1883        painter->setClipRegion();
    21221884
    21231885        CGContextRef cg = qt_mac_cg_context(target);
     
    21251887        HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted);
    21261888
    2127         const QVector<QRect> &rects = translated.rects();
     1889        const QVector<QRect> &rects = .rects();
    21281890        for (int i = 0; i < rects.size(); ++i) {
    21291891            const QRect rect(rects.at(i));
     
    21351897
    21361898        CGContextRestoreGState(cg);
    2137     } else
    2138 #endif
    2139     {
    2140         const QRect rect(translated.boundingRect());
    2141         painter->setClipRegion(translated);
     1899    } else {
     1900        const QRect rect(rgn.boundingRect());
     1901        painter->setClipRegion(rgn);
    21421902        painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
    21431903    }
    21441904}
    21451905
    2146 /*! \reimp */
    21471906void QMacStyle::polish(QPalette &pal)
    21481907{
    2149     if (qt_mac_backgroundPattern == 0)
     1908    if (!qt_mac_backgroundPattern) {
     1909        if (!qApp)
     1910            return;
    21501911        qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern());
     1912
    21511913
    21521914    QColor pc(Qt::black);
     
    21651927}
    21661928
    2167 /*! \reimp */
    21681929void QMacStyle::polish(QApplication *)
    21691930{
    21701931}
    21711932
    2172 /*! \reimp */
    21731933void QMacStyle::unpolish(QApplication *)
    21741934{
    21751935}
    21761936
    2177 /*! \reimp */
    21781937void QMacStyle::polish(QWidget* w)
    21791938{
     
    21931952        if (!w->testAttribute(Qt::WA_SetPalette)) {
    21941953            QPixmap px(64, 64);
     1954
    21951955            HIThemeMenuDrawInfo mtinfo;
    21961956            mtinfo.version = qt_mac_hitheme_version;
     
    22081968    }
    22091969
    2210     // Adjust the lineedit of the editable combo box
    2211     if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_3) {
    2212         if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(w)) {
    2213             if (qobject_cast<QComboBox *>(lineEdit->parentWidget())
    2214                     && !lineEdit->testAttribute(Qt::WA_SetFont)) {
    2215                 QFont font = lineEdit->font();
    2216                 font.setPointSize(font.pointSize() - 1);
    2217                 lineEdit->setFont(font);
    2218             }
    2219         }
    2220     }
    2221 
    22221970    if (QTabBar *tb = qobject_cast<QTabBar*>(w)) {
    22231971        if (tb->documentMode()) {
     
    22391987}
    22401988
    2241 /*! \reimp */
    22421989void QMacStyle::unpolish(QWidget* w)
    22431990{
     
    22702017}
    22712018
    2272 /*! \reimp */
    22732019int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const
    22742020{
     
    22822028        break;
    22832029    case PM_ToolBarIconSize:
    2284         ret = pixelMetric(PM_LargeIconSize);
     2030        ret = pixelMetric(PM_LargeIconSize);
    22852031        break;
    22862032    case PM_FocusFrameVMargin:
     
    23742120    case PM_SpinBoxFrameWidth:
    23752121        GetThemeMetric(kThemeMetricEditTextFrameOutset, &ret);
    2376         ret += 2;
     2122        switch (d->aquaSizeConstrain(opt, widget)) {
     2123        default:
     2124            ret += 2;
     2125            break;
     2126        case QAquaSizeMini:
     2127            ret += 1;
     2128            break;
     2129        }
    23772130        break;
    23782131    case PM_ButtonShiftHorizontal:
     
    24032156            QCFType<HIShapeRef> region;
    24042157            HIRect hirect = qt_hirectForQRect(tb->rect);
    2405             if (hirect.size.width == -1)
     2158            if (hirect.size.width )
    24062159                hirect.size.width = 100;
    2407             if (hirect.size.height == -1)
     2160            if (hirect.size.height )
    24082161                hirect.size.height = 30;
    24092162
     
    24492202            break;
    24502203        case QAquaSizeMini:
    2451 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) && 0
    2452             if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3) {
    2453                 GetThemeMetric(kThemeMetricMiniScrollBarWidth, &ret);
    2454                 break;
    2455             }
    2456 #endif
    24572204        case QAquaSizeSmall:
    24582205            GetThemeMetric(kThemeMetricSmallScrollBarWidth, &ret);
     
    25562303    case PM_ToolBarItemSpacing:
    25572304        ret = 4;
    2558         break;
    2559     case PM_MessageBoxIconSize:
    2560         ret = 64;
    25612305        break;
    25622306    case PM_SplitterWidth:
     
    26352379        ret = 0;
    26362380        break;
     2381
     2382
     2383
    26372384    default:
    26382385        ret = QWindowsStyle::pixelMetric(metric, opt, widget);
     
    26422389}
    26432390
    2644 /*! \reimp */
    26452391QPalette QMacStyle::standardPalette() const
    26462392{
     
    26522398}
    26532399
    2654 /*! \reimp */
    26552400int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
    26562401                         QStyleHintReturn *hret) const
     
    27982543                pix.fill(QColor(fillR, fillG, fillB));
    27992544                QPainter pix_paint(&pix);
    2800                 drawControl(CE_FocusFrame, opt, &pix_paint, w);
     2545                drawControl(CE_FocusFrame, opt, &pix_paint, w);
    28012546                pix_paint.end();
    28022547                img = pix.toImage();
     
    29472692}
    29482693
    2949 /*! \reimp */
    29502694QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
    29512695                                       const QStyleOption *opt) const
     
    29732717
    29742718
    2975 /*! \reimp */
    29762719QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
    29772720                                  const QWidget *widget) const
     
    30042747    return icon.pixmap(size, size);
    30052748}
    3006 /*!
    3007     \enum QMacStyle::FocusRectPolicy
    3008 
    3009     This type is used to signify a widget's focus rectangle policy.
    3010 
    3011     \value FocusEnabled  show a focus rectangle when the widget has focus.
    3012     \value FocusDisabled  never show a focus rectangle for the widget.
    3013     \value FocusDefault  show a focus rectangle when the widget has
    3014     focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit,
    3015     QListBox, QListView, editable QTextEdit, or one of their
    3016     subclasses.
    3017 */
    3018 
    3019 /*!
    3020     \obsolete
    3021     Sets the focus rectangle policy of \a w. The \a policy can be one of
    3022     \l{QMacStyle::FocusRectPolicy}.
    3023 
    3024     This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the
    3025     FocusDefault value does nothing anymore. If you want to set a widget back
    3026     to its default value, you must save the old value of the attribute before
    3027     you change it.
    3028 
    3029     \sa focusRectPolicy() QWidget::setAttribute()
    3030 */
     2749
    30312750void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
    30322751{
     
    30412760}
    30422761
    3043 /*!
    3044     \obsolete
    3045     Returns the focus rectangle policy for the widget \a w.
    3046 
    3047     The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}.
    3048 
    3049     In 4.3 and up this function will simply test for the
    3050     Qt::WA_MacShowFocusRect attribute and will never return
    3051     QMacStyle::FocusDefault.
    3052 
    3053     \sa setFocusRectPolicy(), QWidget::testAttribute()
    3054 */
    30552762QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w)
    30562763{
     
    30582765}
    30592766
    3060 /*!
    3061     \obsolete
    3062 
    3063     Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
    3064     or Qt::WA_MacNormalSize instead.
    3065 */
    30662767void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
    30672768{
     
    30722773}
    30732774
    3074 /*!
    3075     \obsolete
    3076 
    3077     Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
    3078     or Qt::WA_MacNormalSize instead.
    3079 */
    30802775QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
    30812776{
     
    30932788}
    30942789
    3095 /*! \reimp */
    30962790void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
    30972791                              const QWidget *w) const
     
    31642858                break;
    31652859            }
    3166             drawPrimitive(PE_FrameTabWidget, &twf, p, w);
     2860            drawPrimitive(PE_FrameTabWidget, &twf, p, w);
    31672861            p->restore();
    31682862        }
     
    32622956            // In HITheme, up is down, down is up and hamburgers eat people.
    32632957            if (header->sortIndicator != QStyleOptionHeader::None)
    3264                 drawPrimitive(
     2958                drawPrimitive(
    32652959                    (header->sortIndicator == QStyleOptionHeader::SortDown) ?
    32662960                    PE_IndicatorArrowUp : PE_IndicatorArrowDown, header, p, w);
     
    33963090                int lw = frame->lineWidth;
    33973091                if (lw <= 0)
    3398                     lw = pixelMetric(PM_DefaultFrameWidth, frame, w);
     3092                    lw = pixelMetric(PM_DefaultFrameWidth, frame, w);
    33993093                { //clear to base color
    34003094                    p->save();
     
    34213115                = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
    34223116            HIRect hirect = qt_hirectForQRect(twf->rect);
    3423 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    3424             if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    3425                 HIThemeTabPaneDrawInfo tpdi;
    3426                 tpdi.version = qt_mac_hitheme_tab_version();
    3427                 tpdi.state = tds;
    3428                 tpdi.direction = getTabDirection(twf->shape);
    3429                 tpdi.size = kHIThemeTabSizeNormal;
    3430                 if (tpdi.version == 1) {
    3431                     tpdi.kind = kHIThemeTabKindNormal;
    3432                     tpdi.adornment = kHIThemeTabPaneAdornmentNormal;
    3433                 }
    3434                 HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal);
    3435             } else
    3436 #endif
    3437             {
    3438                 HIThemeGroupBoxDrawInfo gdi;
    3439                 gdi.version = qt_mac_hitheme_version;
    3440                 gdi.state = tds;
    3441                 gdi.kind = kHIThemeGroupBoxKindSecondary;
    3442                 HIThemeDrawGroupBox(&hirect, &gdi, cg, kHIThemeOrientationNormal);
    3443             }
     3117            HIThemeTabPaneDrawInfo tpdi;
     3118            tpdi.version = qt_mac_hitheme_tab_version();
     3119            tpdi.state = tds;
     3120            tpdi.direction = getTabDirection(twf->shape);
     3121            tpdi.size = kHIThemeTabSizeNormal;
     3122            tpdi.kind = kHIThemeTabKindNormal;
     3123            tpdi.adornment = kHIThemeTabPaneAdornmentNormal;
     3124            HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal);
    34443125        }
    34453126        break;
     
    34653146            break;
    34663147        }
    3467 
    34683148        // Use the Leopard style only if the status bar is the status bar for a
    34693149        // QMainWindow with a unifed toolbar.
     
    35263206
    35273207
    3528 /*! \reimp */
    35293208void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
    35303209                            const QWidget *w) const
     
    36103289                if (opt->state & State_Enabled)
    36113290                    mode = QIcon::Normal;
    3612                 QPixmap pixmap = header->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
     3291                QPixmap pixmap = header->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
    36133292
    36143293                QRect pixr = header->rect;
    36153294                pixr.setY(header->rect.center().y() - (pixmap.height() - 1) / 2);
    3616                 drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
     3295                drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
    36173296                textr.translate(pixmap.width() + 2, 0);
    36183297            }
    36193298
    3620             drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
    3621                          header->state & State_Enabled, header->text, QPalette::ButtonText);
     3299            drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
     3300                         header->state & State_Enabled, header->text, QPalette::ButtonText);
    36223301        }
    36233302        break;
     
    36303309                int shiftX = 0;
    36313310                int shiftY = 0;
    3632                 if (tb->state & (State_Sunken | State_On)) {
    3633                     shiftX = pixelMetric(PM_ButtonShiftHorizontal, tb, w);
    3634                     shiftY = pixelMetric(PM_ButtonShiftVertical, tb, w);
     3311                bool needText = false;
     3312                int alignment = 0;
     3313                bool down = tb->state & (State_Sunken | State_On);
     3314                if (down) {
     3315                    shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, w);
     3316                    shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, tb, w);
    36353317                }
    36363318                // The down state is special for QToolButtons in a toolbar on the Mac
     
    36383320                // This doesn't really fit into any particular case in QIcon, so we
    36393321                // do the majority of the work ourselves.
    3640                 if (tb->state & State_Sunken
    3641                         && !(tb->features & QStyleOptionToolButton::Arrow)) {
     3322                if (!(tb->features & QStyleOptionToolButton::Arrow)) {
    36423323                    Qt::ToolButtonStyle tbstyle = tb->toolButtonStyle;
    36433324                    if (tb->icon.isNull() && !tb->text.isEmpty())
     
    36453326
    36463327                    switch (tbstyle) {
    3647                     case Qt::ToolButtonTextOnly:
    3648                         drawItemText(p, cr, Qt::AlignCenter, tb->palette,
    3649                                      tb->state & State_Enabled, tb->text);
    3650                         break;
     3328                    case Qt::ToolButtonTextOnly:
     3329                       
     3330                        ;
     3331                        break;
    36513332                    case Qt::ToolButtonIconOnly:
    36523333                    case Qt::ToolButtonTextBesideIcon:
     
    36543335                        QRect pr = cr;
    36553336                        QIcon::Mode iconMode = (tb->state & State_Enabled) ? QIcon::Normal
    3656                                                                                    : QIcon::Disabled;
     3337                                                                            : QIcon::Disabled;
    36573338                        QIcon::State iconState = (tb->state & State_On) ? QIcon::On
    3658                                                                                 : QIcon::Off;
     3339                                                                         : QIcon::Off;
    36593340                        QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState);
    36603341
    36613342                        // Draw the text if it's needed.
    36623343                        if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
    3663                             int alignment = 0;
     3344                            ;
    36643345                            if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
    3665                                 pr.setHeight(pixmap.size().height() + 6);
    3666                                 cr.adjust(0, pr.bottom(), 0, -3);
     3346                                pr.setHeight(pixmap.size().height());
     3347                                cr.adjust(0, pr.bottom());
    36673348                                alignment |= Qt::AlignCenter;
    36683349                            } else {
     
    36713352                                alignment |= Qt::AlignLeft | Qt::AlignVCenter;
    36723353                            }
     3354
     3355
     3356
     3357
     3358
     3359
     3360
     3361
     3362
     3363
     3364
     3365
     3366
     3367
     3368
     3369
    36733370                            cr.translate(shiftX, shiftY);
    3674                             drawItemText(p, cr, alignment, tb->palette,
    3675                                          tb->state & State_Enabled, tb->text);
    3676                             cr.adjust(0, 3, 0, -3); // the drop shadow
    3677                             drawItemText(p, cr, alignment, tb->palette,
    3678                                          tb->state & State_Enabled, tb->text);
     3371                        if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5
     3372                            && (tbstyle == Qt::ToolButtonTextOnly
     3373                                || (tbstyle != Qt::ToolButtonTextOnly && !down))) {
     3374                            QPen pen = p->pen();
     3375                            QColor light = down ? Qt::black : Qt::white;
     3376                            light.setAlphaF(0.375f);
     3377                            p->setPen(light);
     3378                            p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text);
     3379                            p->setPen(pen);
     3380                            if (down && tbstyle == Qt::ToolButtonTextOnly) {
     3381                                pal = QApplication::palette("QMenu");
     3382                                pal.setCurrentColorGroup(tb->palette.currentColorGroup());
     3383                                role = QPalette::HighlightedText;
     3384                            }
    36793385                        }
    3680                         pr.translate(shiftX, shiftY);
    3681                         pixmap = darkenPixmap(pixmap);
    3682                         drawItemPixmap(p, pr, Qt::AlignCenter, pixmap);
    3683                         break; }
     3386                        drawItemText(p, cr, alignment, pal,
     3387                                     tb->state & State_Enabled, tb->text, role);
     3388                        if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 &&
     3389                            (tb->state & State_Sunken)) {
     3390                            // Draw a "drop shadow" in earlier versions.
     3391                            drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment,
     3392                                         tb->palette, tb->state & State_Enabled, tb->text);
     3393                        }
    36843394                    }
    36853395                } else {
     
    37313441
    37323442            if (btn->features & QStyleOptionButton::HasMenu) {
    3733                 int mbi = pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
     3443                int mbi = pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
    37343444                QRect ir = btn->rect;
    37353445                HIRect arrowRect = CGRectMake(ir.right() - mbi - PushButtonRightOffset,
     
    38183528                        int contentW = textRect.width();
    38193529                        if (hasMenu)
    3820                             contentW += pixelMetric(PM_MenuButtonIndicator) + 4;
     3530                            contentW += pixelMetric(PM_MenuButtonIndicator) + 4;
    38213531                        QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
    38223532                        if (mode == QIcon::Normal && btn->state & State_HasFocus)
     
    38323542                        QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height());
    38333543                        QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect);
    3834                         drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap);
     3544                        drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap);
    38353545                        int newOffset = iconDestRect.x() + iconDestRect.width()
    38363546                                        + PushButtonContentPadding - textRect.x();
     
    38403550                    if (hasText) {
    38413551                        textRect = visualRect(btn->direction, freeContentRect, textRect);
    3842                         drawItemText(p, textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, btn->palette,
    3843                                      (btn->state & State_Enabled), btn->text, QPalette::ButtonText);
     3552                        drawItemText(p, textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, btn->palette,
     3553                                     (btn->state & State_Enabled), btn->text, QPalette::ButtonText);
    38443554                    }
    38453555                }
     
    38663576                }
    38673577            }
    3868 
    3869 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    3870             if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) {
    3871                 HIThemeTabDrawInfo tdi;
    3872                 tdi.version = 1;
    3873                 tdi.style = kThemeTabNonFront;
    3874                 tdi.direction = getTabDirection(tabOpt->shape);
    3875                 switch (d->aquaSizeConstrain(opt, w)) {
     3578            HIThemeTabDrawInfo tdi;
     3579            tdi.version = 1;
     3580            tdi.style = kThemeTabNonFront;
     3581            tdi.direction = getTabDirection(tabOpt->shape);
     3582            switch (d->aquaSizeConstrain(opt, w)) {
     3583            default:
     3584            case QAquaSizeUnknown:
     3585            case QAquaSizeLarge:
     3586                tdi.size = kHIThemeTabSizeNormal;
     3587                break;
     3588            case QAquaSizeSmall:
     3589                tdi.size = kHIThemeTabSizeSmall;
     3590                break;
     3591            case QAquaSizeMini:
     3592                tdi.size = kHIThemeTabSizeMini;
     3593                break;
     3594            }
     3595            bool verticalTabs = tdi.direction == kThemeTabWest || tdi.direction == kThemeTabEast;
     3596            QRect tabRect = tabOpt->rect;
     3597
     3598            bool selected = tabOpt->state & State_Selected;
     3599            if (selected) {
     3600                if (!(tabOpt->state & State_Active))
     3601                    tdi.style = kThemeTabFrontUnavailable;
     3602                else if (!(tabOpt->state & State_Enabled))
     3603                    tdi.style = kThemeTabFrontInactive;
     3604                else
     3605                    tdi.style = kThemeTabFront;
     3606            } else if (!(tabOpt->state & State_Active)) {
     3607                tdi.style = kThemeTabNonFrontUnavailable;
     3608            } else if (!(tabOpt->state & State_Enabled)) {
     3609                tdi.style = kThemeTabNonFrontInactive;
     3610            } else if (tabOpt->state & State_Sunken) {
     3611                tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed)
     3612            }
     3613            if (tabOpt->state & State_HasFocus)
     3614                tdi.adornment = kHIThemeTabAdornmentFocus;
     3615            else
     3616                tdi.adornment = kHIThemeTabAdornmentNone;
     3617            tdi.kind = kHIThemeTabKindNormal;
     3618            if (!verticalTabs)
     3619                tabRect.setY(tabRect.y() - 1);
     3620            else
     3621                tabRect.setX(tabRect.x() - 1);
     3622            QStyleOptionTab::TabPosition tp = tabOpt->position;
     3623            QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition;
     3624            if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) {
     3625                if (sp == QStyleOptionTab::NextIsSelected)
     3626                    sp = QStyleOptionTab::PreviousIsSelected;
     3627                else if (sp == QStyleOptionTab::PreviousIsSelected)
     3628                    sp = QStyleOptionTab::NextIsSelected;
     3629                switch (tp) {
     3630                case QStyleOptionTab::Beginning:
     3631                    tp = QStyleOptionTab::End;
     3632                    break;
     3633                case QStyleOptionTab::End:
     3634                    tp = QStyleOptionTab::Beginning;
     3635                    break;
    38763636                default:
    3877                 case QAquaSizeUnknown:
    3878                 case QAquaSizeLarge:
    3879                     tdi.size = kHIThemeTabSizeNormal;
    38803637                    break;
    3881                 case QAquaSizeSmall:
    3882                     tdi.size = kHIThemeTabSizeSmall;
    3883                     break;
    3884                 case QAquaSizeMini:
    3885                     tdi.size = kHIThemeTabSizeMini;
    3886                     break;
    3887                 }
    3888                 bool verticalTabs = tdi.direction == kThemeTabWest || tdi.direction == kThemeTabEast;
    3889                 QRect tabRect = tabOpt->rect;
    3890 
    3891                 if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) {
    3892                     d->drawPantherTab(tabOpt, p, w);
    3893                     break;
    3894                 }
    3895 
    3896                 bool selected = tabOpt->state & State_Selected;
    3897                 if (selected) {
    3898                     if (!(tabOpt->state & State_Active))
    3899                         tdi.style = kThemeTabFrontUnavailable;
    3900                     else if (!(tabOpt->state & State_Enabled))
    3901                         tdi.style = kThemeTabFrontInactive;
    3902                     else
    3903                         tdi.style = kThemeTabFront;
    3904                 } else if (!(tabOpt->state & State_Active)) {
    3905                     tdi.style = kThemeTabNonFrontUnavailable;
    3906                 } else if (!(tabOpt->state & State_Enabled)) {
    3907                     tdi.style = kThemeTabNonFrontInactive;
    3908                 } else if (tabOpt->state & State_Sunken) {
    3909                     tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed)
    3910                 }
    3911                 if (tabOpt->state & State_HasFocus)
    3912                     tdi.adornment = kHIThemeTabAdornmentFocus;
    3913                 else
    3914                     tdi.adornment = kHIThemeTabAdornmentNone;
    3915                 tdi.kind = kHIThemeTabKindNormal;
    3916                 if (!verticalTabs)
    3917                     tabRect.setY(tabRect.y() - 1);
    3918                 else
    3919                     tabRect.setX(tabRect.x() - 1);
    3920                 QStyleOptionTab::TabPosition tp = tabOpt->position;
    3921                 QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition;
    3922                 if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) {
    3923                     if (sp == QStyleOptionTab::NextIsSelected)
    3924                         sp = QStyleOptionTab::PreviousIsSelected;
    3925                     else if (sp == QStyleOptionTab::PreviousIsSelected)
    3926                         sp = QStyleOptionTab::NextIsSelected;
    3927                     switch (tp) {
    3928                         case QStyleOptionTab::Beginning:
    3929                             tp = QStyleOptionTab::End;
    3930                             break;
    3931                         case QStyleOptionTab::End:
    3932                             tp = QStyleOptionTab::Beginning;
    3933                             break;
    3934                         default:
    3935                             break;
    3936                     }
    3937                 }
    3938                 switch (tp) {
    3939                     case QStyleOptionTab::Beginning:
    3940                         tdi.position = kHIThemeTabPositionFirst;
    3941                         if (sp != QStyleOptionTab::NextIsSelected)
    3942                             tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
    3943                         break;
    3944                     case QStyleOptionTab::Middle:
    3945                         tdi.position = kHIThemeTabPositionMiddle;
    3946                         if (selected)
    3947                             tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
    3948                         if (sp != QStyleOptionTab::NextIsSelected)  // Also when we're selected.
    3949                             tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
    3950                         break;
    3951                     case QStyleOptionTab::End:
    3952                         tdi.position = kHIThemeTabPositionLast;
    3953                         if (selected)
    3954                             tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
    3955                         break;
    3956                     case QStyleOptionTab::OnlyOneTab:
    3957                         tdi.position = kHIThemeTabPositionOnly;
    3958                         break;
    3959                 }
     3638                }
     3639            }
     3640            bool stretchTabs = (!verticalTabs && tabRect.height() > 22 || verticalTabs && tabRect.width() > 22);
     3641
     3642            switch (tp) {
     3643            case QStyleOptionTab::Beginning:
     3644                tdi.position = kHIThemeTabPositionFirst;
     3645                if (sp != QStyleOptionTab::NextIsSelected || stretchTabs)
     3646                    tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
     3647                break;
     3648            case QStyleOptionTab::Middle:
     3649                tdi.position = kHIThemeTabPositionMiddle;
     3650                if (selected)
     3651                    tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
     3652                if (sp != QStyleOptionTab::NextIsSelected || stretchTabs)  // Also when we're selected.
     3653                    tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
     3654                break;
     3655            case QStyleOptionTab::End:
     3656                tdi.position = kHIThemeTabPositionLast;
     3657                if (selected)
     3658                    tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
     3659                break;
     3660            case QStyleOptionTab::OnlyOneTab:
     3661                tdi.position = kHIThemeTabPositionOnly;
     3662                break;
     3663            }
     3664            // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves.
     3665            if (stretchTabs) {
     3666                HIRect hirect = CGRectMake(0, 0, 23, 23);
     3667                QPixmap pm(23, 23);
     3668                pm.fill(Qt::transparent);
     3669                {
     3670                    QMacCGContext pmcg(&pm);
     3671                    HIThemeDrawTab(&hirect, &tdi, pmcg, kHIThemeOrientationNormal, 0);
     3672                }
     3673                QStyleHelper::drawBorderPixmap(pm, p, tabRect, 7, 7, 7, 7);
     3674            } else {
    39603675                HIRect hirect = qt_hirectForQRect(tabRect);
    39613676                HIThemeDrawTab(&hirect, &tdi, cg, kHIThemeOrientationNormal, 0);
    3962             } else
    3963 #endif
    3964             {
    3965                 d->drawPantherTab(tabOpt, p, w);
    39663677            }
    39673678        }
     
    39983709                    nr.moveTop(+1);
    39993710                    int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic;
    4000                     drawItemText(p, nr, alignment, np, tab->state & State_Enabled, tab->text, QPalette::WindowText);
     3711                    proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled,
     3712                                               tab->text, QPalette::WindowText);
    40013713                    p->restore();
    40023714                }
     
    41213833        break;
    41223834    case CE_FocusFrame: {
    4123         int xOff = pixelMetric(PM_FocusFrameHMargin, opt, w) + 1;
    4124         int yOff = pixelMetric(PM_FocusFrameVMargin, opt, w) + 1;
     3835        int xOff = pixelMetric(PM_FocusFrameHMargin, opt, w) + 1;
     3836        int yOff = pixelMetric(PM_FocusFrameVMargin, opt, w) + 1;
    41253837        HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
    41263838                                   opt->rect.height() - 2 * yOff);
     
    42453957                                                               : QIcon::Disabled;
    42463958                // Always be normal or disabled to follow the Mac style.
    4247                 int smallIconSize = pixelMetric(PM_SmallIconSize);
     3959                int smallIconSize = pixelMetric(PM_SmallIconSize);
    42483960                QSize iconSize(smallIconSize, smallIconSize);
    42493961                if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) {
     
    42803992                const int xm = macItemFrame + maxpmw + macItemHMargin;
    42813993                QFont myFont = mi->font;
    4282                 if (mi->state & QStyle::State_Mini)
    4283                     myFont.setPointSize(mi->font.pointSize());
     3994                // myFont may not have any "hard" flags set. We override
     3995                // the point size so that when it is resolved against the device, this font will win.
     3996                // This is mainly to handle cases where someone sets the font on the window
     3997                // and then the combo inherits it and passes it onward. At that point the resolve mask
     3998                // is very, very weak. This makes it stonger.
     3999                myFont.setPointSizeF(QFontInfo(mi->font).pointSizeF());
    42844000                p->setFont(myFont);
    42854001                p->drawText(xpos, yPos, contentRect.width() - xm - tabwidth + 1,
     
    43554071                                  Qt::AlignCenter | Qt::TextHideMnemonic | Qt::TextDontClip
    43564072                                  | Qt::TextSingleLine,
    4357                                   mi->icon.pixmap(pixelMetric(PM_SmallIconSize),
     4073                                  mi->icon.pixmap(pixelMetric(PM_SmallIconSize),
    43584074                          (mi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled));
    43594075            } else {
     
    44154131            else
    44164132                tdi.enableState = kThemeTrackActive;
    4417             HIThemeDrawTrack(&tdi, 0, cg, kHIThemeOrientationNormal);
     4133            HIThemeOrientation drawOrientation = kHIThemeOrientationNormal;
     4134            if (reverse) {
     4135                if (vertical) {
     4136                    drawOrientation = kHIThemeOrientationInverted;
     4137                } else {
     4138                    CGContextSaveGState(cg);
     4139                    CGContextTranslateCTM(cg, pb->rect.width(), 0);
     4140                    CGContextScaleCTM(cg, -1, 1);
     4141                }
     4142            }
     4143            HIThemeDrawTrack(&tdi, 0, cg, drawOrientation);
     4144            if (reverse && !vertical)
     4145                CGContextRestoreGState(cg);
    44184146        }
    44194147        break;
     
    45034231        // For unified tool bars, draw nothing.
    45044232        if (w) {
    4505             if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window()))
     4233            if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window()))
    45064234                if (mainWindow->unifiedTitleAndToolBarOnMac())
    45074235                    break;
     4236
    45084237        }
    45094238
     
    45504279    }
    45514280}
    4552 /*! \reimp */
     4281
    45534282QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
    45544283                                const QWidget *widget) const
     
    48444573}
    48454574
    4846 /*! \reimp */
    48474575void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
    48484576                                   const QWidget *widget) const
     
    48754603                        // because on Tiger I only "fake" the reverse stuff.
    48764604                        bool reverseHorizontal = (slider->direction == Qt::RightToLeft
    4877                                                   && slider->orientation == Qt::Horizontal
    4878                                                   && (!slider->upsideDown
    4879                                                       || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4
    4880                                                           && slider->upsideDown)));
     4605                                                  && slider->orientation == Qt::Horizontal);
    48814606                        if ((reverseHorizontal
    48824607                             && slider->activeSubControls == SC_ScrollBarAddLine)
     
    49134638            // there is not enough space for them.
    49144639            if (cc == CC_ScrollBar) {
    4915                 const int scrollBarLenght = (slider->orientation == Qt::Horizontal)
     4640                const int scrollBarLeng = (slider->orientation == Qt::Horizontal)
    49164641                    ? slider->rect.width() : slider->rect.height();
    49174642                const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget);
    4918                 if (scrollBarLenght < scrollButtonsCutoffSize(thumbIndicatorCutoff, sizePolicy))
     4643                if (scrollBarLeng < scrollButtonsCutoffSize(thumbIndicatorCutoff, sizePolicy))
    49194644                    tdi.attributes &= ~kThemeTrackShowThumb;
    4920                 if (scrollBarLenght < scrollButtonsCutoffSize(scrollButtonsCutoff, sizePolicy))
     4645                if (scrollBarLeng < scrollButtonsCutoffSize(scrollButtonsCutoff, sizePolicy))
    49214646                    tdi.enableState = kThemeTrackNothingToScroll;
    49224647            }
     
    49804705                        if (item.state & State_Open)
    49814706                            treeOpt.state |= State_Open;
    4982                         drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget);
     4707                        drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget);
    49834708                    }
    49844709                    y += item.totalHeight;
     
    49944719                GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
    49954720
    4996                 QRect lineeditRect = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget);
     4721                QRect lineeditRect = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget);
    49974722                lineeditRect.adjust(-frame_size, -frame_size, +frame_size, +frame_size);
    49984723
     
    50154740                        break;
    50164741                    case QAquaSizeMini:
     4742
     4743
    50174744                    case QAquaSizeSmall:
    5018                         if (aquaSize == QAquaSizeMini)
    5019                             bdi.kind = kThemeIncDecButtonMini;
    5020                         else
    5021                             bdi.kind = kThemeIncDecButtonSmall;
     4745                        bdi.kind = kThemeIncDecButtonSmall;
    50224746                        break;
    50234747                }
     
    50394763                bdi.adornment = kThemeAdornmentNone;
    50404764
    5041                 QRect updown = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp,
    5042                                                  widget);
    5043                 updown |= subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
     4765                QRect updown =
     4766
     4767                updown |= subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
    50444768                HIRect newRect = qt_hirectForQRect(updown);
    50454769                QRect off_rct;
     
    50504774                                int(outRect.size.width - newRect.size.width),
    50514775                                int(outRect.size.height - newRect.size.height));
    5052 
    5053                 // HIThemeGetButtonBackgroundBounds offsets non-focused normal sized
    5054                 // buttons by one in de y direction, account for that here.
    5055                 if (bdi.adornment == kThemeAdornmentNone && bdi.kind == kThemeIncDecButton)
    5056                     off_rct.adjust(0, 1, 0, 0);
    5057 
    5058                 // Adjust the rect for small buttos also.
    5059                 if (bdi.adornment == kThemeAdornmentFocus && bdi.kind == kThemeIncDecButtonSmall)
    5060                     off_rct.adjust(0, 0, 0, -1);
    50614776
    50624777                newRect = qt_hirectForQRect(updown, off_rct);
     
    51294844                ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox;
    51304845                bool active = titlebar->state & State_Active;
    5131                 int border = 2;
    5132                 titleBarRect.origin.x += border;
    5133                 titleBarRect.origin.y -= border;
     4846                if (qMacVersion() < QSysInfo::MV_10_6) {
     4847                    int border = 2;
     4848                    titleBarRect.origin.x += border;
     4849                    titleBarRect.origin.y -= border;
     4850                }
    51344851
    51354852                while (sc <= SC_TitleBarCloseButton) {
     
    51634880                    ptrHIShapeGetBounds(titleRegion2, &tmpRect);
    51644881                    if (tmpRect.size.width != 1) {
    5165                         int iconExtent = pixelMetric(PM_SmallIconSize);
     4882                        int iconExtent = pixelMetric(PM_SmallIconSize);
    51664883                        iw = titlebar->icon.actualSize(QSize(iconExtent, iconExtent)).width();
    51674884                    }
     
    51814898                        x += br.width() / 2 - p->fontMetrics().width(titlebar->text) / 2;
    51824899                    if (iw)
    5183                         p->drawPixmap(x - iw, y, titlebar->icon.pixmap(pixelMetric(PM_SmallIconSize), QIcon::Normal));
     4900                        p->drawPixmap(x - iw, y,
     4901                                      titlebar->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), QIcon::Normal));
    51844902                    drawItemText(p, br, Qt::AlignCenter, opt->palette, tds == kThemeStateActive,
    51854903                                    titlebar->text, QPalette::Text);
     
    52184936                tti.truncationMaxLines = 1 + groupBox->text.count(QLatin1Char('\n'));
    52194937                QCFString groupText = qt_mac_removeMnemonics(groupBox->text);
    5220                 QRect r = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
     4938                QRect r = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
    52214939                HIRect bounds = qt_hirectForQRect(r);
    52224940                HIThemeDrawTextBox(groupText, &bounds, &tti, cg, kHIThemeOrientationNormal);
     
    52314949                if (tb->subControls & SC_ToolButtonMenu) {
    52324950                    QStyleOption arrowOpt(0);
    5233                     arrowOpt.rect = subControlRect(cc, tb, SC_ToolButtonMenu, widget);
     4951                    arrowOpt.rect = subControlRect(cc, tb, SC_ToolButtonMenu, widget);
    52344952                    arrowOpt.rect.setY(arrowOpt.rect.y() + arrowOpt.rect.height() / 2);
    52354953                    arrowOpt.rect.setHeight(arrowOpt.rect.height() / 2);
    52364954                    arrowOpt.state = tb->state;
    52374955                    arrowOpt.palette = tb->palette;
    5238                     drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
    5239                 } else if (tb->features & QStyleOptionToolButton::HasMenu) {
     4956                    proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
     4957                } else if ((tb->features & QStyleOptionToolButton::HasMenu)
     4958                            && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) {
    52404959                    drawToolbarButtonArrow(tb->rect, tds, cg);
    52414960                }
    52424961                if (tb->state & State_On) {
    5243                     QPen oldPen = p->pen();
    5244                     p->setPen(QColor(0, 0, 0, 0x3a));
    5245                     p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12));
    5246                     p->drawLine(tb->rect.left() + 1, tb->rect.top(),
    5247                                 tb->rect.right() - 1, tb->rect.top());
    5248                     p->drawLine(tb->rect.left() + 1, tb->rect.bottom(),
    5249                                 tb->rect.right() - 1, tb->rect.bottom());
    5250                     p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft());
    5251                     p->drawLine(tb->rect.topRight(), tb->rect.bottomRight());
    5252                     p->setPen(oldPen);
    5253                 }
    5254                 drawControl(CE_ToolButtonLabel, opt, p, widget);
     4962                    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
     4963                        static QPixmap pm(QLatin1String(":/trolltech/mac/style/images/leopard-unified-toolbar-on.png"));
     4964                        p->setRenderHint(QPainter::SmoothPixmapTransform);
     4965                        QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);
     4966                    } else {
     4967                        QPen oldPen = p->pen();
     4968                        p->setPen(QColor(0, 0, 0, 0x3a));
     4969                        p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12));
     4970                        p->drawLine(tb->rect.left() + 1, tb->rect.top(),
     4971                                    tb->rect.right() - 1, tb->rect.top());
     4972                        p->drawLine(tb->rect.left() + 1, tb->rect.bottom(),
     4973                                    tb->rect.right() - 1, tb->rect.bottom());
     4974                        p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft());
     4975                        p->drawLine(tb->rect.topRight(), tb->rect.bottomRight());
     4976                        p->setPen(oldPen);
     4977                    }
     4978                }
     4979                proxy()->drawControl(CE_ToolButtonLabel, opt, p, widget);
    52554980            } else {
    52564981                ThemeButtonKind bkind = kThemeBevelButton;
     
    52614986                    break;
    52624987                case QAquaSizeMini:
    5263 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) && 0
    5264                     if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3) {
    5265                         bkind = kThemeMiniBevelButton;
    5266                         break;
    5267                     }
    5268 #endif
    52694988                case QAquaSizeSmall:
    52704989                    bkind = kThemeSmallBevelButton;
     
    52734992
    52744993                QRect button, menuarea;
    5275                 button   = subControlRect(cc, tb, SC_ToolButton, widget);
    5276                 menuarea = subControlRect(cc, tb, SC_ToolButtonMenu, widget);
     4994                button   = subControlRect(cc, tb, SC_ToolButton, widget);
     4995                menuarea = subControlRect(cc, tb, SC_ToolButtonMenu, widget);
    52774996                State bflags = tb->state,
    52784997                mflags = tb->state;
     
    53375056                    drawToolbarButtonArrow(tb->rect, tds, cg);
    53385057                }
    5339                 QRect buttonRect = subControlRect(CC_ToolButton, tb, SC_ToolButton, widget);
    5340                 int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);
     5058                QRect buttonRect = subControlRect(CC_ToolButton, tb, SC_ToolButton, widget);
     5059                int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);
    53415060                QStyleOptionToolButton label = *tb;
    53425061                label.rect = buttonRect.adjusted(fw, fw, -fw, -fw);
    5343                 drawControl(CE_ToolButtonLabel, &label, p, widget);
    5344             }
    5345         }
     5062                proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
     5063            }
     5064        }
     5065        break;
     5066    case CC_Dial:
     5067        if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt))
     5068            QStyleHelper::drawDial(dial, p);
    53465069        break;
    53475070    default:
     
    53515074}
    53525075
    5353 /*! \reimp */
    53545076QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
    53555077                                                    const QStyleOptionComplex *opt,
     
    53925114            // The arrow buttons are not drawn if the scroll bar is to short,
    53935115            // exclude them from the hit test.
    5394             const int scrollBarLenght = (sb->orientation == Qt::Horizontal)
     5116            const int scrollBarLeng = (sb->orientation == Qt::Horizontal)
    53955117                ? sb->rect.width() : sb->rect.height();
    5396             if (scrollBarLenght < scrollButtonsCutoffSize(scrollButtonsCutoff, widgetSizePolicy(widget)))
     5118            if (scrollBarLeng < scrollButtonsCutoffSize(scrollButtonsCutoff, widgetSizePolicy(widget)))
    53975119                sbi.enableState = kThemeTrackNothingToScroll;
    53985120
     
    54825204}
    54835205
    5484 /*! \reimp */
    54855206QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
    54865207                                const QWidget *widget) const
     
    55135234                                                            : kControlDownButtonPart;
    55145235                    if (slider->direction == Qt::RightToLeft
    5515                         && slider->orientation == Qt::Horizontal
    5516                         && (!slider->upsideDown
    5517                             || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4
    5518                                 && slider->upsideDown))
    5519                         ) {
     5236                        && slider->orientation == Qt::Horizontal) {
    55205237                        if (cpc == kControlDownButtonPart)
    55215238                            cpc = kControlUpButtonPart;
     
    55705287                wrc = kWindowTitleTextRgn;
    55715288            else if (sc == SC_TitleBarSysMenu)
    5572                 ret.setRect(-1024, -1024, 10, pixelMetric(PM_TitleBarHeight,
     5289                ret.setRect(-1024, -1024, 10, pixelMetric(PM_TitleBarHeight,
    55735290                                                             titlebar, widget));
    55745291            if (wrc != kWindowGlobalPortRgn) {
     
    56065323                ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
    56075324                ret.setX(ret.x() + ret.width());
    5608                 ret.setWidth(combo->rect.width() - ret.width() - ret.x());
     5325                ret.setWidth(combo->rect.());
    56095326                break; }
    56105327            case SC_ComboBoxListBoxPopup:{
     
    56125329                    HIRect inner = QMacStylePrivate::comboboxInnerBounds(qt_hirectForQRect(combo->rect), bdi.kind);
    56135330                    QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
    5614                     ret.adjust(qRound(inner.origin.x), 0, qRound(inner.origin.x + inner.size.width), editRect.y() + editRect.height() + 2);
     5331                    const int comboTop = combo->rect.top();
     5332                    ret = QRect(qRound(inner.origin.x),
     5333                                comboTop,
     5334                                qRound(inner.origin.x - combo->rect.left() + inner.size.width),
     5335                                editRect.bottom() - comboTop + 2);
    56155336                } else {
    56165337                    QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
    5617                     ret.adjust(4 - 11, 1, editRect.width() + 10 + 11, 1);
     5338                    ret = QRect(combo->rect.x() + 4 - 11,
     5339                                combo->rect.y() + 1,
     5340                                editRect.width() + 10 + 11,
     5341                                1);
    56185342                 }
    56195343                break; }
     
    56675391                QRect labelRect = alignedRect(groupBox->direction, groupBox->textAlignment,
    56685392                                              QSize(tw, h), ret);
    5669                 int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget);
     5393                int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget);
    56705394                bool rtl = groupBox->direction == Qt::RightToLeft;
    56715395                if (sc == SC_GroupBoxLabel) {
     
    56895413                    int left = rtl ? labelRect.right() - indicatorWidth : labelRect.left();
    56905414                    ret.setRect(left, ret.top(),
    5691                                 indicatorWidth, pixelMetric(PM_IndicatorHeight, opt, widget));
     5415                                indicatorWidth, pixelMetric(PM_IndicatorHeight, opt, widget));
    56925416                }
    56935417                break;
     
    57245448    case CC_SpinBox:
    57255449        if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
    5726             const int spinner_w = 14,
    5727                       fw = pixelMetric(PM_SpinBoxFrameWidth, spin, widget);
     5450            QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget);
     5451            int spinner_w;
     5452            int spinBoxSep;
     5453            int fw = proxy()->pixelMetric(PM_SpinBoxFrameWidth, spin, widget);
     5454            switch (aquaSize) {
     5455            default:
     5456            case QAquaSizeUnknown:
     5457            case QAquaSizeLarge:
     5458                spinner_w = 14;
     5459                spinBoxSep = 2;
     5460                break;
     5461            case QAquaSizeSmall:
     5462                spinner_w = 12;
     5463                spinBoxSep = 2;
     5464                break;
     5465            case QAquaSizeMini:
     5466                spinner_w = 10;
     5467                spinBoxSep = 1;
     5468                break;
     5469            }
     5470
    57285471            switch (sc) {
    57295472            case SC_SpinBoxUp:
     
    57315474                if (spin->buttonSymbols == QAbstractSpinBox::NoButtons)
    57325475                    break;
    5733                 const int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, spin, widget);
    5734                 const int spinner_w = 18;
    5735                 const int y = frameWidth;
    5736                 const int x = spin->rect.width() - spinner_w + frameWidth;
     5476
     5477                const int y = fw;
     5478                const int x = spin->rect.width() - spinner_w;
    57375479                ret.setRect(x + spin->rect.x(), y + spin->rect.y(), spinner_w, spin->rect.height() - y * 2);
    57385480                HIThemeButtonDrawInfo bdi;
    57395481                bdi.version = qt_mac_hitheme_version;
    57405482                bdi.kind = kThemeIncDecButton;
    5741                 QAquaWidgetSize aquaSize = d->aquaSizeConstrain(opt, widget);
     5483                ;
    57425484                switch (aquaSize) {
    5743                     case QAquaSizeUnknown:
    5744                     case QAquaSizeLarge:
    5745                         bdi.kind = kThemeIncDecButton;
    5746                         break;
    5747                     case QAquaSizeMini:
    5748                     case QAquaSizeSmall:
    5749                         if (aquaSize == QAquaSizeMini)
    5750                             bdi.kind = kThemeIncDecButtonMini;
    5751                         else
    5752                             bdi.kind = kThemeIncDecButtonSmall;
    5753                         break;
     5485                default:
     5486                case QAquaSizeUnknown:
     5487                case QAquaSizeLarge:
     5488                    bdi.kind = kThemeIncDecButton;
     5489                    hackTranslateX = 0;
     5490                    break;
     5491                case QAquaSizeSmall:
     5492                    bdi.kind = kThemeIncDecButtonSmall;
     5493                    hackTranslateX = -2;
     5494                    break;
     5495                case QAquaSizeMini:
     5496                    bdi.kind = kThemeIncDecButtonMini;
     5497                    hackTranslateX = -1;
     5498                    break;
    57545499                }
    57555500                bdi.state = kThemeStateActive;
     
    57575502                bdi.adornment = kThemeAdornmentNone;
    57585503                HIRect hirect = qt_hirectForQRect(ret);
     5504
    57595505                HIRect outRect;
    57605506                HIThemeGetButtonBackgroundBounds(&hirect, &bdi, &outRect);
     
    57715517                    break;
    57725518                }
    5773                 ret.translate(-1, -2); // hack: position the buttons correctly (weird that we need this)
     5519                ret.translate(); // hack: position the buttons correctly (weird that we need this)
    57745520                ret = visualRect(spin->direction, spin->rect, ret);
    57755521                break;
    57765522            }
    57775523            case SC_SpinBoxEditField:
    5778                 ret.setRect(fw, fw,
    5779                             spin->rect.width() - spinner_w - fw * 2 - macSpinBoxSep + 1,
    5780                             spin->rect.height() - fw * 2);
     5524                if (spin->buttonSymbols == QAbstractSpinBox::NoButtons) {
     5525                    ret.setRect(fw, fw,
     5526                                spin->rect.width() - fw * 2,
     5527                                spin->rect.height() - fw * 2);
     5528                } else {
     5529                    ret.setRect(fw, fw,
     5530                                spin->rect.width() - fw * 2 - spinBoxSep - spinner_w,
     5531                                spin->rect.height() - fw * 2);
     5532                }
    57815533                ret = visualRect(spin->direction, spin->rect, ret);
    57825534                break;
     
    58005552}
    58015553
    5802 /*! \reimp */
    58035554QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
    58045555                                  const QSize &csz, const QWidget *widget) const
     
    58095560    switch (ct) {
    58105561    case QStyle::CT_SpinBox:
    5811         sz.setWidth(sz.width() + macSpinBoxSep);
    5812         sz.setHeight(sz.height() - 3); // hack to work around horrible sizeHint() code in QAbstractSpinBox
     5562       
     5563        sz.setHeight(sz.height() - 3);
    58135564        break;
    58145565    case QStyle::CT_TabBarTab:
    58155566        if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
    5816             bool newStyleTabs =
    5817 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    5818                 QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 ? true :
    5819 #endif
    5820                 false;
    58215567            const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget);
    58225568            const bool differentFont = (widget && widget->testAttribute(Qt::WA_SetFont))
     
    58265572            if (vertTabs)
    58275573                sz.transpose();
    5828             if (newStyleTabs) {
    5829                 int defaultTabHeight;
    5830                 int defaultExtraSpace = pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK)
    5831                 QFontMetrics fm = opt->fontMetrics;
    5832                 switch (AquaSize) {
    5833                 case QAquaSizeUnknown:
    5834                 case QAquaSizeLarge:
    5835                     if (tab->documentMode)
    5836                         defaultTabHeight = 23;
    5837                     else
    5838                         defaultTabHeight = 21;
    5839                     break;
    5840                 case QAquaSizeSmall:
    5841                     defaultTabHeight = 18;
    5842                     break;
    5843                 case QAquaSizeMini:
    5844                     defaultTabHeight = 16;
    5845                     break;
    5846                 }
    5847 
    5848                 bool setWidth = false;
    5849                 if (differentFont || !tab->icon.isNull()) {
    5850                     sz.rheight() = qMax(defaultTabHeight, sz.height());
    5851                 } else {
    5852                     QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text);
    5853                     sz.rheight() = qMax(defaultTabHeight, textSize.height());
    5854                     sz.rwidth() = textSize.width() + defaultExtraSpace;
    5855                     setWidth = true;
    5856                 }
    5857 
    5858                 if (vertTabs)
    5859                     sz.transpose();
    5860 
    5861                 int maxWidgetHeight = qMax(tab->leftButtonSize.height(), tab->rightButtonSize.height());
    5862                 int maxWidgetWidth = qMax(tab->leftButtonSize.width(), tab->rightButtonSize.width());
    5863 
    5864                 int widgetWidth = 0;
    5865                 int widgetHeight = 0;
    5866                 int padding = 0;
    5867                 if (tab->leftButtonSize.isValid()) {
    5868                     padding += 8;
    5869                     widgetWidth += tab->leftButtonSize.width();
    5870                     widgetHeight += tab->leftButtonSize.height();
    5871                 }
    5872                 if (tab->rightButtonSize.isValid()) {
    5873                     padding += 8;
    5874                     widgetWidth += tab->rightButtonSize.width();
    5875                     widgetHeight += tab->rightButtonSize.height();
    5876                 }
    5877 
    5878                 if (vertTabs) {
    5879                     sz.setHeight(sz.height() + widgetHeight + padding);
    5880                     sz.setWidth(qMax(sz.width(), maxWidgetWidth));
    5881                 } else {
    5882                     if (setWidth)
    5883                         sz.setWidth(sz.width() + widgetWidth + padding);
    5884                     sz.setHeight(qMax(sz.height(), maxWidgetHeight));
    5885                 }
     5574            int defaultTabHeight;
     5575            int defaultExtraSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK)
     5576            QFontMetrics fm = opt->fontMetrics;
     5577            switch (AquaSize) {
     5578            case QAquaSizeUnknown:
     5579            case QAquaSizeLarge:
     5580                if (tab->documentMode)
     5581                    defaultTabHeight = 23;
     5582                else
     5583                    defaultTabHeight = 21;
     5584                break;
     5585            case QAquaSizeSmall:
     5586                defaultTabHeight = 18;
     5587                break;
     5588            case QAquaSizeMini:
     5589                defaultTabHeight = 16;
     5590                break;
     5591            }
     5592            bool setWidth = false;
     5593            if (differentFont || !tab->icon.isNull()) {
     5594                sz.rheight() = qMax(defaultTabHeight, sz.height());
    58865595            } else {
    5887                 SInt32 tabh = sz.height();
    5888                 SInt32 overlap = 0;
    5889                 switch (AquaSize) {
    5890                 default:
    5891                 case QAquaSizeUnknown:
    5892                 case QAquaSizeLarge:
    5893                     GetThemeMetric(kThemeLargeTabHeight, &tabh);
    5894                     GetThemeMetric(kThemeMetricTabFrameOverlap, &overlap);
    5895                     break;
    5896                 case QAquaSizeMini:
    5897                     GetThemeMetric(kThemeMetricMiniTabHeight, &tabh);
    5898                     GetThemeMetric(kThemeMetricMiniTabFrameOverlap, &overlap);
    5899                     break;
    5900                 case QAquaSizeSmall:
    5901                     GetThemeMetric(kThemeSmallTabHeight, &tabh);
    5902                     GetThemeMetric(kThemeMetricSmallTabFrameOverlap, &overlap);
    5903                     break;
    5904                 }
    5905                 tabh += overlap;
    5906                 if (sz.height() < tabh)
    5907                     sz.rheight() = tabh;
     5596                QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text);
     5597                sz.rheight() = qMax(defaultTabHeight, textSize.height());
     5598                sz.rwidth() = textSize.width() + defaultExtraSpace;
     5599                setWidth = true;
     5600            }
     5601
     5602            if (vertTabs)
     5603                sz.transpose();
     5604
     5605            int maxWidgetHeight = qMax(tab->leftButtonSize.height(), tab->rightButtonSize.height());
     5606            int maxWidgetWidth = qMax(tab->leftButtonSize.width(), tab->rightButtonSize.width());
     5607
     5608            int widgetWidth = 0;
     5609            int widgetHeight = 0;
     5610            int padding = 0;
     5611            if (tab->leftButtonSize.isValid()) {
     5612                padding += 8;
     5613                widgetWidth += tab->leftButtonSize.width();
     5614                widgetHeight += tab->leftButtonSize.height();
     5615            }
     5616            if (tab->rightButtonSize.isValid()) {
     5617                padding += 8;
     5618                widgetWidth += tab->rightButtonSize.width();
     5619                widgetHeight += tab->rightButtonSize.height();
     5620            }
     5621
     5622            if (vertTabs) {
     5623                sz.setHeight(sz.height() + widgetHeight + padding);
     5624                sz.setWidth(qMax(sz.width(), maxWidgetWidth));
     5625            } else {
     5626                if (setWidth)
     5627                    sz.setWidth(sz.width() + widgetWidth + padding);
     5628                sz.setHeight(qMax(sz.height(), maxWidgetHeight));
    59085629            }
    59095630        }
     
    59355656                        maxpmw = qMax(maxpmw, iconSize.width());
    59365657                    } else {
    5937                         int iconExtent = pixelMetric(PM_SmallIconSize);
     5658                        int iconExtent = pixelMetric(PM_SmallIconSize);
    59385659                        h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
    59395660                    }
     
    59645685        break;
    59655686    case CT_ToolButton:
     5687
     5688
     5689
     5690
     5691
     5692
     5693
     5694
    59665695        sz.rwidth() += 10;
    59675696        sz.rheight() += 10;
     
    59745703        QStyleOption myOption = *opt;
    59755704        myOption.rect.setSize(sz);
    5976         if (styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) {
     5705        if (styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) {
    59775706            sz = menuMask.region.boundingRect().size();
    59785707        }
     
    60875816}
    60885817
    6089 /*!
    6090     \reimp
    6091 */
    60925818void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
    60935819                             bool enabled, const QString &text, QPalette::ColorRole textRole) const
     
    60985824}
    60995825
    6100 /*!
    6101   \reimp
    6102 */
    61035826bool QMacStyle::event(QEvent *e)
    61045827{
     
    61495872}
    61505873
    6151 void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon = QStyle::SP_CustomBase)
    6152 {
    6153     int size = 16;
    6154     while (size <= 128) {
    6155 
    6156         const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size);
    6157         QPixmap mainIcon;
    6158         if (standardIcon >= QStyle::SP_CustomBase) {
    6159             mainIcon = qt_mac_convert_iconref(icon, size, size);
    6160         } else if (QPixmapCache::find(cacheKey, mainIcon) == false) {
    6161             mainIcon = qt_mac_convert_iconref(icon, size, size);
    6162             QPixmapCache::insert(cacheKey, mainIcon);
    6163         }
    6164 
    6165         if (overlayIcon) {
    6166             int littleSize = size / 2;
    6167             QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize, littleSize);
    6168             QPainter painter(&mainIcon);
    6169             painter.drawPixmap(size - littleSize, size - littleSize, overlayPix);
    6170         }
    6171 
    6172         retIcon->addPixmap(mainIcon);
    6173         size += size;  // 16 -> 32 -> 64 -> 128
    6174     }
    6175 }
    6176 
    6177 /*!
    6178     \internal
    6179 */
    61805874QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
    61815875                                            const QWidget *widget) const
    61825876{
    6183     OSType iconType = 0;
    61845877    switch (standardIcon) {
    6185     case QStyle::SP_MessageBoxQuestion:
    6186     case QStyle::SP_MessageBoxInformation:
    6187     case QStyle::SP_MessageBoxWarning:
    6188     case QStyle::SP_MessageBoxCritical:
    6189         iconType = kGenericApplicationIcon;
    6190         break;
    6191     case SP_DesktopIcon:
    6192         iconType = kDesktopIcon;
    6193         break;
    6194     case SP_TrashIcon:
    6195         iconType = kTrashIcon;
    6196         break;
    6197 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    6198     case SP_ComputerIcon:
    6199         iconType = kComputerIcon;
    6200         break;
    6201 #endif
    6202     case SP_DriveFDIcon:
    6203         iconType = kGenericFloppyIcon;
    6204         break;
    6205     case SP_DriveHDIcon:
    6206         iconType = kGenericHardDiskIcon;
    6207         break;
    6208     case SP_DriveCDIcon:
    6209     case SP_DriveDVDIcon:
    6210         iconType = kGenericCDROMIcon;
    6211         break;
    6212     case SP_DriveNetIcon:
    6213         iconType = kGenericNetworkIcon;
    6214         break;
    6215     case SP_DirOpenIcon:
    6216         iconType = kOpenFolderIcon;
    6217         break;
    6218     case SP_DirClosedIcon:
    6219     case SP_DirLinkIcon:
    6220         iconType = kGenericFolderIcon;
    6221         break;
    6222     case SP_FileLinkIcon:
    6223     case SP_FileIcon:
    6224         iconType = kGenericDocumentIcon;
    6225         break;
     5878    default:
     5879        return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget);
    62265880    case SP_ToolBarHorizontalExtensionButton:
    62275881    case SP_ToolBarVerticalExtensionButton: {
     
    62375891        }
    62385892        return pixmap;
    6239         }
    6240         break;
    6241     case SP_DirIcon: {
    6242         // A rather special case
    6243         QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, opt, widget);
    6244         QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, opt, widget);
    6245         closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On);
    6246         closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On);
    6247         closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On);
    6248         closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On);
    6249         return closeIcon;
    6250     }
    6251     case SP_TitleBarNormalButton:
    6252     case SP_TitleBarCloseButton: {
    6253         QIcon titleBarIcon;
    6254         if (standardIcon == SP_TitleBarCloseButton) {
    6255             titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png"));
    6256             titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
    6257         } else {
    6258             titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png"));
    6259             titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
    6260         }
    6261         return titleBarIcon;
    6262     }
    6263     default:
    6264         break;
    6265     }
    6266     if (iconType != 0) {
    6267         QIcon retIcon;
    6268         IconRef icon;
    6269         IconRef overlayIcon = 0;
    6270         if (iconType != kGenericApplicationIcon) {
    6271             GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon);
    6272         } else {
    6273             FSRef fsRef;
    6274             ProcessSerialNumber psn = { 0, kCurrentProcess };
    6275             GetProcessBundleLocation(&psn, &fsRef);
    6276             GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0);
    6277             if (standardIcon == SP_MessageBoxCritical) {
    6278                 overlayIcon = icon;
    6279                 GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon);
    6280             }
    6281         }
    6282         if (icon) {
    6283             qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon);
    6284             ReleaseIconRef(icon);
    6285         }
    6286         if (overlayIcon)
    6287             ReleaseIconRef(overlayIcon);
    6288         return retIcon;
    6289     }
    6290     return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget);
    6291 }
    6292 
    6293 /*!
    6294   \internal
    6295 */
     5893    }
     5894    }
     5895}
     5896
    62965897int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
    62975898                                           QSizePolicy::ControlType control2,
Note: See TracChangeset for help on using the changeset viewer.