summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qmacstyle_mac.mm
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-09-29 13:37:46 +0200
committerGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-09-29 13:38:11 +0200
commit8ab25620d3df25c43011ae982f4614639578afb3 (patch)
treee94d53c6b7d231ca18f0787a0c09bec07d163a67 /src/widgets/styles/qmacstyle_mac.mm
parentdfe853bff90444edf92a993e391df853780c9e8d (diff)
parent5222abfdf5f034bad12bbe12312a4149550495b7 (diff)
Merge remote-tracking branch 'origin/5.3' into 5.4
Conflicts: src/network/socket/qnativesocketengine_unix.cpp src/widgets/kernel/qwidget_qpa.cpp Change-Id: I6f1aa320d5ca66cd92d601a95885aeaab0abb191
Diffstat (limited to 'src/widgets/styles/qmacstyle_mac.mm')
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm86
1 files changed, 65 insertions, 21 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index f0a45548f6..01a2f2b3bd 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -1749,11 +1749,13 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
return tds;
}
-NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const
+NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind, QPoint *offset) const
{
NSView *bv = buttons[kind];
if (!bv) {
- if (kind == kThemePopupButton)
+ if (kind == kThemePopupButton
+ || kind == kThemePopupButtonSmall
+ || kind == kThemePopupButtonMini)
bv = [[NSPopUpButton alloc] init];
else if (kind == kThemeComboBox)
bv = [[NSComboBox alloc] init];
@@ -1793,25 +1795,61 @@ NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const
break;
}
-// if (kind == kThemePushButtonSmall
-// || kind == kThemePopupButtonSmall
-// || kind == kThemeCheckBoxSmall
-// || kind == kThemeRadioButtonSmall)
-// bc.controlSize = NSSmallControlSize;
-// else if (kind == kThemePushButtonMini
-// || kind == kThemePopupButtonMini
-// || kind == kThemeCheckBoxMini
-// || kind == kThemeRadioButtonMini)
-// bc.controlSize = NSMiniControlSize;
-
if ([bv isKindOfClass:[NSButton class]]) {
NSButton *bc = (NSButton *)bv;
bc.title = nil;
+
+ NSCell *bcell = bc.cell;
+ switch (kind) {
+ case kThemePushButtonSmall:
+ case kThemePopupButtonSmall:
+ case kThemeCheckBoxSmall:
+ case kThemeRadioButtonSmall:
+ bcell.controlSize = NSSmallControlSize;
+ break;
+ case kThemePushButtonMini:
+ case kThemePopupButtonMini:
+ case kThemeCheckBoxMini:
+ case kThemeRadioButtonMini:
+ bcell.controlSize = NSMiniControlSize;
+ break;
+ default:
+ break;
+ }
}
const_cast<QMacStylePrivate *>(this)->buttons.insert(kind, bv);
}
+ if (offset) {
+ switch (kind) {
+ case kThemeRadioButton:
+ offset->setY(2);
+ break;
+ case kThemeRadioButtonSmall:
+ *offset = QPoint(-1, 2);
+ break;
+ case kThemeRadioButtonMini:
+ offset->setY(2);
+ break;
+ case kThemePopupButtonSmall:
+ case kThemeCheckBox:
+ offset->setY(1);
+ break;
+ case kThemeCheckBoxSmall:
+ offset->setX(-1);
+ break;
+ case kThemeCheckBoxMini:
+ *offset = QPoint(7, 5);
+ break;
+ case kThemePopupButtonMini:
+ *offset = QPoint(2, -1);
+ break;
+ default:
+ break;
+ }
+ }
+
return bv;
}
@@ -1827,8 +1865,8 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain
CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height());
[backingStoreNSView addSubview:view];
- view.frame = rect;
- [view drawRect:rect];
+ view.frame = NSRectFromCGRect(rect);
+ [view drawRect:NSRectFromCGRect(rect)];
[view removeFromSuperviewWithoutNeedingDisplay];
[NSGraphicsContext restoreGraphicsState];
@@ -1928,14 +1966,20 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
}
pm = QPixmap::fromImage(image);
} else if ((usingYosemiteOrLater && combo && !editableCombo) || button) {
- NSButton *bc = (NSButton *)buttonOfKind(bdi->kind);
+ QPoint offset;
+ NSButton *bc = (NSButton *)buttonOfKind(bdi->kind, &offset);
[bc highlight:pressed];
bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive;
+ bc.allowsMixedState = YES;
bc.state = bdi->value == kThemeButtonOn ? NSOnState :
bdi->value == kThemeButtonMixed ? NSMixedState : NSOffState;
- p->translate(0, 1);
- drawNSViewInRect(bc, opt->rect, p);
- p->translate(0, -1);
+ // The view frame may differ from what we pass to HITheme
+ QRect rect = opt->rect;
+ if (bdi->kind == kThemePopupButtonMini)
+ rect.adjust(0, 0, -5, 0);
+ p->translate(offset);
+ drawNSViewInRect(bc, rect, p);
+ p->translate(-offset);
return;
} else if (usingYosemiteOrLater && editableCombo) {
QImage image = activePixmap.toImage();
@@ -3821,9 +3865,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
NSBezierPath *pushButtonFocusRingPath;
if (bdi.kind == kThemeBevelButton)
- pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:focusRect];
+ pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRect)];
else
- pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4];
+ pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(focusRect) xRadius:4 yRadius:4];
qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
}