]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dcclient.mm
Remove check for other wxPaintDCs. It should be done in wxWindow instead.
[wxWidgets.git] / src / cocoa / dcclient.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/dcclient.mm
3 // Purpose: wxWindowDC, wxPaintDC, and wxClientDC classes
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/04/01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/dcclient.h"
13 #include "wx/window.h"
14
15 #import <AppKit/NSView.h>
16 #import <AppKit/NSAffineTransform.h>
17
18 /*
19 * wxWindowDC
20 */
21 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
22
23 wxWindowDC::wxWindowDC(void)
24 {
25 };
26
27 wxWindowDC::wxWindowDC( wxWindow *window )
28 {
29 wxFAIL_MSG("non-client window DC's are not supported");
30 };
31
32 wxWindowDC::~wxWindowDC(void)
33 {
34 };
35
36 /*
37 * wxClientDC
38 */
39 IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
40
41 wxClientDC::wxClientDC(void)
42 {
43 };
44
45 wxClientDC::wxClientDC( wxWindow *window )
46 {
47 };
48
49 wxClientDC::~wxClientDC(void)
50 {
51 };
52
53 /*
54 * wxPaintDC
55 */
56 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
57
58 wxPaintDC::wxPaintDC(void)
59 {
60 };
61
62 wxPaintDC::wxPaintDC( wxWindow *window )
63 {
64 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");
65 // This transform flips the graphics since wxDC uses top-left origin
66 if(![window->GetNSView() isFlipped])
67 {
68 // The transform is auto released
69 NSAffineTransform *transform = [NSAffineTransform transform];
70 /* x' = 1x + 0y + 0
71 y' = 0x + -1y + window's height
72 */
73 NSAffineTransformStruct matrix = {
74 1, 0
75 , 0, -1
76 , 0, [window->GetNSView() bounds].size.height
77 };
78 [transform setTransformStruct: matrix];
79 // Apply the transform
80 [transform concat];
81 }
82 // TODO: Apply scaling transformation
83 };
84
85 wxPaintDC::~wxPaintDC(void)
86 {
87 };
88