]>
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 | |
9 | // Licence: wxWindows licence | |
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" | |
21 | #include <math.h> | |
22 | #include "wx/mac/private.h" | |
23 | ||
24 | //----------------------------------------------------------------------------- | |
25 | // constants | |
26 | //----------------------------------------------------------------------------- | |
27 | ||
28 | #define RAD2DEG 57.2957795131 | |
29 | ||
30 | //----------------------------------------------------------------------------- | |
31 | // wxPaintDC | |
32 | //----------------------------------------------------------------------------- | |
33 | ||
34 | #if !USE_SHARED_LIBRARY | |
35 | IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) | |
36 | IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) | |
37 | IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) | |
38 | #endif | |
39 | ||
40 | /* | |
41 | * wxWindowDC | |
42 | */ | |
43 | ||
44 | #include "wx/mac/uma.h" | |
45 | ||
46 | wxWindowDC::wxWindowDC() | |
47 | { | |
48 | m_window = NULL ; | |
49 | } | |
50 | ||
51 | wxWindowDC::wxWindowDC(wxWindow *window) | |
52 | { | |
53 | m_window = window ; | |
54 | wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; | |
55 | WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; | |
56 | ||
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 ) ; | |
66 | m_ok = TRUE ; | |
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 | ||
112 | m_ok = TRUE ; | |
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 | ||
159 | m_ok = TRUE ; | |
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 | } | |
174 | ||
175 |