]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dc.mm
7ef93f80ee6e2b85d823325a75bde249ef2e9df3
[wxWidgets.git] / src / cocoa / dc.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/dc.mm
3 // Purpose: wxDC
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/04/01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #ifndef WX_PRECOMP
14 #include "wx/log.h"
15 #include "wx/dc.h"
16 #endif //WX_PRECOMP
17
18 #include "wx/cocoa/autorelease.h"
19 #include "wx/cocoa/string.h"
20
21 #import <AppKit/NSBezierPath.h>
22 #import <AppKit/NSTextStorage.h>
23 #import <AppKit/NSLayoutManager.h>
24 #import <AppKit/NSTextContainer.h>
25 #import <AppKit/NSGraphicsContext.h>
26 #import <AppKit/NSAffineTransform.h>
27 #import <AppKit/NSColor.h>
28 #import <AppKit/NSTypesetter.h>
29 #import <AppKit/NSImage.h>
30
31 #include "wx/listimpl.cpp"
32 WX_DEFINE_LIST(wxCocoaDCStack);
33
34 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
35 WX_NSTextStorage wxDC::sm_cocoaNSTextStorage = nil;
36 WX_NSLayoutManager wxDC::sm_cocoaNSLayoutManager = nil;
37 WX_NSTextContainer wxDC::sm_cocoaNSTextContainer = nil;
38 wxCocoaDCStack wxDC::sm_cocoaDCStack;
39
40 inline void CocoaSetPenForNSBezierPath(wxPen &pen, NSBezierPath *bezpath)
41 {
42 [pen.GetNSColor() set];
43 const float *pattern;
44 [bezpath setLineDash:pattern count:pen.GetCocoaLineDash(&pattern) phase:0.0];
45 [bezpath setLineWidth:pen.GetWidth()];
46 switch(pen.GetJoin())
47 {
48 case wxJOIN_BEVEL:
49 [bezpath setLineJoinStyle:NSBevelLineJoinStyle];
50 break;
51 case wxJOIN_ROUND:
52 [bezpath setLineJoinStyle:NSRoundLineJoinStyle];
53 break;
54 case wxJOIN_MITER:
55 [bezpath setLineJoinStyle:NSMiterLineJoinStyle];
56 break;
57 }
58 switch(pen.GetCap())
59 {
60 case wxCAP_ROUND:
61 [bezpath setLineCapStyle:NSRoundLineCapStyle];
62 break;
63 case wxCAP_PROJECTING:
64 [bezpath setLineCapStyle:NSSquareLineCapStyle];
65 break;
66 case wxCAP_BUTT:
67 [bezpath setLineCapStyle:NSButtLineCapStyle];
68 break;
69 }
70 }
71
72 void wxDC::CocoaInitializeTextSystem()
73 {
74 wxASSERT_MSG(!sm_cocoaNSTextStorage && !sm_cocoaNSLayoutManager && !sm_cocoaNSTextContainer,wxT("Text system already initalized! BAD PROGRAMMER!"));
75
76 sm_cocoaNSTextStorage = [[NSTextStorage alloc] init];
77
78 sm_cocoaNSLayoutManager = [[NSLayoutManager alloc] init];
79 [sm_cocoaNSTextStorage addLayoutManager:sm_cocoaNSLayoutManager];
80 // NSTextStorage retains NSLayoutManager, but so do we
81 // [sm_cocoaNSLayoutManager release]; [sm_cocoaNSLayoutManager retain];
82
83 // NOTE: initWithContainerSize is the designated initializer, but the
84 // Apple CircleView sample gets away with just calling init, which
85 // is all we really need for our purposes.
86 sm_cocoaNSTextContainer = [[NSTextContainer alloc] init];
87 [sm_cocoaNSLayoutManager addTextContainer:sm_cocoaNSTextContainer];
88 // NSLayoutManager retains NSTextContainer, but so do we
89 // [sm_cocoaNSTextContainer release]; [sm_cocoaNSTextContainer retain];
90 }
91
92 void wxDC::CocoaShutdownTextSystem()
93 {
94 [sm_cocoaNSTextContainer release]; sm_cocoaNSTextContainer = nil;
95 [sm_cocoaNSLayoutManager release]; sm_cocoaNSLayoutManager = nil;
96 [sm_cocoaNSTextStorage release]; sm_cocoaNSTextStorage = nil;
97 }
98
99 void wxDC::CocoaUnwindStackAndLoseFocus()
100 {
101 wxCocoaDCStack::compatibility_iterator ourNode=sm_cocoaDCStack.Find(this);
102 if(ourNode)
103 {
104 wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
105 for(;node!=ourNode; node=sm_cocoaDCStack.GetFirst())
106 {
107 wxDC *dc = node->GetData();
108 wxASSERT(dc);
109 wxASSERT(dc!=this);
110 if(!dc->CocoaUnlockFocus())
111 {
112 wxFAIL_MSG(wxT("Unable to unlock focus on higher-level DC!"));
113 }
114 sm_cocoaDCStack.Erase(node);
115 }
116 wxASSERT(node==ourNode);
117 wxASSERT(ourNode->GetData() == this);
118 ourNode->GetData()->CocoaUnlockFocus();
119 sm_cocoaDCStack.Erase(ourNode);
120 }
121 }
122
123 bool wxDC::CocoaUnwindStackAndTakeFocus()
124 {
125 wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
126 for(;node;node = sm_cocoaDCStack.GetFirst())
127 {
128 wxDC *dc = node->GetData();
129 wxASSERT(dc);
130 // If we're on the stack, then it's unwound enough and we have focus
131 if(dc==this)
132 return true;
133 // If unable to unlockFocus (e.g. wxPaintDC) stop here
134 if(!dc->CocoaUnlockFocus())
135 break;
136 sm_cocoaDCStack.Erase(node);
137 }
138 return CocoaLockFocus();
139 }
140
141 wxDC::wxDC(void)
142 {
143 m_cocoaWxToBoundsTransform = nil;
144 m_pen = *wxBLACK_PEN;
145 }
146
147 wxDC::~wxDC(void)
148 {
149 }
150
151 bool wxDC::CocoaLockFocus()
152 {
153 return false;
154 }
155
156 bool wxDC::CocoaUnlockFocus()
157 {
158 return false;
159 }
160
161 /*static*/ WX_NSAffineTransform wxDC::CocoaGetWxToBoundsTransform(bool isFlipped, float height)
162 {
163 NSAffineTransform *transform = nil;
164 // This transform flips the graphics since wxDC uses top-left origin
165 if(!isFlipped)
166 {
167 // The transform is auto released
168 transform = [NSAffineTransform transform];
169 /* x' = 1x + 0y + 0
170 y' = 0x + -1y + window's height
171 */
172 NSAffineTransformStruct matrix = {
173 1, 0
174 , 0, -1
175 , 0, height
176 };
177 [transform setTransformStruct: matrix];
178 }
179 return transform;
180 }
181
182 void wxDC::CocoaApplyTransformations()
183 {
184 [m_cocoaWxToBoundsTransform concat];
185 // TODO: Apply device/logical/user position/scaling transformations
186 }
187
188 void wxDC::CocoaUnapplyTransformations()
189 {
190 // NOTE: You *must* call this with focus held.
191 // Undo all transforms so we're back in true Cocoa coords with
192 // no scaling or flipping.
193 NSAffineTransform *invertTransform;
194 invertTransform = [m_cocoaWxToBoundsTransform copy];
195 [invertTransform invert];
196 [invertTransform concat];
197 }
198
199 bool wxDC::CocoaGetBounds(void *rectData)
200 {
201 // We don't know what we are so we can't return anything.
202 return false;
203 }
204
205 void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
206 {
207 wxAutoNSAutoreleasePool pool;
208 if(!CocoaTakeFocus()) return;
209 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,width,height)];
210 CocoaSetPenForNSBezierPath(m_pen,bezpath);
211 [bezpath stroke];
212 [m_brush.GetNSColor() set];
213 [bezpath fill];
214 }
215
216 void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
217 {
218 wxAutoNSAutoreleasePool pool;
219 if(!CocoaTakeFocus()) return;
220 NSBezierPath *bezpath = [NSBezierPath bezierPath];
221 [bezpath moveToPoint:NSMakePoint(x1,y1)];
222 [bezpath lineToPoint:NSMakePoint(x2,y2)];
223
224 CocoaSetPenForNSBezierPath(m_pen,bezpath);
225 [bezpath stroke];
226 }
227
228 void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
229 {
230 wxAutoNSAutoreleasePool pool;
231 // FIXME: Cache this so it can be used for DoDrawText
232 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
233 NSAttributedString *attributedString = [[NSAttributedString alloc]
234 initWithString:wxNSStringWithWxString(text.c_str())];
235 [sm_cocoaNSTextStorage setAttributedString:attributedString];
236 [attributedString release];
237
238 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
239 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
240 if(x)
241 *x=(int)usedRect.size.width;
242 if(y)
243 *y=(int)usedRect.size.height;
244 if(descent)
245 *descent=0;
246 if(externalLeading)
247 *externalLeading=0;
248 }
249
250 void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
251 {
252 wxAutoNSAutoreleasePool pool;
253 if(!CocoaTakeFocus()) return;
254 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
255 NSAttributedString *attributedString = [[NSAttributedString alloc]
256 initWithString:wxNSStringWithWxString(text.c_str())];
257 [sm_cocoaNSTextStorage setAttributedString:attributedString];
258 [attributedString release];
259
260 // Set the color (and later font) attributes
261 NSColor *fgColor = m_textForegroundColour.GetNSColor();
262 NSColor *bgColor = m_textBackgroundColour.GetNSColor();
263 if(!fgColor)
264 fgColor = [NSColor clearColor];
265 if(!bgColor)
266 bgColor = [NSColor clearColor];
267 NSDictionary *attrDict = [[NSDictionary alloc] initWithObjectsAndKeys:
268 fgColor, NSForegroundColorAttributeName,
269 bgColor, NSBackgroundColorAttributeName,
270 nil];
271 [sm_cocoaNSTextStorage addAttributes: attrDict range:NSMakeRange(0,[sm_cocoaNSTextStorage length])];
272 [attrDict release];
273
274 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
275 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
276 // NOTE: We'll crash trying to get the location of glyphAtIndex:0 if
277 // there is no length or we don't start at zero
278 if(!glyphRange.length)
279 return;
280 wxASSERT_MSG(glyphRange.location==0,wxT("glyphRange must begin at zero"));
281
282 NSAffineTransform *transform = [NSAffineTransform transform];
283 [transform translateXBy:x yBy:y];
284
285 NSAffineTransform *flipTransform = [NSAffineTransform transform];
286 /* x' = 1x + 0y + 0
287 y' = 0x + -1y + window's height
288 */
289 NSAffineTransformStruct matrix = {
290 1, 0
291 , 0, -1
292 , 0, usedRect.size.height
293 };
294 [flipTransform setTransformStruct: matrix];
295
296 NSGraphicsContext *context = [NSGraphicsContext currentContext];
297 [context saveGraphicsState];
298 [transform concat];
299 [flipTransform concat];
300 #if 0
301 // Draw+fill a rectangle so we can see where the shit is supposed to be.
302 wxLogTrace(wxTRACE_COCOA,wxT("(%f,%f) (%fx%f)"),usedRect.origin.x,usedRect.origin.y,usedRect.size.width,usedRect.size.height);
303 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,usedRect.size.width,usedRect.size.height)];
304 [[NSColor blackColor] set];
305 [bezpath stroke];
306 [[NSColor blueColor] set];
307 [bezpath fill];
308 #endif
309
310 NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0];
311 layoutLocation.x = 0.0;
312 layoutLocation.y *= -1.0;
313 layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0];
314 if(m_backgroundMode==wxSOLID)
315 [sm_cocoaNSLayoutManager drawBackgroundForGlyphRange:glyphRange atPoint:NSZeroPoint];
316 [sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation];
317
318 [context restoreGraphicsState];
319 }
320
321 // wxDCBase functions
322 int wxDCBase::DeviceToLogicalX(int x) const
323 {
324 return x;
325 }
326
327 int wxDCBase::DeviceToLogicalY(int y) const
328 {
329 return y;
330 }
331
332 int wxDCBase::DeviceToLogicalXRel(int x) const
333 {
334 return x;
335 }
336
337 int wxDCBase::DeviceToLogicalYRel(int y) const
338 {
339 return y;
340 }
341
342 int wxDCBase::LogicalToDeviceX(int x) const
343 {
344 return x;
345 }
346
347 int wxDCBase::LogicalToDeviceY(int y) const
348 {
349 return y;
350 }
351
352 int wxDCBase::LogicalToDeviceXRel(int x) const
353 {
354 return x;
355 }
356
357 int wxDCBase::LogicalToDeviceYRel(int y) const
358 {
359 return y;
360 }
361
362 ///////////////////////////////////////////////////////////////////////////
363 // cut here, the rest is stubs
364 ///////////////////////////////////////////////////////////////////////////
365
366 //-----------------------------------------------------------------------------
367 // constants
368 //-----------------------------------------------------------------------------
369
370 #define mm2inches 0.0393700787402
371 #define inches2mm 25.4
372 #define mm2twips 56.6929133859
373 #define twips2mm 0.0176388888889
374 #define mm2pt 2.83464566929
375 #define pt2mm 0.352777777778
376
377 //-----------------------------------------------------------------------------
378 // wxDC
379 //-----------------------------------------------------------------------------
380
381 void wxDC::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) )
382 {
383 };
384
385 void wxDC::DoDrawPoint( int x, int y )
386 {
387 };
388
389 void wxDC::DoDrawPolygon( int, wxPoint *, int, int, int)
390 {
391 };
392
393 void wxDC::DoDrawLines( int, wxPoint *, int, int )
394 {
395 }
396
397 int wxDC::GetDepth() const
398 {
399 return 0;
400 }
401
402 wxSize wxDC::GetPPI() const
403 {
404 return wxSize(0,0);
405 }
406
407 bool wxDC::CanGetTextExtent() const
408 {
409 return false;
410 }
411
412 wxCoord wxDC::GetCharHeight() const
413 {
414 return 0;
415 }
416
417 wxCoord wxDC::GetCharWidth() const
418 {
419 return 0;
420 }
421
422 bool wxDC::CanDrawBitmap() const
423 {
424 return true;
425 }
426
427 bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
428 {
429 return false;
430 }
431
432 void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
433 {
434 }
435
436 void wxDC::SetPen(const wxPen& pen)
437 {
438 m_pen = pen;
439 }
440
441 void wxDC::SetBrush(const wxBrush& brush)
442 {
443 m_brush = brush;
444 }
445
446 void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
447 {
448 }
449
450 void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
451 {
452 }
453
454 void wxDC::DestroyClippingRegion()
455 {
456 }
457
458 void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
459 {
460 }
461
462 void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
463 {
464 }
465
466 void wxDC::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea)
467 {
468 }
469
470 void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
471 {
472 }
473
474 void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
475 {
476 wxAutoNSAutoreleasePool pool;
477 if(!CocoaTakeFocus()) return;
478 if(!bmp.Ok())
479 return;
480
481 #if 0
482 // Draw a rect so we can see where it's supposed to be
483 wxLogTrace(wxTRACE_COCOA,wxT("image at (%d,%d) size %dx%d"),x,y,bmp.GetWidth(),bmp.GetHeight());
484 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,bmp.GetWidth(),bmp.GetHeight())];
485 [[NSColor blackColor] set];
486 [bezpath stroke];
487 [[NSColor blueColor] set];
488 [bezpath fill];
489 #endif // 0
490
491 NSAffineTransform *transform = [NSAffineTransform transform];
492 [transform translateXBy:x yBy:y];
493
494 NSAffineTransform *flipTransform = [NSAffineTransform transform];
495 /* x' = 1x + 0y + 0
496 y' = 0x + -1y + window's height
497 */
498 NSAffineTransformStruct matrix = {
499 1, 0
500 , 0, -1
501 , 0, bmp.GetHeight()
502 };
503 [flipTransform setTransformStruct: matrix];
504
505 NSGraphicsContext *context = [NSGraphicsContext currentContext];
506 [context saveGraphicsState];
507 [transform concat];
508 [flipTransform concat];
509
510 NSImage *nsimage = [bmp.GetNSImage(useMask) retain];
511
512 [nsimage drawAtPoint: NSMakePoint(0,0)
513 fromRect: NSMakeRect(0.0,0.0,bmp.GetWidth(),bmp.GetHeight())
514 operation: NSCompositeSourceOver
515 fraction: 1.0];
516
517 [nsimage release];
518 [context restoreGraphicsState];
519 }
520
521 bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
522 {
523 return false;
524 }
525
526 void wxDC::DoCrossHair(wxCoord x, wxCoord y)
527 {
528 }
529
530
531 bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
532 {
533 if(!CocoaTakeFocus()) return false;
534 if(!source) return false;
535 return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
536 xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
537 }
538
539 bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
540 wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
541 int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
542 {
543 return false;
544 }
545
546 void wxDC::DoGetSize( int* width, int* height ) const
547 {
548 *width = m_maxX-m_minX;
549 *height = m_maxY-m_minY;
550 };
551
552 void wxDC::DoGetSizeMM( int* width, int* height ) const
553 {
554 int w = 0;
555 int h = 0;
556 GetSize( &w, &h );
557 };
558
559 void wxDC::SetTextForeground( const wxColour &col )
560 {
561 if (!Ok()) return;
562 m_textForegroundColour = col;
563 };
564
565 void wxDC::SetTextBackground( const wxColour &col )
566 {
567 if (!Ok()) return;
568 m_textBackgroundColour = col;
569 };
570
571 void wxDC::Clear()
572 {
573 if(!CocoaTakeFocus()) return;
574
575 NSRect boundsRect;
576 if(!CocoaGetBounds(&boundsRect)) return;
577
578 NSGraphicsContext *context = [NSGraphicsContext currentContext];
579 [context saveGraphicsState];
580
581 // Undo all transforms so when we draw our bounds rect we
582 // really overwrite our bounds rect.
583 CocoaUnapplyTransformations();
584
585 [m_backgroundBrush.GetNSColor() set];
586 [NSBezierPath fillRect:boundsRect];
587
588 [context restoreGraphicsState];
589 }
590
591 void wxDC::SetBackground(const wxBrush& brush)
592 {
593 m_backgroundBrush = brush;
594 }
595
596 void wxDC::SetPalette(const wxPalette&)
597 {
598 }
599
600 void wxDC::SetLogicalFunction(int)
601 {
602 }
603
604
605 void wxDC::SetMapMode( int mode )
606 {
607 switch (mode)
608 {
609 case wxMM_TWIPS:
610 break;
611 case wxMM_POINTS:
612 break;
613 case wxMM_METRIC:
614 break;
615 case wxMM_LOMETRIC:
616 break;
617 default:
618 case wxMM_TEXT:
619 SetLogicalScale( 1.0, 1.0 );
620 break;
621 };
622 if (mode != wxMM_TEXT)
623 {
624 };
625 };
626
627 void wxDC::SetUserScale( double x, double y )
628 {
629 // allow negative ? -> no
630 m_userScaleX = x;
631 m_userScaleY = y;
632 ComputeScaleAndOrigin();
633 };
634
635 void wxDC::SetLogicalScale( double x, double y )
636 {
637 // allow negative ?
638 m_logicalScaleX = x;
639 m_logicalScaleY = y;
640 ComputeScaleAndOrigin();
641 };
642
643 void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
644 {
645 m_logicalOriginX = x * m_signX; // is this still correct ?
646 m_logicalOriginY = y * m_signY;
647 ComputeScaleAndOrigin();
648 };
649
650 void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
651 {
652 ComputeScaleAndOrigin();
653 };
654
655 void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
656 {
657 m_signX = (xLeftRight ? 1 : -1);
658 m_signY = (yBottomUp ? -1 : 1);
659 ComputeScaleAndOrigin();
660 };
661
662 void wxDC::ComputeScaleAndOrigin(void)
663 {
664 // CMB: copy scale to see if it changes
665 double origScaleX = m_scaleX;
666 double origScaleY = m_scaleY;
667
668 m_scaleX = m_logicalScaleX * m_userScaleX;
669 m_scaleY = m_logicalScaleY * m_userScaleY;
670
671 // CMB: if scale has changed call SetPen to recalulate the line width
672 if (m_scaleX != origScaleX || m_scaleY != origScaleY)
673 {
674 // this is a bit artificial, but we need to force wxDC to think
675 // the pen has changed
676 const wxPen* pen = & GetPen();
677 wxPen tempPen;
678 m_pen = tempPen;
679 SetPen(* pen);
680 }
681 };
682