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>
20 #include <wx/statline.h>
24 #include <wx/checklst.h>
29 #include <wx/checklst.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
55 wxValidator wxDefaultValidator;
58 //----------------------------------------------------------------------
60 class wxControl : public wxWindow {
63 void Command(wxCommandEvent& event);
66 void SetLabel(const wxString& label);
69 //----------------------------------------------------------------------
71 class wxButton : public wxControl {
73 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
74 const wxPoint& pos = wxPyDefaultPosition,
75 const wxSize& size = wxPyDefaultSize,
77 const wxValidator& validator = wxPyDefaultValidator,
78 char* name = "button");
80 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
85 //----------------------------------------------------------------------
87 class wxBitmapButton : public wxButton {
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");
96 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
98 wxBitmap& GetBitmapLabel();
99 wxBitmap& GetBitmapDisabled();
100 wxBitmap& GetBitmapFocus();
101 wxBitmap& GetBitmapSelected();
102 void SetBitmapDisabled(const wxBitmap& bitmap);
103 void SetBitmapFocus(const wxBitmap& bitmap);
104 void SetBitmapSelected(const wxBitmap& bitmap);
105 void SetBitmapLabel(const wxBitmap& bitmap);
109 //----------------------------------------------------------------------
111 class wxCheckBox : public wxControl {
113 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
114 const wxPoint& pos = wxPyDefaultPosition,
115 const wxSize& size = wxPyDefaultSize,
117 const wxValidator& val = wxPyDefaultValidator,
118 char* name = "checkBox");
120 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
123 void SetValue(const bool state);
126 //----------------------------------------------------------------------
128 class wxChoice : public wxControl {
130 wxChoice(wxWindow *parent, wxWindowID id,
131 const wxPoint& pos = wxPyDefaultPosition,
132 const wxSize& size = wxPyDefaultSize,
133 int LCOUNT=0, wxString* LIST=NULL,
135 const wxValidator& validator = wxPyDefaultValidator,
136 char* name = "choice");
138 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
140 void Append(const wxString& item);
142 int FindString(const wxString& string);
145 wxString GetString(const int n);
146 wxString GetStringSelection();
148 void SetColumns(const int n = 1);
149 void SetSelection(const int n);
150 void SetStringSelection(const wxString& string);
153 //----------------------------------------------------------------------
155 class wxComboBox : public wxChoice {
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,
162 const wxValidator& validator = wxPyDefaultValidator,
163 char* name = "comboBox");
165 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
167 void Append(const wxString& item);
168 // TODO: void Append(const wxString& item, char* clientData);
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();
179 wxString GetString(int n);
180 wxString GetStringSelection();
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();
189 void SetSelection(int n);
190 %name(SetMark)void SetSelection(long from, long to);
191 void SetValue(const wxString& text);
194 //----------------------------------------------------------------------
196 class wxGauge : public wxControl {
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");
205 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
209 int GetShadowWidth();
211 void SetBezelFace(int width);
212 void SetRange(int range);
213 void SetShadowWidth(int width);
214 void SetValue(int pos);
217 //----------------------------------------------------------------------
219 class wxStaticBox : public wxControl {
221 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
222 const wxPoint& pos = wxPyDefaultPosition,
223 const wxSize& size = wxPyDefaultSize,
225 char* name = "staticBox");
229 //----------------------------------------------------------------------
232 class wxStaticLine : public wxControl {
234 wxStaticLine( wxWindow *parent, wxWindowID id,
235 const wxPoint &pos = wxPyDefaultPosition,
236 const wxSize &size = wxPyDefaultSize,
237 long style = wxLI_HORIZONTAL,
238 const char* name = "staticLine" );
242 //----------------------------------------------------------------------
244 class wxStaticText : public wxControl {
246 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
247 const wxPoint& pos = wxPyDefaultPosition,
248 const wxSize& size = wxPyDefaultSize,
250 char* name = "staticText");
252 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
255 void SetLabel(const wxString& label);
258 //----------------------------------------------------------------------
260 class wxListBox : public wxControl {
262 wxListBox(wxWindow* parent, wxWindowID id,
263 const wxPoint& pos = wxPyDefaultPosition,
264 const wxSize& size = wxPyDefaultSize,
265 int LCOUNT, wxString* LIST = NULL,
267 const wxValidator& validator = wxPyDefaultValidator,
268 char* name = "listBox");
270 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
272 void Append(const wxString& item);
273 // TODO: void Append(const wxString& item, char* clientData);
276 void Deselect(int n);
277 int FindString(const wxString& string);
278 // TODO: char* GetClientData(const int n);
281 // int GetSelections(int **selections);
283 PyObject* GetSelections() {
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]));
294 void InsertItems(int LCOUNT, wxString* LIST, int pos);
296 wxString GetString(int n);
297 wxString GetStringSelection();
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);
310 //----------------------------------------------------------------------
312 class wxCheckListBox : public wxListBox {
314 wxCheckListBox(wxWindow *parent, wxWindowID id,
315 const wxPoint& pos = wxPyDefaultPosition,
316 const wxSize& size = wxPyDefaultSize,
318 wxString* LIST = NULL,
320 const wxValidator& validator = wxPyDefaultValidator,
321 char* name = "listBox");
323 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
325 bool IsChecked(int uiIndex);
326 void Check(int uiIndex, int bCheck = TRUE);
327 void InsertItems(int LCOUNT, wxString* LIST, int pos);
332 //----------------------------------------------------------------------
334 class wxTextCtrl : public wxControl {
336 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
337 const wxPoint& pos = wxPyDefaultPosition,
338 const wxSize& size = wxPyDefaultSize,
340 const wxValidator& validator = wxPyDefaultValidator,
341 char* name = "text");
343 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
349 long GetInsertionPoint();
350 long GetLastPosition();
351 int GetLineLength(long lineNo);
352 wxString GetLineText(long lineNo);
353 int GetNumberOfLines();
356 bool LoadFile(const wxString& filename);
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);
369 void AppendText(const wxString& text);
370 long XYToPosition(long x, long y);
377 void GetSelection(long* OUTPUT, long* OUTPUT);
383 void write(const wxString& text) {
384 self->AppendText(text + '\n');
389 //----------------------------------------------------------------------
391 class wxScrollBar : public wxControl {
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");
400 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
404 int GetThumbPosition();
406 void SetThumbPosition(int viewStart);
407 void SetScrollbar(int position, int thumbSize,
408 int range, int pageSize,
409 bool refresh = TRUE);
412 //----------------------------------------------------------------------
414 class wxSpinButton : public wxControl {
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");
425 void SetRange(int min, int max);
426 void SetValue(int value);
429 //----------------------------------------------------------------------
431 class wxStaticBitmap : public wxControl {
433 wxStaticBitmap(wxWindow* parent, wxWindowID id,
434 const wxBitmap& bitmap,
435 const wxPoint& pos = wxPyDefaultPosition,
436 const wxSize& size = wxPyDefaultSize,
438 char* name = "staticBitmap");
440 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
442 const wxBitmap& GetBitmap();
443 void SetBitmap(const wxBitmap& bitmap);
444 void SetIcon(const wxIcon& icon);
447 //----------------------------------------------------------------------
449 class wxRadioBox : public wxControl {
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");
461 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
463 void Enable(bool enable);
464 %name(EnableItem)void Enable(int n, bool enable);
465 int FindString(const wxString& string);
467 //*** wxString GetLabel();
468 //*** void SetLabel(const wxString& label);
470 %name(GetItemLabel)wxString GetLabel(int n);
472 wxString GetString(int n);
473 wxString GetStringSelection();
475 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
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);
482 //----------------------------------------------------------------------
484 class wxRadioButton : public wxControl {
486 wxRadioButton(wxWindow* parent, wxWindowID id,
487 const wxString& label,
488 const wxPoint& pos = wxPyDefaultPosition,
489 const wxSize& size = wxPyDefaultSize,
491 const wxValidator& validator = wxPyDefaultValidator,
492 char* name = "radioButton");
494 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
497 void SetValue(bool value);
500 //----------------------------------------------------------------------
502 class wxSlider : public wxControl {
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");
512 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
522 int GetThumbLength();
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);
536 //----------------------------------------------------------------------