src/gui/styles/qmacstyle_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   340     } else {
   340     } else {
   341         borderTop = QColor(135, 135, 135);
   341         borderTop = QColor(135, 135, 135);
   342         borderHighlightTop = QColor(207, 207, 207);
   342         borderHighlightTop = QColor(207, 207, 207);
   343     }
   343     }
   344     p->setPen(borderHighlightTop);
   344     p->setPen(borderHighlightTop);
   345     p->drawLine(0, 0, width, 0);
   345     p->drawLine(tabRect.x(), 0, width, 0);
   346     p->setPen(borderTop);
   346     p->setPen(borderTop);
   347     p->drawLine(0, 1, width, 1);
   347     p->drawLine(tabRect.x(), 1, width, 1);
   348 
   348 
   349     // center block
   349     // center block
   350     QRect centralRect(0, 2, width, height - 2);
   350     QRect centralRect(tabRect.x(), 2, width, height - 2);
   351     if (active) {
   351     if (active) {
   352         QColor mainColor = QColor(120, 120, 120);
   352         QColor mainColor = QColor(120, 120, 120);
   353         p->fillRect(centralRect, mainColor);
   353         p->fillRect(centralRect, mainColor);
   354     } else {
   354     } else {
   355         QLinearGradient gradient(centralRect.topLeft(), centralRect.bottomLeft());
   355         QLinearGradient gradient(centralRect.topLeft(), centralRect.bottomLeft());
   368     } else {
   368     } else {
   369         borderHighlightBottom = QColor(177, 177, 177);
   369         borderHighlightBottom = QColor(177, 177, 177);
   370         borderBottom = QColor(127, 127, 127);
   370         borderBottom = QColor(127, 127, 127);
   371     }
   371     }
   372     p->setPen(borderHighlightBottom);
   372     p->setPen(borderHighlightBottom);
   373     p->drawLine(0, height - 2, width, height - 2);
   373     p->drawLine(tabRect.x(), height - 2, width, height - 2);
   374     p->setPen(borderBottom);
   374     p->setPen(borderBottom);
   375     p->drawLine(0, height - 1, width, height - 1);
   375     p->drawLine(tabRect.x(), height - 1, width, height - 1);
   376 }
   376 }
   377 
   377 
   378 /*
   378 /*
   379     AHIG:
   379     AHIG:
   380         Apple Human Interface Guidelines
   380         Apple Human Interface Guidelines
  2153                 wdi.attributes = 0;
  2153                 wdi.attributes = 0;
  2154             wdi.titleHeight = tb->rect.height();
  2154             wdi.titleHeight = tb->rect.height();
  2155             wdi.titleWidth = tb->rect.width();
  2155             wdi.titleWidth = tb->rect.width();
  2156             QCFType<HIShapeRef> region;
  2156             QCFType<HIShapeRef> region;
  2157             HIRect hirect = qt_hirectForQRect(tb->rect);
  2157             HIRect hirect = qt_hirectForQRect(tb->rect);
  2158             if (hirect.size.width == -1)
  2158             if (hirect.size.width <= 0)
  2159                 hirect.size.width = 100;
  2159                 hirect.size.width = 100;
  2160             if (hirect.size.height == -1)
  2160             if (hirect.size.height <= 0)
  2161                 hirect.size.height = 30;
  2161                 hirect.size.height = 30;
  2162 
  2162 
  2163             HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, &region);
  2163             HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, &region);
  2164             HIRect rect;
  2164             HIRect rect;
  2165             ptrHIShapeGetBounds(region, &rect);
  2165             ptrHIShapeGetBounds(region, &rect);
  3635                     break;
  3635                     break;
  3636                 default:
  3636                 default:
  3637                     break;
  3637                     break;
  3638                 }
  3638                 }
  3639             }
  3639             }
       
  3640             bool stretchTabs = (!verticalTabs && tabRect.height() > 22 || verticalTabs && tabRect.width() > 22);
       
  3641 
  3640             switch (tp) {
  3642             switch (tp) {
  3641             case QStyleOptionTab::Beginning:
  3643             case QStyleOptionTab::Beginning:
  3642                 tdi.position = kHIThemeTabPositionFirst;
  3644                 tdi.position = kHIThemeTabPositionFirst;
  3643                 if (sp != QStyleOptionTab::NextIsSelected)
  3645                 if (sp != QStyleOptionTab::NextIsSelected || stretchTabs)
  3644                     tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
  3646                     tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
  3645                 break;
  3647                 break;
  3646             case QStyleOptionTab::Middle:
  3648             case QStyleOptionTab::Middle:
  3647                 tdi.position = kHIThemeTabPositionMiddle;
  3649                 tdi.position = kHIThemeTabPositionMiddle;
  3648                 if (selected)
  3650                 if (selected)
  3649                     tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
  3651                     tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
  3650                 if (sp != QStyleOptionTab::NextIsSelected)  // Also when we're selected.
  3652                 if (sp != QStyleOptionTab::NextIsSelected || stretchTabs)  // Also when we're selected.
  3651                     tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
  3653                     tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
  3652                 break;
  3654                 break;
  3653             case QStyleOptionTab::End:
  3655             case QStyleOptionTab::End:
  3654                 tdi.position = kHIThemeTabPositionLast;
  3656                 tdi.position = kHIThemeTabPositionLast;
  3655                 if (selected)
  3657                 if (selected)
  3657                 break;
  3659                 break;
  3658             case QStyleOptionTab::OnlyOneTab:
  3660             case QStyleOptionTab::OnlyOneTab:
  3659                 tdi.position = kHIThemeTabPositionOnly;
  3661                 tdi.position = kHIThemeTabPositionOnly;
  3660                 break;
  3662                 break;
  3661             }
  3663             }
  3662 
       
  3663             // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves.
  3664             // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves.
  3664             if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) {
  3665             if (stretchTabs) {
  3665                 HIRect hirect = CGRectMake(0, 0, 23, 23);
  3666                 HIRect hirect = CGRectMake(0, 0, 23, 23);
  3666                 QPixmap pm(23, 23);
  3667                 QPixmap pm(23, 23);
  3667                 pm.fill(Qt::transparent);
  3668                 pm.fill(Qt::transparent);
  3668                 {
  3669                 {
  3669                     QMacCGContext pmcg(&pm);
  3670                     QMacCGContext pmcg(&pm);
  4840                 wwdi.titleWidth = wdi.titleWidth;
  4841                 wwdi.titleWidth = wdi.titleWidth;
  4841                 ThemeDrawState savedControlState = wwdi.widgetState;
  4842                 ThemeDrawState savedControlState = wwdi.widgetState;
  4842                 uint sc = SC_TitleBarMinButton;
  4843                 uint sc = SC_TitleBarMinButton;
  4843                 ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox;
  4844                 ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox;
  4844                 bool active = titlebar->state & State_Active;
  4845                 bool active = titlebar->state & State_Active;
  4845                 int border = 2;
  4846                 if (qMacVersion() < QSysInfo::MV_10_6) {
  4846                 titleBarRect.origin.x += border;
  4847                     int border = 2;
  4847                 titleBarRect.origin.y -= border;
  4848                     titleBarRect.origin.x += border;
       
  4849                     titleBarRect.origin.y -= border;
       
  4850                 }
  4848 
  4851 
  4849                 while (sc <= SC_TitleBarCloseButton) {
  4852                 while (sc <= SC_TitleBarCloseButton) {
  4850                     if (sc & titlebar->subControls) {
  4853                     if (sc & titlebar->subControls) {
  4851                         uint tmp = sc;
  4854                         uint tmp = sc;
  4852                         wwdi.widgetState = savedControlState;
  4855                         wwdi.widgetState = savedControlState;