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 //----------------------------------------------------------------------
358 wxTextAttr(const wxColour& colText = wxNullColour,
359 const wxColour& colBack = wxNullColour,
360 const wxFont& font = wxNullFont);
364 void SetTextColour(const wxColour& colText);
365 void SetBackgroundColour(const wxColour& colBack);
366 void SetFont(const wxFont& font);
369 bool HasTextColour() const;
370 bool HasBackgroundColour() const;
371 bool HasFont() const;
373 const wxColour& GetTextColour() const;
374 const wxColour& GetBackgroundColour() const;
375 const wxFont& GetFont() const;
380 class wxTextCtrl : public wxControl {
382 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
383 const wxPoint& pos = wxDefaultPosition,
384 const wxSize& size = wxDefaultSize,
386 const wxValidator& validator = wxDefaultValidator,
387 char* name = "text");
389 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
395 long GetInsertionPoint();
396 long GetLastPosition();
397 int GetLineLength(long lineNo);
398 wxString GetLineText(long lineNo);
399 int GetNumberOfLines();
402 bool LoadFile(const wxString& filename);
404 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
405 void Remove(long from, long to);
406 void Replace(long from, long to, const wxString& value);
407 bool SaveFile(const wxString& filename);
408 void SetEditable(bool editable);
409 void SetInsertionPoint(long pos);
410 void SetInsertionPointEnd();
411 void SetSelection(long from, long to);
412 void SetValue(const wxString& value);
413 void ShowPosition(long pos);
414 void WriteText(const wxString& text);
415 void AppendText(const wxString& text);
416 long XYToPosition(long x, long y);
423 void GetSelection(long* OUTPUT, long* OUTPUT);
428 bool SetStyle(long start, long end, const wxTextAttr& style);
429 bool SetDefaultStyle(const wxTextAttr& style);
430 const wxTextAttr& GetDefaultStyle() const;
433 void write(const wxString& text) {
434 self->AppendText(text);
439 //----------------------------------------------------------------------
441 class wxScrollBar : public wxControl {
443 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
444 const wxPoint& pos = wxDefaultPosition,
445 const wxSize& size = wxDefaultSize,
446 long style = wxSB_HORIZONTAL,
447 const wxValidator& validator = wxDefaultValidator,
448 char* name = "scrollBar");
450 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
454 int GetThumbPosition();
456 %name(GetThumbLength) int GetThumbSize(); // to match the docs
457 void SetThumbPosition(int viewStart);
458 void SetScrollbar(int position, int thumbSize,
459 int range, int pageSize,
460 bool refresh = TRUE);
463 //----------------------------------------------------------------------
465 class wxSpinButton : public wxControl {
467 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
468 const wxPoint& pos = wxDefaultPosition,
469 const wxSize& size = wxDefaultSize,
470 long style = wxSP_HORIZONTAL,
471 char* name = "spinButton");
476 void SetRange(int min, int max);
477 void SetValue(int value);
480 //----------------------------------------------------------------------
482 class wxStaticBitmap : public wxControl {
484 wxStaticBitmap(wxWindow* parent, wxWindowID id,
485 const wxBitmap& bitmap,
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
489 char* name = "staticBitmap");
491 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
493 const wxBitmap& GetBitmap();
494 void SetBitmap(const wxBitmap& bitmap);
495 void SetIcon(const wxIcon& icon);
498 //----------------------------------------------------------------------
500 class wxRadioBox : public wxControl {
502 wxRadioBox(wxWindow* parent, wxWindowID id,
503 const wxString& label,
504 const wxPoint& point = wxDefaultPosition,
505 const wxSize& size = wxDefaultSize,
506 int LCOUNT = 0, wxString* choices = NULL,
507 int majorDimension = 0,
508 long style = wxRA_HORIZONTAL,
509 const wxValidator& validator = wxDefaultValidator,
510 char* name = "radioBox");
512 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
514 void Enable(bool enable);
515 %name(EnableItem)void Enable(int n, bool enable);
516 int FindString(const wxString& string);
518 //*** wxString GetLabel();
519 //*** void SetLabel(const wxString& label);
521 %name(GetItemLabel)wxString GetLabel(int n);
523 wxString GetString(int n);
524 wxString GetStringSelection();
526 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
527 void SetSelection(int n);
528 void SetStringSelection(const wxString& string);
529 void Show(bool show);
530 %name(ShowItem)void Show(int item, bool show);
533 //----------------------------------------------------------------------
535 class wxRadioButton : public wxControl {
537 wxRadioButton(wxWindow* parent, wxWindowID id,
538 const wxString& label,
539 const wxPoint& pos = wxDefaultPosition,
540 const wxSize& size = wxDefaultSize,
542 const wxValidator& validator = wxDefaultValidator,
543 char* name = "radioButton");
545 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
548 void SetValue(bool value);
551 //----------------------------------------------------------------------
553 class wxSlider : public wxControl {
555 wxSlider(wxWindow* parent, wxWindowID id,
556 int value, int minValue, int maxValue,
557 const wxPoint& point = wxDefaultPosition,
558 const wxSize& size = wxDefaultSize,
559 long style = wxSL_HORIZONTAL,
560 const wxValidator& validator = wxDefaultValidator,
561 char* name = "slider");
563 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
573 int GetThumbLength();
576 void SetRange(int minValue, int maxValue);
577 void SetTickFreq(int n, int pos);
578 void SetLineSize(int lineSize);
579 void SetPageSize(int pageSize);
580 void SetSelection(int startPos, int endPos);
581 void SetThumbLength(int len);
582 void SetTick(int tickPos);
583 void SetValue(int value);
587 //----------------------------------------------------------------------
589 class wxSpinCtrl : public wxSpinButton {
591 wxSpinCtrl(wxWindow *parent,
593 const char* value = "",
594 const wxPoint& pos = wxDefaultPosition,
595 const wxSize& size = wxDefaultSize,
596 long style = wxSP_ARROW_KEYS,
597 int min = 0, int max = 100, int initial = 0,
598 const char* name = "wxSpinCtrl");
604 void SetRange(int min, int max);
605 void SetValue(int value);
610 //----------------------------------------------------------------------
612 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
614 class wxToggleButton : public wxControl {
616 wxToggleButton(wxWindow *parent,
618 const wxString& label,
619 const wxPoint& pos = wxDefaultPosition,
620 const wxSize& size = wxDefaultSize,
622 const wxValidator& validator = wxDefaultValidator,
623 const char* name = "toggle");
625 void SetValue(bool value);
626 bool GetValue() const ;
627 void SetLabel(const wxString& label);
631 //----------------------------------------------------------------------
632 //----------------------------------------------------------------------
633 //----------------------------------------------------------------------