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/spinctrl.h>
20 #include <wx/dynarray.h>
21 #include <wx/statline.h>
22 //#include <wx/toggbutt.h>
26 #include <wx/checklst.h>
31 #include <wx/checklst.h>
36 //----------------------------------------------------------------------
39 %include my_typemaps.i
41 // Import some definitions of other classes, etc.
48 %pragma(python) code = "import wx"
50 //----------------------------------------------------------------------
53 wxValidator wxDefaultValidator;
56 //----------------------------------------------------------------------
58 class wxControl : public wxWindow {
60 wxControl(wxWindow *parent,
62 const wxPoint& pos=wxDefaultPosition,
63 const wxSize& size=wxDefaultSize,
65 const wxValidator& validator=wxDefaultValidator,
66 const char* name="control");
68 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
70 void Command(wxCommandEvent& event);
72 void SetLabel(const wxString& label);
76 //----------------------------------------------------------------------
78 class wxButton : public wxControl {
80 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
84 const wxValidator& validator = wxDefaultValidator,
85 char* name = "button");
87 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
90 void SetBackgroundColour(const wxColour& colour);
91 void SetForegroundColour(const wxColour& colour);
96 wxSize wxButton_GetDefaultSize() {
97 return wxButton::GetDefaultSize();
101 //----------------------------------------------------------------------
103 class wxBitmapButton : public wxButton {
105 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
106 const wxPoint& pos = wxDefaultPosition,
107 const wxSize& size = wxDefaultSize,
108 long style = wxBU_AUTODRAW,
109 const wxValidator& validator = wxDefaultValidator,
110 char* name = "button");
112 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
114 wxBitmap& GetBitmapLabel();
115 wxBitmap& GetBitmapDisabled();
116 wxBitmap& GetBitmapFocus();
117 wxBitmap& GetBitmapSelected();
118 void SetBitmapDisabled(const wxBitmap& bitmap);
119 void SetBitmapFocus(const wxBitmap& bitmap);
120 void SetBitmapSelected(const wxBitmap& bitmap);
121 void SetBitmapLabel(const wxBitmap& bitmap);
123 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
124 int GetMarginX() const { return m_marginX; }
125 int GetMarginY() const { return m_marginY; }
128 //----------------------------------------------------------------------
130 // class wxToggleButton : public wxControl {
132 // wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label,
133 // const wxPoint& pos = wxDefaultPosition,
134 // const wxSize& size = wxDefaultSize, long style = 0,
135 // const wxValidator& validator = wxDefaultValidator,
136 // const char* name = "toggle");
137 // void SetValue(bool value);
138 // bool GetValue() const ;
139 // void SetLabel(const wxString& label);
142 // class wxBitmapToggleButton : public wxToggleButton {
144 // wxBitmapToggleButton(wxWindow *parent, wxWindowID id, const wxBitmap *label,
145 // const wxPoint& pos = wxDefaultPosition,
146 // const wxSize& size = wxDefaultSize, long style = 0,
147 // const wxValidator& validator = wxDefaultValidator,
148 // const char *name = "toggle");
149 // void SetLabel(const wxBitmap& bitmap);
153 //----------------------------------------------------------------------
155 class wxCheckBox : public wxControl {
157 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
158 const wxPoint& pos = wxDefaultPosition,
159 const wxSize& size = wxDefaultSize,
161 const wxValidator& val = wxDefaultValidator,
162 char* name = "checkBox");
164 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
167 void SetValue(const bool state);
170 //----------------------------------------------------------------------
172 class wxChoice : public wxControl {
174 wxChoice(wxWindow *parent, wxWindowID id,
175 const wxPoint& pos = wxDefaultPosition,
176 const wxSize& size = wxDefaultSize,
177 int LCOUNT=0, wxString* choices=NULL,
179 const wxValidator& validator = wxDefaultValidator,
180 char* name = "choice");
182 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
184 void Append(const wxString& item);
186 int FindString(const wxString& string);
189 wxString GetString(const int n);
190 wxString GetStringSelection();
192 void SetColumns(const int n = 1);
193 void SetSelection(const int n);
194 void SetStringSelection(const wxString& string);
197 //----------------------------------------------------------------------
199 class wxComboBox : public wxChoice {
201 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize,
204 int LCOUNT=0, wxString* choices=NULL,
206 const wxValidator& validator = wxDefaultValidator,
207 char* name = "comboBox");
209 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
211 void Append(const wxString& item);
212 // TODO: void Append(const wxString& item, char* clientData);
217 // NotMember??: void Deselect(int n);
218 int FindString(const wxString& string);
219 // TODO: char* GetClientData(const int n);
220 long GetInsertionPoint();
221 long GetLastPosition();
223 wxString GetString(int n);
224 wxString GetStringSelection();
228 void Replace(long from, long to, const wxString& text);
229 void Remove(long from, long to);
230 // TODO: void SetClientData(const int n, char* data);
231 void SetInsertionPoint(long pos);
232 void SetInsertionPointEnd();
233 void SetSelection(int n);
234 %name(SetMark)void SetSelection(long from, long to);
235 void SetValue(const wxString& text);
238 //----------------------------------------------------------------------
240 class wxGauge : public wxControl {
242 wxGauge(wxWindow* parent, wxWindowID id, int range,
243 const wxPoint& pos = wxDefaultPosition,
244 const wxSize& size = wxDefaultSize,
245 long style = wxGA_HORIZONTAL,
246 const wxValidator& validator = wxDefaultValidator,
247 char* name = "gauge");
249 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
253 int GetShadowWidth();
255 void SetBezelFace(int width);
256 void SetRange(int range);
257 void SetShadowWidth(int width);
258 void SetValue(int pos);
261 //----------------------------------------------------------------------
263 class wxStaticBox : public wxControl {
265 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
266 const wxPoint& pos = wxDefaultPosition,
267 const wxSize& size = wxDefaultSize,
269 char* name = "staticBox");
273 //----------------------------------------------------------------------
276 class wxStaticLine : public wxControl {
278 wxStaticLine( wxWindow *parent, wxWindowID id,
279 const wxPoint &pos = wxDefaultPosition,
280 const wxSize &size = wxDefaultSize,
281 long style = wxLI_HORIZONTAL,
282 const char* name = "staticLine" );
286 //----------------------------------------------------------------------
288 class wxStaticText : public wxControl {
290 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
291 const wxPoint& pos = wxDefaultPosition,
292 const wxSize& size = wxDefaultSize,
294 char* name = "staticText");
296 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
299 void SetLabel(const wxString& label);
302 //----------------------------------------------------------------------
304 class wxListBox : public wxControl {
306 wxListBox(wxWindow* parent, wxWindowID id,
307 const wxPoint& pos = wxDefaultPosition,
308 const wxSize& size = wxDefaultSize,
309 int LCOUNT, wxString* choices = NULL,
311 const wxValidator& validator = wxDefaultValidator,
312 char* name = "listBox");
314 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
316 void Append(const wxString& item);
317 // TODO: void Append(const wxString& item, char* clientData);
320 void Deselect(int n);
321 int FindString(const wxString& string);
322 // TODO: char* GetClientData(const int n);
325 // int GetSelections(int **selections);
327 PyObject* GetSelections() {
329 self->GetSelections(lst);
330 PyObject *tup = PyTuple_New(lst.GetCount());
331 for(size_t i=0; i<lst.GetCount(); i++) {
332 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
338 void InsertItems(int LCOUNT, wxString* choices, int pos);
340 wxString GetString(int n);
341 wxString GetStringSelection();
343 bool Selected(const int n);
344 void Set(int LCOUNT, wxString* choices);
345 // TODO: void SetClientData(const int n, char* data);
346 void SetFirstItem(int n);
347 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
348 void SetSelection(int n, bool select = TRUE);
349 void SetString(int n, const wxString& string);
350 void SetStringSelection(const wxString& string, bool select = TRUE);
354 //----------------------------------------------------------------------
356 class wxCheckListBox : public wxListBox {
358 wxCheckListBox(wxWindow *parent, wxWindowID id,
359 const wxPoint& pos = wxDefaultPosition,
360 const wxSize& size = wxDefaultSize,
362 wxString* choices = NULL,
364 const wxValidator& validator = wxDefaultValidator,
365 char* name = "listBox");
367 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
369 bool IsChecked(int uiIndex);
370 void Check(int uiIndex, int bCheck = TRUE);
371 void InsertItems(int LCOUNT, wxString* choices, int pos);
376 //----------------------------------------------------------------------
378 class wxTextCtrl : public wxControl {
380 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
381 const wxPoint& pos = wxDefaultPosition,
382 const wxSize& size = wxDefaultSize,
384 const wxValidator& validator = wxDefaultValidator,
385 char* name = "text");
387 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
393 long GetInsertionPoint();
394 long GetLastPosition();
395 int GetLineLength(long lineNo);
396 wxString GetLineText(long lineNo);
397 int GetNumberOfLines();
400 bool LoadFile(const wxString& filename);
402 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
403 void Remove(long from, long to);
404 void Replace(long from, long to, const wxString& value);
405 bool SaveFile(const wxString& filename);
406 void SetEditable(bool editable);
407 void SetInsertionPoint(long pos);
408 void SetInsertionPointEnd();
409 void SetSelection(long from, long to);
410 void SetValue(const wxString& value);
411 void ShowPosition(long pos);
412 void WriteText(const wxString& text);
413 void AppendText(const wxString& text);
414 long XYToPosition(long x, long y);
421 void GetSelection(long* OUTPUT, long* OUTPUT);
427 void write(const wxString& text) {
428 self->AppendText(text + '\n');
433 //----------------------------------------------------------------------
435 class wxScrollBar : public wxControl {
437 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
438 const wxPoint& pos = wxDefaultPosition,
439 const wxSize& size = wxDefaultSize,
440 long style = wxSB_HORIZONTAL,
441 const wxValidator& validator = wxDefaultValidator,
442 char* name = "scrollBar");
444 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
448 int GetThumbPosition();
450 %name(GetThumbLength) int GetThumbSize(); // to match the docs
451 void SetThumbPosition(int viewStart);
452 void SetScrollbar(int position, int thumbSize,
453 int range, int pageSize,
454 bool refresh = TRUE);
457 //----------------------------------------------------------------------
459 class wxSpinButton : public wxControl {
461 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
462 const wxPoint& pos = wxDefaultPosition,
463 const wxSize& size = wxDefaultSize,
464 long style = wxSP_HORIZONTAL,
465 char* name = "spinButton");
470 void SetRange(int min, int max);
471 void SetValue(int value);
474 //----------------------------------------------------------------------
476 class wxStaticBitmap : public wxControl {
478 wxStaticBitmap(wxWindow* parent, wxWindowID id,
479 const wxBitmap& bitmap,
480 const wxPoint& pos = wxDefaultPosition,
481 const wxSize& size = wxDefaultSize,
483 char* name = "staticBitmap");
485 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
487 const wxBitmap& GetBitmap();
488 void SetBitmap(const wxBitmap& bitmap);
489 void SetIcon(const wxIcon& icon);
492 //----------------------------------------------------------------------
494 class wxRadioBox : public wxControl {
496 wxRadioBox(wxWindow* parent, wxWindowID id,
497 const wxString& label,
498 const wxPoint& point = wxDefaultPosition,
499 const wxSize& size = wxDefaultSize,
500 int LCOUNT = 0, wxString* choices = NULL,
501 int majorDimension = 0,
502 long style = wxRA_HORIZONTAL,
503 const wxValidator& validator = wxDefaultValidator,
504 char* name = "radioBox");
506 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
508 void Enable(bool enable);
509 %name(EnableItem)void Enable(int n, bool enable);
510 int FindString(const wxString& string);
512 //*** wxString GetLabel();
513 //*** void SetLabel(const wxString& label);
515 %name(GetItemLabel)wxString GetLabel(int n);
517 wxString GetString(int n);
518 wxString GetStringSelection();
520 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
521 void SetSelection(int n);
522 void SetStringSelection(const wxString& string);
523 void Show(bool show);
524 %name(ShowItem)void Show(int item, bool show);
527 //----------------------------------------------------------------------
529 class wxRadioButton : public wxControl {
531 wxRadioButton(wxWindow* parent, wxWindowID id,
532 const wxString& label,
533 const wxPoint& pos = wxDefaultPosition,
534 const wxSize& size = wxDefaultSize,
536 const wxValidator& validator = wxDefaultValidator,
537 char* name = "radioButton");
539 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
542 void SetValue(bool value);
545 //----------------------------------------------------------------------
547 class wxSlider : public wxControl {
549 wxSlider(wxWindow* parent, wxWindowID id,
550 int value, int minValue, int maxValue,
551 const wxPoint& point = wxDefaultPosition,
552 const wxSize& size = wxDefaultSize,
553 long style = wxSL_HORIZONTAL,
554 const wxValidator& validator = wxDefaultValidator,
555 char* name = "slider");
557 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
567 int GetThumbLength();
570 void SetRange(int minValue, int maxValue);
571 void SetTickFreq(int n, int pos);
572 void SetLineSize(int lineSize);
573 void SetPageSize(int pageSize);
574 void SetSelection(int startPos, int endPos);
575 void SetThumbLength(int len);
576 void SetTick(int tickPos);
577 void SetValue(int value);
581 //----------------------------------------------------------------------
583 class wxSpinCtrl : public wxSpinButton {
585 wxSpinCtrl(wxWindow *parent,
587 const char* value = "",
588 const wxPoint& pos = wxDefaultPosition,
589 const wxSize& size = wxDefaultSize,
590 long style = wxSP_ARROW_KEYS,
591 int min = 0, int max = 100, int initial = 0,
592 const char* name = "wxSpinCtrl");
598 void SetRange(int min, int max);
599 void SetValue(int value);
604 //----------------------------------------------------------------------