]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: controls.i | |
3 | // Purpose: Control (widget) classes for wxPython | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 6/10/98 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
03e9bead | 13 | %module controls |
7bf85405 | 14 | |
03e9bead | 15 | %{ |
7bf85405 RD |
16 | #include "helpers.h" |
17 | #include <wx/slider.h> | |
62bd0874 | 18 | #include <wx/spinbutt.h> |
f6bcfd97 | 19 | #include <wx/spinctrl.h> |
cf694132 | 20 | #include <wx/dynarray.h> |
8bf5d46e | 21 | #include <wx/statline.h> |
d1679124 | 22 | #include <wx/tglbtn.h> |
fb5e0af0 RD |
23 | |
24 | #ifdef __WXMSW__ | |
9c039d08 RD |
25 | #if wxUSE_OWNER_DRAWN |
26 | #include <wx/checklst.h> | |
27 | #endif | |
fb5e0af0 | 28 | #endif |
c95e68d8 RD |
29 | |
30 | #ifdef __WXGTK__ | |
31 | #include <wx/checklst.h> | |
32 | #endif | |
bb0054cd | 33 | |
7bf85405 RD |
34 | %} |
35 | ||
36 | //---------------------------------------------------------------------- | |
37 | ||
38 | %include typemaps.i | |
39 | %include my_typemaps.i | |
40 | ||
41 | // Import some definitions of other classes, etc. | |
42 | %import _defs.i | |
43 | %import misc.i | |
44 | %import windows.i | |
45 | %import gdi.i | |
46 | %import events.i | |
47 | ||
b8b8dda7 | 48 | %pragma(python) code = "import wx" |
9c039d08 | 49 | |
7bf85405 RD |
50 | //---------------------------------------------------------------------- |
51 | ||
2f90df85 RD |
52 | %readonly |
53 | wxValidator wxDefaultValidator; | |
54 | %readwrite | |
55 | ||
7bf85405 RD |
56 | //---------------------------------------------------------------------- |
57 | ||
58 | class wxControl : public wxWindow { | |
59 | public: | |
9b3d3bc4 RD |
60 | wxControl(wxWindow *parent, |
61 | wxWindowID id, | |
b68dc582 RD |
62 | const wxPoint& pos=wxDefaultPosition, |
63 | const wxSize& size=wxDefaultSize, | |
9b3d3bc4 | 64 | long style=0, |
b68dc582 | 65 | const wxValidator& validator=wxDefaultValidator, |
9b3d3bc4 | 66 | const char* name="control"); |
09f3d4e6 RD |
67 | %name(wxPreControl)wxControl(); |
68 | ||
69 | bool Create(wxWindow *parent, | |
70 | wxWindowID id, | |
71 | const wxPoint& pos=wxDefaultPosition, | |
72 | const wxSize& size=wxDefaultSize, | |
73 | long style=0, | |
74 | const wxValidator& validator=wxDefaultValidator, | |
75 | const char* name="control"); | |
9b3d3bc4 | 76 | |
0122b7e3 | 77 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 78 | %pragma(python) addtomethod = "wxPreControl:val._setOORInfo(val)" |
6999b0d8 | 79 | |
7bf85405 | 80 | void Command(wxCommandEvent& event); |
fb5e0af0 | 81 | wxString GetLabel(); |
7bf85405 RD |
82 | void SetLabel(const wxString& label); |
83 | }; | |
84 | ||
6999b0d8 | 85 | |
7bf85405 RD |
86 | //---------------------------------------------------------------------- |
87 | ||
900d9886 RD |
88 | |
89 | class wxControlWithItems : public wxControl { | |
90 | public: | |
91 | ||
92 | // void Clear(); ambiguous, redefine below... | |
93 | void Delete(int n); | |
94 | ||
95 | int GetCount(); | |
96 | %pragma(python) addtoclass = "Number = GetCount" | |
97 | wxString GetString(int n); | |
98 | void SetString(int n, const wxString& s); | |
99 | int FindString(const wxString& s); | |
100 | ||
101 | void Select(int n); | |
102 | int GetSelection(); | |
103 | ||
104 | wxString GetStringSelection() const; | |
105 | ||
106 | // void Append(const wxString& item); | |
107 | // void Append(const wxString& item, char* clientData); | |
108 | // char* GetClientData(const int n); | |
109 | // void SetClientData(const int n, char* data); | |
110 | %addmethods { | |
111 | void Append(const wxString& item, PyObject* clientData=NULL) { | |
112 | if (clientData) { | |
113 | wxPyClientData* data = new wxPyClientData(clientData); | |
114 | self->Append(item, data); | |
115 | } else | |
116 | self->Append(item); | |
117 | } | |
118 | ||
119 | PyObject* GetClientData(int n) { | |
120 | wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n); | |
121 | if (data) { | |
122 | Py_INCREF(data->m_obj); | |
123 | return data->m_obj; | |
124 | } else { | |
125 | Py_INCREF(Py_None); | |
126 | return Py_None; | |
127 | } | |
128 | } | |
129 | ||
130 | void SetClientData(int n, PyObject* clientData) { | |
131 | wxPyClientData* data = new wxPyClientData(clientData); | |
132 | self->SetClientObject(n, data); | |
133 | } | |
134 | } | |
135 | ||
136 | }; | |
137 | //---------------------------------------------------------------------- | |
138 | ||
7bf85405 RD |
139 | class wxButton : public wxControl { |
140 | public: | |
141 | wxButton(wxWindow* parent, wxWindowID id, const wxString& label, | |
b68dc582 RD |
142 | const wxPoint& pos = wxDefaultPosition, |
143 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 144 | long style = 0, |
b68dc582 | 145 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 146 | char* name = "button"); |
09f3d4e6 RD |
147 | %name(wxPreButton)wxButton(); |
148 | ||
149 | bool Create(wxWindow* parent, wxWindowID id, const wxString& label, | |
150 | const wxPoint& pos = wxDefaultPosition, | |
151 | const wxSize& size = wxDefaultSize, | |
152 | long style = 0, | |
153 | const wxValidator& validator = wxDefaultValidator, | |
154 | char* name = "button"); | |
9c039d08 | 155 | |
0122b7e3 | 156 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 157 | %pragma(python) addtomethod = "wxPreButton:val._setOORInfo(val)" |
9c039d08 | 158 | |
7bf85405 | 159 | void SetDefault(); |
9b3d3bc4 RD |
160 | void SetBackgroundColour(const wxColour& colour); |
161 | void SetForegroundColour(const wxColour& colour); | |
059a841c | 162 | #ifdef __WXMSW__ |
09f3d4e6 RD |
163 | void SetImageLabel(const wxBitmap& bitmap); |
164 | void SetImageMargins(wxCoord x, wxCoord y); | |
059a841c | 165 | #endif |
09f3d4e6 RD |
166 | static wxSize GetDefaultSize(); |
167 | }; | |
6999b0d8 | 168 | |
7bf85405 RD |
169 | //---------------------------------------------------------------------- |
170 | ||
171 | class wxBitmapButton : public wxButton { | |
172 | public: | |
173 | wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, | |
b68dc582 RD |
174 | const wxPoint& pos = wxDefaultPosition, |
175 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 176 | long style = wxBU_AUTODRAW, |
b68dc582 | 177 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 178 | char* name = "button"); |
09f3d4e6 RD |
179 | %name(wxPreBitmapButton)wxBitmapButton(); |
180 | ||
181 | bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, | |
182 | const wxPoint& pos = wxDefaultPosition, | |
183 | const wxSize& size = wxDefaultSize, | |
184 | long style = wxBU_AUTODRAW, | |
185 | const wxValidator& validator = wxDefaultValidator, | |
186 | char* name = "button"); | |
7bf85405 | 187 | |
0122b7e3 | 188 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 189 | %pragma(python) addtomethod = "wxPreBitmapButton:val._setOORInfo(val)" |
9c039d08 | 190 | |
fb5e0af0 | 191 | wxBitmap& GetBitmapLabel(); |
7bf85405 RD |
192 | wxBitmap& GetBitmapDisabled(); |
193 | wxBitmap& GetBitmapFocus(); | |
7bf85405 RD |
194 | wxBitmap& GetBitmapSelected(); |
195 | void SetBitmapDisabled(const wxBitmap& bitmap); | |
196 | void SetBitmapFocus(const wxBitmap& bitmap); | |
7bf85405 | 197 | void SetBitmapSelected(const wxBitmap& bitmap); |
fb5e0af0 | 198 | void SetBitmapLabel(const wxBitmap& bitmap); |
7bf85405 | 199 | |
f6bcfd97 BP |
200 | void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } |
201 | int GetMarginX() const { return m_marginX; } | |
202 | int GetMarginY() const { return m_marginY; } | |
7bf85405 RD |
203 | }; |
204 | ||
205 | //---------------------------------------------------------------------- | |
206 | ||
207 | class wxCheckBox : public wxControl { | |
208 | public: | |
209 | wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, | |
b68dc582 RD |
210 | const wxPoint& pos = wxDefaultPosition, |
211 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 212 | long style = 0, |
b68dc582 | 213 | const wxValidator& val = wxDefaultValidator, |
7bf85405 | 214 | char* name = "checkBox"); |
09f3d4e6 RD |
215 | %name(wxPreCheckBox)wxCheckBox(); |
216 | ||
217 | bool Create(wxWindow* parent, wxWindowID id, const wxString& label, | |
218 | const wxPoint& pos = wxDefaultPosition, | |
219 | const wxSize& size = wxDefaultSize, | |
220 | long style = 0, | |
221 | const wxValidator& val = wxDefaultValidator, | |
222 | char* name = "checkBox"); | |
7bf85405 | 223 | |
0122b7e3 | 224 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 225 | %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)" |
9c039d08 | 226 | |
7bf85405 RD |
227 | bool GetValue(); |
228 | void SetValue(const bool state); | |
229 | }; | |
230 | ||
231 | //---------------------------------------------------------------------- | |
232 | ||
900d9886 | 233 | class wxChoice : public wxControlWithItems { |
7bf85405 RD |
234 | public: |
235 | wxChoice(wxWindow *parent, wxWindowID id, | |
b68dc582 RD |
236 | const wxPoint& pos = wxDefaultPosition, |
237 | const wxSize& size = wxDefaultSize, | |
eec92d76 | 238 | int LCOUNT=0, wxString* choices=NULL, |
7bf85405 | 239 | long style = 0, |
b68dc582 | 240 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 241 | char* name = "choice"); |
09f3d4e6 RD |
242 | %name(wxPreChoice)wxChoice(); |
243 | ||
244 | bool Create(wxWindow *parent, wxWindowID id, | |
245 | const wxPoint& pos = wxDefaultPosition, | |
246 | const wxSize& size = wxDefaultSize, | |
247 | int LCOUNT=0, wxString* choices=NULL, | |
248 | long style = 0, | |
249 | const wxValidator& validator = wxDefaultValidator, | |
250 | char* name = "choice"); | |
7bf85405 | 251 | |
0122b7e3 | 252 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 253 | %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)" |
0122b7e3 | 254 | |
7bf85405 | 255 | void Clear(); |
900d9886 | 256 | |
7bf85405 | 257 | int GetColumns(); |
7bf85405 RD |
258 | void SetColumns(const int n = 1); |
259 | void SetSelection(const int n); | |
260 | void SetStringSelection(const wxString& string); | |
0adbc166 RD |
261 | void SetString(int n, const wxString& s); |
262 | ||
263 | %pragma(python) addtoclass = " | |
0adbc166 RD |
264 | Select = SetSelection |
265 | " | |
7bf85405 RD |
266 | }; |
267 | ||
268 | //---------------------------------------------------------------------- | |
269 | ||
bb0054cd | 270 | class wxComboBox : public wxChoice { |
7bf85405 RD |
271 | public: |
272 | wxComboBox(wxWindow* parent, wxWindowID id, char* value = "", | |
b68dc582 RD |
273 | const wxPoint& pos = wxDefaultPosition, |
274 | const wxSize& size = wxDefaultSize, | |
eec92d76 | 275 | int LCOUNT=0, wxString* choices=NULL, |
7bf85405 | 276 | long style = 0, |
b68dc582 | 277 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 278 | char* name = "comboBox"); |
09f3d4e6 RD |
279 | %name(wxPreComboBox)wxComboBox(); |
280 | ||
281 | bool Create(wxWindow* parent, wxWindowID id, char* value = "", | |
282 | const wxPoint& pos = wxDefaultPosition, | |
283 | const wxSize& size = wxDefaultSize, | |
284 | int LCOUNT=0, wxString* choices=NULL, | |
285 | long style = 0, | |
286 | const wxValidator& validator = wxDefaultValidator, | |
287 | char* name = "comboBox"); | |
7bf85405 | 288 | |
0122b7e3 | 289 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 290 | %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)" |
9c039d08 | 291 | |
7bf85405 RD |
292 | void Copy(); |
293 | void Cut(); | |
7bf85405 RD |
294 | long GetInsertionPoint(); |
295 | long GetLastPosition(); | |
7bf85405 | 296 | wxString GetValue(); |
7bf85405 RD |
297 | void Paste(); |
298 | void Replace(long from, long to, const wxString& text); | |
299 | void Remove(long from, long to); | |
7bf85405 RD |
300 | void SetInsertionPoint(long pos); |
301 | void SetInsertionPointEnd(); | |
1d99702e | 302 | void SetSelection(int n); |
7bf85405 RD |
303 | %name(SetMark)void SetSelection(long from, long to); |
304 | void SetValue(const wxString& text); | |
0adbc166 | 305 | void SetEditable(bool editable); |
7bf85405 RD |
306 | }; |
307 | ||
308 | //---------------------------------------------------------------------- | |
309 | ||
310 | class wxGauge : public wxControl { | |
311 | public: | |
312 | wxGauge(wxWindow* parent, wxWindowID id, int range, | |
b68dc582 RD |
313 | const wxPoint& pos = wxDefaultPosition, |
314 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 315 | long style = wxGA_HORIZONTAL, |
b68dc582 | 316 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 317 | char* name = "gauge"); |
09f3d4e6 RD |
318 | %name(wxPreGauge)wxGauge(); |
319 | ||
320 | bool Create(wxWindow* parent, wxWindowID id, int range, | |
321 | const wxPoint& pos = wxDefaultPosition, | |
322 | const wxSize& size = wxDefaultSize, | |
323 | long style = wxGA_HORIZONTAL, | |
324 | const wxValidator& validator = wxDefaultValidator, | |
325 | char* name = "gauge"); | |
7bf85405 | 326 | |
0122b7e3 | 327 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 328 | %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)" |
9c039d08 | 329 | |
7bf85405 RD |
330 | int GetBezelFace(); |
331 | int GetRange(); | |
332 | int GetShadowWidth(); | |
333 | int GetValue(); | |
334 | void SetBezelFace(int width); | |
335 | void SetRange(int range); | |
336 | void SetShadowWidth(int width); | |
337 | void SetValue(int pos); | |
338 | }; | |
339 | ||
340 | //---------------------------------------------------------------------- | |
341 | ||
342 | class wxStaticBox : public wxControl { | |
343 | public: | |
344 | wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label, | |
b68dc582 RD |
345 | const wxPoint& pos = wxDefaultPosition, |
346 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
347 | long style = 0, |
348 | char* name = "staticBox"); | |
09f3d4e6 RD |
349 | %name(wxPreStaticBox)wxStaticBox(); |
350 | ||
351 | bool Create(wxWindow* parent, wxWindowID id, const wxString& label, | |
352 | const wxPoint& pos = wxDefaultPosition, | |
353 | const wxSize& size = wxDefaultSize, | |
354 | long style = 0, | |
355 | char* name = "staticBox"); | |
0122b7e3 RD |
356 | |
357 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
17c0e08c | 358 | %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)" |
7bf85405 RD |
359 | }; |
360 | ||
361 | ||
bb0054cd RD |
362 | //---------------------------------------------------------------------- |
363 | ||
8bf5d46e | 364 | |
bb0054cd RD |
365 | class wxStaticLine : public wxControl { |
366 | public: | |
367 | wxStaticLine( wxWindow *parent, wxWindowID id, | |
b68dc582 RD |
368 | const wxPoint &pos = wxDefaultPosition, |
369 | const wxSize &size = wxDefaultSize, | |
bb0054cd | 370 | long style = wxLI_HORIZONTAL, |
d24a34bb | 371 | const char* name = "staticLine" ); |
09f3d4e6 RD |
372 | %name(wxPreStaticLine)wxStaticLine(); |
373 | ||
374 | bool Create( wxWindow *parent, wxWindowID id, | |
375 | const wxPoint &pos = wxDefaultPosition, | |
376 | const wxSize &size = wxDefaultSize, | |
377 | long style = wxLI_HORIZONTAL, | |
378 | const char* name = "staticLine" ); | |
0122b7e3 RD |
379 | |
380 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
17c0e08c | 381 | %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)" |
bb0054cd | 382 | }; |
8bf5d46e | 383 | |
bb0054cd | 384 | |
7bf85405 RD |
385 | //---------------------------------------------------------------------- |
386 | ||
387 | class wxStaticText : public wxControl { | |
388 | public: | |
389 | wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label, | |
b68dc582 RD |
390 | const wxPoint& pos = wxDefaultPosition, |
391 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
392 | long style = 0, |
393 | char* name = "staticText"); | |
09f3d4e6 RD |
394 | %name(wxPreStaticText)wxStaticText(); |
395 | ||
396 | bool Create(wxWindow* parent, wxWindowID id, const wxString& label, | |
397 | const wxPoint& pos = wxDefaultPosition, | |
398 | const wxSize& size = wxDefaultSize, | |
399 | long style = 0, | |
400 | char* name = "staticText"); | |
7bf85405 | 401 | |
0122b7e3 | 402 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 403 | %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)" |
9c039d08 | 404 | |
7bf85405 RD |
405 | wxString GetLabel(); |
406 | void SetLabel(const wxString& label); | |
407 | }; | |
408 | ||
409 | //---------------------------------------------------------------------- | |
410 | ||
900d9886 | 411 | class wxListBox : public wxControlWithItems { |
7bf85405 RD |
412 | public: |
413 | wxListBox(wxWindow* parent, wxWindowID id, | |
b68dc582 RD |
414 | const wxPoint& pos = wxDefaultPosition, |
415 | const wxSize& size = wxDefaultSize, | |
eec92d76 | 416 | int LCOUNT, wxString* choices = NULL, |
7bf85405 | 417 | long style = 0, |
b68dc582 | 418 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 419 | char* name = "listBox"); |
09f3d4e6 RD |
420 | %name(wxPreListBox)wxListBox(); |
421 | ||
422 | bool Create(wxWindow* parent, wxWindowID id, | |
423 | const wxPoint& pos = wxDefaultPosition, | |
424 | const wxSize& size = wxDefaultSize, | |
425 | int LCOUNT, wxString* choices = NULL, | |
426 | long style = 0, | |
427 | const wxValidator& validator = wxDefaultValidator, | |
428 | char* name = "listBox"); | |
7bf85405 | 429 | |
0122b7e3 | 430 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 431 | %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)" |
0122b7e3 | 432 | |
7bf85405 | 433 | void Clear(); |
7bf85405 | 434 | void Deselect(int n); |
cf694132 RD |
435 | |
436 | // int GetSelections(int **selections); | |
437 | %addmethods { | |
438 | PyObject* GetSelections() { | |
439 | wxArrayInt lst; | |
440 | self->GetSelections(lst); | |
441 | PyObject *tup = PyTuple_New(lst.GetCount()); | |
f6bcfd97 | 442 | for(size_t i=0; i<lst.GetCount(); i++) { |
cf694132 RD |
443 | PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i])); |
444 | } | |
445 | return tup; | |
446 | } | |
447 | } | |
448 | ||
900d9886 | 449 | |
eec92d76 | 450 | void InsertItems(int LCOUNT, wxString* choices, int pos); |
2f90df85 | 451 | |
0adbc166 | 452 | bool IsSelected(const int n); |
7bf85405 | 453 | bool Selected(const int n); |
eec92d76 | 454 | void Set(int LCOUNT, wxString* choices); |
7bf85405 RD |
455 | void SetFirstItem(int n); |
456 | %name(SetFirstItemStr)void SetFirstItem(const wxString& string); | |
457 | void SetSelection(int n, bool select = TRUE); | |
458 | void SetString(int n, const wxString& string); | |
459 | void SetStringSelection(const wxString& string, bool select = TRUE); | |
460 | }; | |
461 | ||
462 | ||
9c039d08 RD |
463 | //---------------------------------------------------------------------- |
464 | ||
9c039d08 RD |
465 | class wxCheckListBox : public wxListBox { |
466 | public: | |
467 | wxCheckListBox(wxWindow *parent, wxWindowID id, | |
b68dc582 RD |
468 | const wxPoint& pos = wxDefaultPosition, |
469 | const wxSize& size = wxDefaultSize, | |
9c039d08 | 470 | int LCOUNT = 0, |
eec92d76 | 471 | wxString* choices = NULL, |
9c039d08 | 472 | long style = 0, |
b68dc582 | 473 | const wxValidator& validator = wxDefaultValidator, |
9c039d08 | 474 | char* name = "listBox"); |
09f3d4e6 RD |
475 | %name(wxPreCheckListBox)wxCheckListBox(); |
476 | ||
477 | bool Create(wxWindow *parent, wxWindowID id, | |
478 | const wxPoint& pos = wxDefaultPosition, | |
479 | const wxSize& size = wxDefaultSize, | |
480 | int LCOUNT = 0, | |
481 | wxString* choices = NULL, | |
482 | long style = 0, | |
483 | const wxValidator& validator = wxDefaultValidator, | |
484 | char* name = "listBox"); | |
9c039d08 | 485 | |
0122b7e3 | 486 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 487 | %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)" |
9c039d08 RD |
488 | |
489 | bool IsChecked(int uiIndex); | |
694759cf | 490 | void Check(int uiIndex, int bCheck = TRUE); |
eec92d76 | 491 | void InsertItems(int LCOUNT, wxString* choices, int pos); |
9c039d08 | 492 | |
e6056257 | 493 | #ifndef __WXMAC__ |
9c039d08 | 494 | int GetItemHeight(); |
e6056257 | 495 | #endif |
9c039d08 | 496 | }; |
9c039d08 | 497 | |
7bf85405 RD |
498 | //---------------------------------------------------------------------- |
499 | ||
d56cebe7 RD |
500 | |
501 | class wxTextAttr | |
502 | { | |
503 | public: | |
504 | // ctors | |
505 | wxTextAttr(const wxColour& colText = wxNullColour, | |
506 | const wxColour& colBack = wxNullColour, | |
507 | const wxFont& font = wxNullFont); | |
508 | ~wxTextAttr(); | |
509 | ||
510 | // setters | |
511 | void SetTextColour(const wxColour& colText); | |
512 | void SetBackgroundColour(const wxColour& colBack); | |
513 | void SetFont(const wxFont& font); | |
514 | ||
515 | // accessors | |
516 | bool HasTextColour() const; | |
517 | bool HasBackgroundColour() const; | |
518 | bool HasFont() const; | |
519 | ||
520 | const wxColour& GetTextColour() const; | |
521 | const wxColour& GetBackgroundColour() const; | |
522 | const wxFont& GetFont() const; | |
98624b49 RD |
523 | |
524 | // returns false if we have any attributes set, true otherwise | |
525 | bool IsDefault(); | |
d56cebe7 RD |
526 | }; |
527 | ||
528 | ||
529 | ||
7bf85405 RD |
530 | class wxTextCtrl : public wxControl { |
531 | public: | |
532 | wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "", | |
b68dc582 RD |
533 | const wxPoint& pos = wxDefaultPosition, |
534 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 535 | long style = 0, |
b68dc582 | 536 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 537 | char* name = "text"); |
09f3d4e6 RD |
538 | %name(wxPreTextCtrl)wxTextCtrl(); |
539 | ||
540 | bool Create(wxWindow* parent, wxWindowID id, char* value = "", | |
541 | const wxPoint& pos = wxDefaultPosition, | |
542 | const wxSize& size = wxDefaultSize, | |
543 | long style = 0, | |
544 | const wxValidator& validator = wxDefaultValidator, | |
545 | char* name = "text"); | |
7bf85405 | 546 | |
0122b7e3 | 547 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 548 | %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)" |
9c039d08 | 549 | |
98624b49 RD |
550 | |
551 | wxString GetValue() const; | |
552 | void SetValue(const wxString& value); | |
553 | ||
554 | int GetLineLength(long lineNo) const; | |
555 | wxString GetLineText(long lineNo) const; | |
556 | int GetNumberOfLines() const; | |
557 | ||
558 | bool IsModified() const; | |
559 | bool IsEditable() const; | |
560 | ||
561 | // If the return values from and to are the same, there is no selection. | |
562 | void GetSelection(long* OUTPUT, long* OUTPUT) const; | |
b78b83ec | 563 | wxString GetStringSelection(); |
98624b49 | 564 | |
7bf85405 | 565 | void Clear(); |
7bf85405 | 566 | void Replace(long from, long to, const wxString& value); |
98624b49 RD |
567 | void Remove(long from, long to); |
568 | ||
569 | // load/save the controls contents from/to the file | |
570 | bool LoadFile(const wxString& file); | |
571 | bool SaveFile(const wxString& file = wxEmptyString); | |
572 | ||
573 | // clears the dirty flag | |
574 | void DiscardEdits(); | |
575 | ||
576 | // set the max number of characters which may be entered in a single line | |
577 | // text control | |
578 | void SetMaxLength(unsigned long len); | |
579 | ||
580 | // writing text inserts it at the current position, appending always | |
581 | // inserts it at the end | |
7bf85405 | 582 | void WriteText(const wxString& text); |
cf694132 | 583 | void AppendText(const wxString& text); |
b1462dfa | 584 | |
98624b49 RD |
585 | // text control under some platforms supports the text styles: these |
586 | // methods allow to apply the given text style to the given selection or to | |
587 | // set/get the style which will be used for all appended text | |
d56cebe7 RD |
588 | bool SetStyle(long start, long end, const wxTextAttr& style); |
589 | bool SetDefaultStyle(const wxTextAttr& style); | |
590 | const wxTextAttr& GetDefaultStyle() const; | |
591 | ||
98624b49 RD |
592 | // translate between the position (which is just an index in the text ctrl |
593 | // considering all its contents as a single strings) and (x, y) coordinates | |
594 | // which represent column and line. | |
595 | long XYToPosition(long x, long y) const; | |
596 | bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const; | |
597 | ||
598 | void ShowPosition(long pos); | |
599 | ||
600 | // Clipboard operations | |
601 | void Copy(); | |
602 | void Cut(); | |
603 | void Paste(); | |
604 | ||
605 | bool CanCopy() const; | |
606 | bool CanCut() const; | |
607 | bool CanPaste() const; | |
608 | ||
609 | // Undo/redo | |
610 | void Undo(); | |
611 | void Redo(); | |
612 | ||
613 | bool CanUndo() const; | |
614 | bool CanRedo() const; | |
615 | ||
616 | // Insertion point | |
617 | void SetInsertionPoint(long pos); | |
618 | void SetInsertionPointEnd(); | |
619 | long GetInsertionPoint() const; | |
620 | long GetLastPosition() const; | |
621 | ||
622 | void SetSelection(long from, long to); | |
623 | void SelectAll(); | |
624 | void SetEditable(bool editable); | |
00b6c4e3 | 625 | |
b1462dfa RD |
626 | %addmethods { |
627 | void write(const wxString& text) { | |
d56cebe7 | 628 | self->AppendText(text); |
b1462dfa RD |
629 | } |
630 | } | |
7bf85405 RD |
631 | }; |
632 | ||
633 | //---------------------------------------------------------------------- | |
634 | ||
635 | class wxScrollBar : public wxControl { | |
636 | public: | |
637 | wxScrollBar(wxWindow* parent, wxWindowID id = -1, | |
b68dc582 RD |
638 | const wxPoint& pos = wxDefaultPosition, |
639 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 640 | long style = wxSB_HORIZONTAL, |
b68dc582 | 641 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 642 | char* name = "scrollBar"); |
09f3d4e6 RD |
643 | %name(wxPreScrollBar)wxScrollBar(); |
644 | ||
645 | bool Create(wxWindow* parent, wxWindowID id = -1, | |
646 | const wxPoint& pos = wxDefaultPosition, | |
647 | const wxSize& size = wxDefaultSize, | |
648 | long style = wxSB_HORIZONTAL, | |
649 | const wxValidator& validator = wxDefaultValidator, | |
650 | char* name = "scrollBar"); | |
7bf85405 | 651 | |
0122b7e3 | 652 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 653 | %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)" |
9c039d08 | 654 | |
7bf85405 RD |
655 | int GetRange(); |
656 | int GetPageSize(); | |
b8b8dda7 | 657 | int GetThumbPosition(); |
7bf85405 | 658 | int GetThumbSize(); |
26b9cf27 | 659 | %name(GetThumbLength) int GetThumbSize(); // to match the docs |
b8b8dda7 | 660 | void SetThumbPosition(int viewStart); |
7bf85405 RD |
661 | void SetScrollbar(int position, int thumbSize, |
662 | int range, int pageSize, | |
663 | bool refresh = TRUE); | |
664 | }; | |
665 | ||
666 | //---------------------------------------------------------------------- | |
667 | ||
668 | class wxSpinButton : public wxControl { | |
669 | public: | |
670 | wxSpinButton(wxWindow* parent, wxWindowID id = -1, | |
b68dc582 RD |
671 | const wxPoint& pos = wxDefaultPosition, |
672 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
673 | long style = wxSP_HORIZONTAL, |
674 | char* name = "spinButton"); | |
09f3d4e6 RD |
675 | %name(wxPreSpinButton)wxSpinButton(); |
676 | ||
677 | bool Create(wxWindow* parent, wxWindowID id = -1, | |
678 | const wxPoint& pos = wxDefaultPosition, | |
679 | const wxSize& size = wxDefaultSize, | |
680 | long style = wxSP_HORIZONTAL, | |
681 | char* name = "spinButton"); | |
7bf85405 | 682 | |
0122b7e3 | 683 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 684 | %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)" |
0122b7e3 | 685 | |
7bf85405 RD |
686 | int GetMax(); |
687 | int GetMin(); | |
688 | int GetValue(); | |
689 | void SetRange(int min, int max); | |
690 | void SetValue(int value); | |
691 | }; | |
692 | ||
693 | //---------------------------------------------------------------------- | |
694 | ||
695 | class wxStaticBitmap : public wxControl { | |
696 | public: | |
697 | wxStaticBitmap(wxWindow* parent, wxWindowID id, | |
698 | const wxBitmap& bitmap, | |
b68dc582 RD |
699 | const wxPoint& pos = wxDefaultPosition, |
700 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
701 | long style = 0, |
702 | char* name = "staticBitmap"); | |
09f3d4e6 RD |
703 | %name(wxPreStaticBitmap)wxStaticBitmap(); |
704 | ||
705 | bool Create(wxWindow* parent, wxWindowID id, | |
706 | const wxBitmap& bitmap, | |
707 | const wxPoint& pos = wxDefaultPosition, | |
708 | const wxSize& size = wxDefaultSize, | |
709 | long style = 0, | |
710 | char* name = "staticBitmap"); | |
7bf85405 | 711 | |
0122b7e3 | 712 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 713 | %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)" |
9c039d08 | 714 | |
cf694132 | 715 | const wxBitmap& GetBitmap(); |
7bf85405 | 716 | void SetBitmap(const wxBitmap& bitmap); |
8bf5d46e | 717 | void SetIcon(const wxIcon& icon); |
7bf85405 RD |
718 | }; |
719 | ||
720 | //---------------------------------------------------------------------- | |
721 | ||
722 | class wxRadioBox : public wxControl { | |
723 | public: | |
724 | wxRadioBox(wxWindow* parent, wxWindowID id, | |
725 | const wxString& label, | |
b68dc582 RD |
726 | const wxPoint& point = wxDefaultPosition, |
727 | const wxSize& size = wxDefaultSize, | |
eec92d76 | 728 | int LCOUNT = 0, wxString* choices = NULL, |
7bf85405 RD |
729 | int majorDimension = 0, |
730 | long style = wxRA_HORIZONTAL, | |
b68dc582 | 731 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 732 | char* name = "radioBox"); |
09f3d4e6 RD |
733 | %name(wxPreRadioBox)wxRadioBox(); |
734 | ||
735 | bool Create(wxWindow* parent, wxWindowID id, | |
736 | const wxString& label, | |
737 | const wxPoint& point = wxDefaultPosition, | |
738 | const wxSize& size = wxDefaultSize, | |
739 | int LCOUNT = 0, wxString* choices = NULL, | |
740 | int majorDimension = 0, | |
741 | long style = wxRA_HORIZONTAL, | |
742 | const wxValidator& validator = wxDefaultValidator, | |
743 | char* name = "radioBox"); | |
7bf85405 | 744 | |
0122b7e3 | 745 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 746 | %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)" |
9c039d08 | 747 | |
0699c864 RD |
748 | void Enable(bool enable); |
749 | %name(EnableItem)void Enable(int n, bool enable); | |
7bf85405 | 750 | int FindString(const wxString& string); |
bb0054cd | 751 | |
7bf85405 | 752 | wxString GetString(int n); |
2c8a649d | 753 | |
e6056257 RD |
754 | #ifdef __WXGTK__ |
755 | %name(GetItemLabel)wxString GetLabel( int item ); | |
756 | %name(SetItemLabel)void SetLabel( int item, const wxString& label ); | |
757 | #else | |
0adbc166 RD |
758 | void SetString(int n, const wxString& label); |
759 | %pragma(python) addtoclass = " | |
760 | GetItemLabel = GetString | |
761 | SetItemLabel = SetString | |
762 | " | |
2c8a649d RD |
763 | int GetColumnCount(); |
764 | int GetRowCount(); | |
2c8a649d RD |
765 | #endif |
766 | ||
0adbc166 | 767 | int GetSelection(); |
7bf85405 | 768 | wxString GetStringSelection(); |
0adbc166 RD |
769 | int GetCount(); |
770 | %pragma(python) addtoclass = "Number = GetCount" | |
771 | ||
7bf85405 RD |
772 | void SetSelection(int n); |
773 | void SetStringSelection(const wxString& string); | |
774 | void Show(bool show); | |
775 | %name(ShowItem)void Show(int item, bool show); | |
776 | }; | |
777 | ||
778 | //---------------------------------------------------------------------- | |
779 | ||
780 | class wxRadioButton : public wxControl { | |
781 | public: | |
782 | wxRadioButton(wxWindow* parent, wxWindowID id, | |
783 | const wxString& label, | |
b68dc582 RD |
784 | const wxPoint& pos = wxDefaultPosition, |
785 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 786 | long style = 0, |
b68dc582 | 787 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 788 | char* name = "radioButton"); |
09f3d4e6 RD |
789 | %name(wxPreRadioButton)wxRadioButton(); |
790 | ||
791 | bool Create(wxWindow* parent, wxWindowID id, | |
792 | const wxString& label, | |
793 | const wxPoint& pos = wxDefaultPosition, | |
794 | const wxSize& size = wxDefaultSize, | |
795 | long style = 0, | |
796 | const wxValidator& validator = wxDefaultValidator, | |
797 | char* name = "radioButton"); | |
7bf85405 | 798 | |
0122b7e3 | 799 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 800 | %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)" |
9c039d08 | 801 | |
7bf85405 RD |
802 | bool GetValue(); |
803 | void SetValue(bool value); | |
804 | }; | |
805 | ||
806 | //---------------------------------------------------------------------- | |
807 | ||
808 | class wxSlider : public wxControl { | |
809 | public: | |
810 | wxSlider(wxWindow* parent, wxWindowID id, | |
811 | int value, int minValue, int maxValue, | |
b68dc582 RD |
812 | const wxPoint& point = wxDefaultPosition, |
813 | const wxSize& size = wxDefaultSize, | |
7bf85405 | 814 | long style = wxSL_HORIZONTAL, |
b68dc582 | 815 | const wxValidator& validator = wxDefaultValidator, |
7bf85405 | 816 | char* name = "slider"); |
09f3d4e6 RD |
817 | %name(wxPreSlider)wxSlider(); |
818 | ||
819 | bool Create(wxWindow* parent, wxWindowID id, | |
820 | int value, int minValue, int maxValue, | |
821 | const wxPoint& point = wxDefaultPosition, | |
822 | const wxSize& size = wxDefaultSize, | |
823 | long style = wxSL_HORIZONTAL, | |
824 | const wxValidator& validator = wxDefaultValidator, | |
825 | char* name = "slider"); | |
7bf85405 | 826 | |
0122b7e3 | 827 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 828 | %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)" |
9c039d08 | 829 | |
7bf85405 RD |
830 | void ClearSel(); |
831 | void ClearTicks(); | |
832 | int GetLineSize(); | |
833 | int GetMax(); | |
834 | int GetMin(); | |
835 | int GetPageSize(); | |
836 | int GetSelEnd(); | |
837 | int GetSelStart(); | |
838 | int GetThumbLength(); | |
839 | int GetTickFreq(); | |
840 | int GetValue(); | |
841 | void SetRange(int minValue, int maxValue); | |
842 | void SetTickFreq(int n, int pos); | |
843 | void SetLineSize(int lineSize); | |
844 | void SetPageSize(int pageSize); | |
845 | void SetSelection(int startPos, int endPos); | |
846 | void SetThumbLength(int len); | |
847 | void SetTick(int tickPos); | |
848 | void SetValue(int value); | |
849 | }; | |
850 | ||
851 | ||
852 | //---------------------------------------------------------------------- | |
853 | ||
f6bcfd97 BP |
854 | class wxSpinCtrl : public wxSpinButton { |
855 | public: | |
856 | wxSpinCtrl(wxWindow *parent, | |
857 | wxWindowID id = -1, | |
858 | const char* value = "", | |
b68dc582 RD |
859 | const wxPoint& pos = wxDefaultPosition, |
860 | const wxSize& size = wxDefaultSize, | |
f6bcfd97 BP |
861 | long style = wxSP_ARROW_KEYS, |
862 | int min = 0, int max = 100, int initial = 0, | |
863 | const char* name = "wxSpinCtrl"); | |
09f3d4e6 RD |
864 | %name(wxPreSpinCtrl)wxSpinCtrl(); |
865 | ||
866 | bool Create(wxWindow *parent, | |
867 | wxWindowID id = -1, | |
868 | const char* value = "", | |
869 | const wxPoint& pos = wxDefaultPosition, | |
870 | const wxSize& size = wxDefaultSize, | |
871 | long style = wxSP_ARROW_KEYS, | |
872 | int min = 0, int max = 100, int initial = 0, | |
873 | const char* name = "wxSpinCtrl"); | |
f6bcfd97 | 874 | |
0122b7e3 | 875 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 876 | %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)" |
f6bcfd97 | 877 | |
c368d904 RD |
878 | int GetMax(); |
879 | int GetMin(); | |
880 | int GetValue(); | |
881 | void SetRange(int min, int max); | |
882 | void SetValue(int value); | |
883 | ||
f6bcfd97 BP |
884 | }; |
885 | ||
886 | ||
887 | //---------------------------------------------------------------------- | |
888 | ||
e6056257 | 889 | #ifndef __WXMAC__ |
d1679124 RD |
890 | enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, }; |
891 | ||
892 | class wxToggleButton : public wxControl { | |
893 | public: | |
894 | wxToggleButton(wxWindow *parent, | |
895 | wxWindowID id, | |
896 | const wxString& label, | |
897 | const wxPoint& pos = wxDefaultPosition, | |
898 | const wxSize& size = wxDefaultSize, | |
899 | long style = 0, | |
900 | const wxValidator& validator = wxDefaultValidator, | |
901 | const char* name = "toggle"); | |
09f3d4e6 RD |
902 | %name(wxPreToggleButton)wxToggleButton(); |
903 | ||
904 | bool Create(wxWindow *parent, | |
905 | wxWindowID id, | |
906 | const wxString& label, | |
907 | const wxPoint& pos = wxDefaultPosition, | |
908 | const wxSize& size = wxDefaultSize, | |
909 | long style = 0, | |
910 | const wxValidator& validator = wxDefaultValidator, | |
911 | const char* name = "toggle"); | |
d1679124 | 912 | |
0122b7e3 | 913 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 914 | %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)" |
0122b7e3 | 915 | |
d1679124 RD |
916 | void SetValue(bool value); |
917 | bool GetValue() const ; | |
918 | void SetLabel(const wxString& label); | |
919 | ||
920 | }; | |
921 | ||
e6056257 | 922 | #endif |
d1679124 RD |
923 | //---------------------------------------------------------------------- |
924 | //---------------------------------------------------------------------- | |
925 | //---------------------------------------------------------------------- | |
926 | ||
c368d904 RD |
927 | |
928 |