QMacStyle: Add optional block parameter to drawNSViewInRect()

In some cases we want to do something different than just calling
- [NSView drawRect:].

Change-Id: I7db704daa39611f33f270b0192c4301de62ec1bf
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
bb10
Gabriel de Dietrich 2014-10-03 14:14:09 +02:00 committed by Gabriel de Dietrich
parent 239b71d07d
commit 8dd15fd955
2 changed files with 8 additions and 3 deletions

View File

@ -1888,7 +1888,7 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget, QPoint *offset) cons
return bv;
}
void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p) const
void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPainter *p, QCocoaDrawRectBlock drawRectBlock) const
{
QMacCGContext ctx(p);
CGContextSaveGState(ctx);
@ -1901,7 +1901,10 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain
[backingStoreNSView addSubview:view];
view.frame = rect;
[view drawRect:rect];
if (drawRectBlock)
drawRectBlock(rect, (CGContextRef)ctx);
else
[view drawRect:rect];
[view removeFromSuperviewWithoutNeedingDisplay];
[NSGraphicsContext restoreGraphicsState];

View File

@ -132,6 +132,8 @@ enum QCocoaWidgetKind {
typedef QPair<QCocoaWidgetKind, QAquaWidgetSize> QCocoaWidget;
typedef void (^QCocoaDrawRectBlock)(NSRect, CGContextRef);
#define SIZE(large, small, mini) \
(controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))
@ -201,7 +203,7 @@ public:
NSView *cocoaControl(QCocoaWidget widget, QPoint *offset) const;
void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const;
void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p, QCocoaDrawRectBlock drawRectBlock = nil) const;
void resolveCurrentNSView(QWindow *window);
public: