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