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/tglbtn.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 wxCheckBox : public wxControl {
132 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
133 const wxPoint& pos = wxDefaultPosition,
134 const wxSize& size = wxDefaultSize,
136 const wxValidator& val = wxDefaultValidator,
137 char* name = "checkBox");
139 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
142 void SetValue(const bool state);
145 //----------------------------------------------------------------------
147 class wxChoice : public wxControl {
149 wxChoice(wxWindow *parent, wxWindowID id,
150 const wxPoint& pos = wxDefaultPosition,
151 const wxSize& size = wxDefaultSize,
152 int LCOUNT=0, wxString* choices=NULL,
154 const wxValidator& validator = wxDefaultValidator,
155 char* name = "choice");
157 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
159 void Append(const wxString& item);
161 int FindString(const wxString& string);
164 wxString GetString(const int n);
165 wxString GetStringSelection();
167 void SetColumns(const int n = 1);
168 void SetSelection(const int n);
169 void SetStringSelection(const wxString& string);
172 //----------------------------------------------------------------------
174 class wxComboBox : public wxChoice {
176 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
177 const wxPoint& pos = wxDefaultPosition,
178 const wxSize& size = wxDefaultSize,
179 int LCOUNT=0, wxString* choices=NULL,
181 const wxValidator& validator = wxDefaultValidator,
182 char* name = "comboBox");
184 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
186 void Append(const wxString& item);
187 // TODO: void Append(const wxString& item, char* clientData);
192 // NotMember??: void Deselect(int n);
193 int FindString(const wxString& string);
194 // TODO: char* GetClientData(const int n);
195 long GetInsertionPoint();
196 long GetLastPosition();
198 wxString GetString(int n);
199 wxString GetStringSelection();
203 void Replace(long from, long to, const wxString& text);
204 void Remove(long from, long to);
205 // TODO: void SetClientData(const int n, char* data);
206 void SetInsertionPoint(long pos);
207 void SetInsertionPointEnd();
208 void SetSelection(int n);
209 %name(SetMark)void SetSelection(long from, long to);
210 void SetValue(const wxString& text);
213 //----------------------------------------------------------------------
215 class wxGauge : public wxControl {
217 wxGauge(wxWindow* parent, wxWindowID id, int range,
218 const wxPoint& pos = wxDefaultPosition,
219 const wxSize& size = wxDefaultSize,
220 long style = wxGA_HORIZONTAL,
221 const wxValidator& validator = wxDefaultValidator,
222 char* name = "gauge");
224 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
228 int GetShadowWidth();
230 void SetBezelFace(int width);
231 void SetRange(int range);
232 void SetShadowWidth(int width);
233 void SetValue(int pos);
236 //----------------------------------------------------------------------
238 class wxStaticBox : public wxControl {
240 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
241 const wxPoint& pos = wxDefaultPosition,
242 const wxSize& size = wxDefaultSize,
244 char* name = "staticBox");
248 //----------------------------------------------------------------------
251 class wxStaticLine : public wxControl {
253 wxStaticLine( wxWindow *parent, wxWindowID id,
254 const wxPoint &pos = wxDefaultPosition,
255 const wxSize &size = wxDefaultSize,
256 long style = wxLI_HORIZONTAL,
257 const char* name = "staticLine" );
261 //----------------------------------------------------------------------
263 class wxStaticText : public wxControl {
265 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
266 const wxPoint& pos = wxDefaultPosition,
267 const wxSize& size = wxDefaultSize,
269 char* name = "staticText");
271 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
274 void SetLabel(const wxString& label);
277 //----------------------------------------------------------------------
279 class wxListBox : public wxControl {
281 wxListBox(wxWindow* parent, wxWindowID id,
282 const wxPoint& pos = wxDefaultPosition,
283 const wxSize& size = wxDefaultSize,
284 int LCOUNT, wxString* choices = NULL,
286 const wxValidator& validator = wxDefaultValidator,
287 char* name = "listBox");
289 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
291 void Append(const wxString& item);
292 // TODO: void Append(const wxString& item, char* clientData);
295 void Deselect(int n);
296 int FindString(const wxString& string);
297 // TODO: char* GetClientData(const int n);
300 // int GetSelections(int **selections);
302 PyObject* GetSelections() {
304 self->GetSelections(lst);
305 PyObject *tup = PyTuple_New(lst.GetCount());
306 for(size_t i=0; i<lst.GetCount(); i++) {
307 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
313 void InsertItems(int LCOUNT, wxString* choices, int pos);
315 wxString GetString(int n);
316 wxString GetStringSelection();
318 bool Selected(const int n);
319 void Set(int LCOUNT, wxString* choices);
320 // TODO: void SetClientData(const int n, char* data);
321 void SetFirstItem(int n);
322 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
323 void SetSelection(int n, bool select = TRUE);
324 void SetString(int n, const wxString& string);
325 void SetStringSelection(const wxString& string, bool select = TRUE);
329 //----------------------------------------------------------------------
331 class wxCheckListBox : public wxListBox {
333 wxCheckListBox(wxWindow *parent, wxWindowID id,
334 const wxPoint& pos = wxDefaultPosition,
335 const wxSize& size = wxDefaultSize,
337 wxString* choices = NULL,
339 const wxValidator& validator = wxDefaultValidator,
340 char* name = "listBox");
342 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
344 bool IsChecked(int uiIndex);
345 void Check(int uiIndex, int bCheck = TRUE);
346 void InsertItems(int LCOUNT, wxString* choices, int pos);
351 //----------------------------------------------------------------------
353 class wxTextCtrl : public wxControl {
355 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
359 const wxValidator& validator = wxDefaultValidator,
360 char* name = "text");
362 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
368 long GetInsertionPoint();
369 long GetLastPosition();
370 int GetLineLength(long lineNo);
371 wxString GetLineText(long lineNo);
372 int GetNumberOfLines();
375 bool LoadFile(const wxString& filename);
377 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
378 void Remove(long from, long to);
379 void Replace(long from, long to, const wxString& value);
380 bool SaveFile(const wxString& filename);
381 void SetEditable(bool editable);
382 void SetInsertionPoint(long pos);
383 void SetInsertionPointEnd();
384 void SetSelection(long from, long to);
385 void SetValue(const wxString& value);
386 void ShowPosition(long pos);
387 void WriteText(const wxString& text);
388 void AppendText(const wxString& text);
389 long XYToPosition(long x, long y);
396 void GetSelection(long* OUTPUT, long* OUTPUT);
402 void write(const wxString& text) {
403 self->AppendText(text + '\n');
408 //----------------------------------------------------------------------
410 class wxScrollBar : public wxControl {
412 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
415 long style = wxSB_HORIZONTAL,
416 const wxValidator& validator = wxDefaultValidator,
417 char* name = "scrollBar");
419 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
423 int GetThumbPosition();
425 %name(GetThumbLength) int GetThumbSize(); // to match the docs
426 void SetThumbPosition(int viewStart);
427 void SetScrollbar(int position, int thumbSize,
428 int range, int pageSize,
429 bool refresh = TRUE);
432 //----------------------------------------------------------------------
434 class wxSpinButton : public wxControl {
436 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
439 long style = wxSP_HORIZONTAL,
440 char* name = "spinButton");
445 void SetRange(int min, int max);
446 void SetValue(int value);
449 //----------------------------------------------------------------------
451 class wxStaticBitmap : public wxControl {
453 wxStaticBitmap(wxWindow* parent, wxWindowID id,
454 const wxBitmap& bitmap,
455 const wxPoint& pos = wxDefaultPosition,
456 const wxSize& size = wxDefaultSize,
458 char* name = "staticBitmap");
460 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
462 const wxBitmap& GetBitmap();
463 void SetBitmap(const wxBitmap& bitmap);
464 void SetIcon(const wxIcon& icon);
467 //----------------------------------------------------------------------
469 class wxRadioBox : public wxControl {
471 wxRadioBox(wxWindow* parent, wxWindowID id,
472 const wxString& label,
473 const wxPoint& point = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
475 int LCOUNT = 0, wxString* choices = NULL,
476 int majorDimension = 0,
477 long style = wxRA_HORIZONTAL,
478 const wxValidator& validator = wxDefaultValidator,
479 char* name = "radioBox");
481 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
483 void Enable(bool enable);
484 %name(EnableItem)void Enable(int n, bool enable);
485 int FindString(const wxString& string);
487 //*** wxString GetLabel();
488 //*** void SetLabel(const wxString& label);
490 %name(GetItemLabel)wxString GetLabel(int n);
492 wxString GetString(int n);
493 wxString GetStringSelection();
495 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
496 void SetSelection(int n);
497 void SetStringSelection(const wxString& string);
498 void Show(bool show);
499 %name(ShowItem)void Show(int item, bool show);
502 //----------------------------------------------------------------------
504 class wxRadioButton : public wxControl {
506 wxRadioButton(wxWindow* parent, wxWindowID id,
507 const wxString& label,
508 const wxPoint& pos = wxDefaultPosition,
509 const wxSize& size = wxDefaultSize,
511 const wxValidator& validator = wxDefaultValidator,
512 char* name = "radioButton");
514 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
517 void SetValue(bool value);
520 //----------------------------------------------------------------------
522 class wxSlider : public wxControl {
524 wxSlider(wxWindow* parent, wxWindowID id,
525 int value, int minValue, int maxValue,
526 const wxPoint& point = wxDefaultPosition,
527 const wxSize& size = wxDefaultSize,
528 long style = wxSL_HORIZONTAL,
529 const wxValidator& validator = wxDefaultValidator,
530 char* name = "slider");
532 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
542 int GetThumbLength();
545 void SetRange(int minValue, int maxValue);
546 void SetTickFreq(int n, int pos);
547 void SetLineSize(int lineSize);
548 void SetPageSize(int pageSize);
549 void SetSelection(int startPos, int endPos);
550 void SetThumbLength(int len);
551 void SetTick(int tickPos);
552 void SetValue(int value);
556 //----------------------------------------------------------------------
558 class wxSpinCtrl : public wxSpinButton {
560 wxSpinCtrl(wxWindow *parent,
562 const char* value = "",
563 const wxPoint& pos = wxDefaultPosition,
564 const wxSize& size = wxDefaultSize,
565 long style = wxSP_ARROW_KEYS,
566 int min = 0, int max = 100, int initial = 0,
567 const char* name = "wxSpinCtrl");
573 void SetRange(int min, int max);
574 void SetValue(int value);
579 //----------------------------------------------------------------------
581 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
583 class wxToggleButton : public wxControl {
585 wxToggleButton(wxWindow *parent,
587 const wxString& label,
588 const wxPoint& pos = wxDefaultPosition,
589 const wxSize& size = wxDefaultSize,
591 const wxValidator& validator = wxDefaultValidator,
592 const char* name = "toggle");
594 void SetValue(bool value);
595 bool GetValue() const ;
596 void SetLabel(const wxString& label);
600 //----------------------------------------------------------------------
601 //----------------------------------------------------------------------
602 //----------------------------------------------------------------------