]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dccg.cpp
Unified flags for orienting wxBookCtrls (with backward compatibility). Centralised...
[wxWidgets.git] / src / mac / carbon / dccg.cpp
index 0781f8c3047fa532baafbe78a0544910c15c2a63..eaaa2f179cfdb301401f576d28e515cefff7d064 100755 (executable)
@@ -9,10 +9,6 @@
 // Licence:       wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "dc.h"
-#endif
-
 #include "wx/wxprec.h"
 
 #include "wx/dc.h"
 #include "wx/log.h"
 
 
-#if __MSL__ >= 0x6000
-#include "math.h"
-using namespace std ;
+#ifdef __MSL__
+    #if __MSL__ >= 0x6000
+        #include "math.h"
+        using namespace std ;
+    #endif
 #endif
 
 #include "wx/mac/private.h"
@@ -132,6 +130,10 @@ static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
 // also coordinate conversions should be moved to native matrix ops
 //-----------------------------------------------------------------------------
 
+// we always stock two context states, one at entry, to be able to preserve the
+// state we were called with, the other one after changing to HI Graphics orientation
+// (this one is used for getting back clippings etc)
+
 wxMacCGPath::wxMacCGPath()
 {
     m_path = CGPathCreateMutable() ;
@@ -153,6 +155,11 @@ void wxMacCGPath::AddLineToPoint( wxCoord x1 , wxCoord y1 )
     CGPathAddLineToPoint( m_path , NULL , x1 , y1 ) ;
 }
 
+void wxMacCGPath::AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 )
+{
+    CGPathAddQuadCurveToPoint( m_path , NULL , cx1 , cy1 , x1 , y1 );
+}
+
 void wxMacCGPath::AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
 {
     CGRect cgRect = { { x , y } , { w , h } } ;
@@ -175,9 +182,6 @@ CGPathRef wxMacCGPath::GetPath() const
     return m_path ;
 }
 
-// we always stock two context states, one at entry, the other one after 
-// changing to HI Graphics orientation (this one is used for getting back clippings etc)
-
 wxMacCGContext::wxMacCGContext( CGrafPtr port ) 
 {
     m_qdPort = port ;
@@ -1420,6 +1424,65 @@ void  wxDC::DoDrawLines(int n, wxPoint points[],
     delete path ;
 }
 
+#if wxUSE_SPLINES
+void wxDC::DoDrawSpline(wxList *points)
+{
+    wxCHECK_RET(Ok(), wxT("Invalid DC"));
+    
+    if ( m_logicalFunction != wxCOPY )
+        return ;
+    
+    wxGraphicPath* path = m_graphicContext->CreatePath() ;
+    
+    wxList::compatibility_iterator node = points->GetFirst();
+    if (node == wxList::compatibility_iterator())
+        // empty list
+        return;
+    
+    wxPoint *p = (wxPoint *)node->GetData();
+    
+    wxCoord x1 = p->x;
+    wxCoord y1 = p->y;
+    
+    node = node->GetNext();
+    p = (wxPoint *)node->GetData();
+    
+    wxCoord x2 = p->x;
+    wxCoord y2 = p->y;
+    wxCoord cx1 = ( x1 + x2 ) / 2;
+    wxCoord cy1 = ( y1 + y2 ) / 2;
+    
+    path->MoveToPoint( XLOG2DEVMAC( x1 ) , XLOG2DEVMAC( y1 ) ) ;
+    path->AddLineToPoint( XLOG2DEVMAC( cx1 ) , XLOG2DEVMAC( cy1 ) ) ;
+    
+#if !wxUSE_STL
+    while ((node = node->GetNext()) != NULL)
+#else
+    while ((node = node->GetNext()))
+#endif // !wxUSE_STL
+    {
+        p = (wxPoint *)node->GetData();
+        x1 = x2;
+        y1 = y2;
+        x2 = p->x;
+        y2 = p->y;
+        wxCoord cx4 = (x1 + x2) / 2;
+        wxCoord cy4 = (y1 + y2) / 2;
+        
+        path->AddQuadCurveToPoint( XLOG2DEVMAC( x1 ) , XLOG2DEVMAC( y1 ) , 
+                                   XLOG2DEVMAC( cx4 ) , XLOG2DEVMAC( cy4 ) ) ;
+        
+        cx1 = cx4;
+        cy1 = cy4;
+    }
+            
+    path->AddLineToPoint( XLOG2DEVMAC( x2 ) , XLOG2DEVMAC( y2 ) ) ;
+    
+    m_graphicContext->StrokePath( path ) ;
+    delete path ;
+}
+#endif
+
 void  wxDC::DoDrawPolygon(int n, wxPoint points[],
                           wxCoord xoffset, wxCoord yoffset,
                           int fillStyle )