]>
Commit | Line | Data |
---|---|---|
2646f485 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dcclient.cpp | |
3 | // Purpose: wxClientDC class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
2646f485 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "dcclient.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/dcclient.h" | |
17 | #include "wx/dcmemory.h" | |
18 | #include "wx/region.h" | |
19 | #include "wx/window.h" | |
20 | #include "wx/toplevel.h" | |
463c4d71 | 21 | #include "wx/math.h" |
2646f485 SC |
22 | #include "wx/mac/private.h" |
23 | ||
24 | //----------------------------------------------------------------------------- | |
25 | // constants | |
26 | //----------------------------------------------------------------------------- | |
27 | ||
28 | #define RAD2DEG 57.2957795131 | |
29 | ||
30 | //----------------------------------------------------------------------------- | |
31 | // wxPaintDC | |
32 | //----------------------------------------------------------------------------- | |
33 | ||
2646f485 SC |
34 | IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) |
35 | IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) | |
36 | IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) | |
2646f485 SC |
37 | |
38 | /* | |
39 | * wxWindowDC | |
40 | */ | |
41 | ||
42 | #include "wx/mac/uma.h" | |
43 | ||
44 | wxWindowDC::wxWindowDC() | |
45 | { | |
46 | m_window = NULL ; | |
47 | } | |
48 | ||
49 | wxWindowDC::wxWindowDC(wxWindow *window) | |
50 | { | |
51 | m_window = window ; | |
52 | wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; | |
53 | WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; | |
54 | ||
55 | int x , y ; | |
56 | x = y = 0 ; | |
57 | window->MacWindowToRootWindow( &x , &y ) ; | |
58 | m_macLocalOrigin.x = x ; | |
59 | m_macLocalOrigin.y = y ; | |
60 | CopyRgn( (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; | |
61 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; | |
62 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
63 | m_macPort = UMAGetWindowPort( windowref ) ; | |
64 | m_ok = TRUE ; | |
65 | SetBackground(window->MacGetBackgroundBrush()); | |
66 | } | |
67 | ||
68 | wxWindowDC::~wxWindowDC() | |
69 | { | |
70 | } | |
71 | ||
72 | void wxWindowDC::DoGetSize( int* width, int* height ) const | |
73 | { | |
74 | wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); | |
75 | ||
76 | m_window->GetSize(width, height); | |
77 | } | |
78 | ||
79 | /* | |
80 | * wxClientDC | |
81 | */ | |
82 | ||
83 | wxClientDC::wxClientDC() | |
84 | { | |
85 | m_window = NULL ; | |
86 | } | |
87 | ||
88 | wxClientDC::wxClientDC(wxWindow *window) | |
89 | { | |
90 | m_window = window ; | |
91 | wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; | |
92 | if (!rootwindow) | |
93 | return; | |
94 | WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; | |
95 | wxPoint origin = window->GetClientAreaOrigin() ; | |
96 | wxSize size = window->GetClientSize() ; | |
97 | int x , y ; | |
98 | x = origin.x ; | |
99 | y = origin.y ; | |
100 | window->MacWindowToRootWindow( &x , &y ) ; | |
101 | m_macLocalOrigin.x = x ; | |
102 | m_macLocalOrigin.y = y ; | |
103 | SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; | |
104 | SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; | |
105 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; | |
106 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; | |
107 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; | |
108 | m_macPort = UMAGetWindowPort( windowref ) ; | |
109 | ||
110 | m_ok = TRUE ; | |
111 | SetBackground(window->MacGetBackgroundBrush()); | |
112 | SetFont( window->GetFont() ) ; | |
113 | } | |
114 | ||
115 | wxClientDC::~wxClientDC() | |
116 | { | |
117 | } | |
118 | ||
119 | void wxClientDC::DoGetSize(int *width, int *height) const | |
120 | { | |
121 | wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); | |
122 | ||
123 | m_window->GetClientSize( width, height ); | |
124 | } | |
125 | ||
126 | ||
127 | /* | |
128 | * wxPaintDC | |
129 | */ | |
130 | ||
131 | wxPaintDC::wxPaintDC() | |
132 | { | |
133 | m_window = NULL ; | |
134 | } | |
135 | ||
136 | wxPaintDC::wxPaintDC(wxWindow *window) | |
137 | { | |
138 | m_window = window ; | |
139 | wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; | |
140 | WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; | |
141 | wxPoint origin = window->GetClientAreaOrigin() ; | |
142 | wxSize size = window->GetClientSize() ; | |
143 | int x , y ; | |
144 | x = origin.x ; | |
145 | y = origin.y ; | |
146 | window->MacWindowToRootWindow( &x , &y ) ; | |
147 | m_macLocalOrigin.x = x ; | |
148 | m_macLocalOrigin.y = y ; | |
149 | SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; | |
150 | SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; | |
151 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; | |
152 | SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; | |
153 | OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; | |
154 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
155 | m_macPort = UMAGetWindowPort( windowref ) ; | |
156 | ||
157 | m_ok = TRUE ; | |
158 | SetBackground(window->MacGetBackgroundBrush()); | |
159 | SetFont( window->GetFont() ) ; | |
160 | } | |
161 | ||
162 | wxPaintDC::~wxPaintDC() | |
163 | { | |
164 | } | |
165 | ||
166 | void wxPaintDC::DoGetSize(int *width, int *height) const | |
167 | { | |
168 | wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") ); | |
169 | ||
170 | m_window->GetClientSize( width, height ); | |
171 | } | |
172 | ||
173 |