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)
27 wxWindowDC::wxWindowDC( wxWindow *window )
29 wxFAIL_MSG("non-client window DC's are not supported");
32 wxWindowDC::~wxWindowDC(void)
39 IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
41 wxClientDC::wxClientDC(void)
45 wxClientDC::wxClientDC( wxWindow *window )
49 wxClientDC::~wxClientDC(void)
56 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
58 wxPaintDC::wxPaintDC(void)
62 wxPaintDC::wxPaintDC( wxWindow *window )
64 wxASSERT_MSG(!sm_focusedDC,"Found another wxDC with focus. Do not use wxPaintDC outside of paint handlers!");
65 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");
67 // This transform flips the graphics since wxDC uses top-left origin
68 if(![window->GetNSView() isFlipped])
70 // The transform is auto released
71 NSAffineTransform *transform = [NSAffineTransform transform];
73 y' = 0x + -1y + window's height
75 NSAffineTransformStruct matrix = {
78 , 0, [window->GetNSView() bounds].size.height
80 [transform setTransformStruct: matrix];
81 // Apply the transform
84 // TODO: Apply scaling transformation
87 wxPaintDC::~wxPaintDC(void)
89 if(sm_focusedDC==this)