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