1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Control (widget) classes for wxPython
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/slider.h>
18 #include <wx/spinbutt.h>
19 #include <wx/dynarray.h>
23 #include <wx/checklst.h>
28 #include <wx/checklst.h>
32 //----------------------------------------------------------------------
35 %include my_typemaps.i
37 // Import some definitions of other classes, etc.
44 %pragma(python) code = "import wx"
46 //----------------------------------------------------------------------
49 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
52 //----------------------------------------------------------------------
54 class wxControl : public wxWindow {
56 void Command(wxCommandEvent& event);
58 void SetLabel(const wxString& label);
61 //----------------------------------------------------------------------
63 class wxButton : public wxControl {
65 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
66 const wxPoint& pos = wxPyDefaultPosition,
67 const wxSize& size = wxPyDefaultSize,
69 const wxValidator& validator = wxPyDefaultValidator,
70 char* name = "button");
72 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
77 //----------------------------------------------------------------------
79 class wxBitmapButton : public wxButton {
81 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
82 const wxPoint& pos = wxPyDefaultPosition,
83 const wxSize& size = wxPyDefaultSize,
84 long style = wxBU_AUTODRAW,
85 const wxValidator& validator = wxPyDefaultValidator,
86 char* name = "button");
88 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
90 wxBitmap& GetBitmapLabel();
91 wxBitmap& GetBitmapDisabled();
92 wxBitmap& GetBitmapFocus();
93 wxBitmap& GetBitmapSelected();
94 void SetBitmapDisabled(const wxBitmap& bitmap);
95 void SetBitmapFocus(const wxBitmap& bitmap);
96 void SetBitmapSelected(const wxBitmap& bitmap);
97 void SetBitmapLabel(const wxBitmap& bitmap);
101 //----------------------------------------------------------------------
103 class wxCheckBox : public wxControl {
105 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
106 const wxPoint& pos = wxPyDefaultPosition,
107 const wxSize& size = wxPyDefaultSize,
109 const wxValidator& val = wxPyDefaultValidator,
110 char* name = "checkBox");
112 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
115 void SetValue(const bool state);
118 //----------------------------------------------------------------------
120 class wxChoice : public wxControl {
122 wxChoice(wxWindow *parent, wxWindowID id,
123 const wxPoint& pos = wxPyDefaultPosition,
124 const wxSize& size = wxPyDefaultSize,
125 int LCOUNT=0, wxString* LIST=NULL,
127 const wxValidator& validator = wxPyDefaultValidator,
128 char* name = "choice");
130 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
132 void Append(const wxString& item);
134 int FindString(const wxString& string);
137 wxString GetString(const int n);
138 wxString GetStringSelection();
140 void SetColumns(const int n = 1);
141 void SetSelection(const int n);
142 void SetStringSelection(const wxString& string);
145 //----------------------------------------------------------------------
147 class wxComboBox : public wxControl {
149 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
150 const wxPoint& pos = wxPyDefaultPosition,
151 const wxSize& size = wxPyDefaultSize,
152 int LCOUNT=0, wxString* LIST=NULL,
154 const wxValidator& validator = wxPyDefaultValidator,
155 char* name = "comboBox");
157 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
159 void Append(const wxString& item);
160 // TODO: void Append(const wxString& item, char* clientData);
165 // NotMember??: void Deselect(int n);
166 int FindString(const wxString& string);
167 // TODO: char* GetClientData(const int n);
168 long GetInsertionPoint();
169 long GetLastPosition();
171 wxString GetString(int n);
172 wxString GetStringSelection();
176 void Replace(long from, long to, const wxString& text);
177 void Remove(long from, long to);
178 // TODO: void SetClientData(const int n, char* data);
179 void SetInsertionPoint(long pos);
180 void SetInsertionPointEnd();
181 void SetSelection(int n, bool select = TRUE);
182 %name(SetMark)void SetSelection(long from, long to);
183 void SetValue(const wxString& text);
186 //----------------------------------------------------------------------
188 class wxGauge : public wxControl {
190 wxGauge(wxWindow* parent, wxWindowID id, int range,
191 const wxPoint& pos = wxPyDefaultPosition,
192 const wxSize& size = wxPyDefaultSize,
193 long style = wxGA_HORIZONTAL,
194 const wxValidator& validator = wxPyDefaultValidator,
195 char* name = "gauge");
197 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
201 int GetShadowWidth();
203 void SetBezelFace(int width);
204 void SetRange(int range);
205 void SetShadowWidth(int width);
206 void SetValue(int pos);
209 //----------------------------------------------------------------------
211 class wxStaticBox : public wxControl {
213 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
214 const wxPoint& pos = wxPyDefaultPosition,
215 const wxSize& size = wxPyDefaultSize,
217 char* name = "staticBox");
221 //----------------------------------------------------------------------
223 class wxStaticText : public wxControl {
225 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
226 const wxPoint& pos = wxPyDefaultPosition,
227 const wxSize& size = wxPyDefaultSize,
229 char* name = "staticText");
231 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
234 void SetLabel(const wxString& label);
237 //----------------------------------------------------------------------
239 class wxListBox : public wxControl {
241 wxListBox(wxWindow* parent, wxWindowID id,
242 const wxPoint& pos = wxPyDefaultPosition,
243 const wxSize& size = wxPyDefaultSize,
244 int LCOUNT, wxString* LIST = NULL,
246 const wxValidator& validator = wxPyDefaultValidator,
247 char* name = "listBox");
249 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
251 void Append(const wxString& item);
252 // TODO: void Append(const wxString& item, char* clientData);
255 void Deselect(int n);
256 int FindString(const wxString& string);
257 // TODO: char* GetClientData(const int n);
260 // int GetSelections(int **selections);
262 PyObject* GetSelections() {
264 self->GetSelections(lst);
265 PyObject *tup = PyTuple_New(lst.GetCount());
266 for(int i=0; i<lst.GetCount(); i++) {
267 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
273 wxString GetString(int n);
274 wxString GetStringSelection();
276 bool Selected(const int n);
277 void Set(int LCOUNT, wxString* LIST);
278 // TODO: void SetClientData(const int n, char* data);
279 void SetFirstItem(int n);
280 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
281 void SetSelection(int n, bool select = TRUE);
282 void SetString(int n, const wxString& string);
283 void SetStringSelection(const wxString& string, bool select = TRUE);
287 //----------------------------------------------------------------------
289 class wxCheckListBox : public wxListBox {
291 wxCheckListBox(wxWindow *parent, wxWindowID id,
292 const wxPoint& pos = wxPyDefaultPosition,
293 const wxSize& size = wxPyDefaultSize,
295 wxString* LIST = NULL,
297 const wxValidator& validator = wxPyDefaultValidator,
298 char* name = "listBox");
300 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
302 bool IsChecked(int uiIndex);
303 void Check(int uiIndex, bool bCheck = TRUE);
308 //----------------------------------------------------------------------
310 class wxTextCtrl : public wxControl {
312 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
313 const wxPoint& pos = wxPyDefaultPosition,
314 const wxSize& size = wxPyDefaultSize,
316 const wxValidator& validator = wxPyDefaultValidator,
317 char* name = "text");
319 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
325 long GetInsertionPoint();
326 long GetLastPosition();
327 int GetLineLength(long lineNo);
328 wxString GetLineText(long lineNo);
329 int GetNumberOfLines();
332 bool LoadFile(const wxString& filename);
334 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
335 void Remove(long from, long to);
336 void Replace(long from, long to, const wxString& value);
337 bool SaveFile(const wxString& filename);
338 void SetEditable(bool editable);
339 void SetInsertionPoint(long pos);
340 void SetInsertionPointEnd();
341 void SetSelection(long from, long to);
342 void SetValue(const wxString& value);
343 void ShowPosition(long pos);
344 void WriteText(const wxString& text);
345 void AppendText(const wxString& text);
346 long XYToPosition(long x, long y);
353 void GetSelection(long* OUTPUT, long* OUTPUT);
357 //----------------------------------------------------------------------
359 class wxScrollBar : public wxControl {
361 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
362 const wxPoint& pos = wxPyDefaultPosition,
363 const wxSize& size = wxPyDefaultSize,
364 long style = wxSB_HORIZONTAL,
365 const wxValidator& validator = wxPyDefaultValidator,
366 char* name = "scrollBar");
368 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
372 int GetThumbPosition();
374 void SetThumbPosition(int viewStart);
375 void SetScrollbar(int position, int thumbSize,
376 int range, int pageSize,
377 bool refresh = TRUE);
380 //----------------------------------------------------------------------
382 class wxSpinButton : public wxControl {
384 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
385 const wxPoint& pos = wxPyDefaultPosition,
386 const wxSize& size = wxPyDefaultSize,
387 long style = wxSP_HORIZONTAL,
388 char* name = "spinButton");
393 void SetRange(int min, int max);
394 void SetValue(int value);
397 //----------------------------------------------------------------------
399 class wxStaticBitmap : public wxControl {
401 wxStaticBitmap(wxWindow* parent, wxWindowID id,
402 const wxBitmap& bitmap,
403 const wxPoint& pos = wxPyDefaultPosition,
404 const wxSize& size = wxPyDefaultSize,
406 char* name = "staticBitmap");
408 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
410 const wxBitmap& GetBitmap();
411 void SetBitmap(const wxBitmap& bitmap);
414 //----------------------------------------------------------------------
416 class wxRadioBox : public wxControl {
418 wxRadioBox(wxWindow* parent, wxWindowID id,
419 const wxString& label,
420 const wxPoint& point = wxPyDefaultPosition,
421 const wxSize& size = wxPyDefaultSize,
422 int LCOUNT = 0, wxString* LIST = NULL,
423 int majorDimension = 0,
424 long style = wxRA_HORIZONTAL,
425 const wxValidator& validator = wxPyDefaultValidator,
426 char* name = "radioBox");
428 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
430 void Enable(bool enable);
431 %name(EnableItem)void Enable(int n, bool enable);
432 int FindString(const wxString& string);
436 %name(GetItemLabel)wxString GetLabel(int n);
438 wxString GetString(int n);
439 wxString GetStringSelection();
441 void SetLabel(const wxString& label);
442 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
443 void SetSelection(int n);
444 void SetStringSelection(const wxString& string);
445 void Show(bool show);
446 %name(ShowItem)void Show(int item, bool show);
449 //----------------------------------------------------------------------
451 class wxRadioButton : public wxControl {
453 wxRadioButton(wxWindow* parent, wxWindowID id,
454 const wxString& label,
455 const wxPoint& pos = wxPyDefaultPosition,
456 const wxSize& size = wxPyDefaultSize,
458 const wxValidator& validator = wxPyDefaultValidator,
459 char* name = "radioButton");
461 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
464 void SetValue(bool value);
467 //----------------------------------------------------------------------
469 class wxSlider : public wxControl {
471 wxSlider(wxWindow* parent, wxWindowID id,
472 int value, int minValue, int maxValue,
473 const wxPoint& point = wxPyDefaultPosition,
474 const wxSize& size = wxPyDefaultSize,
475 long style = wxSL_HORIZONTAL,
476 const wxValidator& validator = wxPyDefaultValidator,
477 char* name = "slider");
479 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
489 int GetThumbLength();
492 void SetRange(int minValue, int maxValue);
493 void SetTickFreq(int n, int pos);
494 void SetLineSize(int lineSize);
495 void SetPageSize(int pageSize);
496 void SetSelection(int startPos, int endPos);
497 void SetThumbLength(int len);
498 void SetTick(int tickPos);
499 void SetValue(int value);
503 //----------------------------------------------------------------------
506 /////////////////////////////////////////////////////////////////////////////
509 // Revision 1.13 1999/04/30 21:13:43 RD
510 // wxPython 2.0b9, first phase (win32)
511 // Added gobs of stuff, see wxPython/README.txt for details
513 // Revision 1.12 1999/04/30 03:29:18 RD
515 // wxPython 2.0b9, first phase (win32)
516 // Added gobs of stuff, see wxPython/README.txt for details
518 // Revision 1.11.4.1 1999/03/27 23:29:14 RD
521 // Python thread support
522 // various minor additions
523 // various minor fixes
525 // Revision 1.11 1999/02/25 07:08:30 RD
527 // wxPython version 2.0b5
529 // Revision 1.10 1998/12/17 17:52:19 RD
532 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
533 // versions are much closer now!
535 // Revision 1.9 1998/12/17 14:07:29 RR
537 // Removed minor differences between wxMSW and wxGTK
539 // Revision 1.8 1998/12/15 20:41:15 RD
540 // Changed the import semantics from "from wxPython import *" to "from
541 // wxPython.wx import *" This is for people who are worried about
542 // namespace pollution, they can use "from wxPython import wx" and then
543 // prefix all the wxPython identifiers with "wx."
545 // Added wxTaskbarIcon for wxMSW.
547 // Made the events work for wxGrid.
551 // Added wxMiniFrame for wxGTK, (untested.)
553 // Changed many of the args and return values that were pointers to gdi
554 // objects to references to reflect changes in the wxWindows API.
556 // Other assorted fixes and additions.
558 // Revision 1.7 1998/11/16 00:00:53 RD
559 // Generic treectrl for wxPython/GTK compiles...
561 // Revision 1.6 1998/11/15 23:03:43 RD
562 // Removing some ifdef's for wxGTK
564 // Revision 1.5 1998/10/07 07:34:32 RD
565 // Version 0.4.1 for wxGTK
567 // Revision 1.4 1998/10/02 06:40:35 RD
569 // Version 0.4 of wxPython for MSW.
571 // Revision 1.3 1998/08/18 19:48:14 RD
572 // more wxGTK compatibility things.
574 // It builds now but there are serious runtime problems...
576 // Revision 1.2 1998/08/15 07:36:28 RD
577 // - Moved the header in the .i files out of the code that gets put into
578 // the .cpp files. It caused CVS conflicts because of the RCS ID being
579 // different each time.
581 // - A few minor fixes.
583 // Revision 1.1 1998/08/09 08:25:49 RD