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