]>
Commit | Line | Data |
---|---|---|
2ac013b1 | 1 | ///////////////////////////////////////////////////////////////////////////// |
e9576ca5 SC |
2 | // Name: dc.cpp |
3 | // Purpose: wxDC class | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 SC |
5 | // Modified by: |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 | 10 | ///////////////////////////////////////////////////////////////////////////// |
e40298d5 | 11 | |
e9576ca5 SC |
12 | #ifdef __GNUG__ |
13 | #pragma implementation "dc.h" | |
14 | #endif | |
e40298d5 | 15 | |
e9576ca5 | 16 | #include "wx/dc.h" |
03e11df5 | 17 | #include "wx/app.h" |
2f1ae414 | 18 | #include "wx/mac/uma.h" |
3dec57ad | 19 | #include "wx/dcmemory.h" |
a7390348 | 20 | #include "wx/dcprint.h" |
3dec57ad SC |
21 | #include "wx/region.h" |
22 | #include "wx/image.h" | |
b1699cd3 | 23 | #include "wx/log.h" |
e9576ca5 | 24 | |
5b781a67 | 25 | #if __MSL__ >= 0x6000 |
6b1a8b64 | 26 | namespace std {} |
b34039cf | 27 | using namespace std ; |
5b781a67 | 28 | #endif |
a7390348 | 29 | |
b34039cf | 30 | #include "wx/mac/private.h" |
7f0c3a63 SC |
31 | #include <ATSUnicode.h> |
32 | #include <TextCommon.h> | |
33 | #include <TextEncodingConverter.h> | |
34 | #include <FixMath.h> | |
2f1ae414 | 35 | #if !USE_SHARED_LIBRARY |
e9576ca5 | 36 | IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) |
2f1ae414 | 37 | #endif |
e40298d5 | 38 | |
e9576ca5 SC |
39 | //----------------------------------------------------------------------------- |
40 | // constants | |
41 | //----------------------------------------------------------------------------- | |
e40298d5 | 42 | |
3dec57ad | 43 | const double RAD2DEG = 180.0 / M_PI; |
76a5e5d2 SC |
44 | const short kEmulatedMode = -1 ; |
45 | const short kUnsupportedMode = -2 ; | |
e40298d5 | 46 | |
939fba6c SC |
47 | extern TECObjectRef s_TECNativeCToUnicode ; |
48 | ||
8bebc229 SC |
49 | // set to 0 if problems arise |
50 | #define wxMAC_EXPERIMENTAL_DC 1 | |
51 | ||
66a09d47 | 52 | wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : |
e40298d5 | 53 | m_ph( (GrafPtr) dc->m_macPort ) |
66a09d47 | 54 | { |
e40298d5 JS |
55 | wxASSERT( dc->Ok() ) ; |
56 | m_dc = dc ; | |
57 | dc->MacSetupPort(&m_ph) ; | |
66a09d47 | 58 | } |
99030bdf | 59 | wxMacPortSetter::~wxMacPortSetter() |
66a09d47 | 60 | { |
e40298d5 | 61 | m_dc->MacCleanupPort(&m_ph) ; |
66a09d47 | 62 | } |
e40298d5 | 63 | |
8bebc229 SC |
64 | #if wxMAC_EXPERIMENTAL_DC |
65 | class wxMacFastPortSetter | |
66 | { | |
67 | public : | |
ab9d0a8c | 68 | wxMacFastPortSetter( const wxDC *dc ) |
8bebc229 | 69 | { |
ab9d0a8c WS |
70 | wxASSERT( dc->Ok() ) ; |
71 | m_swapped = QDSwapPort( (GrafPtr) dc->m_macPort , &m_oldPort ) ; | |
72 | m_clipRgn = NewRgn() ; | |
73 | GetClip( m_clipRgn ) ; | |
74 | m_dc = dc ; | |
75 | dc->MacSetupPort( NULL ) ; | |
8bebc229 SC |
76 | } |
77 | ~wxMacFastPortSetter() | |
78 | { | |
bb253bfd | 79 | // SetPort( (GrafPtr) m_dc->m_macPort ) ; |
105b0fca | 80 | SetClip( m_clipRgn ) ; |
bb253bfd | 81 | if ( m_swapped ) |
ab9d0a8c WS |
82 | SetPort( m_oldPort ) ; |
83 | m_dc->MacCleanupPort( NULL ) ; | |
84 | DisposeRgn( m_clipRgn ) ; | |
8bebc229 SC |
85 | } |
86 | private : | |
bb253bfd | 87 | bool m_swapped ; |
105b0fca | 88 | RgnHandle m_clipRgn ; |
8bebc229 SC |
89 | GrafPtr m_oldPort ; |
90 | const wxDC* m_dc ; | |
91 | } ; | |
92 | ||
93 | #else | |
94 | typedef wxMacPortSetter wxMacFastPortSetter ; | |
95 | #endif | |
96 | ||
facd6764 SC |
97 | wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : |
98 | wxMacPortSaver( (GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ) | |
15cae9eb | 99 | { |
01299d56 | 100 | m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ; |
15cae9eb SC |
101 | m_formerClip = NewRgn() ; |
102 | m_newClip = NewRgn() ; | |
103 | GetClip( m_formerClip ) ; | |
ab9d0a8c | 104 | |
15cae9eb SC |
105 | if ( win ) |
106 | { | |
1dd85cc3 SC |
107 | int x = 0 , y = 0; |
108 | win->MacWindowToRootWindow( &x,&y ) ; | |
facd6764 SC |
109 | // get area including focus rect |
110 | CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ; | |
111 | if ( !EmptyRgn( m_newClip ) ) | |
112 | OffsetRgn( m_newClip , x , y ) ; | |
113 | ||
1dd85cc3 | 114 | SetClip( m_newClip ) ; |
e40298d5 | 115 | } |
15cae9eb | 116 | } |
e40298d5 | 117 | |
ab9d0a8c | 118 | wxMacWindowClipper::~wxMacWindowClipper() |
15cae9eb | 119 | { |
01299d56 | 120 | SetPort( m_newPort ) ; |
15cae9eb | 121 | SetClip( m_formerClip ) ; |
e40298d5 JS |
122 | DisposeRgn( m_newClip ) ; |
123 | DisposeRgn( m_formerClip ) ; | |
15cae9eb | 124 | } |
e40298d5 | 125 | |
01299d56 SC |
126 | wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) : |
127 | wxMacWindowClipper( win ) | |
128 | { | |
129 | // the port is already set at this point | |
130 | m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ; | |
131 | GetThemeDrawingState( &m_themeDrawingState ) ; | |
132 | } | |
133 | ||
ab9d0a8c | 134 | wxMacWindowStateSaver::~wxMacWindowStateSaver() |
01299d56 SC |
135 | { |
136 | SetPort( m_newPort ) ; | |
137 | SetThemeDrawingState( m_themeDrawingState , true ) ; | |
138 | } | |
139 | ||
3dec57ad SC |
140 | //----------------------------------------------------------------------------- |
141 | // Local functions | |
142 | //----------------------------------------------------------------------------- | |
3dec57ad SC |
143 | static inline double dmin(double a, double b) { return a < b ? a : b; } |
144 | static inline double dmax(double a, double b) { return a > b ? a : b; } | |
145 | static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } | |
e40298d5 | 146 | |
e9576ca5 SC |
147 | //----------------------------------------------------------------------------- |
148 | // wxDC | |
149 | //----------------------------------------------------------------------------- | |
76a5e5d2 SC |
150 | // this function emulates all wx colour manipulations, used to verify the implementation |
151 | // by setting the mode in the blitting functions to kEmulatedMode | |
76a5e5d2 | 152 | void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) ; |
e40298d5 | 153 | |
76a5e5d2 SC |
154 | void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) |
155 | { | |
156 | switch ( logical_func ) | |
157 | { | |
e40298d5 JS |
158 | case wxAND: // src AND dst |
159 | dstColor.red = dstColor.red & srcColor.red ; | |
160 | dstColor.green = dstColor.green & srcColor.green ; | |
161 | dstColor.blue = dstColor.blue & srcColor.blue ; | |
162 | break ; | |
163 | case wxAND_INVERT: // (NOT src) AND dst | |
164 | dstColor.red = dstColor.red & ~srcColor.red ; | |
165 | dstColor.green = dstColor.green & ~srcColor.green ; | |
166 | dstColor.blue = dstColor.blue & ~srcColor.blue ; | |
167 | break ; | |
168 | case wxAND_REVERSE:// src AND (NOT dst) | |
169 | dstColor.red = ~dstColor.red & srcColor.red ; | |
170 | dstColor.green = ~dstColor.green & srcColor.green ; | |
171 | dstColor.blue = ~dstColor.blue & srcColor.blue ; | |
172 | break ; | |
173 | case wxCLEAR: // 0 | |
174 | dstColor.red = 0 ; | |
175 | dstColor.green = 0 ; | |
176 | dstColor.blue = 0 ; | |
177 | break ; | |
76a5e5d2 | 178 | case wxCOPY: // src |
e40298d5 JS |
179 | dstColor.red = srcColor.red ; |
180 | dstColor.green = srcColor.green ; | |
181 | dstColor.blue = srcColor.blue ; | |
182 | break ; | |
183 | case wxEQUIV: // (NOT src) XOR dst | |
184 | dstColor.red = dstColor.red ^ ~srcColor.red ; | |
185 | dstColor.green = dstColor.green ^ ~srcColor.green ; | |
186 | dstColor.blue = dstColor.blue ^ ~srcColor.blue ; | |
187 | break ; | |
188 | case wxINVERT: // NOT dst | |
189 | dstColor.red = ~dstColor.red ; | |
190 | dstColor.green = ~dstColor.green ; | |
191 | dstColor.blue = ~dstColor.blue ; | |
192 | break ; | |
193 | case wxNAND: // (NOT src) OR (NOT dst) | |
194 | dstColor.red = ~dstColor.red | ~srcColor.red ; | |
195 | dstColor.green = ~dstColor.green | ~srcColor.green ; | |
196 | dstColor.blue = ~dstColor.blue | ~srcColor.blue ; | |
197 | break ; | |
198 | case wxNOR: // (NOT src) AND (NOT dst) | |
199 | dstColor.red = ~dstColor.red & ~srcColor.red ; | |
200 | dstColor.green = ~dstColor.green & ~srcColor.green ; | |
201 | dstColor.blue = ~dstColor.blue & ~srcColor.blue ; | |
202 | break ; | |
203 | case wxNO_OP: // dst | |
204 | break ; | |
205 | case wxOR: // src OR dst | |
206 | dstColor.red = dstColor.red | srcColor.red ; | |
207 | dstColor.green = dstColor.green | srcColor.green ; | |
208 | dstColor.blue = dstColor.blue | srcColor.blue ; | |
209 | break ; | |
210 | case wxOR_INVERT: // (NOT src) OR dst | |
211 | dstColor.red = dstColor.red | ~srcColor.red ; | |
212 | dstColor.green = dstColor.green | ~srcColor.green ; | |
213 | dstColor.blue = dstColor.blue | ~srcColor.blue ; | |
214 | break ; | |
215 | case wxOR_REVERSE: // src OR (NOT dst) | |
216 | dstColor.red = ~dstColor.red | srcColor.red ; | |
217 | dstColor.green = ~dstColor.green | srcColor.green ; | |
218 | dstColor.blue = ~dstColor.blue | srcColor.blue ; | |
219 | break ; | |
220 | case wxSET: // 1 | |
221 | dstColor.red = 0xFFFF ; | |
222 | dstColor.green = 0xFFFF ; | |
223 | dstColor.blue = 0xFFFF ; | |
224 | break ; | |
225 | case wxSRC_INVERT: // (NOT src) | |
226 | dstColor.red = ~srcColor.red ; | |
227 | dstColor.green = ~srcColor.green ; | |
228 | dstColor.blue = ~srcColor.blue ; | |
229 | break ; | |
230 | case wxXOR: // src XOR dst | |
231 | dstColor.red = dstColor.red ^ srcColor.red ; | |
232 | dstColor.green = dstColor.green ^ srcColor.green ; | |
233 | dstColor.blue = dstColor.blue ^ srcColor.blue ; | |
234 | break ; | |
76a5e5d2 | 235 | } |
76a5e5d2 | 236 | } |
e40298d5 | 237 | |
2f1ae414 | 238 | wxDC::wxDC() |
e9576ca5 | 239 | { |
ab9d0a8c WS |
240 | m_ok = false; |
241 | m_colour = true; | |
e40298d5 JS |
242 | m_mm_to_pix_x = mm2pt; |
243 | m_mm_to_pix_y = mm2pt; | |
244 | m_internalDeviceOriginX = 0; | |
245 | m_internalDeviceOriginY = 0; | |
246 | m_externalDeviceOriginX = 0; | |
247 | m_externalDeviceOriginY = 0; | |
248 | m_logicalScaleX = 1.0; | |
249 | m_logicalScaleY = 1.0; | |
250 | m_userScaleX = 1.0; | |
251 | m_userScaleY = 1.0; | |
252 | m_scaleX = 1.0; | |
253 | m_scaleY = 1.0; | |
ab9d0a8c WS |
254 | m_needComputeScaleX = false; |
255 | m_needComputeScaleY = false; | |
e40298d5 JS |
256 | m_macPort = NULL ; |
257 | m_macMask = NULL ; | |
ab9d0a8c | 258 | m_ok = false ; |
e40298d5 JS |
259 | m_macFontInstalled = false ; |
260 | m_macBrushInstalled = false ; | |
261 | m_macPenInstalled = false ; | |
262 | m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; | |
263 | m_macBoundaryClipRgn = NewRgn() ; | |
264 | m_macCurrentClipRgn = NewRgn() ; | |
265 | SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; | |
266 | SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; | |
9ff647cf SC |
267 | m_pen = *wxBLACK_PEN; |
268 | m_font = *wxNORMAL_FONT; | |
269 | m_brush = *wxWHITE_BRUSH; | |
26b9b4e1 | 270 | #ifdef __WXDEBUG__ |
ab9d0a8c | 271 | // needed to debug possible errors with two active drawing methods at the same time on |
26b9b4e1 | 272 | // the same DC |
66a09d47 | 273 | m_macCurrentPortStateHelper = NULL ; |
26b9b4e1 | 274 | #endif |
66a09d47 SC |
275 | m_macATSUIStyle = NULL ; |
276 | m_macAliasWasEnabled = false; | |
277 | m_macForegroundPixMap = NULL ; | |
278 | m_macBackgroundPixMap = NULL ; | |
0eaa1d68 | 279 | } |
e40298d5 | 280 | |
e9576ca5 SC |
281 | wxDC::~wxDC(void) |
282 | { | |
76a5e5d2 SC |
283 | DisposeRgn( (RgnHandle) m_macBoundaryClipRgn ) ; |
284 | DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ; | |
3dec57ad | 285 | } |
e40298d5 | 286 | |
76a5e5d2 | 287 | void wxDC::MacSetupPort(wxMacPortStateHelper* help) const |
519cb848 | 288 | { |
26b9b4e1 | 289 | #ifdef __WXDEBUG__ |
66a09d47 SC |
290 | wxASSERT( m_macCurrentPortStateHelper == NULL ) ; |
291 | m_macCurrentPortStateHelper = help ; | |
26b9b4e1 | 292 | #endif |
e40298d5 | 293 | SetClip( (RgnHandle) m_macCurrentClipRgn); |
8bebc229 | 294 | #if ! wxMAC_EXPERIMENTAL_DC |
e40298d5 JS |
295 | m_macFontInstalled = false ; |
296 | m_macBrushInstalled = false ; | |
297 | m_macPenInstalled = false ; | |
8bebc229 | 298 | #endif |
519cb848 | 299 | } |
66a09d47 SC |
300 | void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const |
301 | { | |
26b9b4e1 | 302 | #ifdef __WXDEBUG__ |
66a09d47 SC |
303 | wxASSERT( m_macCurrentPortStateHelper == help ) ; |
304 | m_macCurrentPortStateHelper = NULL ; | |
26b9b4e1 | 305 | #endif |
66a09d47 SC |
306 | if( m_macATSUIStyle ) |
307 | { | |
308 | ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle); | |
309 | m_macATSUIStyle = NULL ; | |
310 | } | |
311 | if ( m_macAliasWasEnabled ) | |
312 | { | |
313 | SetAntiAliasedTextEnabled(m_macFormerAliasState, m_macFormerAliasSize); | |
314 | m_macAliasWasEnabled = false ; | |
315 | } | |
316 | if ( m_macForegroundPixMap ) | |
317 | { | |
318 | Pattern blackColor ; | |
319 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
c99d6f99 | 320 | DisposePixPat( (PixPatHandle) m_macForegroundPixMap ) ; |
66a09d47 SC |
321 | m_macForegroundPixMap = NULL ; |
322 | } | |
323 | if ( m_macBackgroundPixMap ) | |
324 | { | |
325 | Pattern whiteColor ; | |
326 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
c99d6f99 | 327 | DisposePixPat( (PixPatHandle) m_macBackgroundPixMap ) ; |
66a09d47 SC |
328 | m_macBackgroundPixMap = NULL ; |
329 | } | |
330 | } | |
e40298d5 | 331 | |
2f1ae414 | 332 | void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) |
519cb848 | 333 | { |
3dec57ad | 334 | wxCHECK_RET( Ok(), wxT("invalid window dc") ); |
3dec57ad | 335 | wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); |
8bebc229 | 336 | wxMacFastPortSetter helper(this) ; |
7d9d1fd7 SC |
337 | wxCoord xx = XLOG2DEVMAC(x); |
338 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
339 | wxCoord w = bmp.GetWidth(); |
340 | wxCoord h = bmp.GetHeight(); | |
341 | wxCoord ww = XLOG2DEVREL(w); | |
342 | wxCoord hh = YLOG2DEVREL(h); | |
3dec57ad SC |
343 | // Set up drawing mode |
344 | short mode = (m_logicalFunction == wxCOPY ? srcCopy : | |
345 | //m_logicalFunction == wxCLEAR ? WHITENESS : | |
346 | //m_logicalFunction == wxSET ? BLACKNESS : | |
347 | m_logicalFunction == wxINVERT ? hilite : | |
348 | //m_logicalFunction == wxAND ? MERGECOPY : | |
349 | m_logicalFunction == wxOR ? srcOr : | |
350 | m_logicalFunction == wxSRC_INVERT ? notSrcCopy : | |
351 | m_logicalFunction == wxXOR ? srcXor : | |
352 | m_logicalFunction == wxOR_REVERSE ? notSrcOr : | |
353 | //m_logicalFunction == wxAND_REVERSE ? SRCERASE : | |
354 | //m_logicalFunction == wxSRC_OR ? srcOr : | |
355 | //m_logicalFunction == wxSRC_AND ? SRCAND : | |
356 | srcCopy ); | |
3dec57ad SC |
357 | if ( bmp.GetBitmapType() == kMacBitmapTypePict ) { |
358 | Rect bitmaprect = { 0 , 0 , hh, ww }; | |
359 | ::OffsetRect( &bitmaprect, xx, yy ) ; | |
76a5e5d2 | 360 | ::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ; |
519cb848 | 361 | } |
3dec57ad SC |
362 | else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld ) |
363 | { | |
76a5e5d2 | 364 | GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() ); |
3dec57ad | 365 | PixMapHandle bmappixels ; |
3dec57ad SC |
366 | // Set foreground and background colours (for bitmaps depth = 1) |
367 | if(bmp.GetDepth() == 1) | |
368 | { | |
76a5e5d2 SC |
369 | RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel()); |
370 | RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()); | |
3dec57ad SC |
371 | RGBForeColor(&fore); |
372 | RGBBackColor(&back); | |
373 | } | |
374 | else | |
375 | { | |
376 | RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; | |
377 | RGBColor black = { 0,0,0} ; | |
378 | RGBForeColor( &black ) ; | |
379 | RGBBackColor( &white ) ; | |
380 | } | |
3dec57ad | 381 | bmappixels = GetGWorldPixMap( bmapworld ) ; |
3dec57ad SC |
382 | wxCHECK_RET(LockPixels(bmappixels), |
383 | wxT("DoDrawBitmap: Unable to lock pixels")); | |
3dec57ad SC |
384 | Rect source = { 0, 0, h, w }; |
385 | Rect dest = { yy, xx, yy + hh, xx + ww }; | |
3dec57ad SC |
386 | if ( useMask && bmp.GetMask() ) |
387 | { | |
76a5e5d2 | 388 | if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())))) |
3dec57ad SC |
389 | { |
390 | CopyDeepMask | |
391 | ( | |
392 | GetPortBitMapForCopyBits(bmapworld), | |
76a5e5d2 SC |
393 | GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())), |
394 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ), | |
3dec57ad SC |
395 | &source, &source, &dest, mode, NULL |
396 | ); | |
76a5e5d2 | 397 | UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))); |
3dec57ad SC |
398 | } |
399 | } | |
400 | else { | |
401 | CopyBits( GetPortBitMapForCopyBits( bmapworld ), | |
76a5e5d2 | 402 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ), |
3dec57ad SC |
403 | &source, &dest, mode, NULL ) ; |
404 | } | |
405 | UnlockPixels( bmappixels ) ; | |
406 | } | |
407 | else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon ) | |
408 | { | |
409 | Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ; | |
410 | OffsetRect( &bitmaprect, xx, yy ) ; | |
76a5e5d2 | 411 | PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ; |
3dec57ad SC |
412 | } |
413 | m_macPenInstalled = false ; | |
414 | m_macBrushInstalled = false ; | |
415 | m_macFontInstalled = false ; | |
519cb848 | 416 | } |
e40298d5 | 417 | |
2f1ae414 | 418 | void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) |
e9576ca5 | 419 | { |
e40298d5 JS |
420 | wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); |
421 | wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); | |
a2f94f40 | 422 | DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ; |
3dec57ad | 423 | } |
e40298d5 | 424 | |
2f1ae414 | 425 | void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) |
e9576ca5 | 426 | { |
3dec57ad SC |
427 | wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC")); |
428 | wxCoord xx, yy, ww, hh; | |
7d9d1fd7 SC |
429 | xx = XLOG2DEVMAC(x); |
430 | yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
431 | ww = XLOG2DEVREL(width); |
432 | hh = YLOG2DEVREL(height); | |
76a5e5d2 SC |
433 | SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ; |
434 | SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; | |
3dec57ad SC |
435 | if( m_clipping ) |
436 | { | |
437 | m_clipX1 = wxMax( m_clipX1 , xx ); | |
438 | m_clipY1 = wxMax( m_clipY1 , yy ); | |
439 | m_clipX2 = wxMin( m_clipX2, (xx + ww)); | |
440 | m_clipY2 = wxMin( m_clipY2, (yy + hh)); | |
441 | } | |
442 | else | |
443 | { | |
ab9d0a8c | 444 | m_clipping = true; |
3dec57ad SC |
445 | m_clipX1 = xx; |
446 | m_clipY1 = yy; | |
447 | m_clipX2 = xx + ww; | |
448 | m_clipY2 = yy + hh; | |
449 | } | |
3dec57ad | 450 | } |
e40298d5 | 451 | |
2f1ae414 SC |
452 | void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) |
453 | { | |
3dec57ad | 454 | wxCHECK_RET( Ok(), wxT("invalid window dc") ) ; |
2f1ae414 SC |
455 | if (region.Empty()) |
456 | { | |
457 | DestroyClippingRegion(); | |
458 | return; | |
459 | } | |
8bebc229 | 460 | wxMacFastPortSetter helper(this) ; |
ffba56ed SC |
461 | wxCoord x, y, w, h; |
462 | region.GetBox( x, y, w, h ); | |
2f1ae414 | 463 | wxCoord xx, yy, ww, hh; |
7d9d1fd7 SC |
464 | xx = XLOG2DEVMAC(x); |
465 | yy = YLOG2DEVMAC(y); | |
ffba56ed SC |
466 | ww = XLOG2DEVREL(w); |
467 | hh = YLOG2DEVREL(h); | |
ffba56ed SC |
468 | // if we have a scaling that we cannot map onto native regions |
469 | // we must use the box | |
ffba56ed SC |
470 | if ( ww != w || hh != h ) |
471 | { | |
472 | wxDC::DoSetClippingRegion( x, y, w, h ); | |
473 | } | |
474 | else | |
475 | { | |
76a5e5d2 | 476 | CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ; |
ffba56ed SC |
477 | if ( xx != x || yy != y ) |
478 | { | |
76a5e5d2 | 479 | OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ; |
ffba56ed | 480 | } |
76a5e5d2 | 481 | SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; |
ffba56ed SC |
482 | if( m_clipping ) |
483 | { | |
484 | m_clipX1 = wxMax( m_clipX1 , xx ); | |
485 | m_clipY1 = wxMax( m_clipY1 , yy ); | |
486 | m_clipX2 = wxMin( m_clipX2, (xx + ww)); | |
487 | m_clipY2 = wxMin( m_clipY2, (yy + hh)); | |
488 | } | |
489 | else | |
490 | { | |
ab9d0a8c | 491 | m_clipping = true; |
ffba56ed SC |
492 | m_clipX1 = xx; |
493 | m_clipY1 = yy; | |
494 | m_clipX2 = xx + ww; | |
495 | m_clipY2 = yy + hh; | |
496 | } | |
497 | } | |
ee41971c | 498 | } |
e40298d5 | 499 | |
3dec57ad | 500 | void wxDC::DestroyClippingRegion() |
e9576ca5 | 501 | { |
8bebc229 | 502 | wxMacFastPortSetter helper(this) ; |
e40298d5 | 503 | CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; |
d16b634f | 504 | ResetClipping(); |
99030bdf | 505 | } |
e40298d5 | 506 | |
2f1ae414 | 507 | void wxDC::DoGetSizeMM( int* width, int* height ) const |
e9576ca5 | 508 | { |
e40298d5 JS |
509 | int w = 0; |
510 | int h = 0; | |
511 | GetSize( &w, &h ); | |
512 | *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); | |
513 | *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); | |
3dec57ad | 514 | } |
e40298d5 | 515 | |
e9576ca5 SC |
516 | void wxDC::SetTextForeground( const wxColour &col ) |
517 | { | |
3dec57ad SC |
518 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
519 | m_textForegroundColour = col; | |
520 | m_macFontInstalled = false ; | |
521 | } | |
e40298d5 | 522 | |
e9576ca5 SC |
523 | void wxDC::SetTextBackground( const wxColour &col ) |
524 | { | |
3dec57ad SC |
525 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
526 | m_textBackgroundColour = col; | |
527 | m_macFontInstalled = false ; | |
528 | } | |
e40298d5 | 529 | |
e9576ca5 SC |
530 | void wxDC::SetMapMode( int mode ) |
531 | { | |
e40298d5 JS |
532 | switch (mode) |
533 | { | |
e3065973 | 534 | case wxMM_TWIPS: |
e40298d5 JS |
535 | SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); |
536 | break; | |
e3065973 | 537 | case wxMM_POINTS: |
e40298d5 JS |
538 | SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); |
539 | break; | |
e3065973 | 540 | case wxMM_METRIC: |
e40298d5 JS |
541 | SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); |
542 | break; | |
e3065973 | 543 | case wxMM_LOMETRIC: |
e40298d5 JS |
544 | SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); |
545 | break; | |
e9576ca5 | 546 | default: |
e3065973 | 547 | case wxMM_TEXT: |
e40298d5 JS |
548 | SetLogicalScale( 1.0, 1.0 ); |
549 | break; | |
550 | } | |
551 | if (mode != wxMM_TEXT) | |
552 | { | |
ab9d0a8c WS |
553 | m_needComputeScaleX = true; |
554 | m_needComputeScaleY = true; | |
e40298d5 | 555 | } |
3dec57ad | 556 | } |
e40298d5 | 557 | |
e9576ca5 SC |
558 | void wxDC::SetUserScale( double x, double y ) |
559 | { | |
e40298d5 JS |
560 | // allow negative ? -> no |
561 | m_userScaleX = x; | |
562 | m_userScaleY = y; | |
563 | ComputeScaleAndOrigin(); | |
3dec57ad | 564 | } |
e40298d5 | 565 | |
e9576ca5 SC |
566 | void wxDC::SetLogicalScale( double x, double y ) |
567 | { | |
e40298d5 JS |
568 | // allow negative ? |
569 | m_logicalScaleX = x; | |
570 | m_logicalScaleY = y; | |
571 | ComputeScaleAndOrigin(); | |
3dec57ad | 572 | } |
e40298d5 | 573 | |
2f1ae414 | 574 | void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) |
e9576ca5 | 575 | { |
e40298d5 JS |
576 | m_logicalOriginX = x * m_signX; // is this still correct ? |
577 | m_logicalOriginY = y * m_signY; | |
578 | ComputeScaleAndOrigin(); | |
3dec57ad | 579 | } |
e40298d5 | 580 | |
2f1ae414 | 581 | void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) |
e9576ca5 | 582 | { |
e40298d5 JS |
583 | m_externalDeviceOriginX = x; |
584 | m_externalDeviceOriginY = y; | |
585 | ComputeScaleAndOrigin(); | |
3dec57ad | 586 | } |
e40298d5 | 587 | |
e9576ca5 SC |
588 | void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) |
589 | { | |
e40298d5 JS |
590 | m_signX = (xLeftRight ? 1 : -1); |
591 | m_signY = (yBottomUp ? -1 : 1); | |
592 | ComputeScaleAndOrigin(); | |
76a5e5d2 | 593 | } |
e40298d5 | 594 | |
2f1ae414 SC |
595 | wxSize wxDC::GetPPI() const |
596 | { | |
597 | return wxSize(72, 72); | |
598 | } | |
e40298d5 | 599 | |
2f1ae414 SC |
600 | int wxDC::GetDepth() const |
601 | { | |
c99d6f99 SC |
602 | if ( IsPortColor( (CGrafPtr) m_macPort ) ) |
603 | { | |
604 | return ( (**GetPortPixMap( (CGrafPtr) m_macPort)).pixelSize ) ; | |
605 | } | |
606 | return 1 ; | |
2f1ae414 | 607 | } |
e40298d5 | 608 | |
3dec57ad | 609 | void wxDC::ComputeScaleAndOrigin() |
e9576ca5 | 610 | { |
e40298d5 JS |
611 | // CMB: copy scale to see if it changes |
612 | double origScaleX = m_scaleX; | |
613 | double origScaleY = m_scaleY; | |
614 | m_scaleX = m_logicalScaleX * m_userScaleX; | |
615 | m_scaleY = m_logicalScaleY * m_userScaleY; | |
616 | m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; | |
617 | m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; | |
618 | // CMB: if scale has changed call SetPen to recalulate the line width | |
619 | if (m_scaleX != origScaleX || m_scaleY != origScaleY) | |
620 | { | |
621 | // this is a bit artificial, but we need to force wxDC to think | |
622 | // the pen has changed | |
7d9aac18 SC |
623 | wxPen pen(GetPen()); |
624 | m_pen = wxNullPen; | |
625 | SetPen(pen); | |
e40298d5 | 626 | } |
3dec57ad | 627 | } |
e40298d5 | 628 | |
519cb848 SC |
629 | void wxDC::SetPalette( const wxPalette& palette ) |
630 | { | |
631 | } | |
e40298d5 | 632 | |
519cb848 SC |
633 | void wxDC::SetBackgroundMode( int mode ) |
634 | { | |
e40298d5 | 635 | m_backgroundMode = mode ; |
519cb848 | 636 | } |
e40298d5 | 637 | |
519cb848 SC |
638 | void wxDC::SetFont( const wxFont &font ) |
639 | { | |
3dec57ad SC |
640 | m_font = font; |
641 | m_macFontInstalled = false ; | |
519cb848 | 642 | } |
e40298d5 | 643 | |
519cb848 SC |
644 | void wxDC::SetPen( const wxPen &pen ) |
645 | { | |
e40298d5 JS |
646 | if ( m_pen == pen ) |
647 | return ; | |
648 | m_pen = pen; | |
649 | m_macPenInstalled = false ; | |
519cb848 | 650 | } |
e40298d5 | 651 | |
519cb848 SC |
652 | void wxDC::SetBrush( const wxBrush &brush ) |
653 | { | |
e40298d5 JS |
654 | if (m_brush == brush) |
655 | return; | |
656 | m_brush = brush; | |
657 | m_macBrushInstalled = false ; | |
519cb848 | 658 | } |
e40298d5 | 659 | |
519cb848 SC |
660 | void wxDC::SetBackground( const wxBrush &brush ) |
661 | { | |
e40298d5 JS |
662 | if (m_backgroundBrush == brush) |
663 | return; | |
664 | m_backgroundBrush = brush; | |
665 | if (!m_backgroundBrush.Ok()) | |
666 | return; | |
667 | m_macBrushInstalled = false ; | |
519cb848 | 668 | } |
e40298d5 | 669 | |
519cb848 SC |
670 | void wxDC::SetLogicalFunction( int function ) |
671 | { | |
e40298d5 JS |
672 | if (m_logicalFunction == function) |
673 | return; | |
674 | m_logicalFunction = function ; | |
675 | m_macFontInstalled = false ; | |
676 | m_macBrushInstalled = false ; | |
677 | m_macPenInstalled = false ; | |
519cb848 | 678 | } |
e40298d5 | 679 | |
99030bdf | 680 | extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, |
3a0a5ada | 681 | const wxColour & col, int style); |
e40298d5 | 682 | |
387ebd3e | 683 | bool wxDC::DoFloodFill(wxCoord x, wxCoord y, |
3a0a5ada VS |
684 | const wxColour& col, int style) |
685 | { | |
387ebd3e | 686 | return wxDoFloodFill(this, x, y, col, style); |
71110b40 | 687 | } |
e40298d5 | 688 | |
99030bdf | 689 | bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const |
519cb848 | 690 | { |
3dec57ad | 691 | wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") ); |
8bebc229 | 692 | wxMacFastPortSetter helper(this) ; |
3dec57ad | 693 | RGBColor colour; |
7d9d1fd7 | 694 | GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour ); |
3dec57ad SC |
695 | // Convert from Mac colour to wx |
696 | col->Set( colour.red >> 8, | |
e40298d5 JS |
697 | colour.green >> 8, |
698 | colour.blue >> 8); | |
3dec57ad | 699 | return true ; |
519cb848 | 700 | } |
e40298d5 | 701 | |
2f1ae414 | 702 | void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) |
519cb848 | 703 | { |
e40298d5 | 704 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 705 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
706 | if (m_pen.GetStyle() != wxTRANSPARENT) |
707 | { | |
708 | MacInstallPen() ; | |
709 | wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : | |
710 | m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; | |
7d9d1fd7 SC |
711 | wxCoord xx1 = XLOG2DEVMAC(x1) - offset; |
712 | wxCoord yy1 = YLOG2DEVMAC(y1) - offset; | |
713 | wxCoord xx2 = XLOG2DEVMAC(x2) - offset; | |
714 | wxCoord yy2 = YLOG2DEVMAC(y2) - offset; | |
2301e281 RR |
715 | if ((m_pen.GetCap() == wxCAP_ROUND) && |
716 | (m_pen.GetWidth() <= 1)) | |
e40298d5 JS |
717 | { |
718 | // Implement LAST_NOT for MAC at least for | |
719 | // orthogonal lines. RR. | |
720 | if (xx1 == xx2) | |
721 | { | |
722 | if (yy1 < yy2) | |
723 | yy2--; | |
724 | if (yy1 > yy2) | |
725 | yy2++; | |
726 | } | |
727 | if (yy1 == yy2) | |
728 | { | |
729 | if (xx1 < xx2) | |
730 | xx2--; | |
731 | if (xx1 > xx2) | |
732 | xx2++; | |
733 | } | |
734 | } | |
735 | ::MoveTo(xx1, yy1); | |
736 | ::LineTo(xx2, yy2); | |
737 | } | |
519cb848 | 738 | } |
e40298d5 | 739 | |
2f1ae414 | 740 | void wxDC::DoCrossHair( wxCoord x, wxCoord y ) |
519cb848 | 741 | { |
3dec57ad | 742 | wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") ); |
8bebc229 | 743 | wxMacFastPortSetter helper(this) ; |
3dec57ad SC |
744 | if (m_pen.GetStyle() != wxTRANSPARENT) |
745 | { | |
746 | int w = 0; | |
747 | int h = 0; | |
748 | GetSize( &w, &h ); | |
7d9d1fd7 SC |
749 | wxCoord xx = XLOG2DEVMAC(x); |
750 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad | 751 | MacInstallPen(); |
7d9d1fd7 SC |
752 | ::MoveTo( XLOG2DEVMAC(0), yy ); |
753 | ::LineTo( XLOG2DEVMAC(w), yy ); | |
754 | ::MoveTo( xx, YLOG2DEVMAC(0) ); | |
755 | ::LineTo( xx, YLOG2DEVMAC(h) ); | |
66a09d47 SC |
756 | CalcBoundingBox(x, y); |
757 | CalcBoundingBox(x+w, y+h); | |
3dec57ad SC |
758 | } |
759 | } | |
e40298d5 | 760 | |
3dec57ad | 761 | /* |
e40298d5 JS |
762 | * To draw arcs properly the angles need to be converted from the WX style: |
763 | * Angles start on the +ve X axis and go anti-clockwise (As you would draw on | |
764 | * a normal axis on paper). | |
765 | * TO | |
766 | * the Mac style: | |
767 | * Angles start on the +ve y axis and go clockwise. | |
768 | */ | |
769 | ||
3dec57ad SC |
770 | static double wxConvertWXangleToMACangle(double angle) |
771 | { | |
2beae4b5 | 772 | double newAngle = 90 - angle ; |
a99915c2 SC |
773 | while ( newAngle > 360 ) newAngle -= 360 ; |
774 | while ( newAngle < 0 ) newAngle += 360 ; | |
2beae4b5 | 775 | return newAngle ; |
519cb848 | 776 | } |
e40298d5 | 777 | |
2f1ae414 | 778 | void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, |
e40298d5 JS |
779 | wxCoord x2, wxCoord y2, |
780 | wxCoord xc, wxCoord yc ) | |
519cb848 | 781 | { |
3dec57ad | 782 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC")); |
8bebc229 | 783 | wxMacFastPortSetter helper(this) ; |
7d9d1fd7 SC |
784 | wxCoord xx1 = XLOG2DEVMAC(x1); |
785 | wxCoord yy1 = YLOG2DEVMAC(y1); | |
786 | wxCoord xx2 = XLOG2DEVMAC(x2); | |
787 | wxCoord yy2 = YLOG2DEVMAC(y2); | |
788 | wxCoord xxc = XLOG2DEVMAC(xc); | |
789 | wxCoord yyc = YLOG2DEVMAC(yc); | |
3dec57ad SC |
790 | double dx = xx1 - xxc; |
791 | double dy = yy1 - yyc; | |
792 | double radius = sqrt((double)(dx*dx+dy*dy)); | |
793 | wxCoord rad = (wxCoord)radius; | |
794 | double radius1, radius2; | |
3dec57ad SC |
795 | if (xx1 == xx2 && yy1 == yy2) |
796 | { | |
797 | radius1 = 0.0; | |
798 | radius2 = 360.0; | |
799 | } | |
800 | else if (radius == 0.0) | |
801 | { | |
802 | radius1 = radius2 = 0.0; | |
803 | } | |
804 | else | |
805 | { | |
806 | radius1 = (xx1 - xxc == 0) ? | |
807 | (yy1 - yyc < 0) ? 90.0 : -90.0 : | |
e40298d5 JS |
808 | -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; |
809 | radius2 = (xx2 - xxc == 0) ? | |
3dec57ad | 810 | (yy2 - yyc < 0) ? 90.0 : -90.0 : |
e40298d5 JS |
811 | -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; |
812 | } | |
813 | wxCoord alpha2 = wxCoord(radius2 - radius1); | |
3dec57ad | 814 | wxCoord alpha1 = wxCoord(wxConvertWXangleToMACangle(radius1)); |
a99915c2 SC |
815 | while( alpha2 < 0 ) alpha2 += 360 ; |
816 | alpha2 = -alpha2 ; | |
3dec57ad | 817 | Rect r = { yyc - rad, xxc - rad, yyc + rad, xxc + rad }; |
3dec57ad SC |
818 | if(m_brush.GetStyle() != wxTRANSPARENT) { |
819 | MacInstallBrush(); | |
820 | PaintArc(&r, alpha1, alpha2); | |
821 | } | |
822 | if(m_pen.GetStyle() != wxTRANSPARENT) { | |
823 | MacInstallPen(); | |
824 | FrameArc(&r, alpha1, alpha2); | |
825 | } | |
519cb848 | 826 | } |
e40298d5 | 827 | |
2f1ae414 | 828 | void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, |
e40298d5 | 829 | double sa, double ea ) |
519cb848 | 830 | { |
3dec57ad | 831 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC")); |
8bebc229 | 832 | wxMacFastPortSetter helper(this) ; |
3dec57ad SC |
833 | Rect r; |
834 | double angle = sa - ea; // Order important Mac in opposite direction to wx | |
2beae4b5 SC |
835 | // we have to make sure that the filling is always counter-clockwise |
836 | if ( angle > 0 ) | |
837 | angle -= 360 ; | |
7d9d1fd7 SC |
838 | wxCoord xx = XLOG2DEVMAC(x); |
839 | wxCoord yy = YLOG2DEVMAC(y); | |
3dec57ad SC |
840 | wxCoord ww = m_signX * XLOG2DEVREL(w); |
841 | wxCoord hh = m_signY * YLOG2DEVREL(h); | |
3dec57ad SC |
842 | // handle -ve width and/or height |
843 | if (ww < 0) { ww = -ww; xx = xx - ww; } | |
844 | if (hh < 0) { hh = -hh; yy = yy - hh; } | |
3dec57ad | 845 | sa = wxConvertWXangleToMACangle(sa); |
3dec57ad SC |
846 | r.top = yy; |
847 | r.left = xx; | |
848 | r.bottom = yy + hh; | |
849 | r.right = xx + ww; | |
3dec57ad SC |
850 | if(m_brush.GetStyle() != wxTRANSPARENT) { |
851 | MacInstallBrush(); | |
852 | PaintArc(&r, (short)sa, (short)angle); | |
853 | } | |
854 | if(m_pen.GetStyle() != wxTRANSPARENT) { | |
855 | MacInstallPen(); | |
856 | FrameArc(&r, (short)sa, (short)angle); | |
857 | } | |
519cb848 | 858 | } |
e40298d5 | 859 | |
2f1ae414 | 860 | void wxDC::DoDrawPoint( wxCoord x, wxCoord y ) |
519cb848 | 861 | { |
e40298d5 | 862 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 863 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
864 | if (m_pen.GetStyle() != wxTRANSPARENT) |
865 | { | |
99030bdf | 866 | wxCoord xx1 = XLOG2DEVMAC(x); |
7d9d1fd7 | 867 | wxCoord yy1 = YLOG2DEVMAC(y); |
5e420341 SC |
868 | RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); |
869 | ::SetCPixel( xx1,yy1,&pencolor) ; | |
870 | CalcBoundingBox(x, y); | |
e40298d5 | 871 | } |
519cb848 | 872 | } |
e40298d5 | 873 | |
2f1ae414 | 874 | void wxDC::DoDrawLines(int n, wxPoint points[], |
e40298d5 JS |
875 | wxCoord xoffset, wxCoord yoffset) |
876 | { | |
877 | wxCHECK_RET(Ok(), wxT("Invalid DC")); | |
8bebc229 | 878 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
879 | if (m_pen.GetStyle() == wxTRANSPARENT) |
880 | return; | |
881 | MacInstallPen() ; | |
882 | wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : | |
883 | m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; | |
884 | wxCoord x1, x2 , y1 , y2 ; | |
885 | x1 = XLOG2DEVMAC(points[0].x + xoffset); | |
886 | y1 = YLOG2DEVMAC(points[0].y + yoffset); | |
887 | ::MoveTo(x1 - offset, y1 - offset ); | |
888 | for (int i = 0; i < n-1; i++) | |
889 | { | |
890 | x2 = XLOG2DEVMAC(points[i+1].x + xoffset); | |
891 | y2 = YLOG2DEVMAC(points[i+1].y + yoffset); | |
892 | ::LineTo( x2 - offset, y2 - offset ); | |
893 | } | |
519cb848 | 894 | } |
e40298d5 | 895 | |
2f1ae414 | 896 | void wxDC::DoDrawPolygon(int n, wxPoint points[], |
d84afea9 GD |
897 | wxCoord xoffset, wxCoord yoffset, |
898 | int fillStyle ) | |
519cb848 | 899 | { |
e40298d5 | 900 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 901 | wxMacFastPortSetter helper(this) ; |
e40298d5 | 902 | wxCoord x1, x2 , y1 , y2 ; |
75f7bc3b SC |
903 | if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) |
904 | return ; | |
e40298d5 JS |
905 | PolyHandle polygon = OpenPoly(); |
906 | x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); | |
907 | y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); | |
908 | ::MoveTo(x1,y1); | |
909 | for (int i = 1; i < n; i++) | |
910 | { | |
911 | x2 = XLOG2DEVMAC(points[i].x + xoffset); | |
912 | y2 = YLOG2DEVMAC(points[i].y + yoffset); | |
913 | ::LineTo(x2, y2); | |
914 | } | |
76a5e5d2 SC |
915 | // close the polyline if necessary |
916 | if ( x1 != x2 || y1 != y2 ) | |
917 | { | |
918 | ::LineTo(x1,y1 ) ; | |
919 | } | |
e40298d5 JS |
920 | ClosePoly(); |
921 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
922 | { | |
923 | MacInstallBrush(); | |
924 | ::PaintPoly( polygon ); | |
925 | } | |
926 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
927 | { | |
928 | MacInstallPen() ; | |
929 | ::FramePoly( polygon ) ; | |
930 | } | |
931 | KillPoly( polygon ); | |
519cb848 | 932 | } |
e40298d5 | 933 | |
3dec57ad | 934 | void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
519cb848 | 935 | { |
3dec57ad | 936 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 937 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
938 | wxCoord xx = XLOG2DEVMAC(x); |
939 | wxCoord yy = YLOG2DEVMAC(y); | |
940 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
941 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
942 | // CMB: draw nothing if transformed w or h is 0 | |
943 | if (ww == 0 || hh == 0) | |
944 | return; | |
945 | // CMB: handle -ve width and/or height | |
946 | if (ww < 0) | |
947 | { | |
948 | ww = -ww; | |
949 | xx = xx - ww; | |
950 | } | |
951 | if (hh < 0) | |
952 | { | |
953 | hh = -hh; | |
954 | yy = yy - hh; | |
955 | } | |
956 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
957 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
958 | { | |
959 | MacInstallBrush() ; | |
960 | ::PaintRect( &rect ) ; | |
961 | } | |
962 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
963 | { | |
964 | MacInstallPen() ; | |
965 | ::FrameRect( &rect ) ; | |
966 | } | |
519cb848 | 967 | } |
e40298d5 | 968 | |
2f1ae414 | 969 | void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, |
e40298d5 JS |
970 | wxCoord width, wxCoord height, |
971 | double radius) | |
519cb848 | 972 | { |
3dec57ad | 973 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 974 | wxMacFastPortSetter helper(this) ; |
99030bdf | 975 | if (radius < 0.0) |
e40298d5 JS |
976 | radius = - radius * ((width < height) ? width : height); |
977 | wxCoord xx = XLOG2DEVMAC(x); | |
978 | wxCoord yy = YLOG2DEVMAC(y); | |
979 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
980 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
981 | // CMB: draw nothing if transformed w or h is 0 | |
982 | if (ww == 0 || hh == 0) | |
983 | return; | |
984 | // CMB: handle -ve width and/or height | |
985 | if (ww < 0) | |
986 | { | |
987 | ww = -ww; | |
988 | xx = xx - ww; | |
989 | } | |
990 | if (hh < 0) | |
991 | { | |
992 | hh = -hh; | |
993 | yy = yy - hh; | |
994 | } | |
995 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
996 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
997 | { | |
998 | MacInstallBrush() ; | |
999 | ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; | |
1000 | } | |
1001 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
1002 | { | |
1003 | MacInstallPen() ; | |
1004 | ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; | |
1005 | } | |
519cb848 | 1006 | } |
e40298d5 | 1007 | |
2f1ae414 | 1008 | void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
519cb848 | 1009 | { |
3dec57ad | 1010 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 1011 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
1012 | wxCoord xx = XLOG2DEVMAC(x); |
1013 | wxCoord yy = YLOG2DEVMAC(y); | |
1014 | wxCoord ww = m_signX * XLOG2DEVREL(width); | |
1015 | wxCoord hh = m_signY * YLOG2DEVREL(height); | |
1016 | // CMB: draw nothing if transformed w or h is 0 | |
1017 | if (ww == 0 || hh == 0) | |
1018 | return; | |
1019 | // CMB: handle -ve width and/or height | |
1020 | if (ww < 0) | |
1021 | { | |
1022 | ww = -ww; | |
1023 | xx = xx - ww; | |
1024 | } | |
1025 | if (hh < 0) | |
1026 | { | |
1027 | hh = -hh; | |
1028 | yy = yy - hh; | |
1029 | } | |
1030 | Rect rect = { yy , xx , yy + hh , xx + ww } ; | |
1031 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
1032 | { | |
1033 | MacInstallBrush() ; | |
1034 | ::PaintOval( &rect ) ; | |
1035 | } | |
1036 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
1037 | { | |
1038 | MacInstallPen() ; | |
1039 | ::FrameOval( &rect ) ; | |
1040 | } | |
519cb848 SC |
1041 | } |
1042 | ||
99030bdf | 1043 | bool wxDC::CanDrawBitmap(void) const |
519cb848 | 1044 | { |
e40298d5 | 1045 | return true ; |
519cb848 SC |
1046 | } |
1047 | ||
2f1ae414 | 1048 | bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
e40298d5 JS |
1049 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, |
1050 | wxCoord xsrcMask, wxCoord ysrcMask ) | |
519cb848 | 1051 | { |
3dec57ad SC |
1052 | wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc")); |
1053 | wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC")); | |
76a5e5d2 | 1054 | if ( logical_func == wxNO_OP ) |
ab9d0a8c | 1055 | return true ; |
0cbff120 JS |
1056 | if (xsrcMask == -1 && ysrcMask == -1) |
1057 | { | |
1058 | xsrcMask = xsrc; ysrcMask = ysrc; | |
1059 | } | |
76a5e5d2 | 1060 | // correct the parameter in case this dc does not have a mask at all |
76a5e5d2 SC |
1061 | if ( useMask && !source->m_macMask ) |
1062 | useMask = false ; | |
e40298d5 JS |
1063 | Rect srcrect , dstrect ; |
1064 | srcrect.top = source->YLOG2DEVMAC(ysrc) ; | |
1065 | srcrect.left = source->XLOG2DEVMAC(xsrc) ; | |
1066 | srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; | |
1067 | srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; | |
1068 | dstrect.top = YLOG2DEVMAC(ydest) ; | |
1069 | dstrect.left = XLOG2DEVMAC(xdest) ; | |
1070 | dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; | |
1071 | dstrect.right = XLOG2DEVMAC(xdest + width ) ; | |
76a5e5d2 SC |
1072 | short mode = kUnsupportedMode ; |
1073 | bool invertDestinationFirst = false ; | |
1074 | switch ( logical_func ) | |
1075 | { | |
e40298d5 | 1076 | case wxAND: // src AND dst |
4a95c885 | 1077 | mode = adMin ; // ok |
e40298d5 JS |
1078 | break ; |
1079 | case wxAND_INVERT: // (NOT src) AND dst | |
1080 | mode = notSrcOr ; // ok | |
1081 | break ; | |
1082 | case wxAND_REVERSE:// src AND (NOT dst) | |
1083 | invertDestinationFirst = true ; | |
1084 | mode = srcOr ; | |
1085 | break ; | |
1086 | case wxCLEAR: // 0 | |
1087 | mode = kEmulatedMode ; | |
1088 | break ; | |
1089 | case wxCOPY: // src | |
1090 | mode = srcCopy ; // ok | |
1091 | break ; | |
1092 | case wxEQUIV: // (NOT src) XOR dst | |
1093 | mode = srcXor ; // ok | |
1094 | break ; | |
1095 | case wxINVERT: // NOT dst | |
1096 | mode = kEmulatedMode ; //or hilite ; | |
1097 | break ; | |
1098 | case wxNAND: // (NOT src) OR (NOT dst) | |
1099 | invertDestinationFirst = true ; | |
1100 | mode = srcBic ; | |
1101 | break ; | |
1102 | case wxNOR: // (NOT src) AND (NOT dst) | |
1103 | invertDestinationFirst = true ; | |
1104 | mode = notSrcOr ; | |
1105 | break ; | |
1106 | case wxNO_OP: // dst | |
1107 | mode = kEmulatedMode ; // this has already been handled upon entry | |
1108 | break ; | |
1109 | case wxOR: // src OR dst | |
1110 | mode = notSrcBic ; | |
1111 | break ; | |
1112 | case wxOR_INVERT: // (NOT src) OR dst | |
1113 | mode = srcBic ; | |
1114 | break ; | |
1115 | case wxOR_REVERSE: // src OR (NOT dst) | |
1116 | invertDestinationFirst = true ; | |
1117 | mode = notSrcBic ; | |
1118 | break ; | |
1119 | case wxSET: // 1 | |
1120 | mode = kEmulatedMode ; | |
1121 | break ; | |
1122 | case wxSRC_INVERT: // (NOT src) | |
1123 | mode = notSrcCopy ; // ok | |
1124 | break ; | |
1125 | case wxXOR: // src XOR dst | |
1126 | mode = notSrcXor ; // ok | |
1127 | break ; | |
1128 | default : | |
1129 | break ; | |
76a5e5d2 | 1130 | } |
76a5e5d2 SC |
1131 | if ( mode == kUnsupportedMode ) |
1132 | { | |
427ff662 | 1133 | wxFAIL_MSG(wxT("unsupported blitting mode" )); |
ab9d0a8c | 1134 | return false ; |
76a5e5d2 | 1135 | } |
e40298d5 JS |
1136 | CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; |
1137 | PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; | |
1138 | if ( LockPixels(bmappixels) ) | |
1139 | { | |
8bebc229 | 1140 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
1141 | if ( source->GetDepth() == 1 ) |
1142 | { | |
1143 | RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; | |
1144 | RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; | |
76a5e5d2 SC |
1145 | } |
1146 | else | |
1147 | { | |
1148 | // the modes need this, otherwise we'll end up having really nice colors... | |
e40298d5 JS |
1149 | RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; |
1150 | RGBColor black = { 0,0,0} ; | |
1151 | RGBForeColor( &black ) ; | |
1152 | RGBBackColor( &white ) ; | |
76a5e5d2 | 1153 | } |
e40298d5 JS |
1154 | if ( useMask && source->m_macMask ) |
1155 | { | |
1156 | if ( mode == srcCopy ) | |
1157 | { | |
1158 | if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) | |
1159 | { | |
1160 | CopyMask( GetPortBitMapForCopyBits( sourcePort ) , | |
1161 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , | |
1162 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1163 | &srcrect, &srcrect , &dstrect ) ; | |
1164 | UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1165 | } | |
1166 | } | |
1167 | else | |
1168 | { | |
1dcbbdcf | 1169 | RgnHandle clipRgn = NewRgn() ; |
76a5e5d2 SC |
1170 | LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; |
1171 | BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1172 | UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; | |
1dcbbdcf | 1173 | OffsetRgn( clipRgn , -srcrect.left + dstrect.left, -srcrect.top + dstrect.top ) ; |
76a5e5d2 SC |
1174 | if ( mode == kEmulatedMode ) |
1175 | { | |
1176 | Pattern pat ; | |
e40298d5 | 1177 | ::PenPat(GetQDGlobalsBlack(&pat)); |
76a5e5d2 SC |
1178 | if ( logical_func == wxSET ) |
1179 | { | |
1180 | RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; | |
e40298d5 | 1181 | ::RGBForeColor( &col ) ; |
76a5e5d2 SC |
1182 | ::PaintRgn( clipRgn ) ; |
1183 | } | |
1184 | else if ( logical_func == wxCLEAR ) | |
1185 | { | |
1186 | RGBColor col= { 0x0000, 0x0000, 0x0000 } ; | |
e40298d5 | 1187 | ::RGBForeColor( &col ) ; |
76a5e5d2 SC |
1188 | ::PaintRgn( clipRgn ) ; |
1189 | } | |
1190 | else if ( logical_func == wxINVERT ) | |
1191 | { | |
1192 | MacInvertRgn( clipRgn ) ; | |
1193 | } | |
1194 | else | |
1195 | { | |
1196 | for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y ) | |
1197 | { | |
1198 | for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x ) | |
1199 | { | |
1200 | Point dstPoint = { dstrect.top + y , dstrect.left + x } ; | |
1201 | Point srcPoint = { srcrect.top + y , srcrect.left + x } ; | |
1202 | if ( PtInRgn( dstPoint , clipRgn ) ) | |
1203 | { | |
1204 | RGBColor srcColor ; | |
1205 | RGBColor dstColor ; | |
76a5e5d2 SC |
1206 | SetPort( (GrafPtr) sourcePort ) ; |
1207 | GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ; | |
1208 | SetPort( (GrafPtr) m_macPort ) ; | |
1209 | GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
76a5e5d2 SC |
1210 | wxMacCalculateColour( logical_func , srcColor , dstColor ) ; |
1211 | SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
1212 | } | |
1213 | } | |
1214 | } | |
76a5e5d2 SC |
1215 | } |
1216 | } | |
1217 | else | |
1218 | { | |
1219 | if ( invertDestinationFirst ) | |
1220 | { | |
1221 | MacInvertRgn( clipRgn ) ; | |
1222 | } | |
e40298d5 JS |
1223 | CopyBits( GetPortBitMapForCopyBits( sourcePort ) , |
1224 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1225 | &srcrect, &dstrect, mode, clipRgn ) ; | |
1226 | } | |
1227 | DisposeRgn( clipRgn ) ; | |
1228 | } | |
1229 | } | |
1230 | else | |
1231 | { | |
0d54461f SC |
1232 | RgnHandle clipRgn = NewRgn() ; |
1233 | SetRectRgn( clipRgn , dstrect.left , dstrect.top , dstrect.right , dstrect.bottom ) ; | |
e40298d5 JS |
1234 | if ( mode == kEmulatedMode ) |
1235 | { | |
0d54461f | 1236 | Pattern pat ; |
e40298d5 | 1237 | ::PenPat(GetQDGlobalsBlack(&pat)); |
0d54461f SC |
1238 | if ( logical_func == wxSET ) |
1239 | { | |
1240 | RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; | |
e40298d5 | 1241 | ::RGBForeColor( &col ) ; |
0d54461f SC |
1242 | ::PaintRgn( clipRgn ) ; |
1243 | } | |
1244 | else if ( logical_func == wxCLEAR ) | |
1245 | { | |
1246 | RGBColor col= { 0x0000, 0x0000, 0x0000 } ; | |
e40298d5 | 1247 | ::RGBForeColor( &col ) ; |
0d54461f SC |
1248 | ::PaintRgn( clipRgn ) ; |
1249 | } | |
1250 | else if ( logical_func == wxINVERT ) | |
1251 | { | |
1252 | MacInvertRgn( clipRgn ) ; | |
1253 | } | |
1254 | else | |
1255 | { | |
1256 | for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y ) | |
1257 | { | |
1258 | for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x ) | |
1259 | { | |
1260 | Point dstPoint = { dstrect.top + y , dstrect.left + x } ; | |
1261 | Point srcPoint = { srcrect.top + y , srcrect.left + x } ; | |
0d54461f SC |
1262 | { |
1263 | RGBColor srcColor ; | |
1264 | RGBColor dstColor ; | |
0d54461f SC |
1265 | SetPort( (GrafPtr) sourcePort ) ; |
1266 | GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ; | |
1267 | SetPort( (GrafPtr) m_macPort ) ; | |
1268 | GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
0d54461f SC |
1269 | wxMacCalculateColour( logical_func , srcColor , dstColor ) ; |
1270 | SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ; | |
1271 | } | |
1272 | } | |
1273 | } | |
1274 | } | |
e40298d5 JS |
1275 | } |
1276 | else | |
1277 | { | |
0d54461f SC |
1278 | if ( invertDestinationFirst ) |
1279 | { | |
1280 | MacInvertRgn( clipRgn ) ; | |
1281 | } | |
e40298d5 JS |
1282 | CopyBits( GetPortBitMapForCopyBits( sourcePort ) , |
1283 | GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , | |
1284 | &srcrect, &dstrect, mode, NULL ) ; | |
1285 | } | |
1286 | DisposeRgn( clipRgn ) ; | |
1287 | } | |
1288 | UnlockPixels( bmappixels ) ; | |
1289 | } | |
1290 | m_macPenInstalled = false ; | |
1291 | m_macBrushInstalled = false ; | |
1292 | m_macFontInstalled = false ; | |
ab9d0a8c | 1293 | return true; |
e40298d5 JS |
1294 | } |
1295 | ||
42800de6 SC |
1296 | #ifndef FixedToInt |
1297 | // as macro in FixMath.h for 10.3 | |
e40298d5 JS |
1298 | inline Fixed IntToFixed( int inInt ) |
1299 | { | |
1300 | return (((SInt32) inInt) << 16); | |
1301 | } | |
1302 | ||
1303 | inline int FixedToInt( Fixed inFixed ) | |
1304 | { | |
1305 | return (((SInt32) inFixed) >> 16); | |
1306 | } | |
42800de6 | 1307 | #endif |
2beae4b5 | 1308 | |
66a09d47 | 1309 | void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, |
3dec57ad | 1310 | double angle) |
2f1ae414 | 1311 | { |
fc58c6be | 1312 | // TODO support text background color (only possible by hand, ATSUI does not support it) |
3dec57ad | 1313 | wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") ); |
26b9b4e1 | 1314 | |
32907dbd SC |
1315 | if ( str.Length() == 0 ) |
1316 | return ; | |
fc58c6be | 1317 | |
8bebc229 | 1318 | wxMacFastPortSetter helper(this) ; |
66a09d47 | 1319 | MacInstallFont() ; |
427ff662 | 1320 | |
66a09d47 | 1321 | if ( 0 ) |
3dec57ad | 1322 | { |
66a09d47 | 1323 | m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); |
facd6764 | 1324 | SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.MacGetFontSize())); |
66a09d47 | 1325 | m_macAliasWasEnabled = true ; |
3dec57ad | 1326 | } |
66a09d47 | 1327 | OSStatus status = noErr ; |
427ff662 SC |
1328 | ATSUTextLayout atsuLayout ; |
1329 | UniCharCount chars = str.Length() ; | |
96cadce3 SC |
1330 | UniChar* ubuf = NULL ; |
1331 | #if SIZEOF_WCHAR_T == 4 | |
ab9d0a8c | 1332 | wxMBConvUTF16BE converter ; |
427ff662 | 1333 | #if wxUSE_UNICODE |
ab9d0a8c WS |
1334 | size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ; |
1335 | ubuf = (UniChar*) malloc( unicharlen + 2 ) ; | |
1336 | converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ; | |
96cadce3 SC |
1337 | #else |
1338 | const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ; | |
ab9d0a8c WS |
1339 | size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ; |
1340 | ubuf = (UniChar*) malloc( unicharlen + 2 ) ; | |
1341 | converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ; | |
96cadce3 SC |
1342 | #endif |
1343 | chars = unicharlen / 2 ; | |
1344 | #else | |
1345 | #if wxUSE_UNICODE | |
1346 | ubuf = (UniChar*) str.wc_str() ; | |
427ff662 | 1347 | #else |
939fba6c | 1348 | wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ; |
96cadce3 SC |
1349 | chars = wxWcslen( wchar.data() ) ; |
1350 | ubuf = (UniChar*) wchar.data() ; | |
427ff662 | 1351 | #endif |
96cadce3 SC |
1352 | #endif |
1353 | ||
1354 | status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 , | |
1355 | &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; | |
1356 | ||
427ff662 | 1357 | wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); |
3340066a | 1358 | int iAngle = int( angle ); |
2beae4b5 SC |
1359 | int drawX = XLOG2DEVMAC(x) ; |
1360 | int drawY = YLOG2DEVMAC(y) ; | |
ab9d0a8c | 1361 | |
2beae4b5 SC |
1362 | ATSUTextMeasurement textBefore ; |
1363 | ATSUTextMeasurement textAfter ; | |
1364 | ATSUTextMeasurement ascent ; | |
1365 | ATSUTextMeasurement descent ; | |
ab9d0a8c WS |
1366 | |
1367 | ||
3340066a | 1368 | if ( abs(iAngle) > 0 ) |
32907dbd | 1369 | { |
3340066a | 1370 | Fixed atsuAngle = IntToFixed( iAngle ) ; |
e40298d5 JS |
1371 | ATSUAttributeTag atsuTags[] = |
1372 | { | |
1373 | kATSULineRotationTag , | |
1374 | } ; | |
1375 | ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = | |
1376 | { | |
1377 | sizeof( Fixed ) , | |
1378 | } ; | |
1379 | ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = | |
1380 | { | |
1381 | &atsuAngle , | |
1382 | } ; | |
1383 | status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), | |
1384 | atsuTags, atsuSizes, atsuValues ) ; | |
1385 | } | |
1386 | status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, | |
1387 | &textBefore , &textAfter, &ascent , &descent ); | |
ab9d0a8c | 1388 | |
5be55d56 VZ |
1389 | drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent)); |
1390 | drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent)); | |
32907dbd | 1391 | status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, |
e40298d5 | 1392 | IntToFixed(drawX) , IntToFixed(drawY) ); |
427ff662 | 1393 | wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); |
66a09d47 | 1394 | Rect rect ; |
e40298d5 JS |
1395 | status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, |
1396 | IntToFixed(drawX) , IntToFixed(drawY) , &rect ); | |
427ff662 | 1397 | wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); |
66a09d47 SC |
1398 | OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; |
1399 | CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); | |
1400 | CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); | |
1401 | ::ATSUDisposeTextLayout(atsuLayout); | |
96cadce3 SC |
1402 | #if SIZEOF_WCHAR_T == 4 |
1403 | free( ubuf ) ; | |
1404 | #endif | |
2f1ae414 | 1405 | } |
e40298d5 | 1406 | |
2f1ae414 | 1407 | void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) |
99030bdf | 1408 | { |
3dec57ad | 1409 | wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC")); |
26b9b4e1 | 1410 | |
8bebc229 | 1411 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
1412 | long xx = XLOG2DEVMAC(x); |
1413 | long yy = YLOG2DEVMAC(y); | |
99030bdf | 1414 | #if TARGET_CARBON |
e40298d5 | 1415 | bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; |
b7047aa5 | 1416 | if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || m_font.GetNoAntiAliasing() ) |
e40298d5 | 1417 | useDrawThemeText = false ; |
6606ecac | 1418 | #endif |
e40298d5 | 1419 | MacInstallFont() ; |
fc58c6be | 1420 | |
e40298d5 JS |
1421 | FontInfo fi ; |
1422 | ::GetFontInfo( &fi ) ; | |
99030bdf | 1423 | #if TARGET_CARBON |
e40298d5 | 1424 | if ( !useDrawThemeText ) |
6606ecac | 1425 | #endif |
e40298d5 JS |
1426 | yy += fi.ascent ; |
1427 | ::MoveTo( xx , yy ); | |
1428 | if ( m_backgroundMode == wxTRANSPARENT ) | |
1429 | { | |
1430 | ::TextMode( srcOr) ; | |
1431 | } | |
1432 | else | |
1433 | { | |
1434 | ::TextMode( srcCopy ) ; | |
1435 | } | |
e40298d5 JS |
1436 | int line = 0 ; |
1437 | { | |
b93f3832 | 1438 | wxString linetext = strtext ; |
6606ecac | 1439 | #if TARGET_CARBON |
32907dbd | 1440 | if ( useDrawThemeText ) |
e40298d5 JS |
1441 | { |
1442 | Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; | |
a9412f8f | 1443 | wxMacCFStringHolder mString( linetext , m_font.GetEncoding()) ; |
4a95c885 | 1444 | |
5fa00d24 SC |
1445 | if ( m_backgroundMode != wxTRANSPARENT ) |
1446 | { | |
e40298d5 JS |
1447 | Point bounds={0,0} ; |
1448 | Rect background = frame ; | |
1449 | SInt16 baseline ; | |
1450 | ::GetThemeTextDimensions( mString, | |
facd6764 | 1451 | m_font.MacGetThemeFontID() , |
e40298d5 JS |
1452 | kThemeStateActive, |
1453 | false, | |
1454 | &bounds, | |
1455 | &baseline ); | |
1456 | background.right = background.left + bounds.h ; | |
1457 | background.bottom = background.top + bounds.v ; | |
1458 | ::EraseRect( &background ) ; | |
5fa00d24 | 1459 | } |
e40298d5 | 1460 | ::DrawThemeTextBox( mString, |
facd6764 | 1461 | m_font.MacGetThemeFontID() , |
e40298d5 JS |
1462 | kThemeStateActive, |
1463 | false, | |
1464 | &frame, | |
1465 | teJustLeft, | |
1466 | nil ); | |
32907dbd SC |
1467 | } |
1468 | else | |
6606ecac | 1469 | #endif |
99030bdf | 1470 | { |
ab9d0a8c | 1471 | wxCharBuffer text = linetext.mb_str(wxConvLocal) ; |
427ff662 SC |
1472 | ::DrawText( text , 0 , strlen(text) ) ; |
1473 | } | |
e40298d5 JS |
1474 | } |
1475 | ::TextMode( srcOr ) ; | |
519cb848 | 1476 | } |
e40298d5 | 1477 | |
99030bdf | 1478 | bool wxDC::CanGetTextExtent() const |
519cb848 | 1479 | { |
e40298d5 JS |
1480 | wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); |
1481 | return true ; | |
519cb848 | 1482 | } |
e40298d5 | 1483 | |
427ff662 | 1484 | void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height, |
e40298d5 JS |
1485 | wxCoord *descent, wxCoord *externalLeading , |
1486 | wxFont *theFont ) const | |
1487 | { | |
1488 | wxCHECK_RET(Ok(), wxT("Invalid DC")); | |
8bebc229 | 1489 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
1490 | wxFont formerFont = m_font ; |
1491 | if ( theFont ) | |
1492 | { | |
1493 | // work around the constness | |
1494 | *((wxFont*)(&m_font)) = *theFont ; | |
1495 | } | |
1496 | MacInstallFont() ; | |
1497 | FontInfo fi ; | |
1498 | ::GetFontInfo( &fi ) ; | |
ab9d0a8c | 1499 | #if TARGET_CARBON |
e40298d5 | 1500 | bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; |
b7047aa5 | 1501 | if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) |
e40298d5 | 1502 | useGetThemeText = false ; |
f52640f3 | 1503 | #endif |
e40298d5 JS |
1504 | if ( height ) |
1505 | *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; | |
1506 | if ( descent ) | |
1507 | *descent =YDEV2LOGREL( fi.descent ); | |
1508 | if ( externalLeading ) | |
1509 | *externalLeading = YDEV2LOGREL( fi.leading ) ; | |
939fba6c | 1510 | |
e40298d5 JS |
1511 | int curwidth = 0 ; |
1512 | if ( width ) | |
1513 | { | |
1514 | *width = 0 ; | |
b93f3832 | 1515 | wxString linetext = strtext ; |
facd6764 | 1516 | |
f52640f3 SC |
1517 | if ( useGetThemeText ) |
1518 | { | |
1519 | Point bounds={0,0} ; | |
aee9fe73 | 1520 | SInt16 baseline ; |
a9412f8f | 1521 | wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; |
facd6764 | 1522 | ThemeFontID themeFont = m_font.MacGetThemeFontID() ; |
e40298d5 | 1523 | ::GetThemeTextDimensions( mString, |
facd6764 | 1524 | themeFont , |
e40298d5 JS |
1525 | kThemeStateActive, |
1526 | false, | |
1527 | &bounds, | |
1528 | &baseline ); | |
e40298d5 | 1529 | curwidth = bounds.h ; |
f52640f3 SC |
1530 | } |
1531 | else | |
f52640f3 | 1532 | { |
ab9d0a8c | 1533 | wxCharBuffer text = linetext.mb_str(wxConvLocal) ; |
427ff662 | 1534 | curwidth = ::TextWidth( text , 0 , strlen(text) ) ; |
e40298d5 JS |
1535 | } |
1536 | if ( curwidth > *width ) | |
1537 | *width = XDEV2LOGREL( curwidth ) ; | |
1538 | } | |
1539 | if ( theFont ) | |
1540 | { | |
1541 | // work around the constness | |
1542 | *((wxFont*)(&m_font)) = formerFont ; | |
1543 | m_macFontInstalled = false ; | |
1544 | } | |
519cb848 | 1545 | } |
e40298d5 | 1546 | |
0919e93e RD |
1547 | |
1548 | bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const | |
1549 | { | |
1550 | wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); | |
1551 | ||
1552 | widths.Empty(); | |
1553 | widths.Add(0, text.Length()); | |
1554 | ||
1555 | if (text.Length() == 0) | |
1556 | return false; | |
ab9d0a8c | 1557 | |
0919e93e RD |
1558 | wxMacFastPortSetter helper(this) ; |
1559 | MacInstallFont() ; | |
ab9d0a8c | 1560 | #if TARGET_CARBON |
0919e93e RD |
1561 | bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; |
1562 | if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) | |
1563 | useGetThemeText = false ; | |
1564 | ||
1565 | if ( useGetThemeText ) | |
1566 | { | |
1567 | // If anybody knows how to do this more efficiently yet still handle | |
1568 | // the fractional glyph widths that may be present when using AA | |
1569 | // fonts, please change it. Currently it is measuring from the | |
1570 | // begining of the string for each succeding substring, which is much | |
1571 | // slower than this should be. | |
1572 | for (size_t i=0; i<text.Length(); i++) | |
1573 | { | |
1574 | wxString str(text.Left(i+1)); | |
1575 | Point bounds = {0,0}; | |
1576 | SInt16 baseline ; | |
1577 | wxMacCFStringHolder mString(str, m_font.GetEncoding()); | |
1578 | ::GetThemeTextDimensions( mString, | |
facd6764 | 1579 | m_font.MacGetThemeFontID(), |
0919e93e RD |
1580 | kThemeStateActive, |
1581 | false, | |
1582 | &bounds, | |
1583 | &baseline ); | |
1584 | widths[i] = XDEV2LOGREL(bounds.h); | |
1585 | } | |
1586 | } | |
ab9d0a8c | 1587 | else |
0919e93e RD |
1588 | #endif |
1589 | { | |
1590 | wxCharBuffer buff = text.mb_str(wxConvLocal); | |
1591 | size_t len = strlen(buff); | |
1592 | short* measurements = new short[len+1]; | |
1593 | MeasureText(len, buff.data(), measurements); | |
1594 | ||
1595 | // Copy to widths, starting at measurements[1] | |
1596 | // NOTE: this doesn't take into account any multi-byte characters | |
1597 | // in buff, it probabkly should... | |
1598 | for (size_t i=0; i<text.Length(); i++) | |
1599 | widths[i] = XDEV2LOGREL(measurements[i+1]); | |
1600 | ||
ab9d0a8c | 1601 | delete [] measurements; |
0919e93e RD |
1602 | } |
1603 | ||
1604 | return true; | |
1605 | } | |
1606 | ||
1607 | ||
1608 | ||
ee41971c | 1609 | wxCoord wxDC::GetCharWidth(void) const |
519cb848 | 1610 | { |
3dec57ad | 1611 | wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); |
8bebc229 | 1612 | wxMacFastPortSetter helper(this) ; |
e40298d5 | 1613 | MacInstallFont() ; |
2beae4b5 SC |
1614 | int width = 0 ; |
1615 | #if TARGET_CARBON | |
e40298d5 | 1616 | bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; |
b7047aa5 | 1617 | if ( UMAGetSystemVersion() < 0x1000 || ((wxFont*)&m_font)->GetNoAntiAliasing() ) |
e40298d5 | 1618 | useGetThemeText = false ; |
2beae4b5 | 1619 | #endif |
95c430aa | 1620 | char text[] = "g" ; |
2beae4b5 SC |
1621 | #if TARGET_CARBON |
1622 | if ( useGetThemeText ) | |
1623 | { | |
1624 | Point bounds={0,0} ; | |
1625 | SInt16 baseline ; | |
1626 | CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; | |
e40298d5 | 1627 | ::GetThemeTextDimensions( mString, |
facd6764 | 1628 | m_font.MacGetThemeFontID(), |
e40298d5 JS |
1629 | kThemeStateActive, |
1630 | false, | |
1631 | &bounds, | |
1632 | &baseline ); | |
1633 | CFRelease( mString ) ; | |
1634 | width = bounds.h ; | |
2beae4b5 SC |
1635 | } |
1636 | else | |
1637 | #endif | |
1638 | { | |
e40298d5 JS |
1639 | width = ::TextWidth( text , 0 , 1 ) ; |
1640 | } | |
1641 | return YDEV2LOGREL(width) ; | |
519cb848 | 1642 | } |
e40298d5 | 1643 | |
ee41971c | 1644 | wxCoord wxDC::GetCharHeight(void) const |
519cb848 | 1645 | { |
3dec57ad | 1646 | wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); |
8bebc229 | 1647 | wxMacFastPortSetter helper(this) ; |
e40298d5 JS |
1648 | MacInstallFont() ; |
1649 | FontInfo fi ; | |
1650 | ::GetFontInfo( &fi ) ; | |
1651 | return YDEV2LOGREL( fi.descent + fi.ascent ); | |
519cb848 | 1652 | } |
e40298d5 | 1653 | |
519cb848 SC |
1654 | void wxDC::Clear(void) |
1655 | { | |
99030bdf | 1656 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
8bebc229 | 1657 | wxMacFastPortSetter helper(this) ; |
e40298d5 | 1658 | Rect rect = { -31000 , -31000 , 31000 , 31000 } ; |
f6809556 | 1659 | if ( m_backgroundBrush.Ok() && m_backgroundBrush.GetStyle() != wxTRANSPARENT) |
e40298d5 JS |
1660 | { |
1661 | ::PenNormal() ; | |
76a5e5d2 | 1662 | MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ; |
e40298d5 JS |
1663 | ::EraseRect( &rect ) ; |
1664 | } | |
519cb848 | 1665 | } |
e40298d5 | 1666 | |
519cb848 SC |
1667 | void wxDC::MacInstallFont() const |
1668 | { | |
3dec57ad | 1669 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
e40298d5 JS |
1670 | // if ( m_macFontInstalled ) |
1671 | // return ; | |
1672 | Pattern blackColor ; | |
1673 | MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; | |
fc58c6be SC |
1674 | if ( m_backgroundMode != wxTRANSPARENT ) |
1675 | { | |
1676 | Pattern whiteColor ; | |
1677 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
1678 | } | |
fcb35beb | 1679 | if ( m_font.Ok() ) |
e40298d5 | 1680 | { |
facd6764 SC |
1681 | ::TextFont( m_font.MacGetFontNum() ) ; |
1682 | ::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ; | |
1683 | ::TextFace( m_font.MacGetFontStyle() ) ; | |
e40298d5 JS |
1684 | m_macFontInstalled = true ; |
1685 | m_macBrushInstalled = false ; | |
1686 | m_macPenInstalled = false ; | |
1687 | RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); | |
1688 | RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); | |
1689 | ::RGBForeColor( &forecolor ); | |
1690 | ::RGBBackColor( &backcolor ); | |
1691 | } | |
1692 | else | |
1693 | { | |
32907dbd | 1694 | FontFamilyID fontId ; |
e40298d5 JS |
1695 | Str255 fontName ; |
1696 | SInt16 fontSize ; | |
1697 | Style fontStyle ; | |
1698 | GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; | |
32907dbd | 1699 | GetFNum( fontName, &fontId ); |
e40298d5 JS |
1700 | ::TextFont( fontId ) ; |
1701 | ::TextSize( short(m_scaleY * fontSize) ) ; | |
1702 | ::TextFace( fontStyle ) ; | |
1703 | // todo reset after spacing changes - or store the current spacing somewhere | |
1704 | m_macFontInstalled = true ; | |
1705 | m_macBrushInstalled = false ; | |
1706 | m_macPenInstalled = false ; | |
1707 | RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); | |
1708 | RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); | |
1709 | ::RGBForeColor( &forecolor ); | |
1710 | ::RGBBackColor( &backcolor ); | |
1711 | } | |
1712 | short mode = patCopy ; | |
1713 | // todo : | |
1714 | switch( m_logicalFunction ) | |
1715 | { | |
1716 | case wxCOPY: // src | |
1717 | mode = patCopy ; | |
1718 | break ; | |
1719 | case wxINVERT: // NOT dst | |
1720 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1721 | mode = patXor ; | |
1722 | break ; | |
1723 | case wxXOR: // src XOR dst | |
1724 | mode = patXor ; | |
1725 | break ; | |
1726 | case wxOR_REVERSE: // src OR (NOT dst) | |
1727 | mode = notPatOr ; | |
1728 | break ; | |
1729 | case wxSRC_INVERT: // (NOT src) | |
1730 | mode = notPatCopy ; | |
1731 | break ; | |
4a95c885 SC |
1732 | case wxAND: // src AND dst |
1733 | mode = adMin ; | |
1734 | break ; | |
e40298d5 JS |
1735 | // unsupported TODO |
1736 | case wxCLEAR: // 0 | |
1737 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
1738 | case wxAND_INVERT: // (NOT src) AND dst |
1739 | case wxNO_OP: // dst | |
1740 | case wxNOR: // (NOT src) AND (NOT dst) | |
1741 | case wxEQUIV: // (NOT src) XOR dst | |
1742 | case wxOR_INVERT: // (NOT src) OR dst | |
1743 | case wxNAND: // (NOT src) OR (NOT dst) | |
1744 | case wxOR: // src OR dst | |
1745 | case wxSET: // 1 | |
1746 | // case wxSRC_OR: // source _bitmap_ OR destination | |
1747 | // case wxSRC_AND: // source _bitmap_ AND destination | |
1748 | break ; | |
1749 | } | |
1750 | ::PenMode( mode ) ; | |
66a09d47 | 1751 | OSStatus status = noErr ; |
facd6764 SC |
1752 | Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ; |
1753 | Style qdStyle = m_font.MacGetATSUAdditionalQDStyles() ; | |
1754 | ATSUFontID atsuFont = m_font.MacGetATSUFontID() ; | |
73bdd73a | 1755 | status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ; |
427ff662 | 1756 | wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; |
e40298d5 JS |
1757 | ATSUAttributeTag atsuTags[] = |
1758 | { | |
1759 | kATSUFontTag , | |
1760 | kATSUSizeTag , | |
1761 | // kATSUColorTag , | |
1762 | // kATSUBaselineClassTag , | |
1763 | kATSUVerticalCharacterTag, | |
1764 | kATSUQDBoldfaceTag , | |
1765 | kATSUQDItalicTag , | |
1766 | kATSUQDUnderlineTag , | |
1767 | kATSUQDCondensedTag , | |
1768 | kATSUQDExtendedTag , | |
1769 | } ; | |
66a09d47 SC |
1770 | ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = |
1771 | { | |
1772 | sizeof( ATSUFontID ) , | |
e40298d5 JS |
1773 | sizeof( Fixed ) , |
1774 | // sizeof( RGBColor ) , | |
1775 | // sizeof( BslnBaselineClass ) , | |
1776 | sizeof( ATSUVerticalCharacterType), | |
1777 | sizeof( Boolean ) , | |
1778 | sizeof( Boolean ) , | |
1779 | sizeof( Boolean ) , | |
1780 | sizeof( Boolean ) , | |
1781 | sizeof( Boolean ) , | |
66a09d47 | 1782 | } ; |
66a09d47 SC |
1783 | Boolean kTrue = true ; |
1784 | Boolean kFalse = false ; | |
5be55d56 | 1785 | //BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; |
32907dbd | 1786 | ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; |
e40298d5 JS |
1787 | ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = |
1788 | { | |
1789 | &atsuFont , | |
1790 | &atsuSize , | |
1791 | // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , | |
1792 | // &kBaselineDefault , | |
1793 | &kHorizontal, | |
1794 | (qdStyle & bold) ? &kTrue : &kFalse , | |
1795 | (qdStyle & italic) ? &kTrue : &kFalse , | |
1796 | (qdStyle & underline) ? &kTrue : &kFalse , | |
1797 | (qdStyle & condense) ? &kTrue : &kFalse , | |
1798 | (qdStyle & extend) ? &kTrue : &kFalse , | |
1799 | } ; | |
26b9b4e1 | 1800 | status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) , |
e40298d5 | 1801 | atsuTags, atsuSizes, atsuValues); |
427ff662 | 1802 | wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ; |
519cb848 | 1803 | } |
e40298d5 | 1804 | |
411bdf74 RR |
1805 | Pattern gPatterns[] = |
1806 | { // hatch patterns | |
a47ae718 VZ |
1807 | { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } , |
1808 | { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } , | |
1809 | { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } , | |
1810 | { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } , | |
1811 | { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } , | |
1812 | { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } , | |
1813 | { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } , | |
411bdf74 | 1814 | // dash patterns |
a47ae718 VZ |
1815 | { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT |
1816 | { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH | |
1817 | { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH | |
1818 | { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH | |
ffd67837 | 1819 | } ; |
e40298d5 | 1820 | |
411bdf74 RR |
1821 | static void wxMacGetPattern(int penStyle, Pattern *pattern) |
1822 | { | |
1823 | int index = 0; // solid pattern by default | |
1824 | switch(penStyle) | |
ab9d0a8c | 1825 | { |
411bdf74 RR |
1826 | // hatches |
1827 | case wxBDIAGONAL_HATCH: index = 1; break; | |
1828 | case wxFDIAGONAL_HATCH: index = 2; break; | |
1829 | case wxCROSS_HATCH: index = 3; break; | |
1830 | case wxHORIZONTAL_HATCH: index = 4; break; | |
1831 | case wxVERTICAL_HATCH: index = 5; break; | |
1832 | case wxCROSSDIAG_HATCH: index = 6; break; | |
1833 | // dashes | |
1834 | case wxDOT: index = 7; break; | |
1835 | case wxLONG_DASH: index = 8; break; | |
1836 | case wxSHORT_DASH: index = 9; break; | |
1837 | case wxDOT_DASH: index = 10; break; | |
1838 | } | |
ab9d0a8c | 1839 | *pattern = gPatterns[index]; |
519cb848 | 1840 | } |
e40298d5 | 1841 | |
519cb848 SC |
1842 | void wxDC::MacInstallPen() const |
1843 | { | |
3dec57ad | 1844 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
a47ae718 | 1845 | //Pattern blackColor; |
e40298d5 JS |
1846 | // if ( m_macPenInstalled ) |
1847 | // return ; | |
1848 | RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); | |
1849 | RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); | |
1850 | ::RGBForeColor( &forecolor ); | |
1851 | ::RGBBackColor( &backcolor ); | |
1852 | ::PenNormal() ; | |
669b65b9 | 1853 | int penWidth = (int) (m_pen.GetWidth() * m_scaleX) ; ; |
e40298d5 JS |
1854 | // null means only one pixel, at whatever resolution |
1855 | if ( penWidth == 0 ) | |
1856 | penWidth = 1 ; | |
1857 | ::PenSize(penWidth, penWidth); | |
ab9d0a8c | 1858 | |
e40298d5 | 1859 | int penStyle = m_pen.GetStyle(); |
411bdf74 RR |
1860 | Pattern pat; |
1861 | if (penStyle == wxUSER_DASH) | |
ab9d0a8c | 1862 | { |
411bdf74 RR |
1863 | // FIXME: there should be exactly 8 items in the dash |
1864 | wxDash* dash ; | |
1865 | int number = m_pen.GetDashes(&dash) ; | |
1866 | int index = 0; | |
1867 | for ( int i = 0 ; i < 8 ; ++i ) | |
1868 | { | |
1869 | pat.pat[i] = dash[index] ; | |
1870 | if (index < number - 1) | |
1871 | index++; | |
1872 | } | |
e40298d5 JS |
1873 | } |
1874 | else | |
1875 | { | |
411bdf74 | 1876 | wxMacGetPattern(penStyle, &pat); |
e40298d5 | 1877 | } |
411bdf74 RR |
1878 | ::PenPat(&pat); |
1879 | ||
e40298d5 JS |
1880 | short mode = patCopy ; |
1881 | // todo : | |
1882 | switch( m_logicalFunction ) | |
1883 | { | |
1884 | case wxCOPY: // only foreground color, leave background (thus not patCopy) | |
1885 | mode = patOr ; | |
1886 | break ; | |
1887 | case wxINVERT: // NOT dst | |
1888 | // ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1889 | mode = patXor ; | |
1890 | break ; | |
1891 | case wxXOR: // src XOR dst | |
1892 | mode = patXor ; | |
1893 | break ; | |
1894 | case wxOR_REVERSE: // src OR (NOT dst) | |
1895 | mode = notPatOr ; | |
1896 | break ; | |
1897 | case wxSRC_INVERT: // (NOT src) | |
1898 | mode = notPatCopy ; | |
1899 | break ; | |
4a95c885 SC |
1900 | case wxAND: // src AND dst |
1901 | mode = adMin ; | |
1902 | break ; | |
e40298d5 JS |
1903 | // unsupported TODO |
1904 | case wxCLEAR: // 0 | |
1905 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
1906 | case wxAND_INVERT: // (NOT src) AND dst |
1907 | case wxNO_OP: // dst | |
1908 | case wxNOR: // (NOT src) AND (NOT dst) | |
1909 | case wxEQUIV: // (NOT src) XOR dst | |
1910 | case wxOR_INVERT: // (NOT src) OR dst | |
1911 | case wxNAND: // (NOT src) OR (NOT dst) | |
1912 | case wxOR: // src OR dst | |
1913 | case wxSET: // 1 | |
1914 | // case wxSRC_OR: // source _bitmap_ OR destination | |
1915 | // case wxSRC_AND: // source _bitmap_ AND destination | |
1916 | break ; | |
1917 | } | |
1918 | ::PenMode( mode ) ; | |
1919 | m_macPenInstalled = true ; | |
1920 | m_macBrushInstalled = false ; | |
1921 | m_macFontInstalled = false ; | |
519cb848 | 1922 | } |
e40298d5 | 1923 | |
99030bdf | 1924 | void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background ) |
1dcbbdcf SC |
1925 | { |
1926 | Pattern whiteColor ; | |
f6809556 | 1927 | if ( background.Ok() ) |
7d9d1fd7 | 1928 | { |
f6809556 | 1929 | switch( background.MacGetBrushKind() ) |
7d9d1fd7 | 1930 | { |
f6809556 | 1931 | case kwxMacBrushTheme : |
e40298d5 | 1932 | { |
f6809556 SC |
1933 | ::SetThemeBackground( background.MacGetTheme() , wxDisplayDepth() , true ) ; |
1934 | break ; | |
e40298d5 | 1935 | } |
f6809556 | 1936 | case kwxMacBrushThemeBackground : |
e40298d5 | 1937 | { |
f6809556 SC |
1938 | Rect extent ; |
1939 | ThemeBackgroundKind bg = background.MacGetThemeBackground( &extent ) ; | |
1940 | ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; | |
1941 | break ; | |
1942 | } | |
1943 | case kwxMacBrushColour : | |
1944 | { | |
1945 | ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); | |
1946 | int brushStyle = background.GetStyle(); | |
1947 | if (brushStyle == wxSOLID) | |
1948 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
ab9d0a8c | 1949 | else if (background.IsHatch()) |
f6809556 SC |
1950 | { |
1951 | Pattern pat ; | |
1952 | wxMacGetPattern(brushStyle, &pat); | |
1953 | ::BackPat(&pat); | |
1954 | } | |
1955 | else | |
1956 | { | |
1957 | ::BackPat(GetQDGlobalsWhite(&whiteColor)); | |
1958 | } | |
1959 | break ; | |
e40298d5 | 1960 | } |
7d9d1fd7 SC |
1961 | } |
1962 | } | |
1dcbbdcf | 1963 | } |
e40298d5 | 1964 | |
519cb848 SC |
1965 | void wxDC::MacInstallBrush() const |
1966 | { | |
3dec57ad | 1967 | wxCHECK_RET(Ok(), wxT("Invalid DC")); |
e40298d5 JS |
1968 | Pattern blackColor ; |
1969 | // if ( m_macBrushInstalled ) | |
1970 | // return ; | |
1971 | // foreground | |
1972 | bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; | |
1973 | ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); | |
1974 | ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); | |
1975 | int brushStyle = m_brush.GetStyle(); | |
1976 | if (brushStyle == wxSOLID) | |
1977 | { | |
1978 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
1979 | } | |
ab9d0a8c | 1980 | else if (m_brush.IsHatch()) |
e40298d5 JS |
1981 | { |
1982 | Pattern pat ; | |
411bdf74 | 1983 | wxMacGetPattern(brushStyle, &pat); |
e40298d5 JS |
1984 | ::PenPat(&pat); |
1985 | } | |
1986 | else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) | |
1987 | { | |
1988 | // we force this in order to be compliant with wxMSW | |
1989 | backgroundTransparent = false ; | |
1990 | // for these the text fore (and back for MASK_OPAQUE) colors are used | |
1991 | wxBitmap* bitmap = m_brush.GetStipple() ; | |
1992 | int width = bitmap->GetWidth() ; | |
1993 | int height = bitmap->GetHeight() ; | |
76a5e5d2 | 1994 | GWorldPtr gw = NULL ; |
e40298d5 JS |
1995 | if ( m_brush.GetStyle() == wxSTIPPLE ) |
1996 | gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; | |
1997 | else | |
1998 | gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; | |
76a5e5d2 SC |
1999 | PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ; |
2000 | LockPixels( gwpixmaphandle ) ; | |
e40298d5 | 2001 | bool isMonochrome = !IsPortColor( gw ) ; |
76a5e5d2 SC |
2002 | if ( !isMonochrome ) |
2003 | { | |
2004 | if ( (**gwpixmaphandle).pixelSize == 1 ) | |
2005 | isMonochrome = true ; | |
2006 | } | |
66a09d47 | 2007 | if ( isMonochrome && width == 8 && height == 8 ) |
e40298d5 JS |
2008 | { |
2009 | ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); | |
2010 | ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); | |
76a5e5d2 SC |
2011 | BitMap* gwbitmap = (BitMap*) *gwpixmaphandle ; // since the color depth is 1 it is a BitMap |
2012 | UInt8 *gwbits = (UInt8*) gwbitmap->baseAddr ; | |
2013 | int alignment = gwbitmap->rowBytes & 0x7FFF ; | |
66a09d47 SC |
2014 | Pattern pat ; |
2015 | for ( int i = 0 ; i < 8 ; ++i ) | |
2016 | { | |
2017 | pat.pat[i] = gwbits[i*alignment+0] ; | |
2018 | } | |
2019 | UnlockPixels( GetGWorldPixMap( gw ) ) ; | |
2020 | ::PenPat( &pat ) ; | |
e40298d5 JS |
2021 | } |
2022 | else | |
2023 | { | |
2024 | // this will be the code to handle power of 2 patterns, we will have to arrive at a nice | |
2025 | // caching scheme before putting this into production | |
2026 | Handle image; | |
2027 | long imageSize; | |
2028 | PixPatHandle pixpat = NewPixPat() ; | |
2029 | CopyPixMap(gwpixmaphandle, (**pixpat).patMap); | |
66a09d47 | 2030 | imageSize = GetPixRowBytes((**pixpat).patMap) * |
e40298d5 JS |
2031 | ((**(**pixpat).patMap).bounds.bottom - |
2032 | (**(**pixpat).patMap).bounds.top); | |
66a09d47 SC |
2033 | PtrToHand( (**gwpixmaphandle).baseAddr, &image, imageSize ); |
2034 | (**pixpat).patData = image; | |
2035 | if ( isMonochrome ) | |
2036 | { | |
e40298d5 JS |
2037 | CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; |
2038 | ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; | |
2039 | if ( ctspec[0].rgb.red == 0x0000 ) | |
2040 | { | |
2041 | ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; | |
2042 | ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; | |
2043 | } | |
2044 | else | |
2045 | { | |
2046 | ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; | |
2047 | ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; | |
2048 | } | |
2049 | ::CTabChanged( ctable ) ; | |
66a09d47 SC |
2050 | } |
2051 | ::PenPixPat(pixpat); | |
2052 | m_macForegroundPixMap = pixpat ; | |
e40298d5 JS |
2053 | } |
2054 | UnlockPixels( gwpixmaphandle ) ; | |
2055 | } | |
1ff301c4 SC |
2056 | else |
2057 | { | |
e40298d5 JS |
2058 | ::PenPat(GetQDGlobalsBlack(&blackColor)); |
2059 | } | |
2060 | short mode = patCopy ; | |
2061 | switch( m_logicalFunction ) | |
2062 | { | |
2063 | case wxCOPY: // src | |
2064 | if ( backgroundTransparent ) | |
2065 | mode = patOr ; | |
2066 | else | |
2067 | mode = patCopy ; | |
2068 | break ; | |
2069 | case wxINVERT: // NOT dst | |
2070 | if ( !backgroundTransparent ) | |
2071 | { | |
2072 | ::PenPat(GetQDGlobalsBlack(&blackColor)); | |
2073 | } | |
2074 | mode = patXor ; | |
2075 | break ; | |
2076 | case wxXOR: // src XOR dst | |
2077 | mode = patXor ; | |
2078 | break ; | |
2079 | case wxOR_REVERSE: // src OR (NOT dst) | |
2080 | mode = notPatOr ; | |
2081 | break ; | |
2082 | case wxSRC_INVERT: // (NOT src) | |
2083 | mode = notPatCopy ; | |
2084 | break ; | |
4a95c885 SC |
2085 | case wxAND: // src AND dst |
2086 | mode = adMin ; | |
2087 | break ; | |
e40298d5 JS |
2088 | // unsupported TODO |
2089 | case wxCLEAR: // 0 | |
2090 | case wxAND_REVERSE:// src AND (NOT dst) | |
e40298d5 JS |
2091 | case wxAND_INVERT: // (NOT src) AND dst |
2092 | case wxNO_OP: // dst | |
2093 | case wxNOR: // (NOT src) AND (NOT dst) | |
2094 | case wxEQUIV: // (NOT src) XOR dst | |
2095 | case wxOR_INVERT: // (NOT src) OR dst | |
2096 | case wxNAND: // (NOT src) OR (NOT dst) | |
2097 | case wxOR: // src OR dst | |
2098 | case wxSET: // 1 | |
2099 | // case wxSRC_OR: // source _bitmap_ OR destination | |
2100 | // case wxSRC_AND: // source _bitmap_ AND destination | |
2101 | break ; | |
2102 | } | |
2103 | ::PenMode( mode ) ; | |
2104 | m_macBrushInstalled = true ; | |
2105 | m_macPenInstalled = false ; | |
2106 | m_macFontInstalled = false ; | |
519cb848 | 2107 | } |
e40298d5 | 2108 | |
2f1ae414 SC |
2109 | // --------------------------------------------------------------------------- |
2110 | // coordinates transformations | |
2111 | // --------------------------------------------------------------------------- | |
519cb848 | 2112 | |
2f1ae414 SC |
2113 | wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const |
2114 | { | |
2115 | return ((wxDC *)this)->XDEV2LOG(x); | |
2116 | } | |
e40298d5 | 2117 | |
2f1ae414 SC |
2118 | wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const |
2119 | { | |
2120 | return ((wxDC *)this)->YDEV2LOG(y); | |
2121 | } | |
e40298d5 | 2122 | |
2f1ae414 SC |
2123 | wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const |
2124 | { | |
2125 | return ((wxDC *)this)->XDEV2LOGREL(x); | |
2126 | } | |
e40298d5 | 2127 | |
2f1ae414 SC |
2128 | wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const |
2129 | { | |
2130 | return ((wxDC *)this)->YDEV2LOGREL(y); | |
2131 | } | |
e40298d5 | 2132 | |
2f1ae414 SC |
2133 | wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const |
2134 | { | |
2135 | return ((wxDC *)this)->XLOG2DEV(x); | |
2136 | } | |
e40298d5 | 2137 | |
2f1ae414 SC |
2138 | wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const |
2139 | { | |
2140 | return ((wxDC *)this)->YLOG2DEV(y); | |
2141 | } | |
e40298d5 | 2142 | |
2f1ae414 SC |
2143 | wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const |
2144 | { | |
2145 | return ((wxDC *)this)->XLOG2DEVREL(x); | |
2146 | } | |
e40298d5 | 2147 | |
2f1ae414 SC |
2148 | wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const |
2149 | { | |
2150 | return ((wxDC *)this)->YLOG2DEVREL(y); | |
a7390348 | 2151 | } |