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