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