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 {
63 wxControl(wxWindow *parent,
65 const wxPoint& pos=wxPyDefaultPosition,
66 const wxSize& size=wxPyDefaultSize,
68 const wxValidator& validator=wxPyDefaultValidator,
69 const char* name="control");
71 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
73 void Command(wxCommandEvent& event);
75 void SetLabel(const wxString& label);
79 //----------------------------------------------------------------------
81 class wxButton : public wxControl {
83 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
84 const wxPoint& pos = wxPyDefaultPosition,
85 const wxSize& size = wxPyDefaultSize,
87 const wxValidator& validator = wxPyDefaultValidator,
88 char* name = "button");
90 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
93 void SetBackgroundColour(const wxColour& colour);
94 void SetForegroundColour(const wxColour& colour);
99 wxSize wxButton_GetDefaultSize() {
100 return wxButton::GetDefaultSize();
104 //----------------------------------------------------------------------
106 class wxBitmapButton : public wxButton {
108 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
109 const wxPoint& pos = wxPyDefaultPosition,
110 const wxSize& size = wxPyDefaultSize,
111 long style = wxBU_AUTODRAW,
112 const wxValidator& validator = wxPyDefaultValidator,
113 char* name = "button");
115 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
117 wxBitmap& GetBitmapLabel();
118 wxBitmap& GetBitmapDisabled();
119 wxBitmap& GetBitmapFocus();
120 wxBitmap& GetBitmapSelected();
121 void SetBitmapDisabled(const wxBitmap& bitmap);
122 void SetBitmapFocus(const wxBitmap& bitmap);
123 void SetBitmapSelected(const wxBitmap& bitmap);
124 void SetBitmapLabel(const wxBitmap& bitmap);
128 //----------------------------------------------------------------------
130 // class wxToggleButton : public wxControl {
132 // wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label,
133 // const wxPoint& pos = wxPyDefaultPosition,
134 // const wxSize& size = wxPyDefaultSize, long style = 0,
135 // const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
146 // const wxSize& size = wxPyDefaultSize, long style = 0,
147 // const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
159 const wxSize& size = wxPyDefaultSize,
161 const wxValidator& val = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
176 const wxSize& size = wxPyDefaultSize,
177 int LCOUNT=0, wxString* choices=NULL,
179 const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
203 const wxSize& size = wxPyDefaultSize,
204 int LCOUNT=0, wxString* choices=NULL,
206 const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
244 const wxSize& size = wxPyDefaultSize,
245 long style = wxGA_HORIZONTAL,
246 const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
267 const wxSize& size = wxPyDefaultSize,
269 char* name = "staticBox");
273 //----------------------------------------------------------------------
276 class wxStaticLine : public wxControl {
278 wxStaticLine( wxWindow *parent, wxWindowID id,
279 const wxPoint &pos = wxPyDefaultPosition,
280 const wxSize &size = wxPyDefaultSize,
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 = wxPyDefaultPosition,
292 const wxSize& size = wxPyDefaultSize,
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 = wxPyDefaultPosition,
308 const wxSize& size = wxPyDefaultSize,
309 int LCOUNT, wxString* choices = NULL,
311 const wxValidator& validator = wxPyDefaultValidator,
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(int 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 = wxPyDefaultPosition,
360 const wxSize& size = wxPyDefaultSize,
362 wxString* choices = NULL,
364 const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
382 const wxSize& size = wxPyDefaultSize,
384 const wxValidator& validator = wxPyDefaultValidator,
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 = wxPyDefaultPosition,
439 const wxSize& size = wxPyDefaultSize,
440 long style = wxSB_HORIZONTAL,
441 const wxValidator& validator = wxPyDefaultValidator,
442 char* name = "scrollBar");
444 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
448 int GetThumbPosition();
450 void SetThumbPosition(int viewStart);
451 void SetScrollbar(int position, int thumbSize,
452 int range, int pageSize,
453 bool refresh = TRUE);
456 //----------------------------------------------------------------------
458 class wxSpinButton : public wxControl {
460 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
461 const wxPoint& pos = wxPyDefaultPosition,
462 const wxSize& size = wxPyDefaultSize,
463 long style = wxSP_HORIZONTAL,
464 char* name = "spinButton");
469 void SetRange(int min, int max);
470 void SetValue(int value);
473 //----------------------------------------------------------------------
475 class wxStaticBitmap : public wxControl {
477 wxStaticBitmap(wxWindow* parent, wxWindowID id,
478 const wxBitmap& bitmap,
479 const wxPoint& pos = wxPyDefaultPosition,
480 const wxSize& size = wxPyDefaultSize,
482 char* name = "staticBitmap");
484 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
486 const wxBitmap& GetBitmap();
487 void SetBitmap(const wxBitmap& bitmap);
488 void SetIcon(const wxIcon& icon);
491 //----------------------------------------------------------------------
493 class wxRadioBox : public wxControl {
495 wxRadioBox(wxWindow* parent, wxWindowID id,
496 const wxString& label,
497 const wxPoint& point = wxPyDefaultPosition,
498 const wxSize& size = wxPyDefaultSize,
499 int LCOUNT = 0, wxString* choices = NULL,
500 int majorDimension = 0,
501 long style = wxRA_HORIZONTAL,
502 const wxValidator& validator = wxPyDefaultValidator,
503 char* name = "radioBox");
505 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
507 void Enable(bool enable);
508 %name(EnableItem)void Enable(int n, bool enable);
509 int FindString(const wxString& string);
511 //*** wxString GetLabel();
512 //*** void SetLabel(const wxString& label);
514 %name(GetItemLabel)wxString GetLabel(int n);
516 wxString GetString(int n);
517 wxString GetStringSelection();
519 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
520 void SetSelection(int n);
521 void SetStringSelection(const wxString& string);
522 void Show(bool show);
523 %name(ShowItem)void Show(int item, bool show);
526 //----------------------------------------------------------------------
528 class wxRadioButton : public wxControl {
530 wxRadioButton(wxWindow* parent, wxWindowID id,
531 const wxString& label,
532 const wxPoint& pos = wxPyDefaultPosition,
533 const wxSize& size = wxPyDefaultSize,
535 const wxValidator& validator = wxPyDefaultValidator,
536 char* name = "radioButton");
538 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
541 void SetValue(bool value);
544 //----------------------------------------------------------------------
546 class wxSlider : public wxControl {
548 wxSlider(wxWindow* parent, wxWindowID id,
549 int value, int minValue, int maxValue,
550 const wxPoint& point = wxPyDefaultPosition,
551 const wxSize& size = wxPyDefaultSize,
552 long style = wxSL_HORIZONTAL,
553 const wxValidator& validator = wxPyDefaultValidator,
554 char* name = "slider");
556 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
566 int GetThumbLength();
569 void SetRange(int minValue, int maxValue);
570 void SetTickFreq(int n, int pos);
571 void SetLineSize(int lineSize);
572 void SetPageSize(int pageSize);
573 void SetSelection(int startPos, int endPos);
574 void SetThumbLength(int len);
575 void SetTick(int tickPos);
576 void SetValue(int value);
580 //----------------------------------------------------------------------