1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface for wxPen
 
   7 // Created:     7-July-1997
 
   9 // Copyright:   (c) 2003 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  16 //---------------------------------------------------------------------------
 
  18 // wxDash is a signed char, byte is unsigned char...
 
  19 %typemap(in) (int dashes, wxDash* dashes_array ) {
 
  20     $1 = PyList_Size($input);
 
  21     $2 = (wxDash*)byte_LIST_helper($input);
 
  22     if ($2 == NULL) SWIG_fail;
 
  24 %typemap(freearg) (int dashes, wxDash* dashes_array ) {
 
  28 //---------------------------------------------------------------------------
 
  34 class wxPen : public wxGDIObject {
 
  36     wxPen(wxColour& colour, int width=1, int style=wxSOLID);
 
  46     %pythoncode { Ok = IsOk }
 
  48     void SetCap(int cap_style);
 
  49     void SetColour(wxColour& colour);
 
  50     void SetJoin(int join_style);
 
  51     void SetStyle(int style);
 
  52     void SetWidth(int width);
 
  54     void SetDashes(int dashes, wxDash* dashes_array);
 
  55     //int GetDashes(wxDash **dashes);
 
  57         PyObject* GetDashes() {
 
  59             int count = self->GetDashes(&dashes);
 
  60             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
  61             PyObject* retval = PyList_New(0);
 
  62             for (int x=0; x<count; x++) {
 
  63                 PyObject* pyint = PyInt_FromLong(dashes[x]);
 
  64                 PyList_Append(retval, pyint);
 
  67             wxPyEndBlockThreads(blocked);
 
  71         void _SetDashes(PyObject* _self, PyObject* pyDashes) {
 
  72             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
  73             int size = PyList_Size(pyDashes);
 
  74             wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
 
  76             // black magic warning!  The array of wxDashes needs to exist as
 
  77             // long as the pen does because wxPen does not copy the array.  So
 
  78             // stick a copy in a Python string object and attach it to _self,
 
  79             // and then call SetDashes with a pointer to that array.  Then
 
  80             // when the Python pen object is destroyed the array will be
 
  82             PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
 
  83             PyObject_SetAttrString(_self, "_dashes", strDashes);
 
  85             self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
 
  88             wxPyEndBlockThreads(blocked);
 
  92     def SetDashes(self, dashes):
 
  94         Associate a list of dash lengths with the Pen.
 
  96         self._SetDashes(self, dashes)
 
 101     int GetDashCount() const;
 
 102     %property(DashCount, GetDashCount, doc="See `GetDashCount`");
 
 106     wxBitmap* GetStipple();
 
 107     void SetStipple(wxBitmap& stipple);
 
 108     %property(Stipple, GetStipple, SetStipple, doc="See `GetStipple` and `SetStipple`");
 
 113         bool __eq__(const wxPen* other) { return other ? (*self == *other) : false; }
 
 114         bool __ne__(const wxPen* other) { return other ? (*self != *other) : true;  }
 
 116     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
 118     %property(Cap, GetCap, SetCap, doc="See `GetCap` and `SetCap`");
 
 119     %property(Colour, GetColour, SetColour, doc="See `GetColour` and `SetColour`");
 
 120     %property(Dashes, GetDashes, SetDashes, doc="See `GetDashes` and `SetDashes`");
 
 121     %property(Join, GetJoin, SetJoin, doc="See `GetJoin` and `SetJoin`");
 
 122     %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
 
 123     %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
 
 127 //---------------------------------------------------------------------------