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>
35 //----------------------------------------------------------------------
38 %include my_typemaps.i
40 // Import some definitions of other classes, etc.
47 %pragma(python) code = "import wx"
49 //----------------------------------------------------------------------
52 wxValidator wxDefaultValidator;
55 //----------------------------------------------------------------------
58 //#define DECLARE_DEF_STRING(name) static wxString* wxPy##name
60 // Put some wx default wxChar* values into wxStrings.
61 DECLARE_DEF_STRING(ControlNameStr);
62 DECLARE_DEF_STRING(ButtonNameStr);
63 DECLARE_DEF_STRING(CheckBoxNameStr);
64 DECLARE_DEF_STRING(ChoiceNameStr);
65 DECLARE_DEF_STRING(ComboBoxNameStr);
66 DECLARE_DEF_STRING(GaugeNameStr);
67 DECLARE_DEF_STRING(StaticBoxNameStr);
68 DECLARE_DEF_STRING(StaticTextNameStr);
69 DECLARE_DEF_STRING(ListBoxNameStr);
70 DECLARE_DEF_STRING(TextCtrlNameStr);
71 DECLARE_DEF_STRING(ScrollBarNameStr);
72 DECLARE_DEF_STRING(SPIN_BUTTON_NAME);
73 DECLARE_DEF_STRING(StaticBitmapNameStr);
74 DECLARE_DEF_STRING(RadioBoxNameStr);
75 DECLARE_DEF_STRING(RadioButtonNameStr);
76 DECLARE_DEF_STRING(SliderNameStr);
78 wxChar* wxSpinCtrlNameStr = _T("wxSpinCtrl");
79 DECLARE_DEF_STRING(SpinCtrlNameStr);
81 static const wxString wxPyEmptyString(wxT(""));
84 //----------------------------------------------------------------------
86 // This is the base class for a control or 'widget'.
88 // A control is generally a small window which processes user input and/or
89 // displays one or more item of data.
90 class wxControl : public wxWindow {
94 wxControl(wxWindow *parent,
96 const wxPoint& pos=wxDefaultPosition,
97 const wxSize& size=wxDefaultSize,
99 const wxValidator& validator=wxDefaultValidator,
100 const wxString& name=wxPyControlNameStr);
103 %name(wxPreControl)wxControl();
106 bool Create(wxWindow *parent,
108 const wxPoint& pos=wxDefaultPosition,
109 const wxSize& size=wxDefaultSize,
111 const wxValidator& validator=wxDefaultValidator,
112 const wxString& name=wxPyControlNameStr);
114 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
115 %pragma(python) addtomethod = "wxPreControl:val._setOORInfo(val)"
117 // Simulates the effect of the user issuing a command to the item. See
119 void Command(wxCommandEvent& event);
121 // Return a control's text.
124 // Sets the item's text.
125 void SetLabel(const wxString& label);
129 //----------------------------------------------------------------------
132 class wxControlWithItems : public wxControl {
135 // void Clear(); ambiguous, redefine below...
137 // Deletes an item from the control
140 // Returns the number of items in the control.
142 %pragma(python) addtoclass = "Number = GetCount"
144 // Returns the string at the given position.
145 wxString GetString(int n);
147 // Sets the string value of an item.
148 void SetString(int n, const wxString& s);
150 // Finds an item matching the given string. Returns the zero-based
151 // position of the item, or -1 if the string was not found.
152 int FindString(const wxString& s);
154 // Select the item at postion n.
157 // Gets the position of the selected item.
160 // Gets the current selection as a string.
161 wxString GetStringSelection() const;
163 // void Append(const wxString& item);
164 // void Append(const wxString& item, char* clientData);
165 // char* GetClientData(const int n);
166 // void SetClientData(const int n, char* data);
170 // Adds the item to the control, associating the given data with the
172 void Append(const wxString& item, PyObject* clientData=NULL) {
174 wxPyClientData* data = new wxPyClientData(clientData);
175 self->Append(item, data);
180 // Returns the client data associated with the given item, (if any.)
181 PyObject* GetClientData(int n) {
182 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
184 Py_INCREF(data->m_obj);
192 // Associate the given client data with the item at position n.
193 void SetClientData(int n, PyObject* clientData) {
194 wxPyClientData* data = new wxPyClientData(clientData);
195 self->SetClientObject(n, data);
199 // append several items at once to the control
200 %name(AppendItems)void Append(const wxArrayString& strings);
204 //----------------------------------------------------------------------
206 // A button is a control that contains a text string, and is one of the most
207 // common elements of a GUI. It may be placed on a dialog box or panel, or
208 // indeed almost any other window.
211 // wxBU_LEFT: Left-justifies the label. WIN32 only.
212 // wxBU_TOP: Aligns the label to the top of the button. WIN32 only.
213 // wxBU_RIGHT: Right-justifies the bitmap label. WIN32 only.
214 // wxBU_BOTTOM: Aligns the label to the bottom of the button. WIN32 only.
215 // wxBU_EXACTFIT: Creates the button as small as possible instead of making
216 // it of the standard size (which is the default behaviour.)
219 // EVT_BUTTON(win,id,func):
220 // Sent when the button is clicked.
222 class wxButton : public wxControl {
224 // Constructor, creating and showing a button.
226 // parent: Parent window. Must not be None.
227 // id: Button identifier. A value of -1 indicates a default value.
228 // label: The text to be displayed on the button.
229 // pos: The button position on it's parent.
230 // size: Button size. If the default size (-1, -1) is specified then the
231 // button is sized appropriately for the text.
232 // style: Window style. See wxButton.
233 // validator: Window validator.
234 // name: Window name.
235 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
236 const wxPoint& pos = wxDefaultPosition,
237 const wxSize& size = wxDefaultSize,
239 const wxValidator& validator = wxDefaultValidator,
240 const wxString& name = wxPyButtonNameStr);
242 // Default constructor
243 %name(wxPreButton)wxButton();
245 // Button creation function for two-step creation.
246 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
247 const wxPoint& pos = wxDefaultPosition,
248 const wxSize& size = wxDefaultSize,
250 const wxValidator& validator = wxDefaultValidator,
251 const wxString& name = wxPyButtonNameStr);
253 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
254 %pragma(python) addtomethod = "wxPreButton:val._setOORInfo(val)"
256 // This sets the button to be the default item for the panel or dialog box.
258 // Under Windows, only dialog box buttons respond to this function. As
259 // normal under Windows and Motif, pressing return causes the default
260 // button to be depressed when the return key is pressed. See also
261 // wxWindow.SetFocus which sets the keyboard focus for windows and text
262 // panel items, and wxPanel.SetDefaultItem.
266 void SetBackgroundColour(const wxColour& colour);
268 void SetForegroundColour(const wxColour& colour);
271 // show the image in the button in addition to the label
272 void SetImageLabel(const wxBitmap& bitmap);
274 // set the margins around the image
275 void SetImageMargins(wxCoord x, wxCoord y);
278 // returns the default button size for this platform
279 static wxSize GetDefaultSize();
282 //----------------------------------------------------------------------
284 class wxBitmapButton : public wxButton {
286 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
287 const wxPoint& pos = wxDefaultPosition,
288 const wxSize& size = wxDefaultSize,
289 long style = wxBU_AUTODRAW,
290 const wxValidator& validator = wxDefaultValidator,
291 const wxString& name = wxPyButtonNameStr);
292 %name(wxPreBitmapButton)wxBitmapButton();
294 bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = wxBU_AUTODRAW,
298 const wxValidator& validator = wxDefaultValidator,
299 const wxString& name = wxPyButtonNameStr);
301 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
302 %pragma(python) addtomethod = "wxPreBitmapButton:val._setOORInfo(val)"
304 wxBitmap GetBitmapLabel();
305 wxBitmap GetBitmapDisabled();
306 wxBitmap GetBitmapFocus();
307 wxBitmap GetBitmapSelected();
308 void SetBitmapDisabled(const wxBitmap& bitmap);
309 void SetBitmapFocus(const wxBitmap& bitmap);
310 void SetBitmapSelected(const wxBitmap& bitmap);
311 void SetBitmapLabel(const wxBitmap& bitmap);
313 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
314 int GetMarginX() const { return m_marginX; }
315 int GetMarginY() const { return m_marginY; }
318 //----------------------------------------------------------------------
320 class wxCheckBox : public wxControl {
322 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
323 const wxPoint& pos = wxDefaultPosition,
324 const wxSize& size = wxDefaultSize,
326 const wxValidator& val = wxDefaultValidator,
327 const wxString& name = wxPyCheckBoxNameStr);
328 %name(wxPreCheckBox)wxCheckBox();
330 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
331 const wxPoint& pos = wxDefaultPosition,
332 const wxSize& size = wxDefaultSize,
334 const wxValidator& val = wxDefaultValidator,
335 const wxString& name = wxPyCheckBoxNameStr);
337 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
338 %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)"
341 void SetValue(const bool state);
344 //----------------------------------------------------------------------
346 class wxChoice : public wxControlWithItems {
348 wxChoice(wxWindow *parent, wxWindowID id,
349 const wxPoint& pos = wxDefaultPosition,
350 const wxSize& size = wxDefaultSize,
351 int LCOUNT=0, wxString* choices=NULL,
353 const wxValidator& validator = wxDefaultValidator,
354 const wxString& name = wxPyChoiceNameStr);
355 %name(wxPreChoice)wxChoice();
357 bool Create(wxWindow *parent, wxWindowID id,
358 const wxPoint& pos = wxDefaultPosition,
359 const wxSize& size = wxDefaultSize,
360 int LCOUNT=0, wxString* choices=NULL,
362 const wxValidator& validator = wxDefaultValidator,
363 const wxString& name = wxPyChoiceNameStr);
365 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
366 %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)"
371 void SetColumns(const int n = 1);
372 void SetSelection(const int n);
373 void SetStringSelection(const wxString& string);
374 void SetString(int n, const wxString& s);
376 %pragma(python) addtoclass = "
377 Select = SetSelection
381 //----------------------------------------------------------------------
383 // wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or
384 // even wxControlWithItems, so we have to duplicate the methods
388 class wxComboBox : public wxControl
391 wxComboBox(wxWindow* parent, wxWindowID id,
392 const wxString& value = wxPyEmptyString,
393 const wxPoint& pos = wxDefaultPosition,
394 const wxSize& size = wxDefaultSize,
395 int LCOUNT=0, wxString* choices=NULL,
397 const wxValidator& validator = wxDefaultValidator,
398 const wxString& name = wxPyComboBoxNameStr);
399 %name(wxPreComboBox)wxComboBox();
401 bool Create(wxWindow* parent, wxWindowID id,
402 const wxString& value = wxPyEmptyString,
403 const wxPoint& pos = wxDefaultPosition,
404 const wxSize& size = wxDefaultSize,
405 int LCOUNT=0, wxString* choices=NULL,
407 const wxValidator& validator = wxDefaultValidator,
408 const wxString& name = wxPyComboBoxNameStr);
410 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
411 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
415 long GetInsertionPoint();
416 long GetLastPosition();
419 void Replace(long from, long to, const wxString& text);
420 void Remove(long from, long to);
421 void SetInsertionPoint(long pos);
422 void SetInsertionPointEnd();
423 void SetSelection(int n);
424 %name(SetMark)void SetSelection(long from, long to);
425 void SetValue(const wxString& text);
426 void SetEditable(bool editable);
433 %pragma(python) addtoclass = "Number = GetCount"
434 wxString GetString(int n);
435 int FindString(const wxString& s);
437 //void SetString(int n, const wxString& s); *** No equivalent for wxGTK!!!
439 // void Select(int n);
440 %pragma(python) addtoclass = "Select = SetSelection"
443 wxString GetStringSelection() const;
445 // void Append(const wxString& item);
446 // void Append(const wxString& item, char* clientData);
447 // char* GetClientData(const int n);
448 // void SetClientData(const int n, char* data);
450 void Append(const wxString& item, PyObject* clientData=NULL) {
452 wxPyClientData* data = new wxPyClientData(clientData);
453 self->Append(item, data);
458 PyObject* GetClientData(int n) {
459 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
461 Py_INCREF(data->m_obj);
469 void SetClientData(int n, PyObject* clientData) {
470 wxPyClientData* data = new wxPyClientData(clientData);
471 self->SetClientObject(n, data);
479 #else // For all but wxGTK
482 class wxComboBox : public wxChoice {
484 wxComboBox(wxWindow* parent, wxWindowID id,
485 const wxString& value = wxPyEmptyString,
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
488 int LCOUNT=0, wxString* choices=NULL,
490 const wxValidator& validator = wxDefaultValidator,
491 const wxString& name = wxPyComboBoxNameStr);
492 %name(wxPreComboBox)wxComboBox();
494 bool Create(wxWindow* parent, wxWindowID id,
495 const wxString& value = wxPyEmptyString,
496 const wxPoint& pos = wxDefaultPosition,
497 const wxSize& size = wxDefaultSize,
498 int LCOUNT=0, wxString* choices=NULL,
500 const wxValidator& validator = wxDefaultValidator,
501 const wxString& name = wxPyComboBoxNameStr);
503 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
504 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
508 long GetInsertionPoint();
509 long GetLastPosition();
512 void Replace(long from, long to, const wxString& text);
513 void Remove(long from, long to);
514 void SetInsertionPoint(long pos);
515 void SetInsertionPointEnd();
516 void SetSelection(int n);
517 %name(SetMark)void SetSelection(long from, long to);
518 void SetValue(const wxString& text);
519 void SetEditable(bool editable);
524 //----------------------------------------------------------------------
526 class wxGauge : public wxControl {
528 wxGauge(wxWindow* parent, wxWindowID id, int range,
529 const wxPoint& pos = wxDefaultPosition,
530 const wxSize& size = wxDefaultSize,
531 long style = wxGA_HORIZONTAL,
532 const wxValidator& validator = wxDefaultValidator,
533 const wxString& name = wxPyGaugeNameStr);
534 %name(wxPreGauge)wxGauge();
536 bool Create(wxWindow* parent, wxWindowID id, int range,
537 const wxPoint& pos = wxDefaultPosition,
538 const wxSize& size = wxDefaultSize,
539 long style = wxGA_HORIZONTAL,
540 const wxValidator& validator = wxDefaultValidator,
541 const wxString& name = wxPyGaugeNameStr);
543 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
544 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
548 int GetShadowWidth();
550 void SetBezelFace(int width);
551 void SetRange(int range);
552 void SetShadowWidth(int width);
553 void SetValue(int pos);
556 //----------------------------------------------------------------------
558 class wxStaticBox : public wxControl {
560 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
561 const wxPoint& pos = wxDefaultPosition,
562 const wxSize& size = wxDefaultSize,
564 const wxString& name = wxPyStaticBoxNameStr);
565 %name(wxPreStaticBox)wxStaticBox();
567 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
568 const wxPoint& pos = wxDefaultPosition,
569 const wxSize& size = wxDefaultSize,
571 const wxString& name = wxPyStaticBoxNameStr);
573 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
574 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
578 //----------------------------------------------------------------------
581 class wxStaticLine : public wxControl {
583 wxStaticLine( wxWindow *parent, wxWindowID id,
584 const wxPoint &pos = wxDefaultPosition,
585 const wxSize &size = wxDefaultSize,
586 long style = wxLI_HORIZONTAL,
587 const wxString& name = wxPyStaticTextNameStr);
588 %name(wxPreStaticLine)wxStaticLine();
590 bool Create( wxWindow *parent, wxWindowID id,
591 const wxPoint &pos = wxDefaultPosition,
592 const wxSize &size = wxDefaultSize,
593 long style = wxLI_HORIZONTAL,
594 const wxString& name = wxPyStaticTextNameStr);
596 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
597 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
601 //----------------------------------------------------------------------
603 class wxStaticText : public wxControl {
605 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
606 const wxPoint& pos = wxDefaultPosition,
607 const wxSize& size = wxDefaultSize,
609 const wxString& name = wxPyStaticTextNameStr);
610 %name(wxPreStaticText)wxStaticText();
612 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
613 const wxPoint& pos = wxDefaultPosition,
614 const wxSize& size = wxDefaultSize,
616 const wxString& name = wxPyStaticTextNameStr);
618 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
619 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
622 void SetLabel(const wxString& label);
625 //----------------------------------------------------------------------
627 class wxListBox : public wxControlWithItems {
629 wxListBox(wxWindow* parent, wxWindowID id,
630 const wxPoint& pos = wxDefaultPosition,
631 const wxSize& size = wxDefaultSize,
632 int LCOUNT, wxString* choices = NULL,
634 const wxValidator& validator = wxDefaultValidator,
635 const wxString& name = wxPyListBoxNameStr);
636 %name(wxPreListBox)wxListBox();
638 bool Create(wxWindow* parent, wxWindowID id,
639 const wxPoint& pos = wxDefaultPosition,
640 const wxSize& size = wxDefaultSize,
641 int LCOUNT, wxString* choices = NULL,
643 const wxValidator& validator = wxDefaultValidator,
644 const wxString& name = wxPyListBoxNameStr);
646 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
647 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
650 void Deselect(int n);
652 // int GetSelections(int **selections);
654 PyObject* GetSelections() {
656 self->GetSelections(lst);
657 PyObject *tup = PyTuple_New(lst.GetCount());
658 for(size_t i=0; i<lst.GetCount(); i++) {
659 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
666 void InsertItems(int LCOUNT, wxString* choices, int pos);
668 bool IsSelected(const int n);
669 bool Selected(const int n);
670 void Set(int LCOUNT, wxString* choices);
671 void SetFirstItem(int n);
672 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
673 void SetSelection(int n, bool select = TRUE);
674 void SetString(int n, const wxString& string);
675 void SetStringSelection(const wxString& string, bool select = TRUE);
679 //----------------------------------------------------------------------
681 class wxCheckListBox : public wxListBox {
683 wxCheckListBox(wxWindow *parent, wxWindowID id,
684 const wxPoint& pos = wxDefaultPosition,
685 const wxSize& size = wxDefaultSize,
687 wxString* choices = NULL,
689 const wxValidator& validator = wxDefaultValidator,
690 const wxString& name = wxPyListBoxNameStr);
691 %name(wxPreCheckListBox)wxCheckListBox();
693 bool Create(wxWindow *parent, wxWindowID id,
694 const wxPoint& pos = wxDefaultPosition,
695 const wxSize& size = wxDefaultSize,
697 wxString* choices = NULL,
699 const wxValidator& validator = wxDefaultValidator,
700 const wxString& name = wxPyListBoxNameStr);
702 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
703 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
705 bool IsChecked(int uiIndex);
706 void Check(int uiIndex, int bCheck = TRUE);
707 void InsertItems(int LCOUNT, wxString* choices, int pos);
713 // return the index of the item at this position or wxNOT_FOUND
714 int HitTest(const wxPoint& pt) const;
715 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
719 //----------------------------------------------------------------------
726 wxTextAttr(const wxColour& colText = wxNullColour,
727 const wxColour& colBack = wxNullColour,
728 const wxFont& font = wxNullFont);
732 void SetTextColour(const wxColour& colText);
733 void SetBackgroundColour(const wxColour& colBack);
734 void SetFont(const wxFont& font);
737 bool HasTextColour() const;
738 bool HasBackgroundColour() const;
739 bool HasFont() const;
741 wxColour GetTextColour() const;
742 wxColour GetBackgroundColour() const;
743 wxFont GetFont() const;
745 // returns false if we have any attributes set, true otherwise
748 // return the attribute having the valid font and colours: it uses the
749 // attributes set in attr and falls back first to attrDefault and then to
750 // the text control font/colours for those attributes which are not set
751 static wxTextAttr Combine(const wxTextAttr& attr,
752 const wxTextAttr& attrDef,
753 const wxTextCtrl *text);
758 class wxTextCtrl : public wxControl {
760 wxTextCtrl(wxWindow* parent, wxWindowID id,
761 const wxString& value = wxPyEmptyString,
762 const wxPoint& pos = wxDefaultPosition,
763 const wxSize& size = wxDefaultSize,
765 const wxValidator& validator = wxDefaultValidator,
766 const wxString& name = wxPyTextCtrlNameStr);
767 %name(wxPreTextCtrl)wxTextCtrl();
769 bool Create(wxWindow* parent, wxWindowID id,
770 const wxString& value = wxPyEmptyString,
771 const wxPoint& pos = wxDefaultPosition,
772 const wxSize& size = wxDefaultSize,
774 const wxValidator& validator = wxDefaultValidator,
775 const wxString& name = wxPyTextCtrlNameStr);
777 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
778 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
781 wxString GetValue() const;
782 void SetValue(const wxString& value);
784 wxString GetRange(long from, long to);
786 int GetLineLength(long lineNo) const;
787 wxString GetLineText(long lineNo) const;
788 int GetNumberOfLines() const;
790 bool IsModified() const;
791 bool IsEditable() const;
793 // If the return values from and to are the same, there is no selection.
794 void GetSelection(long* OUTPUT, long* OUTPUT) const;
795 wxString GetStringSelection();
798 void Replace(long from, long to, const wxString& value);
799 void Remove(long from, long to);
801 // load/save the controls contents from/to the file
802 bool LoadFile(const wxString& file);
803 bool SaveFile(const wxString& file = wxPyEmptyString);
805 // clears the dirty flag
808 // set the max number of characters which may be entered in a single line
810 void SetMaxLength(unsigned long len);
812 // writing text inserts it at the current position, appending always
813 // inserts it at the end
814 void WriteText(const wxString& text);
815 void AppendText(const wxString& text);
817 // insert the character which would have resulted from this key event,
818 // return TRUE if anything has been inserted
819 bool EmulateKeyPress(const wxKeyEvent& event);
821 // text control under some platforms supports the text styles: these
822 // methods allow to apply the given text style to the given selection or to
823 // set/get the style which will be used for all appended text
824 bool SetStyle(long start, long end, const wxTextAttr& style);
825 bool SetDefaultStyle(const wxTextAttr& style);
826 const wxTextAttr& GetDefaultStyle() const;
828 // translate between the position (which is just an index in the text ctrl
829 // considering all its contents as a single strings) and (x, y) coordinates
830 // which represent column and line.
831 long XYToPosition(long x, long y) const;
832 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
834 //bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
835 // TODO: check return value, raise exception.
837 void ShowPosition(long pos);
839 // Clipboard operations
844 bool CanCopy() const;
846 bool CanPaste() const;
852 bool CanUndo() const;
853 bool CanRedo() const;
856 void SetInsertionPoint(long pos);
857 void SetInsertionPointEnd();
858 long GetInsertionPoint() const;
859 long GetLastPosition() const;
861 void SetSelection(long from, long to);
863 void SetEditable(bool editable);
870 void write(const wxString& text) {
871 self->AppendText(text);
875 // TODO: replace this when the method is really added to wxTextCtrl
877 wxString GetString(long from, long to) {
878 return self->GetValue().Mid(from, to - from);
883 //----------------------------------------------------------------------
885 class wxScrollBar : public wxControl {
887 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
888 const wxPoint& pos = wxDefaultPosition,
889 const wxSize& size = wxDefaultSize,
890 long style = wxSB_HORIZONTAL,
891 const wxValidator& validator = wxDefaultValidator,
892 const wxString& name = wxPyScrollBarNameStr);
893 %name(wxPreScrollBar)wxScrollBar();
895 bool Create(wxWindow* parent, wxWindowID id = -1,
896 const wxPoint& pos = wxDefaultPosition,
897 const wxSize& size = wxDefaultSize,
898 long style = wxSB_HORIZONTAL,
899 const wxValidator& validator = wxDefaultValidator,
900 const wxString& name = wxPyScrollBarNameStr);
902 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
903 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
907 int GetThumbPosition();
909 %name(GetThumbLength) int GetThumbSize(); // to match the docs
913 void SetThumbPosition(int viewStart);
914 void SetScrollbar(int position, int thumbSize,
915 int range, int pageSize,
916 bool refresh = TRUE);
919 //----------------------------------------------------------------------
921 class wxSpinButton : public wxControl {
923 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
924 const wxPoint& pos = wxDefaultPosition,
925 const wxSize& size = wxDefaultSize,
926 long style = wxSP_HORIZONTAL,
927 const wxString& name = wxPySPIN_BUTTON_NAME);
928 %name(wxPreSpinButton)wxSpinButton();
930 bool Create(wxWindow* parent, wxWindowID id = -1,
931 const wxPoint& pos = wxDefaultPosition,
932 const wxSize& size = wxDefaultSize,
933 long style = wxSP_HORIZONTAL,
934 const wxString& name = wxPySPIN_BUTTON_NAME);
936 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
937 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
942 void SetRange(int min, int max);
943 void SetValue(int value);
946 //----------------------------------------------------------------------
948 class wxStaticBitmap : public wxControl {
950 wxStaticBitmap(wxWindow* parent, wxWindowID id,
951 const wxBitmap& bitmap,
952 const wxPoint& pos = wxDefaultPosition,
953 const wxSize& size = wxDefaultSize,
955 const wxString& name = wxPyStaticBitmapNameStr);
956 %name(wxPreStaticBitmap)wxStaticBitmap();
958 bool Create(wxWindow* parent, wxWindowID id,
959 const wxBitmap& bitmap,
960 const wxPoint& pos = wxDefaultPosition,
961 const wxSize& size = wxDefaultSize,
963 const wxString& name = wxPyStaticBitmapNameStr);
965 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
966 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
968 wxBitmap GetBitmap();
969 void SetBitmap(const wxBitmap& bitmap);
970 void SetIcon(const wxIcon& icon);
973 //----------------------------------------------------------------------
975 class wxRadioBox : public wxControl {
977 wxRadioBox(wxWindow* parent, wxWindowID id,
978 const wxString& label,
979 const wxPoint& point = wxDefaultPosition,
980 const wxSize& size = wxDefaultSize,
981 int LCOUNT = 0, wxString* choices = NULL,
982 int majorDimension = 0,
983 long style = wxRA_HORIZONTAL,
984 const wxValidator& validator = wxDefaultValidator,
985 const wxString& name = wxPyRadioBoxNameStr);
986 %name(wxPreRadioBox)wxRadioBox();
988 bool Create(wxWindow* parent, wxWindowID id,
989 const wxString& label,
990 const wxPoint& point = wxDefaultPosition,
991 const wxSize& size = wxDefaultSize,
992 int LCOUNT = 0, wxString* choices = NULL,
993 int majorDimension = 0,
994 long style = wxRA_HORIZONTAL,
995 const wxValidator& validator = wxDefaultValidator,
996 const wxString& name = wxPyRadioBoxNameStr);
998 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
999 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
1001 void Enable(bool enable);
1002 %name(EnableItem)void Enable(int n, bool enable);
1003 int FindString(const wxString& string);
1005 wxString GetString(int n);
1008 %name(GetItemLabel)wxString GetLabel( int item );
1009 %name(SetItemLabel)void SetLabel( int item, const wxString& label );
1011 void SetString(int n, const wxString& label);
1012 %pragma(python) addtoclass = "
1013 GetItemLabel = GetString
1014 SetItemLabel = SetString
1016 int GetColumnCount();
1021 wxString GetStringSelection();
1023 %pragma(python) addtoclass = "Number = GetCount"
1025 void SetSelection(int n);
1026 void SetStringSelection(const wxString& string);
1027 void Show(bool show);
1028 %name(ShowItem)void Show(int item, bool show);
1031 //----------------------------------------------------------------------
1033 class wxRadioButton : public wxControl {
1035 wxRadioButton(wxWindow* parent, wxWindowID id,
1036 const wxString& label,
1037 const wxPoint& pos = wxDefaultPosition,
1038 const wxSize& size = wxDefaultSize,
1040 const wxValidator& validator = wxDefaultValidator,
1041 const wxString& name = wxPyRadioButtonNameStr);
1042 %name(wxPreRadioButton)wxRadioButton();
1044 bool Create(wxWindow* parent, wxWindowID id,
1045 const wxString& label,
1046 const wxPoint& pos = wxDefaultPosition,
1047 const wxSize& size = wxDefaultSize,
1049 const wxValidator& validator = wxDefaultValidator,
1050 const wxString& name = wxPyRadioButtonNameStr);
1052 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1053 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
1056 void SetValue(bool value);
1059 //----------------------------------------------------------------------
1061 class wxSlider : public wxControl {
1063 wxSlider(wxWindow* parent, wxWindowID id,
1064 int value, int minValue, int maxValue,
1065 const wxPoint& point = wxDefaultPosition,
1066 const wxSize& size = wxDefaultSize,
1067 long style = wxSL_HORIZONTAL,
1068 const wxValidator& validator = wxDefaultValidator,
1069 const wxString& name = wxPySliderNameStr);
1070 %name(wxPreSlider)wxSlider();
1072 bool Create(wxWindow* parent, wxWindowID id,
1073 int value, int minValue, int maxValue,
1074 const wxPoint& point = wxDefaultPosition,
1075 const wxSize& size = wxDefaultSize,
1076 long style = wxSL_HORIZONTAL,
1077 const wxValidator& validator = wxDefaultValidator,
1078 const wxString& name = wxPySliderNameStr);
1080 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1081 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
1091 int GetThumbLength();
1094 void SetRange(int minValue, int maxValue);
1095 void SetTickFreq(int n, int pos);
1096 void SetLineSize(int lineSize);
1097 void SetPageSize(int pageSize);
1098 void SetSelection(int startPos, int endPos);
1099 void SetThumbLength(int len);
1100 void SetTick(int tickPos);
1101 void SetValue(int value);
1105 //----------------------------------------------------------------------
1107 class wxSpinCtrl : public wxSpinButton {
1109 wxSpinCtrl(wxWindow *parent,
1111 const wxString& value = wxPyEmptyString,
1112 const wxPoint& pos = wxDefaultPosition,
1113 const wxSize& size = wxDefaultSize,
1114 long style = wxSP_ARROW_KEYS,
1115 int min = 0, int max = 100, int initial = 0,
1116 const wxString& name = wxPySpinCtrlNameStr);
1117 %name(wxPreSpinCtrl)wxSpinCtrl();
1119 bool Create(wxWindow *parent,
1121 const wxString& value = wxPyEmptyString,
1122 const wxPoint& pos = wxDefaultPosition,
1123 const wxSize& size = wxDefaultSize,
1124 long style = wxSP_ARROW_KEYS,
1125 int min = 0, int max = 100, int initial = 0,
1126 const wxString& name = wxPySpinCtrlNameStr);
1128 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1129 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
1134 void SetRange(int min, int max);
1135 void SetValue(int value);
1140 //----------------------------------------------------------------------
1143 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1145 class wxToggleButton : public wxControl {
1147 wxToggleButton(wxWindow *parent,
1149 const wxString& label,
1150 const wxPoint& pos = wxDefaultPosition,
1151 const wxSize& size = wxDefaultSize,
1153 const wxValidator& validator = wxDefaultValidator,
1154 const wxString& name = wxPyCheckBoxNameStr);
1155 %name(wxPreToggleButton)wxToggleButton();
1157 bool Create(wxWindow *parent,
1159 const wxString& label,
1160 const wxPoint& pos = wxDefaultPosition,
1161 const wxSize& size = wxDefaultSize,
1163 const wxValidator& validator = wxDefaultValidator,
1164 const wxString& name = wxPyCheckBoxNameStr);
1166 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1167 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
1169 void SetValue(bool value);
1170 bool GetValue() const ;
1171 void SetLabel(const wxString& label);
1177 //----------------------------------------------------------------------
1178 //----------------------------------------------------------------------
1179 //----------------------------------------------------------------------