]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/dcmemory.mm
Ensure that the windows are shown when Initialize is called too
[wxWidgets.git] / src / cocoa / dcmemory.mm
index 7ce8c835aa88af74217a0fdaa09e30cf0f3b17b9..ff5882d9955c878cadb36957a92011cf40c6cf4a 100644 (file)
     #include "wx/dcmemory.h"
 #endif //WX_PRECOMP
 
+#include "wx/cocoa/autorelease.h"
+
 #import <AppKit/NSImage.h>
 #import <AppKit/NSAffineTransform.h>
 #import <AppKit/NSGraphicsContext.h>
+#import <AppKit/NSColor.h>
+#import <AppKit/NSBezierPath.h>
 
 //-----------------------------------------------------------------------------
 // wxMemoryDC
@@ -67,6 +71,7 @@ bool wxMemoryDC::CocoaUnlockFocus()
 // instead copy the data to an offscreen window, then copy it back
 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
 {
+    wxAutoNSAutoreleasePool pool;
     if(m_selectedBitmap.Ok())
     {
         CocoaTakeFocus();
@@ -147,3 +152,20 @@ bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
     return false;
 }
 
+void wxMemoryDC::Clear()
+{
+    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];
+}
+