summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm13
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h6
2 files changed, 14 insertions, 5 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index a3b394a291..0bd2894402 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -2110,7 +2110,12 @@ QMacStyle::QMacStyle()
name:NSPreferredScrollerStyleDidChangeNotification
object:nil];
- d->nsscroller = [[NSScroller alloc] init];
+ // Create scroller objects. Scroller internal direction setup happens
+ // on initWithFrame and cannot be changed later on. Create two scrollers
+ // initialized with fake geometry. Correct geometry is set at draw time.
+ d->horizontalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)];
+ d->verticalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)];
+
d->indicatorBranchButtonCell = nil;
}
@@ -2119,7 +2124,8 @@ QMacStyle::~QMacStyle()
Q_D(QMacStyle);
QMacAutoReleasePool pool;
- [reinterpret_cast<NSScroller*>(d->nsscroller) release];
+ [d->horizontalScroller release];
+ [d->verticalScroller release];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
[[NSNotificationCenter defaultCenter] removeObserver:receiver];
@@ -5451,8 +5457,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]];
- NSScroller *scroller = reinterpret_cast<NSScroller*>(d->nsscroller);
- [scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())];
+ NSScroller *scroller = isHorizontal ? d->horizontalScroller : d-> verticalScroller;
// mac os behaviour: as soon as one color channel is >= 128,
// the bg is considered bright, scroller is dark
const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget);
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index 9bbd0995a5..e5d2ffdc9d 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -115,6 +115,9 @@
// We mean it.
//
+Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
+Q_FORWARD_DECLARE_OBJC_CLASS(NSScroller);
+
QT_BEGIN_NAMESPACE
/*
@@ -246,7 +249,8 @@ public:
CFAbsoluteTime defaultButtonStart;
bool mouseDown;
void* receiver;
- void *nsscroller;
+ NSScroller *horizontalScroller;
+ NSScroller *verticalScroller;
void *indicatorBranchButtonCell;
NSView *backingStoreNSView;
QHash<QCocoaWidget, NSView *> cocoaControls;