]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_control.i
added a test to check how exception handling works with Win32 SEH; corrected copyright
[wxWidgets.git] / wxPython / src / _control.i
CommitLineData
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 18MAKE_CONST_WXSTRING(ControlNameStr);
d14a1e28
RD
19
20//---------------------------------------------------------------------------
21%newgroup;
22
23
861d4832
RD
24DocStr(wxControl,
25"This is the base class for a control or 'widget'.
26
d07d2bc9
RD
27A control is generally a small window which processes user input
28and/or displays one or more item of data.", "");
861d4832 29
ab1f7d2a
RD
30MustHaveApp(wxControl);
31
d14a1e28
RD
32class wxControl : public wxWindow
33{
34public:
2b9048c5
RD
35 %pythonAppend wxControl "self._setOORInfo(self)"
36 %pythonAppend wxControl() ""
b39c3fa0 37 %typemap(out) wxControl*; // turn off this typemap
d14a1e28 38
861d4832
RD
39 DocCtorStr(
40 wxControl(wxWindow *parent,
11ec0dce
RD
41 wxWindowID id=-1,
42 const wxPoint& pos=wxDefaultPosition,
43 const wxSize& size=wxDefaultSize,
44 long style=0,
45 const wxValidator& validator=wxDefaultValidator,
861d4832 46 const wxString& name=wxPyControlNameStr),
d07d2bc9
RD
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.", "");
861d4832
RD
49
50 DocCtorStrName(
51 wxControl(),
d07d2bc9 52 "Precreate a Control control for 2-phase creation", "",
861d4832
RD
53 PreControl);
54
b39c3fa0
RD
55 // Turn it back on again
56 %typemap(out) wxControl* { $result = wxPyMake_wxObject($1, $owner); }
57
58
861d4832
RD
59 DocDeclStr(
60 bool , Create(wxWindow *parent,
d5573410 61 wxWindowID id=-1,
861d4832
RD
62 const wxPoint& pos=wxDefaultPosition,
63 const wxSize& size=wxDefaultSize,
64 long style=0,
65 const wxValidator& validator=wxDefaultValidator,
66 const wxString& name=wxPyControlNameStr),
d07d2bc9 67 "Do the 2nd phase and create the GUI control.", "");
861d4832 68
d14a1e28 69
861d4832
RD
70 DocDeclStr(
71 void , Command(wxCommandEvent& event),
d07d2bc9
RD
72 "Simulates the effect of the user issuing a command to the item.
73
74:see: `wx.CommandEvent`
75", "");
861d4832
RD
76
77 DocDeclStr(
78 wxString , GetLabel(),
d07d2bc9 79 "Return a control's text.", "");
861d4832
RD
80
81 DocDeclStr(
82 void , SetLabel(const wxString& label),
d07d2bc9 83 "Sets the item's text.", "");
174051f6 84
fe161a26 85
d8d39b51
RD
86// DocDeclStr(
87// bool , GetAdjustMinSizeFlag(),
88// "Returns whether the minsize should be adjusted for this control when
89// `SetLabel` or `SetFont` are called.", "");
fe161a26 90
d8d39b51
RD
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// ");
174051f6
RD
99
100 static wxVisualAttributes
101 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
102};
103
104
105//---------------------------------------------------------------------------
106%newgroup;
107
108
861d4832
RD
109DocStr(wxItemContainer,
110"wx.ItemContainer defines an interface which is implemented by all
d07d2bc9
RD
111controls which have string subitems, each of which may be selected,
112such as `wx.ListBox`, `wx.CheckListBox`, `wx.Choice` as well as
113`wx.ComboBox` which implements an extended interface deriving from
114this one.
861d4832 115
d07d2bc9
RD
116It defines the methods for accessing the control's items and although
117each of the derived classes implements them differently, they still
118all conform to the same interface.
861d4832 119
d07d2bc9
RD
120The items in a wx.ItemContainer have (non empty) string labels and,
121optionally, client data associated with them.
122", "");
861d4832 123
d14a1e28
RD
124class wxItemContainer
125{
126public:
b870f2e6 127 // wxItemContainer() ** It's an ABC
861d4832 128
d14a1e28 129
d14a1e28 130 %extend {
861d4832 131 DocStr(Append,
d07d2bc9
RD
132 "Adds the item to the control, associating the given data with the item
133if not None. The return value is the index of the newly added item
134which may be different from the last one if the control is sorted (e.g.
135has wx.LB_SORT or wx.CB_SORT style).", "");
d14a1e28
RD
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
d20c6820 145 DocDeclAStrName(
861d4832 146 void , Append(const wxArrayString& strings),
8423f117 147 "AppendItems(self, List strings)",
d07d2bc9
RD
148 "Apend several items at once to the control. Notice that calling this
149method may be much faster than appending the items one by one if you
150need to add a lot of items.", "",
861d4832 151 AppendItems);
d14a1e28 152
861d4832 153
d14a1e28 154 %extend {
861d4832 155 DocStr(Insert,
d07d2bc9
RD
156 "Insert an item into the control before the item at the ``pos`` index,
157optionally associating some data object with the item.", "");
d14a1e28
RD
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
861d4832
RD
168 DocDeclStr(
169 virtual void , Clear(),
d07d2bc9 170 "Removes all items from the control.", "");
861d4832
RD
171
172 DocDeclStr(
173 virtual void , Delete(int n),
d07d2bc9
RD
174 "Deletes the item at the zero-based index 'n' from the control. Note
175that it is an error (signalled by a `wx.PyAssertionError` exception if
176enabled) to remove an item with the index negative or greater or equal
177than the number of items in the control.", "");
861d4832 178
d14a1e28
RD
179
180
861d4832
RD
181 DocDeclStr(
182 virtual int , GetCount() const,
d07d2bc9 183 "Returns the number of items in the control.", "");
861d4832
RD
184
185 DocDeclStr(
186 bool , IsEmpty() const,
d07d2bc9 187 "Returns True if the control is empty or False if it has some items.", "");
861d4832
RD
188
189 DocDeclStr(
190 virtual wxString , GetString(int n) const,
d07d2bc9 191 "Returns the label of the item with the given index.", "");
861d4832
RD
192
193 DocDeclStr(
194 wxArrayString , GetStrings() const,
d07d2bc9 195 "", "");
861d4832
RD
196
197 DocDeclStr(
198 virtual void , SetString(int n, const wxString& s),
d07d2bc9 199 "Sets the label for the given item.", "");
861d4832
RD
200
201 DocDeclStr(
202 virtual int , FindString(const wxString& s) const,
d07d2bc9
RD
203 "Finds an item whose label matches the given string. Returns the
204zero-based position of the item, or ``wx.NOT_FOUND`` if the string was not
205found.", "");
861d4832 206
d14a1e28
RD
207
208
861d4832
RD
209 DocDeclStr(
210 virtual void , Select(int n),
d07d2bc9 211 "Sets the item at index 'n' to be the selected item.", "");
d14a1e28 212
861d4832
RD
213 %pythoncode { SetSelection = Select }
214
215 DocDeclStr(
216 virtual int , GetSelection() const,
d07d2bc9
RD
217 "Returns the index of the selected item or ``wx.NOT_FOUND`` if no item
218is selected.", "");
861d4832
RD
219
220
221 DocDeclStr(
222 wxString , GetStringSelection() const,
d07d2bc9
RD
223 "Returns the label of the selected item or an empty string if no item
224is selected.", "");
861d4832 225
d14a1e28
RD
226
227
d14a1e28 228 %extend {
861d4832 229 DocStr(GetClientData,
d07d2bc9 230 "Returns the client data associated with the given item, (if any.)", "");
d14a1e28
RD
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
861d4832 242 DocStr(SetClientData,
d07d2bc9 243 "Associate the given client data with the item at position n.", "");
d14a1e28
RD
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
861d4832 256DocStr(wxControlWithItems,
d07d2bc9
RD
257"wx.ControlWithItems combines the ``wx.ItemContainer`` class with the
258wx.Control class, and is used for the base class of various controls
259that have items.", "");
861d4832 260
d14a1e28
RD
261class wxControlWithItems : public wxControl, public wxItemContainer
262{
263public:
264};
265
266//---------------------------------------------------------------------------
267