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);
162 int FindString(const wxString& string);
165 wxString GetString(const int n);
166 wxString GetStringSelection();
168 void SetColumns(const int n = 1);
169 void SetSelection(const int n);
170 void SetStringSelection(const wxString& string);
171 void SetString(int n, const wxString& s);
173 %pragma(python) addtoclass = "
175 Select = SetSelection
180 //----------------------------------------------------------------------
182 class wxComboBox : public wxChoice {
184 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
185 const wxPoint& pos = wxDefaultPosition,
186 const wxSize& size = wxDefaultSize,
187 int LCOUNT=0, wxString* choices=NULL,
189 const wxValidator& validator = wxDefaultValidator,
190 char* name = "comboBox");
192 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
194 void Append(const wxString& item);
195 // TODO: void Append(const wxString& item, char* clientData);
200 // NotMember??: void Deselect(int n);
201 int FindString(const wxString& string);
202 // TODO: char* GetClientData(const int n);
203 long GetInsertionPoint();
204 long GetLastPosition();
206 wxString GetString(int n);
207 wxString GetStringSelection();
210 void Replace(long from, long to, const wxString& text);
211 void Remove(long from, long to);
212 // TODO: void SetClientData(const int n, char* data);
213 void SetInsertionPoint(long pos);
214 void SetInsertionPointEnd();
215 void SetSelection(int n);
216 %name(SetMark)void SetSelection(long from, long to);
217 void SetValue(const wxString& text);
218 void SetEditable(bool editable);
221 //----------------------------------------------------------------------
223 class wxGauge : public wxControl {
225 wxGauge(wxWindow* parent, wxWindowID id, int range,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize,
228 long style = wxGA_HORIZONTAL,
229 const wxValidator& validator = wxDefaultValidator,
230 char* name = "gauge");
232 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
236 int GetShadowWidth();
238 void SetBezelFace(int width);
239 void SetRange(int range);
240 void SetShadowWidth(int width);
241 void SetValue(int pos);
244 //----------------------------------------------------------------------
246 class wxStaticBox : public wxControl {
248 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
249 const wxPoint& pos = wxDefaultPosition,
250 const wxSize& size = wxDefaultSize,
252 char* name = "staticBox");
256 //----------------------------------------------------------------------
259 class wxStaticLine : public wxControl {
261 wxStaticLine( wxWindow *parent, wxWindowID id,
262 const wxPoint &pos = wxDefaultPosition,
263 const wxSize &size = wxDefaultSize,
264 long style = wxLI_HORIZONTAL,
265 const char* name = "staticLine" );
269 //----------------------------------------------------------------------
271 class wxStaticText : public wxControl {
273 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
274 const wxPoint& pos = wxDefaultPosition,
275 const wxSize& size = wxDefaultSize,
277 char* name = "staticText");
279 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
282 void SetLabel(const wxString& label);
285 //----------------------------------------------------------------------
287 class wxListBox : public wxControl {
289 wxListBox(wxWindow* parent, wxWindowID id,
290 const wxPoint& pos = wxDefaultPosition,
291 const wxSize& size = wxDefaultSize,
292 int LCOUNT, wxString* choices = NULL,
294 const wxValidator& validator = wxDefaultValidator,
295 char* name = "listBox");
297 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
299 void Append(const wxString& item);
300 // TODO: void Append(const wxString& item, char* clientData);
303 void Deselect(int n);
304 int FindString(const wxString& string);
305 // TODO: char* GetClientData(const int n);
308 // int GetSelections(int **selections);
310 PyObject* GetSelections() {
312 self->GetSelections(lst);
313 PyObject *tup = PyTuple_New(lst.GetCount());
314 for(size_t i=0; i<lst.GetCount(); i++) {
315 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
321 void InsertItems(int LCOUNT, wxString* choices, int pos);
323 wxString GetString(int n);
324 wxString GetStringSelection();
326 %pragma(python) addtoclass = "Number = GetCount"
327 bool IsSelected(const int n);
328 bool Selected(const int n);
329 void Set(int LCOUNT, wxString* choices);
330 // TODO: void SetClientData(const int n, char* data);
331 void SetFirstItem(int n);
332 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
333 void SetSelection(int n, bool select = TRUE);
334 void SetString(int n, const wxString& string);
335 void SetStringSelection(const wxString& string, bool select = TRUE);
339 //----------------------------------------------------------------------
341 class wxCheckListBox : public wxListBox {
343 wxCheckListBox(wxWindow *parent, wxWindowID id,
344 const wxPoint& pos = wxDefaultPosition,
345 const wxSize& size = wxDefaultSize,
347 wxString* choices = NULL,
349 const wxValidator& validator = wxDefaultValidator,
350 char* name = "listBox");
352 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
354 bool IsChecked(int uiIndex);
355 void Check(int uiIndex, int bCheck = TRUE);
356 void InsertItems(int LCOUNT, wxString* choices, int pos);
361 //----------------------------------------------------------------------
368 wxTextAttr(const wxColour& colText = wxNullColour,
369 const wxColour& colBack = wxNullColour,
370 const wxFont& font = wxNullFont);
374 void SetTextColour(const wxColour& colText);
375 void SetBackgroundColour(const wxColour& colBack);
376 void SetFont(const wxFont& font);
379 bool HasTextColour() const;
380 bool HasBackgroundColour() const;
381 bool HasFont() const;
383 const wxColour& GetTextColour() const;
384 const wxColour& GetBackgroundColour() const;
385 const wxFont& GetFont() const;
390 class wxTextCtrl : public wxControl {
392 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
393 const wxPoint& pos = wxDefaultPosition,
394 const wxSize& size = wxDefaultSize,
396 const wxValidator& validator = wxDefaultValidator,
397 char* name = "text");
399 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
405 long GetInsertionPoint();
406 long GetLastPosition();
407 int GetLineLength(long lineNo);
408 wxString GetLineText(long lineNo);
409 int GetNumberOfLines();
412 bool LoadFile(const wxString& filename);
414 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
415 void Remove(long from, long to);
416 void Replace(long from, long to, const wxString& value);
417 bool SaveFile(const wxString& filename);
418 void SetEditable(bool editable);
419 void SetInsertionPoint(long pos);
420 void SetInsertionPointEnd();
421 void SetSelection(long from, long to);
422 void SetValue(const wxString& value);
423 void ShowPosition(long pos);
424 void WriteText(const wxString& text);
425 void AppendText(const wxString& text);
426 long XYToPosition(long x, long y);
433 void GetSelection(long* OUTPUT, long* OUTPUT);
438 bool SetStyle(long start, long end, const wxTextAttr& style);
439 bool SetDefaultStyle(const wxTextAttr& style);
440 const wxTextAttr& GetDefaultStyle() const;
443 void write(const wxString& text) {
444 self->AppendText(text);
449 //----------------------------------------------------------------------
451 class wxScrollBar : public wxControl {
453 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
454 const wxPoint& pos = wxDefaultPosition,
455 const wxSize& size = wxDefaultSize,
456 long style = wxSB_HORIZONTAL,
457 const wxValidator& validator = wxDefaultValidator,
458 char* name = "scrollBar");
460 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
464 int GetThumbPosition();
466 %name(GetThumbLength) int GetThumbSize(); // to match the docs
467 void SetThumbPosition(int viewStart);
468 void SetScrollbar(int position, int thumbSize,
469 int range, int pageSize,
470 bool refresh = TRUE);
473 //----------------------------------------------------------------------
475 class wxSpinButton : public wxControl {
477 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
478 const wxPoint& pos = wxDefaultPosition,
479 const wxSize& size = wxDefaultSize,
480 long style = wxSP_HORIZONTAL,
481 char* name = "spinButton");
486 void SetRange(int min, int max);
487 void SetValue(int value);
490 //----------------------------------------------------------------------
492 class wxStaticBitmap : public wxControl {
494 wxStaticBitmap(wxWindow* parent, wxWindowID id,
495 const wxBitmap& bitmap,
496 const wxPoint& pos = wxDefaultPosition,
497 const wxSize& size = wxDefaultSize,
499 char* name = "staticBitmap");
501 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
503 const wxBitmap& GetBitmap();
504 void SetBitmap(const wxBitmap& bitmap);
505 void SetIcon(const wxIcon& icon);
508 //----------------------------------------------------------------------
510 class wxRadioBox : public wxControl {
512 wxRadioBox(wxWindow* parent, wxWindowID id,
513 const wxString& label,
514 const wxPoint& point = wxDefaultPosition,
515 const wxSize& size = wxDefaultSize,
516 int LCOUNT = 0, wxString* choices = NULL,
517 int majorDimension = 0,
518 long style = wxRA_HORIZONTAL,
519 const wxValidator& validator = wxDefaultValidator,
520 char* name = "radioBox");
522 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
524 void Enable(bool enable);
525 %name(EnableItem)void Enable(int n, bool enable);
526 int FindString(const wxString& string);
528 wxString GetString(int n);
531 void SetString(int n, const wxString& label);
532 %pragma(python) addtoclass = "
533 GetItemLabel = GetString
534 SetItemLabel = SetString
536 int GetColumnCount();
539 %name(GetItemLabel)wxString GetLabel( int item );
540 %name(SetItemLabel)void SetLabel( int item, const wxString& label );
544 wxString GetStringSelection();
546 %pragma(python) addtoclass = "Number = GetCount"
548 void SetSelection(int n);
549 void SetStringSelection(const wxString& string);
550 void Show(bool show);
551 %name(ShowItem)void Show(int item, bool show);
554 //----------------------------------------------------------------------
556 class wxRadioButton : public wxControl {
558 wxRadioButton(wxWindow* parent, wxWindowID id,
559 const wxString& label,
560 const wxPoint& pos = wxDefaultPosition,
561 const wxSize& size = wxDefaultSize,
563 const wxValidator& validator = wxDefaultValidator,
564 char* name = "radioButton");
566 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
569 void SetValue(bool value);
572 //----------------------------------------------------------------------
574 class wxSlider : public wxControl {
576 wxSlider(wxWindow* parent, wxWindowID id,
577 int value, int minValue, int maxValue,
578 const wxPoint& point = wxDefaultPosition,
579 const wxSize& size = wxDefaultSize,
580 long style = wxSL_HORIZONTAL,
581 const wxValidator& validator = wxDefaultValidator,
582 char* name = "slider");
584 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
594 int GetThumbLength();
597 void SetRange(int minValue, int maxValue);
598 void SetTickFreq(int n, int pos);
599 void SetLineSize(int lineSize);
600 void SetPageSize(int pageSize);
601 void SetSelection(int startPos, int endPos);
602 void SetThumbLength(int len);
603 void SetTick(int tickPos);
604 void SetValue(int value);
608 //----------------------------------------------------------------------
610 class wxSpinCtrl : public wxSpinButton {
612 wxSpinCtrl(wxWindow *parent,
614 const char* value = "",
615 const wxPoint& pos = wxDefaultPosition,
616 const wxSize& size = wxDefaultSize,
617 long style = wxSP_ARROW_KEYS,
618 int min = 0, int max = 100, int initial = 0,
619 const char* name = "wxSpinCtrl");
625 void SetRange(int min, int max);
626 void SetValue(int value);
631 //----------------------------------------------------------------------
633 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
635 class wxToggleButton : public wxControl {
637 wxToggleButton(wxWindow *parent,
639 const wxString& label,
640 const wxPoint& pos = wxDefaultPosition,
641 const wxSize& size = wxDefaultSize,
643 const wxValidator& validator = wxDefaultValidator,
644 const char* name = "toggle");
646 void SetValue(bool value);
647 bool GetValue() const ;
648 void SetLabel(const wxString& label);
652 //----------------------------------------------------------------------
653 //----------------------------------------------------------------------
654 //----------------------------------------------------------------------