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>
21 //#include <wx/toggbutt.h>
25 #include <wx/checklst.h>
30 #include <wx/checklst.h>
35 //----------------------------------------------------------------------
38 %include my_typemaps.i
40 // Import some definitions of other classes, etc.
47 %pragma(python) code = "import wx"
49 //----------------------------------------------------------------------
52 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
56 wxValidator wxDefaultValidator;
59 //----------------------------------------------------------------------
61 class wxControl : public wxWindow {
66 void Command(wxCommandEvent& event);
69 void SetLabel(const wxString& label);
74 // class wxPyControl : public wxControl {
76 // wxPyControl(wxWindow *parent,
78 // const wxPoint& pos,
79 // const wxSize& size,
81 // const wxValidator& validator,
82 // const wxString& name)
84 // CreateControl(parent, id, pos, size, style, validator, name);
90 // class wxPyControl : public wxControl {
92 // wxPyControl(wxWindow* parent, wxWindowID id,
93 // const wxPoint& pos = wxPyDefaultPosition,
94 // const wxSize& size = wxPyDefaultSize,
96 // const wxValidator& validator = wxPyDefaultValidator,
97 // char* name = "control");
101 //----------------------------------------------------------------------
103 class wxButton : public wxControl {
105 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
106 const wxPoint& pos = wxPyDefaultPosition,
107 const wxSize& size = wxPyDefaultSize,
109 const wxValidator& validator = wxPyDefaultValidator,
110 char* name = "button");
112 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
119 wxSize wxButton_GetDefaultSize() {
120 return wxButton::GetDefaultSize();
124 //----------------------------------------------------------------------
126 class wxBitmapButton : public wxButton {
128 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
129 const wxPoint& pos = wxPyDefaultPosition,
130 const wxSize& size = wxPyDefaultSize,
131 long style = wxBU_AUTODRAW,
132 const wxValidator& validator = wxPyDefaultValidator,
133 char* name = "button");
135 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
137 wxBitmap& GetBitmapLabel();
138 wxBitmap& GetBitmapDisabled();
139 wxBitmap& GetBitmapFocus();
140 wxBitmap& GetBitmapSelected();
141 void SetBitmapDisabled(const wxBitmap& bitmap);
142 void SetBitmapFocus(const wxBitmap& bitmap);
143 void SetBitmapSelected(const wxBitmap& bitmap);
144 void SetBitmapLabel(const wxBitmap& bitmap);
148 //----------------------------------------------------------------------
150 // class wxToggleButton : public wxControl {
152 // wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label,
153 // const wxPoint& pos = wxPyDefaultPosition,
154 // const wxSize& size = wxPyDefaultSize, long style = 0,
155 // const wxValidator& validator = wxPyDefaultValidator,
156 // const char* name = "toggle");
157 // void SetValue(bool value);
158 // bool GetValue() const ;
159 // void SetLabel(const wxString& label);
162 // class wxBitmapToggleButton : public wxToggleButton {
164 // wxBitmapToggleButton(wxWindow *parent, wxWindowID id, const wxBitmap *label,
165 // const wxPoint& pos = wxPyDefaultPosition,
166 // const wxSize& size = wxPyDefaultSize, long style = 0,
167 // const wxValidator& validator = wxPyDefaultValidator,
168 // const char *name = "toggle");
169 // void SetLabel(const wxBitmap& bitmap);
173 //----------------------------------------------------------------------
175 class wxCheckBox : public wxControl {
177 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
178 const wxPoint& pos = wxPyDefaultPosition,
179 const wxSize& size = wxPyDefaultSize,
181 const wxValidator& val = wxPyDefaultValidator,
182 char* name = "checkBox");
184 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
187 void SetValue(const bool state);
190 //----------------------------------------------------------------------
192 class wxChoice : public wxControl {
194 wxChoice(wxWindow *parent, wxWindowID id,
195 const wxPoint& pos = wxPyDefaultPosition,
196 const wxSize& size = wxPyDefaultSize,
197 int LCOUNT=0, wxString* LIST=NULL,
199 const wxValidator& validator = wxPyDefaultValidator,
200 char* name = "choice");
202 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
204 void Append(const wxString& item);
206 int FindString(const wxString& string);
209 wxString GetString(const int n);
210 wxString GetStringSelection();
212 void SetColumns(const int n = 1);
213 void SetSelection(const int n);
214 void SetStringSelection(const wxString& string);
217 //----------------------------------------------------------------------
219 class wxComboBox : public wxChoice {
221 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
222 const wxPoint& pos = wxPyDefaultPosition,
223 const wxSize& size = wxPyDefaultSize,
224 int LCOUNT=0, wxString* LIST=NULL,
226 const wxValidator& validator = wxPyDefaultValidator,
227 char* name = "comboBox");
229 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
231 void Append(const wxString& item);
232 // TODO: void Append(const wxString& item, char* clientData);
237 // NotMember??: void Deselect(int n);
238 int FindString(const wxString& string);
239 // TODO: char* GetClientData(const int n);
240 long GetInsertionPoint();
241 long GetLastPosition();
243 wxString GetString(int n);
244 wxString GetStringSelection();
248 void Replace(long from, long to, const wxString& text);
249 void Remove(long from, long to);
250 // TODO: void SetClientData(const int n, char* data);
251 void SetInsertionPoint(long pos);
252 void SetInsertionPointEnd();
253 void SetSelection(int n);
254 %name(SetMark)void SetSelection(long from, long to);
255 void SetValue(const wxString& text);
258 //----------------------------------------------------------------------
260 class wxGauge : public wxControl {
262 wxGauge(wxWindow* parent, wxWindowID id, int range,
263 const wxPoint& pos = wxPyDefaultPosition,
264 const wxSize& size = wxPyDefaultSize,
265 long style = wxGA_HORIZONTAL,
266 const wxValidator& validator = wxPyDefaultValidator,
267 char* name = "gauge");
269 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
273 int GetShadowWidth();
275 void SetBezelFace(int width);
276 void SetRange(int range);
277 void SetShadowWidth(int width);
278 void SetValue(int pos);
281 //----------------------------------------------------------------------
283 class wxStaticBox : public wxControl {
285 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
286 const wxPoint& pos = wxPyDefaultPosition,
287 const wxSize& size = wxPyDefaultSize,
289 char* name = "staticBox");
293 //----------------------------------------------------------------------
296 class wxStaticLine : public wxControl {
298 wxStaticLine( wxWindow *parent, wxWindowID id,
299 const wxPoint &pos = wxPyDefaultPosition,
300 const wxSize &size = wxPyDefaultSize,
301 long style = wxLI_HORIZONTAL,
302 const char* name = "staticLine" );
306 //----------------------------------------------------------------------
308 class wxStaticText : public wxControl {
310 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
311 const wxPoint& pos = wxPyDefaultPosition,
312 const wxSize& size = wxPyDefaultSize,
314 char* name = "staticText");
316 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
319 void SetLabel(const wxString& label);
322 //----------------------------------------------------------------------
324 class wxListBox : public wxControl {
326 wxListBox(wxWindow* parent, wxWindowID id,
327 const wxPoint& pos = wxPyDefaultPosition,
328 const wxSize& size = wxPyDefaultSize,
329 int LCOUNT, wxString* LIST = NULL,
331 const wxValidator& validator = wxPyDefaultValidator,
332 char* name = "listBox");
334 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
336 void Append(const wxString& item);
337 // TODO: void Append(const wxString& item, char* clientData);
340 void Deselect(int n);
341 int FindString(const wxString& string);
342 // TODO: char* GetClientData(const int n);
345 // int GetSelections(int **selections);
347 PyObject* GetSelections() {
349 self->GetSelections(lst);
350 PyObject *tup = PyTuple_New(lst.GetCount());
351 for(int i=0; i<lst.GetCount(); i++) {
352 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
358 void InsertItems(int LCOUNT, wxString* LIST, int pos);
360 wxString GetString(int n);
361 wxString GetStringSelection();
363 bool Selected(const int n);
364 void Set(int LCOUNT, wxString* LIST);
365 // TODO: void SetClientData(const int n, char* data);
366 void SetFirstItem(int n);
367 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
368 void SetSelection(int n, bool select = TRUE);
369 void SetString(int n, const wxString& string);
370 void SetStringSelection(const wxString& string, bool select = TRUE);
374 //----------------------------------------------------------------------
376 class wxCheckListBox : public wxListBox {
378 wxCheckListBox(wxWindow *parent, wxWindowID id,
379 const wxPoint& pos = wxPyDefaultPosition,
380 const wxSize& size = wxPyDefaultSize,
382 wxString* LIST = NULL,
384 const wxValidator& validator = wxPyDefaultValidator,
385 char* name = "listBox");
387 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
389 bool IsChecked(int uiIndex);
390 void Check(int uiIndex, int bCheck = TRUE);
391 void InsertItems(int LCOUNT, wxString* LIST, int pos);
396 //----------------------------------------------------------------------
398 class wxTextCtrl : public wxControl {
400 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
401 const wxPoint& pos = wxPyDefaultPosition,
402 const wxSize& size = wxPyDefaultSize,
404 const wxValidator& validator = wxPyDefaultValidator,
405 char* name = "text");
407 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
413 long GetInsertionPoint();
414 long GetLastPosition();
415 int GetLineLength(long lineNo);
416 wxString GetLineText(long lineNo);
417 int GetNumberOfLines();
420 bool LoadFile(const wxString& filename);
422 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
423 void Remove(long from, long to);
424 void Replace(long from, long to, const wxString& value);
425 bool SaveFile(const wxString& filename);
426 void SetEditable(bool editable);
427 void SetInsertionPoint(long pos);
428 void SetInsertionPointEnd();
429 void SetSelection(long from, long to);
430 void SetValue(const wxString& value);
431 void ShowPosition(long pos);
432 void WriteText(const wxString& text);
433 void AppendText(const wxString& text);
434 long XYToPosition(long x, long y);
441 void GetSelection(long* OUTPUT, long* OUTPUT);
447 void write(const wxString& text) {
448 self->AppendText(text + '\n');
453 //----------------------------------------------------------------------
455 class wxScrollBar : public wxControl {
457 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
458 const wxPoint& pos = wxPyDefaultPosition,
459 const wxSize& size = wxPyDefaultSize,
460 long style = wxSB_HORIZONTAL,
461 const wxValidator& validator = wxPyDefaultValidator,
462 char* name = "scrollBar");
464 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
468 int GetThumbPosition();
470 void SetThumbPosition(int viewStart);
471 void SetScrollbar(int position, int thumbSize,
472 int range, int pageSize,
473 bool refresh = TRUE);
476 //----------------------------------------------------------------------
478 class wxSpinButton : public wxControl {
480 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
481 const wxPoint& pos = wxPyDefaultPosition,
482 const wxSize& size = wxPyDefaultSize,
483 long style = wxSP_HORIZONTAL,
484 char* name = "spinButton");
489 void SetRange(int min, int max);
490 void SetValue(int value);
493 //----------------------------------------------------------------------
495 class wxStaticBitmap : public wxControl {
497 wxStaticBitmap(wxWindow* parent, wxWindowID id,
498 const wxBitmap& bitmap,
499 const wxPoint& pos = wxPyDefaultPosition,
500 const wxSize& size = wxPyDefaultSize,
502 char* name = "staticBitmap");
504 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
506 const wxBitmap& GetBitmap();
507 void SetBitmap(const wxBitmap& bitmap);
508 void SetIcon(const wxIcon& icon);
511 //----------------------------------------------------------------------
513 class wxRadioBox : public wxControl {
515 wxRadioBox(wxWindow* parent, wxWindowID id,
516 const wxString& label,
517 const wxPoint& point = wxPyDefaultPosition,
518 const wxSize& size = wxPyDefaultSize,
519 int LCOUNT = 0, wxString* LIST = NULL,
520 int majorDimension = 0,
521 long style = wxRA_HORIZONTAL,
522 const wxValidator& validator = wxPyDefaultValidator,
523 char* name = "radioBox");
525 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
527 void Enable(bool enable);
528 %name(EnableItem)void Enable(int n, bool enable);
529 int FindString(const wxString& string);
531 //*** wxString GetLabel();
532 //*** void SetLabel(const wxString& label);
534 %name(GetItemLabel)wxString GetLabel(int n);
536 wxString GetString(int n);
537 wxString GetStringSelection();
539 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
540 void SetSelection(int n);
541 void SetStringSelection(const wxString& string);
542 void Show(bool show);
543 %name(ShowItem)void Show(int item, bool show);
546 //----------------------------------------------------------------------
548 class wxRadioButton : public wxControl {
550 wxRadioButton(wxWindow* parent, wxWindowID id,
551 const wxString& label,
552 const wxPoint& pos = wxPyDefaultPosition,
553 const wxSize& size = wxPyDefaultSize,
555 const wxValidator& validator = wxPyDefaultValidator,
556 char* name = "radioButton");
558 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
561 void SetValue(bool value);
564 //----------------------------------------------------------------------
566 class wxSlider : public wxControl {
568 wxSlider(wxWindow* parent, wxWindowID id,
569 int value, int minValue, int maxValue,
570 const wxPoint& point = wxPyDefaultPosition,
571 const wxSize& size = wxPyDefaultSize,
572 long style = wxSL_HORIZONTAL,
573 const wxValidator& validator = wxPyDefaultValidator,
574 char* name = "slider");
576 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
586 int GetThumbLength();
589 void SetRange(int minValue, int maxValue);
590 void SetTickFreq(int n, int pos);
591 void SetLineSize(int lineSize);
592 void SetPageSize(int pageSize);
593 void SetSelection(int startPos, int endPos);
594 void SetThumbLength(int len);
595 void SetTick(int tickPos);
596 void SetValue(int value);
600 //----------------------------------------------------------------------