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
parent
239b71d07d
commit
8dd15fd955
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue