Moved Clear() implementation into wxDC using a new virtual CocoaGetBounds()
to determine the rect to clear. Also added CocoaUnapplyTransformations() to bring the coordinate system back into Cocoa coordinates for those cases such as Clear() where it makes more sense. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31440 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -185,6 +185,23 @@ void wxDC::CocoaApplyTransformations()
|
||||
// TODO: Apply device/logical/user position/scaling transformations
|
||||
}
|
||||
|
||||
void wxDC::CocoaUnapplyTransformations()
|
||||
{
|
||||
// NOTE: You *must* call this with focus held.
|
||||
// Undo all transforms so we're back in true Cocoa coords with
|
||||
// no scaling or flipping.
|
||||
NSAffineTransform *invertTransform;
|
||||
invertTransform = [m_cocoaWxToBoundsTransform copy];
|
||||
[invertTransform invert];
|
||||
[invertTransform concat];
|
||||
}
|
||||
|
||||
bool wxDC::CocoaGetBounds(void *rectData)
|
||||
{
|
||||
// We don't know what we are so we can't return anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
wxAutoNSAutoreleasePool pool;
|
||||
@@ -553,6 +570,22 @@ void wxDC::SetTextBackground( const wxColour &col )
|
||||
|
||||
void wxDC::Clear()
|
||||
{
|
||||
if(!CocoaTakeFocus()) return;
|
||||
|
||||
NSRect boundsRect;
|
||||
if(!CocoaGetBounds(&boundsRect)) return;
|
||||
|
||||
NSGraphicsContext *context = [NSGraphicsContext currentContext];
|
||||
[context saveGraphicsState];
|
||||
|
||||
// Undo all transforms so when we draw our bounds rect we
|
||||
// really overwrite our bounds rect.
|
||||
CocoaUnapplyTransformations();
|
||||
|
||||
[m_backgroundBrush.GetNSColor() set];
|
||||
[NSBezierPath fillRect:boundsRect];
|
||||
|
||||
[context restoreGraphicsState];
|
||||
}
|
||||
|
||||
void wxDC::SetBackground(const wxBrush& brush)
|
||||
|
@@ -80,17 +80,15 @@ bool wxWindowDC::CocoaUnlockFocus()
|
||||
return CocoaUnlockFocusOnNSView();
|
||||
}
|
||||
|
||||
void wxWindowDC::Clear()
|
||||
bool wxWindowDC::CocoaGetBounds(void *rectData)
|
||||
{
|
||||
if(!CocoaTakeFocus()) return;
|
||||
|
||||
NSGraphicsContext *context = [NSGraphicsContext currentContext];
|
||||
[context saveGraphicsState];
|
||||
|
||||
[m_backgroundBrush.GetNSColor() set];
|
||||
[NSBezierPath fillRect:[m_lockedNSView bounds]];
|
||||
|
||||
[context restoreGraphicsState];
|
||||
if(!rectData)
|
||||
return false;
|
||||
if(!m_lockedNSView)
|
||||
return false;
|
||||
NSRect *pRect = (NSRect*)rectData;
|
||||
*pRect = [m_lockedNSView bounds];
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -151,20 +151,16 @@ bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxMemoryDC::Clear()
|
||||
bool wxMemoryDC::CocoaGetBounds(void *rectData)
|
||||
{
|
||||
if(!CocoaTakeFocus()) return;
|
||||
|
||||
NSGraphicsContext *context = [NSGraphicsContext currentContext];
|
||||
[context saveGraphicsState];
|
||||
|
||||
[m_backgroundBrush.GetNSColor() set];
|
||||
NSRect rect;
|
||||
rect.origin.x = 0;
|
||||
rect.origin.y = 0;
|
||||
rect.size = [m_cocoaNSImage size];
|
||||
[NSBezierPath fillRect:rect];
|
||||
|
||||
[context restoreGraphicsState];
|
||||
if(!rectData)
|
||||
return false;
|
||||
if(!m_cocoaNSImage)
|
||||
return false;
|
||||
NSRect *pRect = (NSRect*)rectData;
|
||||
pRect->origin.x = 0.0;
|
||||
pRect->origin.y = 0.0;
|
||||
pRect->size = [m_cocoaNSImage size];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user