]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_control.i
Some change notes
[wxWidgets.git] / wxPython / src / _control.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _control.i
3 // Purpose: SWIG interface defs for wxControl and other base classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 10-June-1998
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 MAKE_CONST_WXSTRING(ControlNameStr);
19
20 //---------------------------------------------------------------------------
21 %newgroup;
22
23
24 DocStr(wxControl,
25 "This is the base class for a control or 'widget'.
26
27 A control is generally a small window which processes user input
28 and/or displays one or more item of data.", "");
29
30 MustHaveApp(wxControl);
31
32 class wxControl : public wxWindow
33 {
34 public:
35 %pythonAppend wxControl "self._setOORInfo(self)"
36 %pythonAppend wxControl() ""
37 %typemap(out) wxControl*; // turn off this typemap
38
39 DocCtorStr(
40 wxControl(wxWindow *parent,
41 wxWindowID id=-1,
42 const wxPoint& pos=wxDefaultPosition,
43 const wxSize& size=wxDefaultSize,
44 long style=0,
45 const wxValidator& validator=wxDefaultValidator,
46 const wxString& name=wxPyControlNameStr),
47 "Create a Control. Normally you should only call this from a subclass'
48 __init__ as a plain old wx.Control is not very useful.", "");
49
50 DocCtorStrName(
51 wxControl(),
52 "Precreate a Control control for 2-phase creation", "",
53 PreControl);
54
55 // Turn it back on again
56 %typemap(out) wxControl* { $result = wxPyMake_wxObject($1, $owner); }
57
58
59 DocDeclStr(
60 bool , Create(wxWindow *parent,
61 wxWindowID id=-1,
62 const wxPoint& pos=wxDefaultPosition,
63 const wxSize& size=wxDefaultSize,
64 long style=0,
65 const wxValidator& validator=wxDefaultValidator,
66 const wxString& name=wxPyControlNameStr),
67 "Do the 2nd phase and create the GUI control.", "");
68
69
70 DocDeclStr(
71 void , Command(wxCommandEvent& event),
72 "Simulates the effect of the user issuing a command to the item.
73
74 :see: `wx.CommandEvent`
75 ", "");
76
77 DocDeclStr(
78 wxString , GetLabel(),
79 "Return a control's text.", "");
80
81 DocDeclStr(
82 void , SetLabel(const wxString& label),
83 "Sets the item's text.", "");
84
85
86 // DocDeclStr(
87 // bool , GetAdjustMinSizeFlag(),
88 // "Returns whether the minsize should be adjusted for this control when
89 // `SetLabel` or `SetFont` are called.", "");
90
91 // DocDeclStr(
92 // void , SetAdjustMinSizeFlag(bool adjust),
93 // "By default controls will readjust their size and minsize when
94 // `SetLabel` or `SetFont` are called. This flag will allow you to
95 // control this behavior.", "
96
97 // :see: `GetAdjustMinSizeFlag`
98 // ");
99
100 static wxVisualAttributes
101 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
102 };
103
104
105 //---------------------------------------------------------------------------
106 %newgroup;
107
108
109 DocStr(wxItemContainer,
110 "wx.ItemContainer defines an interface which is implemented by all
111 controls which have string subitems, each of which may be selected,
112 such as `wx.ListBox`, `wx.CheckListBox`, `wx.Choice` as well as
113 `wx.ComboBox` which implements an extended interface deriving from
114 this one.
115
116 It defines the methods for accessing the control's items and although
117 each of the derived classes implements them differently, they still
118 all conform to the same interface.
119
120 The items in a wx.ItemContainer have (non empty) string labels and,
121 optionally, client data associated with them.
122 ", "");
123
124 class wxItemContainer
125 {
126 public:
127 // wxItemContainer() { m_clientDataItemsType = wxClientData_None; } ** It's an ABC
128
129
130 %extend {
131 DocStr(Append,
132 "Adds the item to the control, associating the given data with the item
133 if not None. The return value is the index of the newly added item
134 which may be different from the last one if the control is sorted (e.g.
135 has wx.LB_SORT or wx.CB_SORT style).", "");
136 int Append(const wxString& item, PyObject* clientData=NULL) {
137 if (clientData) {
138 wxPyClientData* data = new wxPyClientData(clientData);
139 return self->Append(item, data);
140 } else
141 return self->Append(item);
142 }
143 }
144
145 DocDeclAStrName(
146 void , Append(const wxArrayString& strings),
147 "AppendItems(self, List strings)",
148 "Apend several items at once to the control. Notice that calling this
149 method may be much faster than appending the items one by one if you
150 need to add a lot of items.", "",
151 AppendItems);
152
153
154 %extend {
155 DocStr(Insert,
156 "Insert an item into the control before the item at the ``pos`` index,
157 optionally associating some data object with the item.", "");
158 int Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
159 if (clientData) {
160 wxPyClientData* data = new wxPyClientData(clientData);
161 return self->Insert(item, pos, data);
162 } else
163 return self->Insert(item, pos);
164 }
165 }
166
167
168 DocDeclStr(
169 virtual void , Clear(),
170 "Removes all items from the control.", "");
171
172 DocDeclStr(
173 virtual void , Delete(int n),
174 "Deletes the item at the zero-based index 'n' from the control. Note
175 that it is an error (signalled by a `wx.PyAssertionError` exception if
176 enabled) to remove an item with the index negative or greater or equal
177 than the number of items in the control.", "");
178
179
180
181 DocDeclStr(
182 virtual int , GetCount() const,
183 "Returns the number of items in the control.", "");
184
185 DocDeclStr(
186 bool , IsEmpty() const,
187 "Returns True if the control is empty or False if it has some items.", "");
188
189 DocDeclStr(
190 virtual wxString , GetString(int n) const,
191 "Returns the label of the item with the given index.", "");
192
193 DocDeclStr(
194 wxArrayString , GetStrings() const,
195 "", "");
196
197 DocDeclStr(
198 virtual void , SetString(int n, const wxString& s),
199 "Sets the label for the given item.", "");
200
201 DocDeclStr(
202 virtual int , FindString(const wxString& s) const,
203 "Finds an item whose label matches the given string. Returns the
204 zero-based position of the item, or ``wx.NOT_FOUND`` if the string was not
205 found.", "");
206
207
208
209 DocDeclStr(
210 virtual void , Select(int n),
211 "Sets the item at index 'n' to be the selected item.", "");
212
213 %pythoncode { SetSelection = Select }
214
215 DocDeclStr(
216 virtual int , GetSelection() const,
217 "Returns the index of the selected item or ``wx.NOT_FOUND`` if no item
218 is selected.", "");
219
220
221 DocDeclStr(
222 wxString , GetStringSelection() const,
223 "Returns the label of the selected item or an empty string if no item
224 is selected.", "");
225
226
227
228 %extend {
229 DocStr(GetClientData,
230 "Returns the client data associated with the given item, (if any.)", "");
231 PyObject* GetClientData(int n) {
232 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
233 if (data) {
234 Py_INCREF(data->m_obj);
235 return data->m_obj;
236 } else {
237 Py_INCREF(Py_None);
238 return Py_None;
239 }
240 }
241
242 DocStr(SetClientData,
243 "Associate the given client data with the item at position n.", "");
244 void SetClientData(int n, PyObject* clientData) {
245 wxPyClientData* data = new wxPyClientData(clientData);
246 self->SetClientObject(n, data);
247 }
248 }
249
250 };
251
252
253 //---------------------------------------------------------------------------
254 %newgroup;
255
256 DocStr(wxControlWithItems,
257 "wx.ControlWithItems combines the ``wx.ItemContainer`` class with the
258 wx.Control class, and is used for the base class of various controls
259 that have items.", "");
260
261 class wxControlWithItems : public wxControl, public wxItemContainer
262 {
263 public:
264 };
265
266 //---------------------------------------------------------------------------
267