]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dc.mm
MinGW warning fix.
[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 [m_cocoaWxToBoundsTransform release];
150 }
151
152 bool wxDC::CocoaLockFocus()
153 {
154 return false;
155 }
156
157 bool wxDC::CocoaUnlockFocus()
158 {
159 return false;
160 }
161
162 /*static*/ WX_NSAffineTransform wxDC::CocoaGetWxToBoundsTransform(bool isFlipped, float height)
163 {
164 NSAffineTransform *transform = nil;
165 // This transform flips the graphics since wxDC uses top-left origin
166 if(!isFlipped)
167 {
168 // The transform is auto released
169 transform = [NSAffineTransform transform];
170 /* x' = 1x + 0y + 0
171 y' = 0x + -1y + window's height
172 */
173 NSAffineTransformStruct matrix = {
174 1, 0
175 , 0, -1
176 , 0, height
177 };
178 [transform setTransformStruct: matrix];
179 }
180 return transform;
181 }
182
183 void wxDC::CocoaApplyTransformations()
184 {
185 [m_cocoaWxToBoundsTransform concat];
186 // TODO: Apply device/logical/user position/scaling transformations
187 }
188
189 void wxDC::CocoaUnapplyTransformations()
190 {
191 // NOTE: You *must* call this with focus held.
192 // Undo all transforms so we're back in true Cocoa coords with
193 // no scaling or flipping.
194 NSAffineTransform *invertTransform;
195 invertTransform = [m_cocoaWxToBoundsTransform copy];
196 [invertTransform invert];
197 [invertTransform concat];
198 [invertTransform release];
199 }
200
201 bool wxDC::CocoaGetBounds(void *rectData)
202 {
203 // We don't know what we are so we can't return anything.
204 return false;
205 }
206
207 void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
208 {
209 wxAutoNSAutoreleasePool pool;
210 if(!CocoaTakeFocus()) return;
211 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,width,height)];
212 CocoaSetPenForNSBezierPath(m_pen,bezpath);
213 [bezpath stroke];
214 [m_brush.GetNSColor() set];
215 [bezpath fill];
216 }
217
218 void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
219 {
220 wxAutoNSAutoreleasePool pool;
221 if(!CocoaTakeFocus()) return;
222 NSBezierPath *bezpath = [NSBezierPath bezierPath];
223 [bezpath moveToPoint:NSMakePoint(x1,y1)];
224 [bezpath lineToPoint:NSMakePoint(x2,y2)];
225
226 CocoaSetPenForNSBezierPath(m_pen,bezpath);
227 [bezpath stroke];
228 }
229
230 void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
231 {
232 wxAutoNSAutoreleasePool pool;
233 // FIXME: Cache this so it can be used for DoDrawText
234 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
235 NSAttributedString *attributedString = [[NSAttributedString alloc]
236 initWithString:wxNSStringWithWxString(text.c_str())];
237 [sm_cocoaNSTextStorage setAttributedString:attributedString];
238 [attributedString release];
239
240 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
241 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
242 if(x)
243 *x=(int)usedRect.size.width;
244 if(y)
245 *y=(int)usedRect.size.height;
246 if(descent)
247 *descent=0;
248 if(externalLeading)
249 *externalLeading=0;
250 }
251
252 void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
253 {
254 wxAutoNSAutoreleasePool pool;
255 if(!CocoaTakeFocus()) return;
256 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
257 NSAttributedString *attributedString = [[NSAttributedString alloc]
258 initWithString:wxNSStringWithWxString(text.c_str())];
259 [sm_cocoaNSTextStorage setAttributedString:attributedString];
260 [attributedString release];
261
262 // Set the color (and later font) attributes
263 NSColor *fgColor = m_textForegroundColour.GetNSColor();
264 NSColor *bgColor = m_textBackgroundColour.GetNSColor();
265 if(!fgColor)
266 fgColor = [NSColor clearColor];
267 if(!bgColor)
268 bgColor = [NSColor clearColor];
269 NSDictionary *attrDict = [[NSDictionary alloc] initWithObjectsAndKeys:
270 fgColor, NSForegroundColorAttributeName,
271 bgColor, NSBackgroundColorAttributeName,
272 nil];
273 [sm_cocoaNSTextStorage addAttributes: attrDict range:NSMakeRange(0,[sm_cocoaNSTextStorage length])];
274 [attrDict release];
275
276 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
277 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
278 // NOTE: We'll crash trying to get the location of glyphAtIndex:0 if
279 // there is no length or we don't start at zero
280 if(!glyphRange.length)
281 return;
282 wxASSERT_MSG(glyphRange.location==0,wxT("glyphRange must begin at zero"));
283
284 NSAffineTransform *transform = [NSAffineTransform transform];
285 [transform translateXBy:x yBy:y];
286
287 NSAffineTransform *flipTransform = [NSAffineTransform transform];
288 /* x' = 1x + 0y + 0
289 y' = 0x + -1y + window's height
290 */
291 NSAffineTransformStruct matrix = {
292 1, 0
293 , 0, -1
294 , 0, usedRect.size.height
295 };
296 [flipTransform setTransformStruct: matrix];
297
298 NSGraphicsContext *context = [NSGraphicsContext currentContext];
299 [context saveGraphicsState];
300 [transform concat];
301 [flipTransform concat];
302 #if 0
303 // Draw+fill a rectangle so we can see where the shit is supposed to be.
304 wxLogTrace(wxTRACE_COCOA,wxT("(%f,%f) (%fx%f)"),usedRect.origin.x,usedRect.origin.y,usedRect.size.width,usedRect.size.height);
305 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,usedRect.size.width,usedRect.size.height)];
306 [[NSColor blackColor] set];
307 [bezpath stroke];
308 [[NSColor blueColor] set];
309 [bezpath fill];
310 #endif
311
312 NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0];
313 layoutLocation.x = 0.0;
314 layoutLocation.y *= -1.0;
315 layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0];
316 if(m_backgroundMode==wxSOLID)
317 [sm_cocoaNSLayoutManager drawBackgroundForGlyphRange:glyphRange atPoint:NSZeroPoint];
318 [sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation];
319
320 [context restoreGraphicsState];
321 }
322
323 // wxDCBase functions
324 int wxDCBase::DeviceToLogicalX(int x) const
325 {
326 return x;
327 }
328
329 int wxDCBase::DeviceToLogicalY(int y) const
330 {
331 return y;
332 }
333
334 int wxDCBase::DeviceToLogicalXRel(int x) const
335 {
336 return x;
337 }
338
339 int wxDCBase::DeviceToLogicalYRel(int y) const
340 {
341 return y;
342 }
343
344 int wxDCBase::LogicalToDeviceX(int x) const
345 {
346 return x;
347 }
348
349 int wxDCBase::LogicalToDeviceY(int y) const
350 {
351 return y;
352 }
353
354 int wxDCBase::LogicalToDeviceXRel(int x) const
355 {
356 return x;
357 }
358
359 int wxDCBase::LogicalToDeviceYRel(int y) const
360 {
361 return y;
362 }
363
364 ///////////////////////////////////////////////////////////////////////////
365 // cut here, the rest is stubs
366 ///////////////////////////////////////////////////////////////////////////
367
368 //-----------------------------------------------------------------------------
369 // constants
370 //-----------------------------------------------------------------------------
371
372 #define mm2inches 0.0393700787402
373 #define inches2mm 25.4
374 #define mm2twips 56.6929133859
375 #define twips2mm 0.0176388888889
376 #define mm2pt 2.83464566929
377 #define pt2mm 0.352777777778
378
379 //-----------------------------------------------------------------------------
380 // wxDC
381 //-----------------------------------------------------------------------------
382
383 void wxDC::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) )
384 {
385 };
386
387 void wxDC::DoDrawPoint( int x, int y )
388 {
389 };
390
391 void wxDC::DoDrawPolygon( int, wxPoint *, int, int, int)
392 {
393 };
394
395 void wxDC::DoDrawLines( int, wxPoint *, int, int )
396 {
397 }
398
399 int wxDC::GetDepth() const
400 {
401 return 0;
402 }
403
404 wxSize wxDC::GetPPI() const
405 {
406 return wxSize(0,0);
407 }
408
409 bool wxDC::CanGetTextExtent() const
410 {
411 return false;
412 }
413
414 wxCoord wxDC::GetCharHeight() const
415 {
416 return 0;
417 }
418
419 wxCoord wxDC::GetCharWidth() const
420 {
421 return 0;
422 }
423
424 bool wxDC::CanDrawBitmap() const
425 {
426 return true;
427 }
428
429 bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
430 {
431 return false;
432 }
433
434 void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
435 {
436 }
437
438 void wxDC::SetPen(const wxPen& pen)
439 {
440 m_pen = pen;
441 }
442
443 void wxDC::SetBrush(const wxBrush& brush)
444 {
445 m_brush = brush;
446 }
447
448 void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
449 {
450 }
451
452 void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
453 {
454 }
455
456 void wxDC::DestroyClippingRegion()
457 {
458 }
459
460 void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
461 {
462 }
463
464 void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
465 {
466 }
467
468 void wxDC::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea)
469 {
470 }
471
472 void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
473 {
474 }
475
476 void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
477 {
478 wxAutoNSAutoreleasePool pool;
479 if(!CocoaTakeFocus()) return;
480 if(!bmp.Ok())
481 return;
482
483 #if 0
484 // Draw a rect so we can see where it's supposed to be
485 wxLogTrace(wxTRACE_COCOA,wxT("image at (%d,%d) size %dx%d"),x,y,bmp.GetWidth(),bmp.GetHeight());
486 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,bmp.GetWidth(),bmp.GetHeight())];
487 [[NSColor blackColor] set];
488 [bezpath stroke];
489 [[NSColor blueColor] set];
490 [bezpath fill];
491 #endif // 0
492
493 NSAffineTransform *transform = [NSAffineTransform transform];
494 [transform translateXBy:x yBy:y];
495
496 NSAffineTransform *flipTransform = [NSAffineTransform transform];
497 /* x' = 1x + 0y + 0
498 y' = 0x + -1y + window's height
499 */
500 NSAffineTransformStruct matrix = {
501 1, 0
502 , 0, -1
503 , 0, bmp.GetHeight()
504 };
505 [flipTransform setTransformStruct: matrix];
506
507 NSGraphicsContext *context = [NSGraphicsContext currentContext];
508 [context saveGraphicsState];
509 [transform concat];
510 [flipTransform concat];
511
512 NSImage *nsimage = [bmp.GetNSImage(useMask) retain];
513
514 [nsimage drawAtPoint: NSMakePoint(0,0)
515 fromRect: NSMakeRect(0.0,0.0,bmp.GetWidth(),bmp.GetHeight())
516 operation: NSCompositeSourceOver
517 fraction: 1.0];
518
519 [nsimage release];
520 [context restoreGraphicsState];
521 }
522
523 bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
524 {
525 return false;
526 }
527
528 void wxDC::DoCrossHair(wxCoord x, wxCoord y)
529 {
530 }
531
532
533 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)
534 {
535 if(!CocoaTakeFocus()) return false;
536 if(!source) return false;
537 return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
538 xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
539 }
540
541 bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
542 wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
543 int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
544 {
545 return false;
546 }
547
548 void wxDC::DoGetSize( int* width, int* height ) const
549 {
550 *width = m_maxX-m_minX;
551 *height = m_maxY-m_minY;
552 };
553
554 void wxDC::DoGetSizeMM( int* width, int* height ) const
555 {
556 int w = 0;
557 int h = 0;
558 GetSize( &w, &h );
559 };
560
561 void wxDC::SetTextForeground( const wxColour &col )
562 {
563 if (!Ok()) return;
564 m_textForegroundColour = col;
565 };
566
567 void wxDC::SetTextBackground( const wxColour &col )
568 {
569 if (!Ok()) return;
570 m_textBackgroundColour = col;
571 };
572
573 void wxDC::Clear()
574 {
575 if(!CocoaTakeFocus()) return;
576
577 NSRect boundsRect;
578 if(!CocoaGetBounds(&boundsRect)) return;
579
580 NSGraphicsContext *context = [NSGraphicsContext currentContext];
581 [context saveGraphicsState];
582
583 // Undo all transforms so when we draw our bounds rect we
584 // really overwrite our bounds rect.
585 CocoaUnapplyTransformations();
586
587 [m_backgroundBrush.GetNSColor() set];
588 [NSBezierPath fillRect:boundsRect];
589
590 [context restoreGraphicsState];
591 }
592
593 void wxDC::SetBackground(const wxBrush& brush)
594 {
595 m_backgroundBrush = brush;
596 }
597
598 void wxDC::SetPalette(const wxPalette&)
599 {
600 }
601
602 void wxDC::SetLogicalFunction(int)
603 {
604 }
605
606
607 void wxDC::SetMapMode( int mode )
608 {
609 switch (mode)
610 {
611 case wxMM_TWIPS:
612 break;
613 case wxMM_POINTS:
614 break;
615 case wxMM_METRIC:
616 break;
617 case wxMM_LOMETRIC:
618 break;
619 default:
620 case wxMM_TEXT:
621 SetLogicalScale( 1.0, 1.0 );
622 break;
623 };
624 if (mode != wxMM_TEXT)
625 {
626 };
627 };
628
629 void wxDC::SetUserScale( double x, double y )
630 {
631 // allow negative ? -> no
632 m_userScaleX = x;
633 m_userScaleY = y;
634 ComputeScaleAndOrigin();
635 };
636
637 void wxDC::SetLogicalScale( double x, double y )
638 {
639 // allow negative ?
640 m_logicalScaleX = x;
641 m_logicalScaleY = y;
642 ComputeScaleAndOrigin();
643 };
644
645 void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
646 {
647 m_logicalOriginX = x * m_signX; // is this still correct ?
648 m_logicalOriginY = y * m_signY;
649 ComputeScaleAndOrigin();
650 };
651
652 void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
653 {
654 ComputeScaleAndOrigin();
655 };
656
657 void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
658 {
659 m_signX = (xLeftRight ? 1 : -1);
660 m_signY = (yBottomUp ? -1 : 1);
661 ComputeScaleAndOrigin();
662 };
663
664 void wxDC::ComputeScaleAndOrigin(void)
665 {
666 // CMB: copy scale to see if it changes
667 double origScaleX = m_scaleX;
668 double origScaleY = m_scaleY;
669
670 m_scaleX = m_logicalScaleX * m_userScaleX;
671 m_scaleY = m_logicalScaleY * m_userScaleY;
672
673 // CMB: if scale has changed call SetPen to recalulate the line width
674 if (m_scaleX != origScaleX || m_scaleY != origScaleY)
675 {
676 // this is a bit artificial, but we need to force wxDC to think
677 // the pen has changed
678 const wxPen* pen = & GetPen();
679 wxPen tempPen;
680 m_pen = tempPen;
681 SetPen(* pen);
682 }
683 };
684