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