-#import <AppKit/NSTypeSetter.h>
-
-IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
-wxDC *wxDC::sm_focusedDC = NULL;
-WX_NSTextStorage wxDC::sm_cocoaNSTextStorage = nil;
-WX_NSLayoutManager wxDC::sm_cocoaNSLayoutManager = nil;
-WX_NSTextContainer wxDC::sm_cocoaNSTextContainer = nil;
-
-void wxDC::CocoaInitializeTextSystem()
-{
- wxASSERT_MSG(!sm_cocoaNSTextStorage && !sm_cocoaNSLayoutManager && !sm_cocoaNSTextContainer,"Text system already initalized! BAD PROGRAMMER!");
-
- sm_cocoaNSTextStorage = [[NSTextStorage alloc] init];
+#import <AppKit/NSTypesetter.h>
+#import <AppKit/NSImage.h>
+
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxCocoaDCStack);
+
+IMPLEMENT_ABSTRACT_CLASS(wxCocoaDCImpl, wxDCImpl)
+
+WX_NSTextStorage wxCocoaDCImpl::sm_cocoaNSTextStorage = nil;
+WX_NSLayoutManager wxCocoaDCImpl::sm_cocoaNSLayoutManager = nil;
+WX_NSTextContainer wxCocoaDCImpl::sm_cocoaNSTextContainer = nil;
+wxCocoaDCStack wxCocoaDCImpl::sm_cocoaDCStack;
+
+inline void CocoaSetPenForNSBezierPath(wxPen &pen, NSBezierPath *bezpath)
+{
+ [pen.GetNSColor() set];
+ const CGFloat *pattern;
+ [bezpath setLineDash:pattern count:pen.GetCocoaLineDash(&pattern) phase:0.0];
+ [bezpath setLineWidth:pen.GetWidth()];
+ switch(pen.GetJoin())
+ {
+ case wxJOIN_BEVEL:
+ [bezpath setLineJoinStyle:NSBevelLineJoinStyle];
+ break;
+ case wxJOIN_ROUND:
+ [bezpath setLineJoinStyle:NSRoundLineJoinStyle];
+ break;
+ case wxJOIN_MITER:
+ [bezpath setLineJoinStyle:NSMiterLineJoinStyle];
+ break;
+ }
+ switch(pen.GetCap())
+ {
+ case wxCAP_ROUND:
+ [bezpath setLineCapStyle:NSRoundLineCapStyle];
+ break;
+ case wxCAP_PROJECTING:
+ [bezpath setLineCapStyle:NSSquareLineCapStyle];
+ break;
+ case wxCAP_BUTT:
+ [bezpath setLineCapStyle:NSButtLineCapStyle];
+ break;
+ }
+}
+
+void wxCocoaDCImpl::CocoaInitializeTextSystem()
+{
+ wxAutoNSAutoreleasePool pool;
+
+ wxASSERT_MSG(!sm_cocoaNSTextStorage && !sm_cocoaNSLayoutManager && !sm_cocoaNSTextContainer,wxT("Text system already initalized! BAD PROGRAMMER!"));
+
+ // FIXME: Never released
+ sm_cocoaNSTextStorage = wxGCSafeRetain([[[NSTextStorage alloc] init] autorelease]);
+
+ // FIXME: Never released
+ sm_cocoaNSLayoutManager = wxGCSafeRetain([[[NSLayoutManager alloc] init] autorelease]);