1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/dcclient.mm
3 // Purpose: wxWindowDC, wxPaintDC, and wxClientDC classes
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/dcclient.h"
13 #include "wx/window.h"
15 #import <AppKit/NSView.h>
16 #import <AppKit/NSAffineTransform.h>
21 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
23 wxWindowDC::wxWindowDC(void)
28 wxWindowDC::wxWindowDC( wxWindow *window )
31 wxFAIL_MSG("non-client window DC's are not supported");
34 wxWindowDC::~wxWindowDC(void)
41 IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
43 wxClientDC::wxClientDC(void)
47 wxClientDC::wxClientDC( wxWindow *window )
52 wxClientDC::~wxClientDC(void)
59 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
61 wxPaintDC::wxPaintDC(void)
65 wxPaintDC::wxPaintDC( wxWindow *window )
68 wxASSERT_MSG([NSView focusView]==window->GetNSView(), "PaintDC's NSView does not have focus. Please use wxPaintDC only as the first DC created in a paint handler");
69 // This transform flips the graphics since wxDC uses top-left origin
70 if(![window->GetNSView() isFlipped])
72 // The transform is auto released
73 NSAffineTransform *transform = [NSAffineTransform transform];
75 y' = 0x + -1y + window's height
77 NSAffineTransformStruct matrix = {
80 , 0, [window->GetNSView() bounds].size.height
82 [transform setTransformStruct: matrix];
83 // Apply the transform
86 // TODO: Apply scaling transformation
89 wxPaintDC::~wxPaintDC(void)