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