]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_pen.i
fixes for the dummy classes (used when wxUSE_GRAPHICS_CONTEXT is 0)
[wxWidgets.git] / wxPython / src / _pen.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _pen.i
3 // Purpose: SWIG interface for wxPen
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
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;
23 }
24 %typemap(freearg) (int dashes, wxDash* dashes_array ) {
25 if ($2) delete [] $2;
26 }
27
28 //---------------------------------------------------------------------------
29 %newgroup
30
31
32 MustHaveApp(wxPen);
33
34 class wxPen : public wxGDIObject {
35 public:
36 wxPen(wxColour& colour, int width=1, int style=wxSOLID);
37 ~wxPen();
38
39 int GetCap();
40 wxColour GetColour();
41 int GetJoin();
42 int GetStyle();
43 int GetWidth();
44
45 bool IsOk();
46 %pythoncode { Ok = IsOk }
47
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);
53
54 void SetDashes(int dashes, wxDash* dashes_array);
55 //int GetDashes(wxDash **dashes);
56 %extend {
57 PyObject* GetDashes() {
58 wxDash* dashes;
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);
65 Py_DECREF(pyint);
66 }
67 wxPyEndBlockThreads(blocked);
68 return retval;
69 }
70
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);
75
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
81 // cleaned up too.
82 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
83 PyObject_SetAttrString(_self, "_dashes", strDashes);
84
85 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
86 delete [] dashes;
87 Py_DECREF(strDashes);
88 wxPyEndBlockThreads(blocked);
89 }
90 }
91 %pythoncode {
92 def SetDashes(self, dashes):
93 """
94 Associate a list of dash lengths with the Pen.
95 """
96 self._SetDashes(self, dashes)
97 }
98
99
100 #ifndef __WXMAC__
101 int GetDashCount() const;
102 %property(DashCount, GetDashCount, doc="See `GetDashCount`");
103 #endif
104
105 #ifdef __WXMSW__
106 wxBitmap* GetStipple();
107 void SetStipple(wxBitmap& stipple);
108 %property(Stipple, GetStipple, SetStipple, doc="See `GetStipple` and `SetStipple`");
109 #endif
110
111
112 %extend {
113 bool __eq__(const wxPen* other) { return other ? (*self == *other) : false; }
114 bool __ne__(const wxPen* other) { return other ? (*self != *other) : true; }
115 }
116 %pythoncode { def __nonzero__(self): return self.IsOk() }
117
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`");
124 };
125
126
127 //---------------------------------------------------------------------------