cleaning up the runloop source properly (was causing crashes in embedded situations...
[wxWidgets.git] / src / mac / carbon / graphics.cpp
index d71dfae32b7103dc5b23075b9a25e3becdba7cf5..6845a1fb1701d19c82491e381480dd2f65c21e96 100755 (executable)
 
 #include "wx/wxprec.h"
 
-#include "wx/graphics.h"
+#if wxUSE_GRAPHICS_CONTEXT && wxMAC_USE_CORE_GRAPHICS
 
-#if wxMAC_USE_CORE_GRAPHICS
+#include "wx/graphics.h"
 
 #ifndef WX_PRECOMP
     #include "wx/log.h"
-    #include "wx/app.h"
-    #include "wx/dcmemory.h"
-    #include "wx/dcprint.h"
     #include "wx/region.h"
-    #include "wx/image.h"
 #endif
 
 #include "wx/mac/uma.h"
 
-
 #ifdef __MSL__
     #if __MSL__ >= 0x6000
         #include "math.h"
@@ -138,7 +133,8 @@ void wxMacCoreGraphicsPath::AddCircle( wxDouble x, wxDouble y , wxDouble r )
 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
 void wxMacCoreGraphicsPath::AddArc( wxDouble x, wxDouble y, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise )
 {
-    CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, clockwise); 
+    // inverse direction as we the 'normal' state is a y axis pointing down, ie mirrored to the standard core graphics setup
+    CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, !clockwise); 
 }
 
 void wxMacCoreGraphicsPath::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r )
@@ -287,19 +283,7 @@ const double M_PI = 3.14159265358979;
 #endif
 #endif
 
-const double RAD2DEG = 180.0 / M_PI;
-const short kEmulatedMode = -1;
-const short kUnsupportedMode = -2;
-
-extern TECObjectRef s_TECNativeCToUnicode;
-
-//-----------------------------------------------------------------------------
-// Local functions
-//-----------------------------------------------------------------------------
-
-static inline double dmin(double a, double b) { return a < b ? a : b; }
-static inline double dmax(double a, double b) { return a > b ? a : b; }
-static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
+static const double RAD2DEG = 180.0 / M_PI;
 
 //-----------------------------------------------------------------------------
 // device context implementation
@@ -519,7 +503,7 @@ const CGPatternCallbacks wxMacCoreGraphicsPattern::ms_Callbacks = { 0, &wxMacCor
 class ImagePattern : public wxMacCoreGraphicsPattern
 {
 public :
-    ImagePattern( const wxBitmap* bmp , CGAffineTransform transform )
+    ImagePattern( const wxBitmap* bmp , const CGAffineTransform& transform )
     {
         wxASSERT( bmp && bmp->Ok() );
 
@@ -527,7 +511,7 @@ public :
     }
 
     // ImagePattern takes ownership of CGImageRef passed in
-    ImagePattern( CGImageRef image , CGAffineTransform transform )
+    ImagePattern( CGImageRef image , const CGAffineTransform& transform )
     {
         if ( image )
             CFRetain( image );
@@ -542,7 +526,7 @@ public :
     }
 
 protected :
-    void Init( CGImageRef image, CGAffineTransform transform )
+    void Init( CGImageRef image, const CGAffineTransform& transform )
     {
         m_image = image;
         if ( m_image )
@@ -568,7 +552,7 @@ protected :
 class HatchPattern : public wxMacCoreGraphicsPattern
 {
 public :
-    HatchPattern( int hatchstyle, CGAffineTransform transform )
+    HatchPattern( int hatchstyle, const CGAffineTransform& transform )
     {
         m_hatch = hatchstyle;
         m_imageBounds = CGRectMake( 0.0, 0.0, 8.0 , 8.0 );
@@ -692,7 +676,7 @@ void wxMacCoreGraphicsContext::SetPen( const wxPen &pen )
     CGContextSetShouldAntialias( m_cgContext , false );
 #endif
 
-    if ( fill | stroke )
+    if ( fill || stroke )
     {
         // set up brushes
         m_mode = kCGPathFill; // just a default
@@ -869,7 +853,7 @@ void wxMacCoreGraphicsContext::SetBrush( const wxBrush &brush )
     CGContextSetShouldAntialias( m_cgContext , false );
 #endif
 
-    if ( fill | stroke )
+    if ( fill || stroke )
     {
         // setup brushes
         m_mode = kCGPathFill; // just a default
@@ -935,7 +919,7 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
     DrawText(str, x, y, 0.0);
 }
 
-void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, double angle ) 
+void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ) 
 {
     OSStatus status = noErr;
     ATSUTextLayout atsuLayout;
@@ -1155,8 +1139,7 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
 #endif
 #endif
 
-    OSStatus status;
-    status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
+    ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
         &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout );
 
     for ( int pos = 0; pos < (int)chars; pos ++ )