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