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>
29 #include <wx/statline.h>
34 //----------------------------------------------------------------------
37 %include my_typemaps.i
39 // Import some definitions of other classes, etc.
46 %pragma(python) code = "import wx"
48 //----------------------------------------------------------------------
51 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
54 //----------------------------------------------------------------------
56 class wxControl : public wxWindow {
58 void Command(wxCommandEvent& event);
60 void SetLabel(const wxString& label);
63 //----------------------------------------------------------------------
65 class wxButton : public wxControl {
67 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
68 const wxPoint& pos = wxPyDefaultPosition,
69 const wxSize& size = wxPyDefaultSize,
71 const wxValidator& validator = wxPyDefaultValidator,
72 char* name = "button");
74 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
79 //----------------------------------------------------------------------
81 class wxBitmapButton : public wxButton {
83 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
84 const wxPoint& pos = wxPyDefaultPosition,
85 const wxSize& size = wxPyDefaultSize,
86 long style = wxBU_AUTODRAW,
87 const wxValidator& validator = wxPyDefaultValidator,
88 char* name = "button");
90 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
92 wxBitmap& GetBitmapLabel();
93 wxBitmap& GetBitmapDisabled();
94 wxBitmap& GetBitmapFocus();
95 wxBitmap& GetBitmapSelected();
96 void SetBitmapDisabled(const wxBitmap& bitmap);
97 void SetBitmapFocus(const wxBitmap& bitmap);
98 void SetBitmapSelected(const wxBitmap& bitmap);
99 void SetBitmapLabel(const wxBitmap& bitmap);
103 //----------------------------------------------------------------------
105 class wxCheckBox : public wxControl {
107 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
108 const wxPoint& pos = wxPyDefaultPosition,
109 const wxSize& size = wxPyDefaultSize,
111 const wxValidator& val = wxPyDefaultValidator,
112 char* name = "checkBox");
114 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
117 void SetValue(const bool state);
120 //----------------------------------------------------------------------
122 class wxChoice : public wxControl {
124 wxChoice(wxWindow *parent, wxWindowID id,
125 const wxPoint& pos = wxPyDefaultPosition,
126 const wxSize& size = wxPyDefaultSize,
127 int LCOUNT=0, wxString* LIST=NULL,
129 const wxValidator& validator = wxPyDefaultValidator,
130 char* name = "choice");
132 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
134 void Append(const wxString& item);
136 int FindString(const wxString& string);
139 wxString GetString(const int n);
140 wxString GetStringSelection();
142 void SetColumns(const int n = 1);
143 void SetSelection(const int n);
144 void SetStringSelection(const wxString& string);
147 //----------------------------------------------------------------------
149 class wxComboBox : public wxChoice {
151 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
152 const wxPoint& pos = wxPyDefaultPosition,
153 const wxSize& size = wxPyDefaultSize,
154 int LCOUNT=0, wxString* LIST=NULL,
156 const wxValidator& validator = wxPyDefaultValidator,
157 char* name = "comboBox");
159 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
161 void Append(const wxString& item);
162 // TODO: void Append(const wxString& item, char* clientData);
167 // NotMember??: void Deselect(int n);
168 int FindString(const wxString& string);
169 // TODO: char* GetClientData(const int n);
170 long GetInsertionPoint();
171 long GetLastPosition();
173 wxString GetString(int n);
174 wxString GetStringSelection();
178 void Replace(long from, long to, const wxString& text);
179 void Remove(long from, long to);
180 // TODO: void SetClientData(const int n, char* data);
181 void SetInsertionPoint(long pos);
182 void SetInsertionPointEnd();
183 //void SetSelection(int n, int select = TRUE); **** Just use the one in wxChoice
184 %name(SetMark)void SetSelection(long from, long to);
185 void SetValue(const wxString& text);
188 //----------------------------------------------------------------------
190 class wxGauge : public wxControl {
192 wxGauge(wxWindow* parent, wxWindowID id, int range,
193 const wxPoint& pos = wxPyDefaultPosition,
194 const wxSize& size = wxPyDefaultSize,
195 long style = wxGA_HORIZONTAL,
196 const wxValidator& validator = wxPyDefaultValidator,
197 char* name = "gauge");
199 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
203 int GetShadowWidth();
205 void SetBezelFace(int width);
206 void SetRange(int range);
207 void SetShadowWidth(int width);
208 void SetValue(int pos);
211 //----------------------------------------------------------------------
213 class wxStaticBox : public wxControl {
215 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
216 const wxPoint& pos = wxPyDefaultPosition,
217 const wxSize& size = wxPyDefaultSize,
219 char* name = "staticBox");
223 //----------------------------------------------------------------------
226 class wxStaticLine : public wxControl {
228 wxStaticLine( wxWindow *parent, wxWindowID id,
229 const wxPoint &pos = wxPyDefaultPosition,
230 const wxSize &size = wxPyDefaultSize,
231 long style = wxLI_HORIZONTAL,
232 const char* name = "staticLine" );
236 //----------------------------------------------------------------------
238 class wxStaticText : public wxControl {
240 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
241 const wxPoint& pos = wxPyDefaultPosition,
242 const wxSize& size = wxPyDefaultSize,
244 char* name = "staticText");
246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
249 void SetLabel(const wxString& label);
252 //----------------------------------------------------------------------
254 class wxListBox : public wxControl {
256 wxListBox(wxWindow* parent, wxWindowID id,
257 const wxPoint& pos = wxPyDefaultPosition,
258 const wxSize& size = wxPyDefaultSize,
259 int LCOUNT, wxString* LIST = NULL,
261 const wxValidator& validator = wxPyDefaultValidator,
262 char* name = "listBox");
264 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
266 void Append(const wxString& item);
267 // TODO: void Append(const wxString& item, char* clientData);
270 void Deselect(int n);
271 int FindString(const wxString& string);
272 // TODO: char* GetClientData(const int n);
275 // int GetSelections(int **selections);
277 PyObject* GetSelections() {
279 self->GetSelections(lst);
280 PyObject *tup = PyTuple_New(lst.GetCount());
281 for(int i=0; i<lst.GetCount(); i++) {
282 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
288 wxString GetString(int n);
289 wxString GetStringSelection();
291 bool Selected(const int n);
292 void Set(int LCOUNT, wxString* LIST);
293 // TODO: void SetClientData(const int n, char* data);
294 void SetFirstItem(int n);
295 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
296 void SetSelection(int n, bool select = TRUE);
297 void SetString(int n, const wxString& string);
298 void SetStringSelection(const wxString& string, bool select = TRUE);
302 //----------------------------------------------------------------------
304 class wxCheckListBox : public wxListBox {
306 wxCheckListBox(wxWindow *parent, wxWindowID id,
307 const wxPoint& pos = wxPyDefaultPosition,
308 const wxSize& size = wxPyDefaultSize,
310 wxString* LIST = NULL,
312 const wxValidator& validator = wxPyDefaultValidator,
313 char* name = "listBox");
315 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
317 bool IsChecked(int uiIndex);
318 void Check(int uiIndex, bool bCheck = TRUE);
323 //----------------------------------------------------------------------
325 class wxTextCtrl : public wxControl {
327 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
328 const wxPoint& pos = wxPyDefaultPosition,
329 const wxSize& size = wxPyDefaultSize,
331 const wxValidator& validator = wxPyDefaultValidator,
332 char* name = "text");
334 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
340 long GetInsertionPoint();
341 long GetLastPosition();
342 int GetLineLength(long lineNo);
343 wxString GetLineText(long lineNo);
344 int GetNumberOfLines();
347 bool LoadFile(const wxString& filename);
349 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
350 void Remove(long from, long to);
351 void Replace(long from, long to, const wxString& value);
352 bool SaveFile(const wxString& filename);
353 void SetEditable(bool editable);
354 void SetInsertionPoint(long pos);
355 void SetInsertionPointEnd();
356 void SetSelection(long from, long to);
357 void SetValue(const wxString& value);
358 void ShowPosition(long pos);
359 void WriteText(const wxString& text);
360 void AppendText(const wxString& text);
361 long XYToPosition(long x, long y);
368 void GetSelection(long* OUTPUT, long* OUTPUT);
372 //----------------------------------------------------------------------
374 class wxScrollBar : public wxControl {
376 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
377 const wxPoint& pos = wxPyDefaultPosition,
378 const wxSize& size = wxPyDefaultSize,
379 long style = wxSB_HORIZONTAL,
380 const wxValidator& validator = wxPyDefaultValidator,
381 char* name = "scrollBar");
383 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
387 int GetThumbPosition();
389 void SetThumbPosition(int viewStart);
390 void SetScrollbar(int position, int thumbSize,
391 int range, int pageSize,
392 bool refresh = TRUE);
395 //----------------------------------------------------------------------
397 class wxSpinButton : public wxControl {
399 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
400 const wxPoint& pos = wxPyDefaultPosition,
401 const wxSize& size = wxPyDefaultSize,
402 long style = wxSP_HORIZONTAL,
403 char* name = "spinButton");
408 void SetRange(int min, int max);
409 void SetValue(int value);
412 //----------------------------------------------------------------------
414 class wxStaticBitmap : public wxControl {
416 wxStaticBitmap(wxWindow* parent, wxWindowID id,
417 const wxBitmap& bitmap,
418 const wxPoint& pos = wxPyDefaultPosition,
419 const wxSize& size = wxPyDefaultSize,
421 char* name = "staticBitmap");
423 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
425 const wxBitmap& GetBitmap();
426 void SetBitmap(const wxBitmap& bitmap);
429 //----------------------------------------------------------------------
431 class wxRadioBox : public wxControl {
433 wxRadioBox(wxWindow* parent, wxWindowID id,
434 const wxString& label,
435 const wxPoint& point = wxPyDefaultPosition,
436 const wxSize& size = wxPyDefaultSize,
437 int LCOUNT = 0, wxString* LIST = NULL,
438 int majorDimension = 0,
439 long style = wxRA_HORIZONTAL,
440 const wxValidator& validator = wxPyDefaultValidator,
441 char* name = "radioBox");
443 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
445 void Enable(bool enable);
446 %name(EnableItem)void Enable(int n, bool enable);
447 int FindString(const wxString& string);
449 //*** wxString GetLabel();
450 //*** void SetLabel(const wxString& label);
452 %name(GetItemLabel)wxString GetLabel(int n);
454 wxString GetString(int n);
455 wxString GetStringSelection();
457 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
458 void SetSelection(int n);
459 void SetStringSelection(const wxString& string);
460 void Show(bool show);
461 %name(ShowItem)void Show(int item, bool show);
464 //----------------------------------------------------------------------
466 class wxRadioButton : public wxControl {
468 wxRadioButton(wxWindow* parent, wxWindowID id,
469 const wxString& label,
470 const wxPoint& pos = wxPyDefaultPosition,
471 const wxSize& size = wxPyDefaultSize,
473 const wxValidator& validator = wxPyDefaultValidator,
474 char* name = "radioButton");
476 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
479 void SetValue(bool value);
482 //----------------------------------------------------------------------
484 class wxSlider : public wxControl {
486 wxSlider(wxWindow* parent, wxWindowID id,
487 int value, int minValue, int maxValue,
488 const wxPoint& point = wxPyDefaultPosition,
489 const wxSize& size = wxPyDefaultSize,
490 long style = wxSL_HORIZONTAL,
491 const wxValidator& validator = wxPyDefaultValidator,
492 char* name = "slider");
494 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
504 int GetThumbLength();
507 void SetRange(int minValue, int maxValue);
508 void SetTickFreq(int n, int pos);
509 void SetLineSize(int lineSize);
510 void SetPageSize(int pageSize);
511 void SetSelection(int startPos, int endPos);
512 void SetThumbLength(int len);
513 void SetTick(int tickPos);
514 void SetValue(int value);
518 //----------------------------------------------------------------------
521 /////////////////////////////////////////////////////////////////////////////
524 // Revision 1.15 1999/06/22 17:45:18 RD
525 // wxPython 2.1b1: Very minor changes needed for wxGTK
527 // Revision 1.14 1999/06/22 07:03:02 RD
529 // wxPython 2.1b1 for wxMSW (wxGTK coming soon)
530 // Lots of changes, see the README.txt for details...
532 // Revision 1.13 1999/04/30 21:13:43 RD
534 // wxPython 2.0b9, first phase (win32)
535 // Added gobs of stuff, see wxPython/README.txt for details
537 // Revision 1.12 1999/04/30 03:29:18 RD
539 // wxPython 2.0b9, first phase (win32)
540 // Added gobs of stuff, see wxPython/README.txt for details
542 // Revision 1.11.4.1 1999/03/27 23:29:14 RD
545 // Python thread support
546 // various minor additions
547 // various minor fixes
549 // Revision 1.11 1999/02/25 07:08:30 RD
551 // wxPython version 2.0b5
553 // Revision 1.10 1998/12/17 17:52:19 RD
556 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
557 // versions are much closer now!
559 // Revision 1.9 1998/12/17 14:07:29 RR
561 // Removed minor differences between wxMSW and wxGTK
563 // Revision 1.8 1998/12/15 20:41:15 RD
564 // Changed the import semantics from "from wxPython import *" to "from
565 // wxPython.wx import *" This is for people who are worried about
566 // namespace pollution, they can use "from wxPython import wx" and then
567 // prefix all the wxPython identifiers with "wx."
569 // Added wxTaskbarIcon for wxMSW.
571 // Made the events work for wxGrid.
575 // Added wxMiniFrame for wxGTK, (untested.)
577 // Changed many of the args and return values that were pointers to gdi
578 // objects to references to reflect changes in the wxWindows API.
580 // Other assorted fixes and additions.
582 // Revision 1.7 1998/11/16 00:00:53 RD
583 // Generic treectrl for wxPython/GTK compiles...
585 // Revision 1.6 1998/11/15 23:03:43 RD
586 // Removing some ifdef's for wxGTK
588 // Revision 1.5 1998/10/07 07:34:32 RD
589 // Version 0.4.1 for wxGTK
591 // Revision 1.4 1998/10/02 06:40:35 RD
593 // Version 0.4 of wxPython for MSW.
595 // Revision 1.3 1998/08/18 19:48:14 RD
596 // more wxGTK compatibility things.
598 // It builds now but there are serious runtime problems...
600 // Revision 1.2 1998/08/15 07:36:28 RD
601 // - Moved the header in the .i files out of the code that gets put into
602 // the .cpp files. It caused CVS conflicts because of the RCS ID being
603 // different each time.
605 // - A few minor fixes.
607 // Revision 1.1 1998/08/09 08:25:49 RD