]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/dc.mm
* Made GSocket::GetError() exp/imp from net library and provide an inline
[wxWidgets.git] / src / cocoa / dc.mm
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
891d0563
DE
2// Name: src/cocoa/dc.mm
3// Purpose: wxDC
4// Author: David Elliott
a24aff65 5// Modified by:
891d0563 6// Created: 2003/04/01
a24aff65 7// RCS-ID: $Id$
891d0563 8// Copyright: (c) 2003 David Elliott
065e208e 9// Licence: wxWidgets licence
a24aff65
DE
10/////////////////////////////////////////////////////////////////////////////
11
449c5673
DE
12#include "wx/wxprec.h"
13#ifndef WX_PRECOMP
14 #include "wx/log.h"
15 #include "wx/dc.h"
16#endif //WX_PRECOMP
a24aff65 17
7fc77f30 18#include "wx/cocoa/autorelease.h"
b0c0a393 19#include "wx/cocoa/string.h"
7fc77f30 20
891d0563
DE
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>
f910a887 28#import <AppKit/NSTypesetter.h>
1fd17880 29#import <AppKit/NSImage.h>
891d0563 30
fe8f7943
DE
31#include <wx/listimpl.cpp>
32WX_DEFINE_LIST(wxCocoaDCStack);
33
a24aff65 34IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
891d0563
DE
35WX_NSTextStorage wxDC::sm_cocoaNSTextStorage = nil;
36WX_NSLayoutManager wxDC::sm_cocoaNSLayoutManager = nil;
37WX_NSTextContainer wxDC::sm_cocoaNSTextContainer = nil;
fe8f7943 38wxCocoaDCStack wxDC::sm_cocoaDCStack;
891d0563 39
5eb5a0ac
DE
40inline 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
891d0563
DE
72void wxDC::CocoaInitializeTextSystem()
73{
2b030203 74 wxASSERT_MSG(!sm_cocoaNSTextStorage && !sm_cocoaNSLayoutManager && !sm_cocoaNSTextContainer,wxT("Text system already initalized! BAD PROGRAMMER!"));
891d0563
DE
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
92void 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
fe8f7943
DE
99void wxDC::CocoaUnwindStackAndLoseFocus()
100{
7ce8248b 101 wxCocoaDCStack::compatibility_iterator ourNode=sm_cocoaDCStack.Find(this);
fe8f7943
DE
102 if(ourNode)
103 {
7ce8248b 104 wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
fe8f7943
DE
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 {
2b030203 112 wxFAIL_MSG(wxT("Unable to unlock focus on higher-level DC!"));
fe8f7943 113 }
7ce8248b 114 sm_cocoaDCStack.Erase(node);
fe8f7943
DE
115 }
116 wxASSERT(node==ourNode);
117 wxASSERT(ourNode->GetData() == this);
118 ourNode->GetData()->CocoaUnlockFocus();
7ce8248b 119 sm_cocoaDCStack.Erase(ourNode);
fe8f7943
DE
120 }
121}
122
123bool wxDC::CocoaUnwindStackAndTakeFocus()
124{
7ce8248b 125 wxCocoaDCStack::compatibility_iterator node=sm_cocoaDCStack.GetFirst();
fe8f7943
DE
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;
7ce8248b 136 sm_cocoaDCStack.Erase(node);
fe8f7943
DE
137 }
138 return CocoaLockFocus();
139}
140
891d0563
DE
141wxDC::wxDC(void)
142{
fe8f7943
DE
143 m_cocoaFlipped = false;
144 m_cocoaHeight = 0.0;
5eb5a0ac 145 m_pen = *wxBLACK_PEN;
891d0563
DE
146}
147
148wxDC::~wxDC(void)
149{
150}
151
fe8f7943
DE
152bool wxDC::CocoaLockFocus()
153{
154 return false;
155}
156
157bool wxDC::CocoaUnlockFocus()
158{
159 return false;
160}
161
162void wxDC::CocoaApplyTransformations()
163{
164 // This transform flips the graphics since wxDC uses top-left origin
165 if(!m_cocoaFlipped)
166 {
167 // The transform is auto released
168 NSAffineTransform *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, m_cocoaHeight
176 };
177 [transform setTransformStruct: matrix];
178 // Apply the transform
179 [transform concat];
180 }
181 // TODO: Apply scaling transformation
182}
183
891d0563
DE
184void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
185{
1b1f8b2d 186 wxAutoNSAutoreleasePool pool;
fe8f7943 187 if(!CocoaTakeFocus()) return;
891d0563 188 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,width,height)];
5eb5a0ac 189 CocoaSetPenForNSBezierPath(m_pen,bezpath);
891d0563 190 [bezpath stroke];
c3b0c2c3
DE
191 [m_brush.GetNSColor() set];
192 [bezpath fill];
891d0563
DE
193}
194
195void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
196{
1b1f8b2d 197 wxAutoNSAutoreleasePool pool;
fe8f7943 198 if(!CocoaTakeFocus()) return;
891d0563
DE
199 NSBezierPath *bezpath = [NSBezierPath bezierPath];
200 [bezpath moveToPoint:NSMakePoint(x1,y1)];
201 [bezpath lineToPoint:NSMakePoint(x2,y2)];
c3b0c2c3 202
5eb5a0ac 203 CocoaSetPenForNSBezierPath(m_pen,bezpath);
891d0563
DE
204 [bezpath stroke];
205}
206
207void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
208{
7fc77f30 209 wxAutoNSAutoreleasePool pool;
891d0563 210// FIXME: Cache this so it can be used for DoDrawText
2b030203 211 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
891d0563 212 NSAttributedString *attributedString = [[NSAttributedString alloc]
b0c0a393 213 initWithString:wxNSStringWithWxString(text.c_str())];
891d0563
DE
214 [sm_cocoaNSTextStorage setAttributedString:attributedString];
215 [attributedString release];
216
217 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
218 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
219 if(x)
dc483f61 220 *x=(int)usedRect.size.width;
891d0563 221 if(y)
dc483f61 222 *y=(int)usedRect.size.height;
891d0563
DE
223 if(descent)
224 *descent=0;
225 if(externalLeading)
226 *externalLeading=0;
227}
228
229void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
230{
1b1f8b2d 231 wxAutoNSAutoreleasePool pool;
fe8f7943 232 if(!CocoaTakeFocus()) return;
2b030203 233 wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!"));
891d0563 234 NSAttributedString *attributedString = [[NSAttributedString alloc]
b0c0a393 235 initWithString:wxNSStringWithWxString(text.c_str())];
891d0563
DE
236 [sm_cocoaNSTextStorage setAttributedString:attributedString];
237 [attributedString release];
238
c0440c78
DE
239 // Set the color (and later font) attributes
240 NSColor *fgColor = m_textForegroundColour.GetNSColor();
241 NSColor *bgColor = m_textBackgroundColour.GetNSColor();
242 if(!fgColor)
243 fgColor = [NSColor clearColor];
244 if(!bgColor)
245 bgColor = [NSColor clearColor];
246 NSDictionary *attrDict = [[NSDictionary alloc] initWithObjectsAndKeys:
247 fgColor, NSForegroundColorAttributeName,
248 bgColor, NSBackgroundColorAttributeName,
249 nil];
250 [sm_cocoaNSTextStorage addAttributes: attrDict range:NSMakeRange(0,[sm_cocoaNSTextStorage length])];
251 [attrDict release];
252
891d0563
DE
253 NSRange glyphRange = [sm_cocoaNSLayoutManager glyphRangeForTextContainer:sm_cocoaNSTextContainer];
254 NSRect usedRect = [sm_cocoaNSLayoutManager usedRectForTextContainer:sm_cocoaNSTextContainer];
13fc3db4
DE
255 // NOTE: We'll crash trying to get the location of glyphAtIndex:0 if
256 // there is no length or we don't start at zero
257 if(!glyphRange.length)
258 return;
2b030203 259 wxASSERT_MSG(glyphRange.location==0,wxT("glyphRange must begin at zero"));
891d0563
DE
260
261 NSAffineTransform *transform = [NSAffineTransform transform];
262 [transform translateXBy:x yBy:y];
263
264 NSAffineTransform *flipTransform = [NSAffineTransform transform];
265 /* x' = 1x + 0y + 0
266 y' = 0x + -1y + window's height
267 */
268 NSAffineTransformStruct matrix = {
269 1, 0
270 , 0, -1
271 , 0, usedRect.size.height
272 };
273 [flipTransform setTransformStruct: matrix];
274
275 NSGraphicsContext *context = [NSGraphicsContext currentContext];
276 [context saveGraphicsState];
277 [transform concat];
278 [flipTransform concat];
c3b0c2c3 279 #if 0
891d0563 280 // Draw+fill a rectangle so we can see where the shit is supposed to be.
48580976 281 wxLogTrace(wxTRACE_COCOA,wxT("(%f,%f) (%fx%f)"),usedRect.origin.x,usedRect.origin.y,usedRect.size.width,usedRect.size.height);
891d0563
DE
282 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,usedRect.size.width,usedRect.size.height)];
283 [[NSColor blackColor] set];
284 [bezpath stroke];
285 [[NSColor blueColor] set];
286 [bezpath fill];
c3b0c2c3 287 #endif
891d0563
DE
288
289 NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0];
290 layoutLocation.x = 0.0;
291 layoutLocation.y *= -1.0;
292 layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0];
c0440c78
DE
293 if(m_backgroundMode==wxSOLID)
294 [sm_cocoaNSLayoutManager drawBackgroundForGlyphRange:glyphRange atPoint:NSZeroPoint];
891d0563
DE
295 [sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation];
296
297 [context restoreGraphicsState];
298}
299
2894667f
DE
300// wxDCBase functions
301int wxDCBase::DeviceToLogicalX(int x) const
302{
303 return x;
304}
305
306int wxDCBase::DeviceToLogicalY(int y) const
307{
308 return y;
309}
310
276a1256
DE
311int wxDCBase::DeviceToLogicalXRel(int x) const
312{
313 return x;
314}
315
316int wxDCBase::DeviceToLogicalYRel(int y) const
317{
318 return y;
319}
320
2894667f
DE
321int wxDCBase::LogicalToDeviceX(int x) const
322{
323 return x;
324}
325
326int wxDCBase::LogicalToDeviceY(int y) const
327{
328 return y;
329}
330
276a1256
DE
331int wxDCBase::LogicalToDeviceXRel(int x) const
332{
333 return x;
334}
335
336int wxDCBase::LogicalToDeviceYRel(int y) const
337{
338 return y;
339}
340
891d0563
DE
341///////////////////////////////////////////////////////////////////////////
342// cut here, the rest is stubs
343///////////////////////////////////////////////////////////////////////////
a24aff65
DE
344
345//-----------------------------------------------------------------------------
346// constants
347//-----------------------------------------------------------------------------
348
349#define mm2inches 0.0393700787402
350#define inches2mm 25.4
351#define mm2twips 56.6929133859
352#define twips2mm 0.0176388888889
353#define mm2pt 2.83464566929
354#define pt2mm 0.352777777778
355
356//-----------------------------------------------------------------------------
357// wxDC
358//-----------------------------------------------------------------------------
359
a24aff65
DE
360void wxDC::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) )
361{
362};
363
364void wxDC::DoDrawPoint( int x, int y )
365{
366};
367
368void wxDC::DoDrawPolygon( int, wxPoint *, int, int, int)
369{
370};
371
372void wxDC::DoDrawLines( int, wxPoint *, int, int )
373{
374}
375
a24aff65
DE
376int wxDC::GetDepth() const
377{
378 return 0;
379}
380
381wxSize wxDC::GetPPI() const
382{
383 return wxSize(0,0);
384}
385
386bool wxDC::CanGetTextExtent() const
387{
388 return false;
389}
390
a24aff65
DE
391wxCoord wxDC::GetCharHeight() const
392{
393 return 0;
394}
395
396wxCoord wxDC::GetCharWidth() const
397{
398 return 0;
399}
400
401bool wxDC::CanDrawBitmap() const
402{
1fd17880 403 return true;
a24aff65
DE
404}
405
406bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
407{
408 return false;
409}
410
411void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
412{
413}
414
415void wxDC::SetPen(const wxPen& pen)
416{
5eb5a0ac 417 m_pen = pen;
a24aff65
DE
418}
419
420void wxDC::SetBrush(const wxBrush& brush)
421{
c3b0c2c3 422 m_brush = brush;
a24aff65
DE
423}
424
425void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
426{
427}
428
429void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
430{
431}
432
433void wxDC::DestroyClippingRegion()
434{
435}
436
437void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
438{
439}
440
441void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
442{
443}
444
445void wxDC::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea)
446{
447}
448
a24aff65
DE
449void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
450{
451}
452
453void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask)
454{
1b1f8b2d 455 wxAutoNSAutoreleasePool pool;
fe8f7943 456 if(!CocoaTakeFocus()) return;
1fd17880
DE
457 if(!bmp.Ok())
458 return;
459
460#if 0
461 // Draw a rect so we can see where it's supposed to be
48580976 462 wxLogTrace(wxTRACE_COCOA,wxT("image at (%d,%d) size %dx%d"),x,y,bmp.GetWidth(),bmp.GetHeight());
1fd17880
DE
463 NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,bmp.GetWidth(),bmp.GetHeight())];
464 [[NSColor blackColor] set];
465 [bezpath stroke];
466 [[NSColor blueColor] set];
467 [bezpath fill];
468#endif // 0
469
470 NSAffineTransform *transform = [NSAffineTransform transform];
471 [transform translateXBy:x yBy:y];
472
473 NSAffineTransform *flipTransform = [NSAffineTransform transform];
474 /* x' = 1x + 0y + 0
475 y' = 0x + -1y + window's height
476 */
477 NSAffineTransformStruct matrix = {
478 1, 0
479 , 0, -1
480 , 0, bmp.GetHeight()
481 };
482 [flipTransform setTransformStruct: matrix];
483
484 NSGraphicsContext *context = [NSGraphicsContext currentContext];
485 [context saveGraphicsState];
486 [transform concat];
487 [flipTransform concat];
488
a00daa65
DE
489 NSImage *nsimage = [bmp.GetNSImage(useMask) retain];
490
1fd17880
DE
491 [nsimage drawAtPoint: NSMakePoint(0,0)
492 fromRect: NSMakeRect(0.0,0.0,bmp.GetWidth(),bmp.GetHeight())
a00daa65 493 operation: NSCompositeSourceOver
1fd17880
DE
494 fraction: 1.0];
495
496 [nsimage release];
497 [context restoreGraphicsState];
a24aff65
DE
498}
499
500bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
501{
502 return false;
503}
504
505void wxDC::DoCrossHair(wxCoord x, wxCoord y)
506{
507}
508
a24aff65
DE
509
510bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
2c23fe91
DE
511{
512 if(!CocoaTakeFocus()) return false;
513 if(!source) return false;
514 return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
515 xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
516}
517
518bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
519 wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
520 int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
a24aff65
DE
521{
522 return false;
523}
524
525void wxDC::DoGetSize( int* width, int* height ) const
526{
527 *width = m_maxX-m_minX;
528 *height = m_maxY-m_minY;
529};
530
531void wxDC::DoGetSizeMM( int* width, int* height ) const
532{
533 int w = 0;
534 int h = 0;
535 GetSize( &w, &h );
536};
537
538void wxDC::SetTextForeground( const wxColour &col )
539{
540 if (!Ok()) return;
541 m_textForegroundColour = col;
542};
543
544void wxDC::SetTextBackground( const wxColour &col )
545{
546 if (!Ok()) return;
547 m_textBackgroundColour = col;
548};
549
550void wxDC::Clear()
551{
552}
553
7bc429ef 554void wxDC::SetBackground(const wxBrush& brush)
a24aff65 555{
7bc429ef 556 m_backgroundBrush = brush;
a24aff65
DE
557}
558
559void wxDC::SetPalette(const wxPalette&)
560{
561}
562
563void wxDC::SetLogicalFunction(int)
564{
565}
566
567
568void wxDC::SetMapMode( int mode )
569{
570 switch (mode)
571 {
572 case wxMM_TWIPS:
573 break;
574 case wxMM_POINTS:
575 break;
576 case wxMM_METRIC:
577 break;
578 case wxMM_LOMETRIC:
579 break;
580 default:
581 case wxMM_TEXT:
582 SetLogicalScale( 1.0, 1.0 );
583 break;
584 };
585 if (mode != wxMM_TEXT)
586 {
587 };
588};
589
590void wxDC::SetUserScale( double x, double y )
591{
592 // allow negative ? -> no
593 m_userScaleX = x;
594 m_userScaleY = y;
595 ComputeScaleAndOrigin();
596};
597
598void wxDC::SetLogicalScale( double x, double y )
599{
600 // allow negative ?
601 m_logicalScaleX = x;
602 m_logicalScaleY = y;
603 ComputeScaleAndOrigin();
604};
605
606void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
607{
608 m_logicalOriginX = x * m_signX; // is this still correct ?
609 m_logicalOriginY = y * m_signY;
610 ComputeScaleAndOrigin();
611};
612
613void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
614{
615 ComputeScaleAndOrigin();
616};
617
618void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
619{
620 m_signX = (xLeftRight ? 1 : -1);
621 m_signY = (yBottomUp ? -1 : 1);
622 ComputeScaleAndOrigin();
623};
624
625void wxDC::ComputeScaleAndOrigin(void)
626{
627 // CMB: copy scale to see if it changes
628 double origScaleX = m_scaleX;
629 double origScaleY = m_scaleY;
630
631 m_scaleX = m_logicalScaleX * m_userScaleX;
632 m_scaleY = m_logicalScaleY * m_userScaleY;
633
634 // CMB: if scale has changed call SetPen to recalulate the line width
635 if (m_scaleX != origScaleX || m_scaleY != origScaleY)
636 {
637 // this is a bit artificial, but we need to force wxDC to think
638 // the pen has changed
639 wxPen* pen = & GetPen();
640 wxPen tempPen;
641 m_pen = tempPen;
642 SetPen(* pen);
643 }
644};
645