]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_graphics.i
initial draft of wxCollapsiblePane (patch 1577412 by Francesco)
[wxWidgets.git] / wxPython / src / _graphics.i
index a0bb9caade97f4c5e25339c3e3beb458fb7f4c11..fd5fce2415578478250cf78fd3fa1785cbe83b41 100644 (file)
 #include <wx/graphics.h>
 %}    
 
+// Turn off the aquisition of the Global Interpreter Lock for the classes and
+// functions in this file
+%threadWrapperOff
+
 //---------------------------------------------------------------------------
 
 
@@ -77,7 +81,7 @@ public:
         return NULL;
     }
     
-    wxGraphicsPath * CreatePath() {}
+    wxGraphicsPath * CreatePath() { return NULL; }
     void PushState() {}
     void PopState() {}
     void Clip( const wxRegion & ) {}
@@ -140,6 +144,17 @@ public:
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 
+
+%typemap(in) (size_t points, wxPoint2D* points_array ) {
+    $2 = wxPoint2D_LIST_helper($input, &$1);
+    if ($2 == NULL) SWIG_fail;
+}
+%typemap(freearg) (size_t points, wxPoint2D* points_array ) {
+    if ($2) delete [] $2;
+}
+
+
+
 MustHaveApp(wxGraphicsPath);
 MustHaveApp(wxGraphicsContext);
 MustHaveApp(wxGCDC);
@@ -210,7 +225,7 @@ point and an end point", "");
 
     DocDeclStr(
         virtual void , AddCircle( wxDouble x, wxDouble y, wxDouble r ),
-        "Appends an ellipsis as a new closed subpath fitting the passed rectangle", "");
+        "Appends a circle as a new closed subpath with the given radius.", "");
     
 
     DocDeclStr(
@@ -221,6 +236,43 @@ to (x2,y2), also a straight line from (current) to (x1,y1)", "");
 
 };
 
+//---------------------------------------------------------------------------
+
+/*
+class wxGraphicsMatrix
+{
+public :
+    wxGraphicsMatrix() {}
+       
+    virtual ~wxGraphicsMatrix() {}
+       
+    wxGraphicsMatrix* Concat( const wxGraphicsMatrix *t ) const;
+       
+    // returns the inverse matrix
+    wxGraphicsMatrix* Invert() const;
+       
+    // returns true if the elements of the transformation matrix are equal ?
+    bool operator==(const wxGraphicsMatrix& t) const;
+       
+    // return true if this is the identity matrix
+    bool IsIdentity();
+       
+    //
+    // transformation
+    //
+    
+    // translate
+    virtual void Translate( wxDouble dx , wxDouble dy ) = 0;
+
+    // scale
+    virtual void Scale( wxDouble xScale , wxDouble yScale ) = 0;
+
+    // rotate (radians)
+    virtual void Rotate( wxDouble angle ) = 0; 
+} ;
+*/
+
+
 //---------------------------------------------------------------------------
 
 
@@ -229,17 +281,30 @@ class wxGraphicsContext
 public:
     // wxGraphicsContext()         This is also an ABC, use Create to make an instance...
     virtual ~wxGraphicsContext();
-    
-    %pythonAppend Create
+
+    %nokwargs Create;
+    %pythonAppend Create( const wxWindowDC& dc)
         "val.__dc = args[0] # save a ref so the other dc will not be deleted before self";
     static wxGraphicsContext* Create( const wxWindowDC& dc);
+    
+    static wxGraphicsContext* Create( wxWindow* window ) ;
+
+    static wxGraphicsContext* CreateFromNative( void * context ) ;
+
 
     // creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ...
     DocDeclStr(
         virtual wxGraphicsPath * , CreatePath(),
         "", "");
     
+    /*
+    // create a 'native' matrix corresponding to these values
+    virtual wxGraphicsMatrix* CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
+                                            wxDouble c=0.0, wxDouble d=1.0, 
+                                            wxDouble tx=0.0, wxDouble ty=0.0) = 0;
+    */
 
+    
     // push the current state of the context, ie the transformation matrix on a stack
     DocDeclStr(
         virtual void , PushState(),
@@ -253,13 +318,32 @@ public:
     
 
     // clips drawings to the region
-    DocDeclStr(
+    DocDeclStrName(
         virtual void , Clip( const wxRegion &region ),
+        "", "",
+        ClipRegion);
+    
+    // clips drawings to the rect
+    DocDeclStr(
+        virtual void , Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h ),
+        "", "");
+    
+       
+    // resets the clipping to original extent
+    DocDeclStr(
+        virtual void , ResetClip(),
+        "", "");
+    
+
+    // returns the native context
+    DocDeclStr(
+        virtual void * , GetNativeContext(),
         "", "");
     
 
+    
     //
-    // transformation
+    // transformation: changes the current transformation matrix CTM of the context
     //
     
     // translate
@@ -351,23 +435,32 @@ public:
         "", "");
     
 
-    DocDeclStr(
+    DocDeclStrName(
         virtual void , DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ),
-        "", "");
+        "", "",
+        DrawRotatedText);
     
 
-    DocDeclStr(
+    DocDeclAStr(
         virtual void , GetTextExtent( const wxString &text,
                                       wxDouble *OUTPUT /*width*/,
                                       wxDouble *OUTPUT /*height*/,
                                       wxDouble *OUTPUT /*descent*/,
                                       wxDouble *OUTPUT /*externalLeading*/ ) const ,
+        "GetTextExtend(self, text) --> (width, height, descent, externalLeading)",
         "", "");
     
 
-    DocDeclStr(
-        virtual void , GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const,
-        "", "");
+    %extend {
+        DocAStr(GetPartialTextExtents,
+                "GetPartialTextExtents(self, text) -> [widths]",
+                "", "");
+        wxArrayDouble GetPartialTextExtents(const wxString& text) {
+            wxArrayDouble widths;
+            self->GetPartialTextExtents(text, widths);
+            return widths;
+        }
+    }
     
 
     //
@@ -392,23 +485,38 @@ public:
     DocDeclStr(
         virtual void , StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2),
         "", "");
-    
 
+    
     // stroke lines connecting each of the points
-    DocDeclStr(
-        virtual void , StrokeLines( size_t n, const wxPoint2D *points),
+    DocDeclAStr(
+        virtual void , StrokeLines( size_t points, const wxPoint2D *points_array),
+        "StrokeLines(self, List points)",
         "", "");
     
 
-    // stroke disconnected lines from begin to end points
-    DocDeclStr(
-        virtual void , StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints),
-        "", "");
-    
+//     // stroke disconnected lines from begin to end points
+//     virtual void StrokeLines( size_t n, const wxPoint2D *beginPoints, const wxPoint2D *endPoints);
+
+    %extend {
+        void StrokeLineSegements(PyObject* beginPoints, PyObject* endPoints)
+        {
+            size_t c1, c2, count;
+            wxPoint2D* beginP = wxPoint2D_LIST_helper(beginPoints, &c1);
+            wxPoint2D* endP =   wxPoint2D_LIST_helper(endPoints, &c2);
+
+            if ( beginP != NULL && endP != NULL )
+            {
+                count = wxMin(c1, c2);
+                self->StrokeLines(count, beginP, endP);
+            }
+            delete [] beginP;
+            delete [] endP;
+        }
+    }
 
     // draws a polygon
     DocDeclStr(
-        virtual void , DrawLines( size_t n, const wxPoint2D *points, int fillStyle = wxWINDING_RULE ),
+        virtual void , DrawLines( size_t points, const wxPoint2D *points_array, int fillStyle = wxWINDING_RULE ),
         "", "");
     
 
@@ -429,12 +537,14 @@ public:
         virtual void , DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius),
         "", "");
     
-
 };
 
 
 //---------------------------------------------------------------------------
 
+%{
+#include "wx/dcgraph.h"
+%}
 
 class wxGCDC: public wxDC
 {
@@ -445,10 +555,15 @@ public:
     //wxGCDC();
     virtual ~wxGCDC();
 
-    wxGraphicsContext* GetGraphicContext();
+    wxGraphicsContext* GetGraphicsContext();
+    virtual void SetGraphicsContext( wxGraphicsContext* ctx );
+
+    %property(GraphicsContext, GetGraphicsContext, SetGraphicsContext);
 };
 
 
+//---------------------------------------------------------------------------
 
+// Turn GIL acquisition back on.
+%threadWrapperOn
 
-//---------------------------------------------------------------------------