]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxMemoryDC::Clear()
authorDavid Elliott <dfe@tgwbd.org>
Mon, 10 Jan 2005 01:52:08 +0000 (01:52 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 10 Jan 2005 01:52:08 +0000 (01:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31302 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/dcmemory.h
src/cocoa/dcmemory.mm

index a81f980166733e5fa9eac7fa67167c4f1243ed15..1265fb84dddf66e3c3e2e71fb67c2239a8edaf6f 100644 (file)
@@ -23,6 +23,8 @@ public:
     ~wxMemoryDC(void);
     virtual void SelectObject(const wxBitmap& bitmap);
     virtual void DoGetSize(int *width, int *height) const;
+
+    virtual void Clear();
 protected:
     wxBitmap m_selectedBitmap;
     WX_NSImage m_cocoaNSImage;
index 1c79b3ad67bd2dfaad83d6fc56eb7ec555e66fc7..ff5882d9955c878cadb36957a92011cf40c6cf4a 100644 (file)
@@ -20,6 +20,8 @@
 #import <AppKit/NSImage.h>
 #import <AppKit/NSAffineTransform.h>
 #import <AppKit/NSGraphicsContext.h>
+#import <AppKit/NSColor.h>
+#import <AppKit/NSBezierPath.h>
 
 //-----------------------------------------------------------------------------
 // wxMemoryDC
@@ -150,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];
+}
+