]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dcclient.mm
Implement SetBackground()
[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 : m_window(NULL)
25 {
26 };
27
28 wxWindowDC::wxWindowDC( wxWindow *window )
29 : m_window(window)
30 {
31 wxFAIL_MSG("non-client window DC's are not supported");
32 };
33
34 wxWindowDC::~wxWindowDC(void)
35 {
36 };
37
38 /*
39 * wxClientDC
40 */
41 IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
42
43 wxClientDC::wxClientDC(void)
44 {
45 };
46
47 wxClientDC::wxClientDC( wxWindow *window )
48 {
49 m_window = window;
50 };
51
52 wxClientDC::~wxClientDC(void)
53 {
54 };
55
56 /*
57 * wxPaintDC
58 */
59 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
60
61 wxPaintDC::wxPaintDC(void)
62 {
63 };
64
65 wxPaintDC::wxPaintDC( wxWindow *window )
66 {
67 m_window = 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])
71 {
72 // The transform is auto released
73 NSAffineTransform *transform = [NSAffineTransform transform];
74 /* x' = 1x + 0y + 0
75 y' = 0x + -1y + window's height
76 */
77 NSAffineTransformStruct matrix = {
78 1, 0
79 , 0, -1
80 , 0, [window->GetNSView() bounds].size.height
81 };
82 [transform setTransformStruct: matrix];
83 // Apply the transform
84 [transform concat];
85 }
86 // TODO: Apply scaling transformation
87 };
88
89 wxPaintDC::~wxPaintDC(void)
90 {
91 };
92