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 // See also wxPy_ReinitStockObjects in helpers.cpp
53 wxValidator wxDefaultValidator;
56 //----------------------------------------------------------------------
59 //#define DECLARE_DEF_STRING(name) static wxString* wxPy##name
61 // Put some wx default wxChar* values into wxStrings.
62 DECLARE_DEF_STRING(ControlNameStr);
63 DECLARE_DEF_STRING(ButtonNameStr);
64 DECLARE_DEF_STRING(CheckBoxNameStr);
65 DECLARE_DEF_STRING(ChoiceNameStr);
66 DECLARE_DEF_STRING(ComboBoxNameStr);
67 DECLARE_DEF_STRING(GaugeNameStr);
68 DECLARE_DEF_STRING(StaticBoxNameStr);
69 DECLARE_DEF_STRING(StaticTextNameStr);
70 DECLARE_DEF_STRING(ListBoxNameStr);
71 DECLARE_DEF_STRING(TextCtrlNameStr);
72 DECLARE_DEF_STRING(ScrollBarNameStr);
73 DECLARE_DEF_STRING(SPIN_BUTTON_NAME);
74 DECLARE_DEF_STRING(StaticBitmapNameStr);
75 DECLARE_DEF_STRING(RadioBoxNameStr);
76 DECLARE_DEF_STRING(RadioButtonNameStr);
77 DECLARE_DEF_STRING(SliderNameStr);
79 wxChar* wxSpinCtrlNameStr = _T("wxSpinCtrl");
80 DECLARE_DEF_STRING(SpinCtrlNameStr);
82 static const wxString wxPyEmptyString(wxT(""));
85 //----------------------------------------------------------------------
87 // This is the base class for a control or 'widget'.
89 // A control is generally a small window which processes user input and/or
90 // displays one or more item of data.
91 class wxControl : public wxWindow {
95 wxControl(wxWindow *parent,
97 const wxPoint& pos=wxDefaultPosition,
98 const wxSize& size=wxDefaultSize,
100 const wxValidator& validator=wxDefaultValidator,
101 const wxString& name=wxPyControlNameStr);
104 %name(wxPreControl)wxControl();
107 bool Create(wxWindow *parent,
109 const wxPoint& pos=wxDefaultPosition,
110 const wxSize& size=wxDefaultSize,
112 const wxValidator& validator=wxDefaultValidator,
113 const wxString& name=wxPyControlNameStr);
115 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
116 %pragma(python) addtomethod = "wxPreControl:val._setOORInfo(val)"
118 // Simulates the effect of the user issuing a command to the item. See
120 void Command(wxCommandEvent& event);
122 // Return a control's text.
125 // Sets the item's text.
126 void SetLabel(const wxString& label);
130 //----------------------------------------------------------------------
133 class wxControlWithItems : public wxControl {
136 // void Clear(); ambiguous, redefine below...
138 // Deletes an item from the control
141 // Returns the number of items in the control.
143 %pragma(python) addtoclass = "Number = GetCount"
145 // Returns the string at the given position.
146 wxString GetString(int n);
148 // Sets the string value of an item.
149 void SetString(int n, const wxString& s);
151 // Finds an item matching the given string. Returns the zero-based
152 // position of the item, or -1 if the string was not found.
153 int FindString(const wxString& s);
155 // Select the item at postion n.
158 // Gets the position of the selected item.
161 // Gets the current selection as a string.
162 wxString GetStringSelection() const;
164 // void Append(const wxString& item);
165 // void Append(const wxString& item, char* clientData);
166 // char* GetClientData(const int n);
167 // void SetClientData(const int n, char* data);
171 // Adds the item to the control, associating the given data with the
173 void Append(const wxString& item, PyObject* clientData=NULL) {
175 wxPyClientData* data = new wxPyClientData(clientData);
176 self->Append(item, data);
181 // Returns the client data associated with the given item, (if any.)
182 PyObject* GetClientData(int n) {
183 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
185 Py_INCREF(data->m_obj);
193 // Associate the given client data with the item at position n.
194 void SetClientData(int n, PyObject* clientData) {
195 wxPyClientData* data = new wxPyClientData(clientData);
196 self->SetClientObject(n, data);
200 // append several items at once to the control
201 %name(AppendItems)void Append(const wxArrayString& strings);
205 //----------------------------------------------------------------------
207 // A button is a control that contains a text string, and is one of the most
208 // common elements of a GUI. It may be placed on a dialog box or panel, or
209 // indeed almost any other window.
212 // wxBU_LEFT: Left-justifies the label. WIN32 only.
213 // wxBU_TOP: Aligns the label to the top of the button. WIN32 only.
214 // wxBU_RIGHT: Right-justifies the bitmap label. WIN32 only.
215 // wxBU_BOTTOM: Aligns the label to the bottom of the button. WIN32 only.
216 // wxBU_EXACTFIT: Creates the button as small as possible instead of making
217 // it of the standard size (which is the default behaviour.)
220 // EVT_BUTTON(win,id,func):
221 // Sent when the button is clicked.
223 class wxButton : public wxControl {
225 // Constructor, creating and showing a button.
227 // parent: Parent window. Must not be None.
228 // id: Button identifier. A value of -1 indicates a default value.
229 // label: The text to be displayed on the button.
230 // pos: The button position on it's parent.
231 // size: Button size. If the default size (-1, -1) is specified then the
232 // button is sized appropriately for the text.
233 // style: Window style. See wxButton.
234 // validator: Window validator.
235 // name: Window name.
236 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
237 const wxPoint& pos = wxDefaultPosition,
238 const wxSize& size = wxDefaultSize,
240 const wxValidator& validator = wxDefaultValidator,
241 const wxString& name = wxPyButtonNameStr);
243 // Default constructor
244 %name(wxPreButton)wxButton();
246 // Button creation function for two-step creation.
247 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
248 const wxPoint& pos = wxDefaultPosition,
249 const wxSize& size = wxDefaultSize,
251 const wxValidator& validator = wxDefaultValidator,
252 const wxString& name = wxPyButtonNameStr);
254 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
255 %pragma(python) addtomethod = "wxPreButton:val._setOORInfo(val)"
257 // This sets the button to be the default item for the panel or dialog box.
259 // Under Windows, only dialog box buttons respond to this function. As
260 // normal under Windows and Motif, pressing return causes the default
261 // button to be depressed when the return key is pressed. See also
262 // wxWindow.SetFocus which sets the keyboard focus for windows and text
263 // panel items, and wxPanel.SetDefaultItem.
267 void SetBackgroundColour(const wxColour& colour);
269 void SetForegroundColour(const wxColour& colour);
272 // show the image in the button in addition to the label
273 void SetImageLabel(const wxBitmap& bitmap);
275 // set the margins around the image
276 void SetImageMargins(wxCoord x, wxCoord y);
279 // returns the default button size for this platform
280 static wxSize GetDefaultSize();
283 //----------------------------------------------------------------------
285 class wxBitmapButton : public wxButton {
287 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
288 const wxPoint& pos = wxDefaultPosition,
289 const wxSize& size = wxDefaultSize,
290 long style = wxBU_AUTODRAW,
291 const wxValidator& validator = wxDefaultValidator,
292 const wxString& name = wxPyButtonNameStr);
293 %name(wxPreBitmapButton)wxBitmapButton();
295 bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
296 const wxPoint& pos = wxDefaultPosition,
297 const wxSize& size = wxDefaultSize,
298 long style = wxBU_AUTODRAW,
299 const wxValidator& validator = wxDefaultValidator,
300 const wxString& name = wxPyButtonNameStr);
302 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
303 %pragma(python) addtomethod = "wxPreBitmapButton:val._setOORInfo(val)"
305 wxBitmap GetBitmapLabel();
306 wxBitmap GetBitmapDisabled();
307 wxBitmap GetBitmapFocus();
308 wxBitmap GetBitmapSelected();
309 void SetBitmapDisabled(const wxBitmap& bitmap);
310 void SetBitmapFocus(const wxBitmap& bitmap);
311 void SetBitmapSelected(const wxBitmap& bitmap);
312 void SetBitmapLabel(const wxBitmap& bitmap);
314 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
315 int GetMarginX() const { return m_marginX; }
316 int GetMarginY() const { return m_marginY; }
319 //----------------------------------------------------------------------
321 class wxCheckBox : public wxControl {
323 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
324 const wxPoint& pos = wxDefaultPosition,
325 const wxSize& size = wxDefaultSize,
327 const wxValidator& validator = wxDefaultValidator,
328 const wxString& name = wxPyCheckBoxNameStr);
329 %name(wxPreCheckBox)wxCheckBox();
331 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
332 const wxPoint& pos = wxDefaultPosition,
333 const wxSize& size = wxDefaultSize,
335 const wxValidator& validator = wxDefaultValidator,
336 const wxString& name = wxPyCheckBoxNameStr);
338 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
339 %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)"
343 void SetValue(const bool state);
346 //----------------------------------------------------------------------
348 class wxChoice : public wxControlWithItems {
350 wxChoice(wxWindow *parent, wxWindowID id,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 int LCOUNT=0, wxString* choices=NULL,
355 const wxValidator& validator = wxDefaultValidator,
356 const wxString& name = wxPyChoiceNameStr);
357 %name(wxPreChoice)wxChoice();
359 bool Create(wxWindow *parent, wxWindowID id,
360 const wxPoint& pos = wxDefaultPosition,
361 const wxSize& size = wxDefaultSize,
362 int LCOUNT=0, wxString* choices=NULL,
364 const wxValidator& validator = wxDefaultValidator,
365 const wxString& name = wxPyChoiceNameStr);
367 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
368 %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)"
373 void SetColumns(const int n = 1);
374 void SetSelection(const int n);
375 void SetStringSelection(const wxString& string);
376 void SetString(int n, const wxString& s);
378 %pragma(python) addtoclass = "
379 Select = SetSelection
383 //----------------------------------------------------------------------
385 // wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or even
386 // wxControlWithItems, so we have to duplicate the methods here... <blech!>
387 // wxMac's inheritace is weird too so we'll fake it with this one too.
390 class wxComboBox : public wxControl
393 wxComboBox(wxWindow* parent, wxWindowID id,
394 const wxString& value = wxPyEmptyString,
395 const wxPoint& pos = wxDefaultPosition,
396 const wxSize& size = wxDefaultSize,
397 int LCOUNT=0, wxString* choices=NULL,
399 const wxValidator& validator = wxDefaultValidator,
400 const wxString& name = wxPyComboBoxNameStr);
401 %name(wxPreComboBox)wxComboBox();
403 bool Create(wxWindow* parent, wxWindowID id,
404 const wxString& value = wxPyEmptyString,
405 const wxPoint& pos = wxDefaultPosition,
406 const wxSize& size = wxDefaultSize,
407 int LCOUNT=0, wxString* choices=NULL,
409 const wxValidator& validator = wxDefaultValidator,
410 const wxString& name = wxPyComboBoxNameStr);
412 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
413 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
417 long GetInsertionPoint();
418 long GetLastPosition();
421 void Replace(long from, long to, const wxString& text);
422 void Remove(long from, long to);
423 void SetInsertionPoint(long pos);
424 void SetInsertionPointEnd();
425 void SetSelection(int n);
426 %name(SetMark)void SetSelection(long from, long to);
427 void SetValue(const wxString& text);
428 void SetEditable(bool editable);
435 %pragma(python) addtoclass = "Number = GetCount"
436 wxString GetString(int n);
437 int FindString(const wxString& s);
439 //void SetString(int n, const wxString& s); *** No equivalent for wxGTK!!!
441 // void Select(int n);
442 %pragma(python) addtoclass = "Select = SetSelection"
445 wxString GetStringSelection() const;
447 // void Append(const wxString& item);
448 // void Append(const wxString& item, char* clientData);
449 // char* GetClientData(const int n);
450 // void SetClientData(const int n, char* data);
452 void Append(const wxString& item, PyObject* clientData=NULL) {
454 wxPyClientData* data = new wxPyClientData(clientData);
455 self->Append(item, data);
460 PyObject* GetClientData(int n) {
461 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
463 Py_INCREF(data->m_obj);
471 void SetClientData(int n, PyObject* clientData) {
472 wxPyClientData* data = new wxPyClientData(clientData);
473 self->SetClientObject(n, data);
482 // MSW's version derives from wxChoice
484 class wxComboBox : public wxChoice {
486 wxComboBox(wxWindow* parent, wxWindowID id,
487 const wxString& value = wxPyEmptyString,
488 const wxPoint& pos = wxDefaultPosition,
489 const wxSize& size = wxDefaultSize,
490 int LCOUNT=0, wxString* choices=NULL,
492 const wxValidator& validator = wxDefaultValidator,
493 const wxString& name = wxPyComboBoxNameStr);
494 %name(wxPreComboBox)wxComboBox();
496 bool Create(wxWindow* parent, wxWindowID id,
497 const wxString& value = wxPyEmptyString,
498 const wxPoint& pos = wxDefaultPosition,
499 const wxSize& size = wxDefaultSize,
500 int LCOUNT=0, wxString* choices=NULL,
502 const wxValidator& validator = wxDefaultValidator,
503 const wxString& name = wxPyComboBoxNameStr);
505 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
506 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
510 long GetInsertionPoint();
511 long GetLastPosition();
514 void Replace(long from, long to, const wxString& text);
515 void Remove(long from, long to);
516 void SetInsertionPoint(long pos);
517 void SetInsertionPointEnd();
518 void SetSelection(int n);
519 %name(SetMark)void SetSelection(long from, long to);
520 void SetValue(const wxString& text);
521 void SetEditable(bool editable);
526 //----------------------------------------------------------------------
528 class wxGauge : public wxControl {
530 wxGauge(wxWindow* parent, wxWindowID id, int range,
531 const wxPoint& pos = wxDefaultPosition,
532 const wxSize& size = wxDefaultSize,
533 long style = wxGA_HORIZONTAL,
534 const wxValidator& validator = wxDefaultValidator,
535 const wxString& name = wxPyGaugeNameStr);
536 %name(wxPreGauge)wxGauge();
538 bool Create(wxWindow* parent, wxWindowID id, int range,
539 const wxPoint& pos = wxDefaultPosition,
540 const wxSize& size = wxDefaultSize,
541 long style = wxGA_HORIZONTAL,
542 const wxValidator& validator = wxDefaultValidator,
543 const wxString& name = wxPyGaugeNameStr);
545 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
546 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
550 int GetShadowWidth();
552 void SetBezelFace(int width);
553 void SetRange(int range);
554 void SetShadowWidth(int width);
555 void SetValue(int pos);
558 //----------------------------------------------------------------------
560 class wxStaticBox : public wxControl {
562 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
563 const wxPoint& pos = wxDefaultPosition,
564 const wxSize& size = wxDefaultSize,
566 const wxString& name = wxPyStaticBoxNameStr);
567 %name(wxPreStaticBox)wxStaticBox();
569 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
570 const wxPoint& pos = wxDefaultPosition,
571 const wxSize& size = wxDefaultSize,
573 const wxString& name = wxPyStaticBoxNameStr);
575 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
576 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
580 //----------------------------------------------------------------------
583 class wxStaticLine : public wxControl {
585 wxStaticLine( wxWindow *parent, wxWindowID id,
586 const wxPoint &pos = wxDefaultPosition,
587 const wxSize &size = wxDefaultSize,
588 long style = wxLI_HORIZONTAL,
589 const wxString& name = wxPyStaticTextNameStr);
590 %name(wxPreStaticLine)wxStaticLine();
592 bool Create( wxWindow *parent, wxWindowID id,
593 const wxPoint &pos = wxDefaultPosition,
594 const wxSize &size = wxDefaultSize,
595 long style = wxLI_HORIZONTAL,
596 const wxString& name = wxPyStaticTextNameStr);
598 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
599 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
603 //----------------------------------------------------------------------
605 class wxStaticText : public wxControl {
607 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
608 const wxPoint& pos = wxDefaultPosition,
609 const wxSize& size = wxDefaultSize,
611 const wxString& name = wxPyStaticTextNameStr);
612 %name(wxPreStaticText)wxStaticText();
614 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
615 const wxPoint& pos = wxDefaultPosition,
616 const wxSize& size = wxDefaultSize,
618 const wxString& name = wxPyStaticTextNameStr);
620 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
621 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
624 void SetLabel(const wxString& label);
627 //----------------------------------------------------------------------
629 class wxListBox : public wxControlWithItems {
631 wxListBox(wxWindow* parent, wxWindowID id,
632 const wxPoint& pos = wxDefaultPosition,
633 const wxSize& size = wxDefaultSize,
634 int LCOUNT, wxString* choices = NULL,
636 const wxValidator& validator = wxDefaultValidator,
637 const wxString& name = wxPyListBoxNameStr);
638 %name(wxPreListBox)wxListBox();
640 bool Create(wxWindow* parent, wxWindowID id,
641 const wxPoint& pos = wxDefaultPosition,
642 const wxSize& size = wxDefaultSize,
643 int LCOUNT, wxString* choices = NULL,
645 const wxValidator& validator = wxDefaultValidator,
646 const wxString& name = wxPyListBoxNameStr);
648 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
649 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
652 void Deselect(int n);
654 // int GetSelections(int **selections);
656 PyObject* GetSelections() {
658 self->GetSelections(lst);
659 PyObject *tup = PyTuple_New(lst.GetCount());
660 for(size_t i=0; i<lst.GetCount(); i++) {
661 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
668 void InsertItems(int LCOUNT, wxString* choices, int pos);
670 bool IsSelected(const int n);
671 bool Selected(const int n);
672 void Set(int LCOUNT, wxString* choices);
673 void SetFirstItem(int n);
674 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
675 void SetSelection(int n, bool select = TRUE);
676 void SetString(int n, const wxString& string);
677 void SetStringSelection(const wxString& string, bool select = TRUE);
681 //----------------------------------------------------------------------
683 class wxCheckListBox : public wxListBox {
685 wxCheckListBox(wxWindow *parent, wxWindowID id,
686 const wxPoint& pos = wxDefaultPosition,
687 const wxSize& size = wxDefaultSize,
689 wxString* choices = NULL,
691 const wxValidator& validator = wxDefaultValidator,
692 const wxString& name = wxPyListBoxNameStr);
693 %name(wxPreCheckListBox)wxCheckListBox();
695 bool Create(wxWindow *parent, wxWindowID id,
696 const wxPoint& pos = wxDefaultPosition,
697 const wxSize& size = wxDefaultSize,
699 wxString* choices = NULL,
701 const wxValidator& validator = wxDefaultValidator,
702 const wxString& name = wxPyListBoxNameStr);
704 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
705 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
707 bool IsChecked(int uiIndex);
708 void Check(int uiIndex, int bCheck = TRUE);
709 void InsertItems(int LCOUNT, wxString* choices, int pos);
715 // return the index of the item at this position or wxNOT_FOUND
716 int HitTest(const wxPoint& pt) const;
717 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
721 //----------------------------------------------------------------------
728 wxTextAttr(const wxColour& colText = wxNullColour,
729 const wxColour& colBack = wxNullColour,
730 const wxFont& font = wxNullFont);
734 void SetTextColour(const wxColour& colText);
735 void SetBackgroundColour(const wxColour& colBack);
736 void SetFont(const wxFont& font);
739 bool HasTextColour() const;
740 bool HasBackgroundColour() const;
741 bool HasFont() const;
743 wxColour GetTextColour() const;
744 wxColour GetBackgroundColour() const;
745 wxFont GetFont() const;
747 // returns false if we have any attributes set, true otherwise
750 // return the attribute having the valid font and colours: it uses the
751 // attributes set in attr and falls back first to attrDefault and then to
752 // the text control font/colours for those attributes which are not set
753 static wxTextAttr Combine(const wxTextAttr& attr,
754 const wxTextAttr& attrDef,
755 const wxTextCtrl *text);
760 class wxTextCtrl : public wxControl {
762 wxTextCtrl(wxWindow* parent, wxWindowID id,
763 const wxString& value = wxPyEmptyString,
764 const wxPoint& pos = wxDefaultPosition,
765 const wxSize& size = wxDefaultSize,
767 const wxValidator& validator = wxDefaultValidator,
768 const wxString& name = wxPyTextCtrlNameStr);
769 %name(wxPreTextCtrl)wxTextCtrl();
771 bool Create(wxWindow* parent, wxWindowID id,
772 const wxString& value = wxPyEmptyString,
773 const wxPoint& pos = wxDefaultPosition,
774 const wxSize& size = wxDefaultSize,
776 const wxValidator& validator = wxDefaultValidator,
777 const wxString& name = wxPyTextCtrlNameStr);
779 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
780 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
783 wxString GetValue() const;
784 void SetValue(const wxString& value);
786 wxString GetRange(long from, long to);
788 int GetLineLength(long lineNo) const;
789 wxString GetLineText(long lineNo) const;
790 int GetNumberOfLines() const;
792 bool IsModified() const;
793 bool IsEditable() const;
795 // If the return values from and to are the same, there is no selection.
796 void GetSelection(long* OUTPUT, long* OUTPUT) const;
797 wxString GetStringSelection();
800 void Replace(long from, long to, const wxString& value);
801 void Remove(long from, long to);
803 // load/save the controls contents from/to the file
804 bool LoadFile(const wxString& file);
805 bool SaveFile(const wxString& file = wxPyEmptyString);
807 // clears the dirty flag
810 // set the max number of characters which may be entered in a single line
812 void SetMaxLength(unsigned long len);
814 // writing text inserts it at the current position, appending always
815 // inserts it at the end
816 void WriteText(const wxString& text);
817 void AppendText(const wxString& text);
819 // insert the character which would have resulted from this key event,
820 // return TRUE if anything has been inserted
821 bool EmulateKeyPress(const wxKeyEvent& event);
823 // text control under some platforms supports the text styles: these
824 // methods allow to apply the given text style to the given selection or to
825 // set/get the style which will be used for all appended text
826 bool SetStyle(long start, long end, const wxTextAttr& style);
827 bool SetDefaultStyle(const wxTextAttr& style);
828 const wxTextAttr& GetDefaultStyle() const;
830 // translate between the position (which is just an index in the text ctrl
831 // considering all its contents as a single strings) and (x, y) coordinates
832 // which represent column and line.
833 long XYToPosition(long x, long y) const;
834 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
836 //bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
837 // TODO: check return value, raise exception.
839 void ShowPosition(long pos);
841 // Clipboard operations
846 bool CanCopy() const;
848 bool CanPaste() const;
854 bool CanUndo() const;
855 bool CanRedo() const;
858 void SetInsertionPoint(long pos);
859 void SetInsertionPointEnd();
860 long GetInsertionPoint() const;
861 long GetLastPosition() const;
863 void SetSelection(long from, long to);
865 void SetEditable(bool editable);
872 void write(const wxString& text) {
873 self->AppendText(text);
877 // TODO: replace this when the method is really added to wxTextCtrl
879 wxString GetString(long from, long to) {
880 return self->GetValue().Mid(from, to - from);
885 //----------------------------------------------------------------------
887 class wxScrollBar : public wxControl {
889 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
890 const wxPoint& pos = wxDefaultPosition,
891 const wxSize& size = wxDefaultSize,
892 long style = wxSB_HORIZONTAL,
893 const wxValidator& validator = wxDefaultValidator,
894 const wxString& name = wxPyScrollBarNameStr);
895 %name(wxPreScrollBar)wxScrollBar();
897 bool Create(wxWindow* parent, wxWindowID id = -1,
898 const wxPoint& pos = wxDefaultPosition,
899 const wxSize& size = wxDefaultSize,
900 long style = wxSB_HORIZONTAL,
901 const wxValidator& validator = wxDefaultValidator,
902 const wxString& name = wxPyScrollBarNameStr);
904 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
905 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
909 int GetThumbPosition();
911 %name(GetThumbLength) int GetThumbSize(); // to match the docs
915 void SetThumbPosition(int viewStart);
916 void SetScrollbar(int position, int thumbSize,
917 int range, int pageSize,
918 bool refresh = TRUE);
921 //----------------------------------------------------------------------
923 class wxSpinButton : public wxControl {
925 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
926 const wxPoint& pos = wxDefaultPosition,
927 const wxSize& size = wxDefaultSize,
928 long style = wxSP_HORIZONTAL,
929 const wxString& name = wxPySPIN_BUTTON_NAME);
930 %name(wxPreSpinButton)wxSpinButton();
932 bool Create(wxWindow* parent, wxWindowID id = -1,
933 const wxPoint& pos = wxDefaultPosition,
934 const wxSize& size = wxDefaultSize,
935 long style = wxSP_HORIZONTAL,
936 const wxString& name = wxPySPIN_BUTTON_NAME);
938 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
939 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
944 void SetRange(int min, int max);
945 void SetValue(int value);
948 //----------------------------------------------------------------------
950 class wxStaticBitmap : public wxControl {
952 wxStaticBitmap(wxWindow* parent, wxWindowID id,
953 const wxBitmap& bitmap,
954 const wxPoint& pos = wxDefaultPosition,
955 const wxSize& size = wxDefaultSize,
957 const wxString& name = wxPyStaticBitmapNameStr);
958 %name(wxPreStaticBitmap)wxStaticBitmap();
960 bool Create(wxWindow* parent, wxWindowID id,
961 const wxBitmap& bitmap,
962 const wxPoint& pos = wxDefaultPosition,
963 const wxSize& size = wxDefaultSize,
965 const wxString& name = wxPyStaticBitmapNameStr);
967 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
968 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
970 wxBitmap GetBitmap();
971 void SetBitmap(const wxBitmap& bitmap);
972 void SetIcon(const wxIcon& icon);
975 //----------------------------------------------------------------------
977 class wxRadioBox : public wxControl {
979 wxRadioBox(wxWindow* parent, wxWindowID id,
980 const wxString& label,
981 const wxPoint& point = wxDefaultPosition,
982 const wxSize& size = wxDefaultSize,
983 int LCOUNT = 0, wxString* choices = NULL,
984 int majorDimension = 0,
985 long style = wxRA_HORIZONTAL,
986 const wxValidator& validator = wxDefaultValidator,
987 const wxString& name = wxPyRadioBoxNameStr);
988 %name(wxPreRadioBox)wxRadioBox();
990 bool Create(wxWindow* parent, wxWindowID id,
991 const wxString& label,
992 const wxPoint& point = wxDefaultPosition,
993 const wxSize& size = wxDefaultSize,
994 int LCOUNT = 0, wxString* choices = NULL,
995 int majorDimension = 0,
996 long style = wxRA_HORIZONTAL,
997 const wxValidator& validator = wxDefaultValidator,
998 const wxString& name = wxPyRadioBoxNameStr);
1000 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1001 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
1003 void Enable(bool enable);
1004 %name(EnableItem)void Enable(int n, bool enable);
1005 int FindString(const wxString& string);
1007 wxString GetString(int n);
1008 void SetString(int n, const wxString& label);
1009 %pragma(python) addtoclass = "
1010 GetItemLabel = GetString
1011 SetItemLabel = SetString
1014 int GetColumnCount();
1016 int GetNextItem(int item, wxDirection dir, long style);
1020 wxString GetStringSelection();
1022 %pragma(python) addtoclass = "Number = GetCount"
1024 void SetSelection(int n);
1025 void SetStringSelection(const wxString& string);
1026 void Show(bool show);
1027 %name(ShowItem)void Show(int item, bool show);
1030 //----------------------------------------------------------------------
1032 class wxRadioButton : public wxControl {
1034 wxRadioButton(wxWindow* parent, wxWindowID id,
1035 const wxString& label,
1036 const wxPoint& pos = wxDefaultPosition,
1037 const wxSize& size = wxDefaultSize,
1039 const wxValidator& validator = wxDefaultValidator,
1040 const wxString& name = wxPyRadioButtonNameStr);
1041 %name(wxPreRadioButton)wxRadioButton();
1043 bool Create(wxWindow* parent, wxWindowID id,
1044 const wxString& label,
1045 const wxPoint& pos = wxDefaultPosition,
1046 const wxSize& size = wxDefaultSize,
1048 const wxValidator& validator = wxDefaultValidator,
1049 const wxString& name = wxPyRadioButtonNameStr);
1051 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1052 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
1055 void SetValue(bool value);
1058 //----------------------------------------------------------------------
1060 class wxSlider : public wxControl {
1062 wxSlider(wxWindow* parent, wxWindowID id,
1063 int value, int minValue, int maxValue,
1064 const wxPoint& point = wxDefaultPosition,
1065 const wxSize& size = wxDefaultSize,
1066 long style = wxSL_HORIZONTAL,
1067 const wxValidator& validator = wxDefaultValidator,
1068 const wxString& name = wxPySliderNameStr);
1069 %name(wxPreSlider)wxSlider();
1071 bool Create(wxWindow* parent, wxWindowID id,
1072 int value, int minValue, int maxValue,
1073 const wxPoint& point = wxDefaultPosition,
1074 const wxSize& size = wxDefaultSize,
1075 long style = wxSL_HORIZONTAL,
1076 const wxValidator& validator = wxDefaultValidator,
1077 const wxString& name = wxPySliderNameStr);
1079 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1080 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
1090 int GetThumbLength();
1093 void SetRange(int minValue, int maxValue);
1094 void SetTickFreq(int n, int pos);
1095 void SetLineSize(int lineSize);
1096 void SetPageSize(int pageSize);
1097 void SetSelection(int startPos, int endPos);
1098 void SetThumbLength(int len);
1099 void SetTick(int tickPos);
1100 void SetValue(int value);
1104 //----------------------------------------------------------------------
1106 class wxSpinCtrl : public wxSpinButton {
1108 wxSpinCtrl(wxWindow *parent,
1110 const wxString& value = wxPyEmptyString,
1111 const wxPoint& pos = wxDefaultPosition,
1112 const wxSize& size = wxDefaultSize,
1113 long style = wxSP_ARROW_KEYS,
1114 int min = 0, int max = 100, int initial = 0,
1115 const wxString& name = wxPySpinCtrlNameStr);
1116 %name(wxPreSpinCtrl)wxSpinCtrl();
1118 bool Create(wxWindow *parent,
1120 const wxString& value = wxPyEmptyString,
1121 const wxPoint& pos = wxDefaultPosition,
1122 const wxSize& size = wxDefaultSize,
1123 long style = wxSP_ARROW_KEYS,
1124 int min = 0, int max = 100, int initial = 0,
1125 const wxString& name = wxPySpinCtrlNameStr);
1127 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1128 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
1133 void SetRange(int min, int max);
1134 void SetValue(int value);
1137 void SetSelection(long from, long to) {
1141 void SetSelection(long from, long to);
1146 //----------------------------------------------------------------------
1149 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1151 class wxToggleButton : public wxControl {
1153 wxToggleButton(wxWindow *parent,
1155 const wxString& label,
1156 const wxPoint& pos = wxDefaultPosition,
1157 const wxSize& size = wxDefaultSize,
1159 const wxValidator& validator = wxDefaultValidator,
1160 const wxString& name = wxPyCheckBoxNameStr);
1161 %name(wxPreToggleButton)wxToggleButton();
1163 bool Create(wxWindow *parent,
1165 const wxString& label,
1166 const wxPoint& pos = wxDefaultPosition,
1167 const wxSize& size = wxDefaultSize,
1169 const wxValidator& validator = wxDefaultValidator,
1170 const wxString& name = wxPyCheckBoxNameStr);
1172 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1173 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
1175 void SetValue(bool value);
1176 bool GetValue() const ;
1177 void SetLabel(const wxString& label);
1183 //----------------------------------------------------------------------
1184 //----------------------------------------------------------------------
1185 //----------------------------------------------------------------------