]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_pen.i
pi --> math.pi
[wxWidgets.git] / wxPython / src / _pen.i
CommitLineData
d14a1e28
RD
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
ab1f7d2a
RD
32MustHaveApp(wxPen);
33
d14a1e28
RD
34class wxPen : public wxGDIObject {
35public:
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 Ok();
46
47 void SetCap(int cap_style);
48 void SetColour(wxColour& colour);
49 void SetJoin(int join_style);
50 void SetStyle(int style);
51 void SetWidth(int width);
52
53 void SetDashes(int dashes, wxDash* dashes_array);
54 //int GetDashes(wxDash **dashes);
55 %extend {
56 PyObject* GetDashes() {
57 wxDash* dashes;
58 int count = self->GetDashes(&dashes);
da32eb53 59 bool blocked = wxPyBeginBlockThreads();
d14a1e28 60 PyObject* retval = PyList_New(0);
ad411ab2
RD
61 for (int x=0; x<count; x++) {
62 PyObject* pyint = PyInt_FromLong(dashes[x]);
63 PyList_Append(retval, pyint);
64 Py_DECREF(pyint);
65 }
da32eb53 66 wxPyEndBlockThreads(blocked);
d14a1e28
RD
67 return retval;
68 }
9e4e25d5
RD
69
70 void _SetDashes(PyObject* _self, PyObject* pyDashes) {
71 bool blocked = wxPyBeginBlockThreads();
72 int size = PyList_Size(pyDashes);
73 wxDash* dashes = (wxDash*)byte_LIST_helper(pyDashes);
74
75 // black magic warning! The array of wxDashes needs to exist as
76 // long as the pen does because wxPen does not copy the array. So
77 // stick a copy in a Python string object and attach it to _self,
78 // and then call SetDashes with a pointer to that array. Then
79 // when the Python pen object is destroyed the array will be
80 // cleaned up too.
81 PyObject* strDashes = PyString_FromStringAndSize((char*)dashes, size*sizeof(wxDash));
82 PyObject_SetAttrString(_self, "_dashes", strDashes);
83
84 self->SetDashes(size, (wxDash*)PyString_AS_STRING(strDashes));
85 delete [] dashes;
86 Py_DECREF(strDashes);
87 wxPyEndBlockThreads(blocked);
88 }
d14a1e28 89 }
9e4e25d5
RD
90 %pythoncode {
91 def SetDashes(self, dashes):
92 """
93 Associate a list of dash lengths with the Pen.
94 """
95 self._SetDashes(self, dashes)
22faec7d 96 }
d14a1e28 97
9e4e25d5 98
9fd4be55 99#ifndef __WXMAC__
3f0ff538 100 int GetDashCount() const;
9fd4be55
RD
101#endif
102
d14a1e28
RD
103#ifdef __WXMSW__
104 wxBitmap* GetStipple();
105 void SetStipple(wxBitmap& stipple);
106#endif
107
9e4e25d5
RD
108
109 %extend {
110 bool __eq__(const wxPen* other) { return other ? (*self == *other) : False; }
111 bool __ne__(const wxPen* other) { return other ? (*self != *other) : True; }
d14a1e28 112 }
9e4e25d5 113 %pythoncode { def __nonzero__(self): return self.Ok() }
d14a1e28
RD
114};
115
d14a1e28
RD
116
117//---------------------------------------------------------------------------