]>
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> |
cf694132 | 19 | #include <wx/dynarray.h> |
8bf5d46e | 20 | #include <wx/statline.h> |
fb5e0af0 RD |
21 | |
22 | #ifdef __WXMSW__ | |
9c039d08 RD |
23 | #if wxUSE_OWNER_DRAWN |
24 | #include <wx/checklst.h> | |
25 | #endif | |
fb5e0af0 | 26 | #endif |
c95e68d8 RD |
27 | |
28 | #ifdef __WXGTK__ | |
29 | #include <wx/checklst.h> | |
30 | #endif | |
bb0054cd | 31 | |
7bf85405 RD |
32 | %} |
33 | ||
34 | //---------------------------------------------------------------------- | |
35 | ||
36 | %include typemaps.i | |
37 | %include my_typemaps.i | |
38 | ||
39 | // Import some definitions of other classes, etc. | |
40 | %import _defs.i | |
41 | %import misc.i | |
42 | %import windows.i | |
43 | %import gdi.i | |
44 | %import events.i | |
45 | ||
b8b8dda7 | 46 | %pragma(python) code = "import wx" |
9c039d08 | 47 | |
7bf85405 RD |
48 | //---------------------------------------------------------------------- |
49 | ||
50 | %{ | |
51 | wxValidator wxPyDefaultValidator; // Non-const default because of SWIG | |
52 | %} | |
53 | ||
2f90df85 RD |
54 | %readonly |
55 | wxValidator wxDefaultValidator; | |
56 | %readwrite | |
57 | ||
7bf85405 RD |
58 | //---------------------------------------------------------------------- |
59 | ||
60 | class wxControl : public wxWindow { | |
61 | public: | |
8bf5d46e | 62 | #ifdef __WXMSW__ |
7bf85405 | 63 | void Command(wxCommandEvent& event); |
8bf5d46e | 64 | #endif |
fb5e0af0 | 65 | wxString GetLabel(); |
7bf85405 RD |
66 | void SetLabel(const wxString& label); |
67 | }; | |
68 | ||
69 | //---------------------------------------------------------------------- | |
70 | ||
71 | class wxButton : public wxControl { | |
72 | public: | |
73 | wxButton(wxWindow* parent, wxWindowID id, const wxString& label, | |
74 | const wxPoint& pos = wxPyDefaultPosition, | |
75 | const wxSize& size = wxPyDefaultSize, | |
76 | long style = 0, | |
77 | const wxValidator& validator = wxPyDefaultValidator, | |
78 | char* name = "button"); | |
9c039d08 | 79 | |
b8b8dda7 | 80 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 81 | |
7bf85405 RD |
82 | void SetDefault(); |
83 | }; | |
84 | ||
85 | //---------------------------------------------------------------------- | |
86 | ||
87 | class wxBitmapButton : public wxButton { | |
88 | public: | |
89 | wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, | |
90 | const wxPoint& pos = wxPyDefaultPosition, | |
91 | const wxSize& size = wxPyDefaultSize, | |
92 | long style = wxBU_AUTODRAW, | |
93 | const wxValidator& validator = wxPyDefaultValidator, | |
94 | char* name = "button"); | |
95 | ||
b8b8dda7 | 96 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 97 | |
fb5e0af0 | 98 | wxBitmap& GetBitmapLabel(); |
7bf85405 RD |
99 | wxBitmap& GetBitmapDisabled(); |
100 | wxBitmap& GetBitmapFocus(); | |
7bf85405 RD |
101 | wxBitmap& GetBitmapSelected(); |
102 | void SetBitmapDisabled(const wxBitmap& bitmap); | |
103 | void SetBitmapFocus(const wxBitmap& bitmap); | |
7bf85405 | 104 | void SetBitmapSelected(const wxBitmap& bitmap); |
fb5e0af0 | 105 | void SetBitmapLabel(const wxBitmap& bitmap); |
7bf85405 RD |
106 | |
107 | }; | |
108 | ||
109 | //---------------------------------------------------------------------- | |
110 | ||
111 | class wxCheckBox : public wxControl { | |
112 | public: | |
113 | wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, | |
114 | const wxPoint& pos = wxPyDefaultPosition, | |
115 | const wxSize& size = wxPyDefaultSize, | |
116 | long style = 0, | |
117 | const wxValidator& val = wxPyDefaultValidator, | |
118 | char* name = "checkBox"); | |
119 | ||
b8b8dda7 | 120 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 121 | |
7bf85405 RD |
122 | bool GetValue(); |
123 | void SetValue(const bool state); | |
124 | }; | |
125 | ||
126 | //---------------------------------------------------------------------- | |
127 | ||
128 | class wxChoice : public wxControl { | |
129 | public: | |
130 | wxChoice(wxWindow *parent, wxWindowID id, | |
131 | const wxPoint& pos = wxPyDefaultPosition, | |
132 | const wxSize& size = wxPyDefaultSize, | |
133 | int LCOUNT=0, wxString* LIST=NULL, | |
134 | long style = 0, | |
135 | const wxValidator& validator = wxPyDefaultValidator, | |
136 | char* name = "choice"); | |
137 | ||
b8b8dda7 | 138 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 139 | |
7bf85405 RD |
140 | void Append(const wxString& item); |
141 | void Clear(); | |
142 | int FindString(const wxString& string); | |
143 | int GetColumns(); | |
144 | int GetSelection(); | |
145 | wxString GetString(const int n); | |
146 | wxString GetStringSelection(); | |
147 | int Number(); | |
148 | void SetColumns(const int n = 1); | |
149 | void SetSelection(const int n); | |
150 | void SetStringSelection(const wxString& string); | |
151 | }; | |
152 | ||
153 | //---------------------------------------------------------------------- | |
154 | ||
bb0054cd | 155 | class wxComboBox : public wxChoice { |
7bf85405 RD |
156 | public: |
157 | wxComboBox(wxWindow* parent, wxWindowID id, char* value = "", | |
158 | const wxPoint& pos = wxPyDefaultPosition, | |
159 | const wxSize& size = wxPyDefaultSize, | |
160 | int LCOUNT=0, wxString* LIST=NULL, | |
161 | long style = 0, | |
162 | const wxValidator& validator = wxPyDefaultValidator, | |
163 | char* name = "comboBox"); | |
164 | ||
b8b8dda7 | 165 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 166 | |
7bf85405 RD |
167 | void Append(const wxString& item); |
168 | // TODO: void Append(const wxString& item, char* clientData); | |
169 | void Clear(); | |
170 | void Copy(); | |
171 | void Cut(); | |
172 | void Delete(int n); | |
173 | // NotMember??: void Deselect(int n); | |
174 | int FindString(const wxString& string); | |
175 | // TODO: char* GetClientData(const int n); | |
176 | long GetInsertionPoint(); | |
177 | long GetLastPosition(); | |
178 | int GetSelection(); | |
179 | wxString GetString(int n); | |
180 | wxString GetStringSelection(); | |
181 | wxString GetValue(); | |
182 | int Number(); | |
183 | void Paste(); | |
184 | void Replace(long from, long to, const wxString& text); | |
185 | void Remove(long from, long to); | |
186 | // TODO: void SetClientData(const int n, char* data); | |
187 | void SetInsertionPoint(long pos); | |
188 | void SetInsertionPointEnd(); | |
1d99702e | 189 | void SetSelection(int n); |
7bf85405 RD |
190 | %name(SetMark)void SetSelection(long from, long to); |
191 | void SetValue(const wxString& text); | |
192 | }; | |
193 | ||
194 | //---------------------------------------------------------------------- | |
195 | ||
196 | class wxGauge : public wxControl { | |
197 | public: | |
198 | wxGauge(wxWindow* parent, wxWindowID id, int range, | |
199 | const wxPoint& pos = wxPyDefaultPosition, | |
200 | const wxSize& size = wxPyDefaultSize, | |
201 | long style = wxGA_HORIZONTAL, | |
202 | const wxValidator& validator = wxPyDefaultValidator, | |
203 | char* name = "gauge"); | |
204 | ||
b8b8dda7 | 205 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 206 | |
7bf85405 RD |
207 | int GetBezelFace(); |
208 | int GetRange(); | |
209 | int GetShadowWidth(); | |
210 | int GetValue(); | |
211 | void SetBezelFace(int width); | |
212 | void SetRange(int range); | |
213 | void SetShadowWidth(int width); | |
214 | void SetValue(int pos); | |
215 | }; | |
216 | ||
217 | //---------------------------------------------------------------------- | |
218 | ||
219 | class wxStaticBox : public wxControl { | |
220 | public: | |
221 | wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label, | |
222 | const wxPoint& pos = wxPyDefaultPosition, | |
223 | const wxSize& size = wxPyDefaultSize, | |
224 | long style = 0, | |
225 | char* name = "staticBox"); | |
226 | }; | |
227 | ||
228 | ||
bb0054cd RD |
229 | //---------------------------------------------------------------------- |
230 | ||
8bf5d46e | 231 | |
bb0054cd RD |
232 | class wxStaticLine : public wxControl { |
233 | public: | |
234 | wxStaticLine( wxWindow *parent, wxWindowID id, | |
235 | const wxPoint &pos = wxPyDefaultPosition, | |
236 | const wxSize &size = wxPyDefaultSize, | |
237 | long style = wxLI_HORIZONTAL, | |
d24a34bb | 238 | const char* name = "staticLine" ); |
bb0054cd | 239 | }; |
8bf5d46e | 240 | |
bb0054cd | 241 | |
7bf85405 RD |
242 | //---------------------------------------------------------------------- |
243 | ||
244 | class wxStaticText : public wxControl { | |
245 | public: | |
246 | wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label, | |
247 | const wxPoint& pos = wxPyDefaultPosition, | |
248 | const wxSize& size = wxPyDefaultSize, | |
249 | long style = 0, | |
250 | char* name = "staticText"); | |
251 | ||
b8b8dda7 | 252 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 253 | |
7bf85405 RD |
254 | wxString GetLabel(); |
255 | void SetLabel(const wxString& label); | |
256 | }; | |
257 | ||
258 | //---------------------------------------------------------------------- | |
259 | ||
260 | class wxListBox : public wxControl { | |
261 | public: | |
262 | wxListBox(wxWindow* parent, wxWindowID id, | |
263 | const wxPoint& pos = wxPyDefaultPosition, | |
264 | const wxSize& size = wxPyDefaultSize, | |
265 | int LCOUNT, wxString* LIST = NULL, | |
266 | long style = 0, | |
267 | const wxValidator& validator = wxPyDefaultValidator, | |
268 | char* name = "listBox"); | |
269 | ||
b8b8dda7 | 270 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 271 | |
7bf85405 RD |
272 | void Append(const wxString& item); |
273 | // TODO: void Append(const wxString& item, char* clientData); | |
274 | void Clear(); | |
275 | void Delete(int n); | |
276 | void Deselect(int n); | |
277 | int FindString(const wxString& string); | |
278 | // TODO: char* GetClientData(const int n); | |
279 | int GetSelection(); | |
cf694132 RD |
280 | |
281 | // int GetSelections(int **selections); | |
282 | %addmethods { | |
283 | PyObject* GetSelections() { | |
284 | wxArrayInt lst; | |
285 | self->GetSelections(lst); | |
286 | PyObject *tup = PyTuple_New(lst.GetCount()); | |
287 | for(int i=0; i<lst.GetCount(); i++) { | |
288 | PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i])); | |
289 | } | |
290 | return tup; | |
291 | } | |
292 | } | |
293 | ||
2f90df85 RD |
294 | void InsertItems(int LCOUNT, wxString* LIST, int pos); |
295 | ||
7bf85405 RD |
296 | wxString GetString(int n); |
297 | wxString GetStringSelection(); | |
298 | int Number(); | |
299 | bool Selected(const int n); | |
300 | void Set(int LCOUNT, wxString* LIST); | |
301 | // TODO: void SetClientData(const int n, char* data); | |
302 | void SetFirstItem(int n); | |
303 | %name(SetFirstItemStr)void SetFirstItem(const wxString& string); | |
304 | void SetSelection(int n, bool select = TRUE); | |
305 | void SetString(int n, const wxString& string); | |
306 | void SetStringSelection(const wxString& string, bool select = TRUE); | |
307 | }; | |
308 | ||
309 | ||
9c039d08 RD |
310 | //---------------------------------------------------------------------- |
311 | ||
9c039d08 RD |
312 | class wxCheckListBox : public wxListBox { |
313 | public: | |
314 | wxCheckListBox(wxWindow *parent, wxWindowID id, | |
315 | const wxPoint& pos = wxPyDefaultPosition, | |
316 | const wxSize& size = wxPyDefaultSize, | |
317 | int LCOUNT = 0, | |
318 | wxString* LIST = NULL, | |
319 | long style = 0, | |
320 | const wxValidator& validator = wxPyDefaultValidator, | |
321 | char* name = "listBox"); | |
322 | ||
b8b8dda7 | 323 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 RD |
324 | |
325 | bool IsChecked(int uiIndex); | |
694759cf RD |
326 | void Check(int uiIndex, int bCheck = TRUE); |
327 | void InsertItems(int LCOUNT, wxString* LIST, int pos); | |
9c039d08 RD |
328 | |
329 | int GetItemHeight(); | |
330 | }; | |
9c039d08 | 331 | |
7bf85405 RD |
332 | //---------------------------------------------------------------------- |
333 | ||
334 | class wxTextCtrl : public wxControl { | |
335 | public: | |
336 | wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "", | |
337 | const wxPoint& pos = wxPyDefaultPosition, | |
338 | const wxSize& size = wxPyDefaultSize, | |
339 | long style = 0, | |
340 | const wxValidator& validator = wxPyDefaultValidator, | |
341 | char* name = "text"); | |
342 | ||
b8b8dda7 | 343 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 344 | |
7bf85405 RD |
345 | void Clear(); |
346 | void Copy(); | |
347 | void Cut(); | |
348 | void DiscardEdits(); | |
349 | long GetInsertionPoint(); | |
350 | long GetLastPosition(); | |
351 | int GetLineLength(long lineNo); | |
352 | wxString GetLineText(long lineNo); | |
353 | int GetNumberOfLines(); | |
354 | wxString GetValue(); | |
355 | bool IsModified(); | |
356 | bool LoadFile(const wxString& filename); | |
357 | void Paste(); | |
358 | void PositionToXY(long pos, long *OUTPUT, long *OUTPUT); | |
359 | void Remove(long from, long to); | |
360 | void Replace(long from, long to, const wxString& value); | |
361 | bool SaveFile(const wxString& filename); | |
362 | void SetEditable(bool editable); | |
363 | void SetInsertionPoint(long pos); | |
364 | void SetInsertionPointEnd(); | |
365 | void SetSelection(long from, long to); | |
366 | void SetValue(const wxString& value); | |
367 | void ShowPosition(long pos); | |
368 | void WriteText(const wxString& text); | |
cf694132 | 369 | void AppendText(const wxString& text); |
7bf85405 | 370 | long XYToPosition(long x, long y); |
d403febc RD |
371 | |
372 | bool CanCopy(); | |
373 | bool CanCut(); | |
374 | bool CanPaste(); | |
375 | bool CanRedo(); | |
376 | bool CanUndo(); | |
377 | void GetSelection(long* OUTPUT, long* OUTPUT); | |
378 | bool IsEditable(); | |
b1462dfa RD |
379 | void Undo(); |
380 | void Redo(); | |
381 | ||
382 | %addmethods { | |
383 | void write(const wxString& text) { | |
384 | self->AppendText(text + '\n'); | |
385 | } | |
386 | } | |
7bf85405 RD |
387 | }; |
388 | ||
389 | //---------------------------------------------------------------------- | |
390 | ||
391 | class wxScrollBar : public wxControl { | |
392 | public: | |
393 | wxScrollBar(wxWindow* parent, wxWindowID id = -1, | |
394 | const wxPoint& pos = wxPyDefaultPosition, | |
395 | const wxSize& size = wxPyDefaultSize, | |
396 | long style = wxSB_HORIZONTAL, | |
397 | const wxValidator& validator = wxPyDefaultValidator, | |
398 | char* name = "scrollBar"); | |
399 | ||
b8b8dda7 | 400 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 401 | |
7bf85405 RD |
402 | int GetRange(); |
403 | int GetPageSize(); | |
b8b8dda7 | 404 | int GetThumbPosition(); |
7bf85405 | 405 | int GetThumbSize(); |
b8b8dda7 | 406 | void SetThumbPosition(int viewStart); |
7bf85405 RD |
407 | void SetScrollbar(int position, int thumbSize, |
408 | int range, int pageSize, | |
409 | bool refresh = TRUE); | |
410 | }; | |
411 | ||
412 | //---------------------------------------------------------------------- | |
413 | ||
414 | class wxSpinButton : public wxControl { | |
415 | public: | |
416 | wxSpinButton(wxWindow* parent, wxWindowID id = -1, | |
417 | const wxPoint& pos = wxPyDefaultPosition, | |
418 | const wxSize& size = wxPyDefaultSize, | |
419 | long style = wxSP_HORIZONTAL, | |
420 | char* name = "spinButton"); | |
421 | ||
422 | int GetMax(); | |
423 | int GetMin(); | |
424 | int GetValue(); | |
425 | void SetRange(int min, int max); | |
426 | void SetValue(int value); | |
427 | }; | |
428 | ||
429 | //---------------------------------------------------------------------- | |
430 | ||
431 | class wxStaticBitmap : public wxControl { | |
432 | public: | |
433 | wxStaticBitmap(wxWindow* parent, wxWindowID id, | |
434 | const wxBitmap& bitmap, | |
435 | const wxPoint& pos = wxPyDefaultPosition, | |
436 | const wxSize& size = wxPyDefaultSize, | |
437 | long style = 0, | |
438 | char* name = "staticBitmap"); | |
439 | ||
b8b8dda7 | 440 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 441 | |
cf694132 | 442 | const wxBitmap& GetBitmap(); |
7bf85405 | 443 | void SetBitmap(const wxBitmap& bitmap); |
8bf5d46e | 444 | void SetIcon(const wxIcon& icon); |
7bf85405 RD |
445 | }; |
446 | ||
447 | //---------------------------------------------------------------------- | |
448 | ||
449 | class wxRadioBox : public wxControl { | |
450 | public: | |
451 | wxRadioBox(wxWindow* parent, wxWindowID id, | |
452 | const wxString& label, | |
453 | const wxPoint& point = wxPyDefaultPosition, | |
454 | const wxSize& size = wxPyDefaultSize, | |
455 | int LCOUNT = 0, wxString* LIST = NULL, | |
456 | int majorDimension = 0, | |
457 | long style = wxRA_HORIZONTAL, | |
458 | const wxValidator& validator = wxPyDefaultValidator, | |
459 | char* name = "radioBox"); | |
460 | ||
b8b8dda7 | 461 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 462 | |
0699c864 RD |
463 | void Enable(bool enable); |
464 | %name(EnableItem)void Enable(int n, bool enable); | |
7bf85405 | 465 | int FindString(const wxString& string); |
bb0054cd RD |
466 | |
467 | //*** wxString GetLabel(); | |
468 | //*** void SetLabel(const wxString& label); | |
469 | ||
0699c864 | 470 | %name(GetItemLabel)wxString GetLabel(int n); |
7bf85405 RD |
471 | int GetSelection(); |
472 | wxString GetString(int n); | |
473 | wxString GetStringSelection(); | |
474 | int Number(); | |
0699c864 | 475 | %name(SetItemLabel)void SetLabel(int n, const wxString& label); |
7bf85405 RD |
476 | void SetSelection(int n); |
477 | void SetStringSelection(const wxString& string); | |
478 | void Show(bool show); | |
479 | %name(ShowItem)void Show(int item, bool show); | |
480 | }; | |
481 | ||
482 | //---------------------------------------------------------------------- | |
483 | ||
484 | class wxRadioButton : public wxControl { | |
485 | public: | |
486 | wxRadioButton(wxWindow* parent, wxWindowID id, | |
487 | const wxString& label, | |
488 | const wxPoint& pos = wxPyDefaultPosition, | |
489 | const wxSize& size = wxPyDefaultSize, | |
490 | long style = 0, | |
491 | const wxValidator& validator = wxPyDefaultValidator, | |
492 | char* name = "radioButton"); | |
493 | ||
b8b8dda7 | 494 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 495 | |
7bf85405 RD |
496 | bool GetValue(); |
497 | void SetValue(bool value); | |
498 | }; | |
499 | ||
500 | //---------------------------------------------------------------------- | |
501 | ||
502 | class wxSlider : public wxControl { | |
503 | public: | |
504 | wxSlider(wxWindow* parent, wxWindowID id, | |
505 | int value, int minValue, int maxValue, | |
506 | const wxPoint& point = wxPyDefaultPosition, | |
507 | const wxSize& size = wxPyDefaultSize, | |
508 | long style = wxSL_HORIZONTAL, | |
509 | const wxValidator& validator = wxPyDefaultValidator, | |
510 | char* name = "slider"); | |
511 | ||
b8b8dda7 | 512 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 513 | |
7bf85405 RD |
514 | void ClearSel(); |
515 | void ClearTicks(); | |
516 | int GetLineSize(); | |
517 | int GetMax(); | |
518 | int GetMin(); | |
519 | int GetPageSize(); | |
520 | int GetSelEnd(); | |
521 | int GetSelStart(); | |
522 | int GetThumbLength(); | |
523 | int GetTickFreq(); | |
524 | int GetValue(); | |
525 | void SetRange(int minValue, int maxValue); | |
526 | void SetTickFreq(int n, int pos); | |
527 | void SetLineSize(int lineSize); | |
528 | void SetPageSize(int pageSize); | |
529 | void SetSelection(int startPos, int endPos); | |
530 | void SetThumbLength(int len); | |
531 | void SetTick(int tickPos); | |
532 | void SetValue(int value); | |
533 | }; | |
534 | ||
535 | ||
536 | //---------------------------------------------------------------------- | |
537 |