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