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 //----------------------------------------------------------------------
324 wxCHK_ALLOW_3RD_STATE_FOR_USER,
331 wxCHK_UNDETERMINED /* 3-state checkbox only */
335 class wxCheckBox : public wxControl {
337 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
338 const wxPoint& pos = wxDefaultPosition,
339 const wxSize& size = wxDefaultSize,
341 const wxValidator& validator = wxDefaultValidator,
342 const wxString& name = wxPyCheckBoxNameStr);
343 %name(wxPreCheckBox)wxCheckBox();
345 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
346 const wxPoint& pos = wxDefaultPosition,
347 const wxSize& size = wxDefaultSize,
349 const wxValidator& validator = wxDefaultValidator,
350 const wxString& name = wxPyCheckBoxNameStr);
352 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
353 %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)"
357 void SetValue(const bool state);
358 wxCheckBoxState Get3StateValue() const;
359 void Set3StateValue(wxCheckBoxState state);
360 bool Is3State() const;
361 bool Is3rdStateAllowedForUser() const;
364 //----------------------------------------------------------------------
366 class wxChoice : public wxControlWithItems {
368 wxChoice(wxWindow *parent, wxWindowID id,
369 const wxPoint& pos = wxDefaultPosition,
370 const wxSize& size = wxDefaultSize,
371 int LCOUNT=0, wxString* choices=NULL,
373 const wxValidator& validator = wxDefaultValidator,
374 const wxString& name = wxPyChoiceNameStr);
375 %name(wxPreChoice)wxChoice();
377 bool Create(wxWindow *parent, wxWindowID id,
378 const wxPoint& pos = wxDefaultPosition,
379 const wxSize& size = wxDefaultSize,
380 int LCOUNT=0, wxString* choices=NULL,
382 const wxValidator& validator = wxDefaultValidator,
383 const wxString& name = wxPyChoiceNameStr);
385 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
386 %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)"
391 void SetColumns(const int n = 1);
392 void SetSelection(const int n);
393 void SetStringSelection(const wxString& string);
394 void SetString(int n, const wxString& s);
396 %pragma(python) addtoclass = "
397 Select = SetSelection
401 //----------------------------------------------------------------------
403 // wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or even
404 // wxControlWithItems, so we have to duplicate the methods here... <blech!>
405 // wxMac's inheritace is weird too so we'll fake it with this one too.
408 class wxComboBox : public wxControl
411 wxComboBox(wxWindow* parent, wxWindowID id,
412 const wxString& value = wxPyEmptyString,
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
415 int LCOUNT=0, wxString* choices=NULL,
417 const wxValidator& validator = wxDefaultValidator,
418 const wxString& name = wxPyComboBoxNameStr);
419 %name(wxPreComboBox)wxComboBox();
421 bool Create(wxWindow* parent, wxWindowID id,
422 const wxString& value = wxPyEmptyString,
423 const wxPoint& pos = wxDefaultPosition,
424 const wxSize& size = wxDefaultSize,
425 int LCOUNT=0, wxString* choices=NULL,
427 const wxValidator& validator = wxDefaultValidator,
428 const wxString& name = wxPyComboBoxNameStr);
430 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
431 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
435 long GetInsertionPoint();
436 long GetLastPosition();
439 void Replace(long from, long to, const wxString& text);
440 void Remove(long from, long to);
441 void SetInsertionPoint(long pos);
442 void SetInsertionPointEnd();
443 void SetSelection(int n);
444 %name(SetMark)void SetSelection(long from, long to);
445 void SetValue(const wxString& text);
446 void SetEditable(bool editable);
453 %pragma(python) addtoclass = "Number = GetCount"
454 wxString GetString(int n);
455 int FindString(const wxString& s);
457 //void SetString(int n, const wxString& s); *** No equivalent for wxGTK!!!
459 // void Select(int n);
460 %pragma(python) addtoclass = "Select = SetSelection"
463 wxString GetStringSelection() const;
465 // void Append(const wxString& item);
466 // void Append(const wxString& item, char* clientData);
467 // char* GetClientData(const int n);
468 // void SetClientData(const int n, char* data);
470 void Append(const wxString& item, PyObject* clientData=NULL) {
472 wxPyClientData* data = new wxPyClientData(clientData);
473 self->Append(item, data);
478 PyObject* GetClientData(int n) {
480 wxPyClientData* data = (wxPyClientData*)self->wxItemContainer::GetClientObject(n);
482 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
485 Py_INCREF(data->m_obj);
493 void SetClientData(int n, PyObject* clientData) {
494 wxPyClientData* data = new wxPyClientData(clientData);
496 self->wxItemContainer::SetClientObject(n, data);
498 self->SetClientObject(n, data);
508 // MSW's version derives from wxChoice
510 class wxComboBox : public wxChoice {
512 wxComboBox(wxWindow* parent, wxWindowID id,
513 const wxString& value = wxPyEmptyString,
514 const wxPoint& pos = wxDefaultPosition,
515 const wxSize& size = wxDefaultSize,
516 int LCOUNT=0, wxString* choices=NULL,
518 const wxValidator& validator = wxDefaultValidator,
519 const wxString& name = wxPyComboBoxNameStr);
520 %name(wxPreComboBox)wxComboBox();
522 bool Create(wxWindow* parent, wxWindowID id,
523 const wxString& value = wxPyEmptyString,
524 const wxPoint& pos = wxDefaultPosition,
525 const wxSize& size = wxDefaultSize,
526 int LCOUNT=0, wxString* choices=NULL,
528 const wxValidator& validator = wxDefaultValidator,
529 const wxString& name = wxPyComboBoxNameStr);
531 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
532 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
536 long GetInsertionPoint();
537 long GetLastPosition();
540 void Replace(long from, long to, const wxString& text);
541 void Remove(long from, long to);
542 void SetInsertionPoint(long pos);
543 void SetInsertionPointEnd();
544 void SetSelection(int n);
545 %name(SetMark)void SetSelection(long from, long to);
546 void SetValue(const wxString& text);
547 void SetEditable(bool editable);
552 //----------------------------------------------------------------------
554 class wxGauge : public wxControl {
556 wxGauge(wxWindow* parent, wxWindowID id, int range,
557 const wxPoint& pos = wxDefaultPosition,
558 const wxSize& size = wxDefaultSize,
559 long style = wxGA_HORIZONTAL,
560 const wxValidator& validator = wxDefaultValidator,
561 const wxString& name = wxPyGaugeNameStr);
562 %name(wxPreGauge)wxGauge();
564 bool Create(wxWindow* parent, wxWindowID id, int range,
565 const wxPoint& pos = wxDefaultPosition,
566 const wxSize& size = wxDefaultSize,
567 long style = wxGA_HORIZONTAL,
568 const wxValidator& validator = wxDefaultValidator,
569 const wxString& name = wxPyGaugeNameStr);
571 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
572 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
576 int GetShadowWidth();
578 bool IsVertical() const;
579 void SetBezelFace(int width);
580 void SetRange(int range);
581 void SetShadowWidth(int width);
582 void SetValue(int pos);
585 //----------------------------------------------------------------------
587 class wxStaticBox : public wxControl {
589 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
590 const wxPoint& pos = wxDefaultPosition,
591 const wxSize& size = wxDefaultSize,
593 const wxString& name = wxPyStaticBoxNameStr);
594 %name(wxPreStaticBox)wxStaticBox();
596 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
597 const wxPoint& pos = wxDefaultPosition,
598 const wxSize& size = wxDefaultSize,
600 const wxString& name = wxPyStaticBoxNameStr);
602 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
603 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
607 //----------------------------------------------------------------------
610 class wxStaticLine : public wxControl {
612 wxStaticLine( wxWindow *parent, wxWindowID id,
613 const wxPoint &pos = wxDefaultPosition,
614 const wxSize &size = wxDefaultSize,
615 long style = wxLI_HORIZONTAL,
616 const wxString& name = wxPyStaticTextNameStr);
617 %name(wxPreStaticLine)wxStaticLine();
619 bool Create( wxWindow *parent, wxWindowID id,
620 const wxPoint &pos = wxDefaultPosition,
621 const wxSize &size = wxDefaultSize,
622 long style = wxLI_HORIZONTAL,
623 const wxString& name = wxPyStaticTextNameStr);
625 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
626 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
630 //----------------------------------------------------------------------
632 class wxStaticText : public wxControl {
634 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
635 const wxPoint& pos = wxDefaultPosition,
636 const wxSize& size = wxDefaultSize,
638 const wxString& name = wxPyStaticTextNameStr);
639 %name(wxPreStaticText)wxStaticText();
641 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
642 const wxPoint& pos = wxDefaultPosition,
643 const wxSize& size = wxDefaultSize,
645 const wxString& name = wxPyStaticTextNameStr);
647 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
648 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
651 void SetLabel(const wxString& label);
654 //----------------------------------------------------------------------
656 class wxListBox : public wxControlWithItems {
658 wxListBox(wxWindow* parent, wxWindowID id,
659 const wxPoint& pos = wxDefaultPosition,
660 const wxSize& size = wxDefaultSize,
661 int LCOUNT, wxString* choices = NULL,
663 const wxValidator& validator = wxDefaultValidator,
664 const wxString& name = wxPyListBoxNameStr);
665 %name(wxPreListBox)wxListBox();
667 bool Create(wxWindow* parent, wxWindowID id,
668 const wxPoint& pos = wxDefaultPosition,
669 const wxSize& size = wxDefaultSize,
670 int LCOUNT, wxString* choices = NULL,
672 const wxValidator& validator = wxDefaultValidator,
673 const wxString& name = wxPyListBoxNameStr);
675 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
676 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
679 void Deselect(int n);
681 // int GetSelections(int **selections);
683 PyObject* GetSelections() {
685 self->GetSelections(lst);
686 PyObject *tup = PyTuple_New(lst.GetCount());
687 for(size_t i=0; i<lst.GetCount(); i++) {
688 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
695 void InsertItems(int LCOUNT, wxString* choices, int pos);
697 bool IsSelected(const int n);
698 bool Selected(const int n);
699 void Set(int LCOUNT, wxString* choices);
700 void SetFirstItem(int n);
701 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
702 void SetSelection(int n, bool select = TRUE);
703 void SetString(int n, const wxString& string);
704 void SetStringSelection(const wxString& string, bool select = TRUE);
708 //----------------------------------------------------------------------
710 class wxCheckListBox : public wxListBox {
712 wxCheckListBox(wxWindow *parent, wxWindowID id,
713 const wxPoint& pos = wxDefaultPosition,
714 const wxSize& size = wxDefaultSize,
716 wxString* choices = NULL,
718 const wxValidator& validator = wxDefaultValidator,
719 const wxString& name = wxPyListBoxNameStr);
720 %name(wxPreCheckListBox)wxCheckListBox();
722 bool Create(wxWindow *parent, wxWindowID id,
723 const wxPoint& pos = wxDefaultPosition,
724 const wxSize& size = wxDefaultSize,
726 wxString* choices = NULL,
728 const wxValidator& validator = wxDefaultValidator,
729 const wxString& name = wxPyListBoxNameStr);
731 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
732 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
734 bool IsChecked(int uiIndex);
735 void Check(int uiIndex, int bCheck = TRUE);
736 void InsertItems(int LCOUNT, wxString* choices, int pos);
742 // return the index of the item at this position or wxNOT_FOUND
743 int HitTest(const wxPoint& pt) const;
744 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
748 //----------------------------------------------------------------------
771 // Flags to indicate which attributes are being applied
772 wxTEXT_ATTR_TEXT_COLOUR,
773 wxTEXT_ATTR_BACKGROUND_COLOUR,
774 wxTEXT_ATTR_FONT_FACE,
775 wxTEXT_ATTR_FONT_SIZE,
776 wxTEXT_ATTR_FONT_WEIGHT,
777 wxTEXT_ATTR_FONT_ITALIC,
778 wxTEXT_ATTR_FONT_UNDERLINE,
780 wxTEXT_ATTR_ALIGNMENT,
781 wxTEXT_ATTR_LEFT_INDENT,
782 wxTEXT_ATTR_RIGHT_INDENT,
788 enum wxTextAttrAlignment
790 wxTEXT_ALIGNMENT_DEFAULT,
791 wxTEXT_ALIGNMENT_LEFT,
792 wxTEXT_ALIGNMENT_CENTRE,
793 wxTEXT_ALIGNMENT_CENTER,
794 wxTEXT_ALIGNMENT_RIGHT,
795 wxTEXT_ALIGNMENT_JUSTIFIED
805 wxTextAttr(const wxColour& colText = wxNullColour,
806 const wxColour& colBack = wxNullColour,
807 const wxFont& font = wxNullFont,
808 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
814 void SetTextColour(const wxColour& colText);
815 void SetBackgroundColour(const wxColour& colBack);
816 void SetFont(const wxFont& font);
817 void SetAlignment(wxTextAttrAlignment alignment);
818 void SetTabs(const wxArrayInt& tabs);
819 void SetLeftIndent(int indent);
820 void SetRightIndent(int indent);
821 void SetFlags(long flags);
824 bool HasTextColour() const;
825 bool HasBackgroundColour() const;
826 bool HasFont() const;
827 bool HasAlignment() const;
828 bool HasTabs() const;
829 bool HasLeftIndent() const;
830 bool HasRightIndent() const;
831 bool HasFlag(long flag) const;
833 wxColour GetTextColour() const;
834 wxColour GetBackgroundColour() const;
835 wxFont GetFont() const;
836 wxTextAttrAlignment GetAlignment();
837 const wxArrayInt& GetTabs() const;
838 long GetLeftIndent() const;
839 long GetRightIndent() const;
840 long GetFlags() const;
843 // returns false if we have any attributes set, true otherwise
846 // return the attribute having the valid font and colours: it uses the
847 // attributes set in attr and falls back first to attrDefault and then to
848 // the text control font/colours for those attributes which are not set
849 static wxTextAttr Combine(const wxTextAttr& attr,
850 const wxTextAttr& attrDef,
851 const wxTextCtrl *text);
856 class wxTextCtrl : public wxControl {
858 wxTextCtrl(wxWindow* parent, wxWindowID id,
859 const wxString& value = wxPyEmptyString,
860 const wxPoint& pos = wxDefaultPosition,
861 const wxSize& size = wxDefaultSize,
863 const wxValidator& validator = wxDefaultValidator,
864 const wxString& name = wxPyTextCtrlNameStr);
865 %name(wxPreTextCtrl)wxTextCtrl();
867 bool Create(wxWindow* parent, wxWindowID id,
868 const wxString& value = wxPyEmptyString,
869 const wxPoint& pos = wxDefaultPosition,
870 const wxSize& size = wxDefaultSize,
872 const wxValidator& validator = wxDefaultValidator,
873 const wxString& name = wxPyTextCtrlNameStr);
875 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
876 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
879 wxString GetValue() const;
880 void SetValue(const wxString& value);
882 wxString GetRange(long from, long to);
884 int GetLineLength(long lineNo) const;
885 wxString GetLineText(long lineNo) const;
886 int GetNumberOfLines() const;
888 bool IsModified() const;
889 bool IsEditable() const;
891 // If the return values from and to are the same, there is no selection.
892 void GetSelection(long* OUTPUT, long* OUTPUT) const;
893 wxString GetStringSelection();
896 void Replace(long from, long to, const wxString& value);
897 void Remove(long from, long to);
899 // load/save the controls contents from/to the file
900 bool LoadFile(const wxString& file);
901 bool SaveFile(const wxString& file = wxPyEmptyString);
903 // sets the dirty flag
904 virtual void MarkDirty() = 0;
906 // clears the dirty flag
909 // set the max number of characters which may be entered in a single line
911 void SetMaxLength(unsigned long len);
913 // writing text inserts it at the current position, appending always
914 // inserts it at the end
915 void WriteText(const wxString& text);
916 void AppendText(const wxString& text);
918 // insert the character which would have resulted from this key event,
919 // return TRUE if anything has been inserted
920 bool EmulateKeyPress(const wxKeyEvent& event);
922 // text control under some platforms supports the text styles: these
923 // methods allow to apply the given text style to the given selection or to
924 // set/get the style which will be used for all appended text
925 bool SetStyle(long start, long end, const wxTextAttr& style);
926 bool SetDefaultStyle(const wxTextAttr& style);
927 const wxTextAttr& GetDefaultStyle() const;
928 bool GetStyle(long position, wxTextAttr& style);
930 // translate between the position (which is just an index in the text ctrl
931 // considering all its contents as a single strings) and (x, y) coordinates
932 // which represent column and line.
933 long XYToPosition(long x, long y) const;
934 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
936 //bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
937 // TODO: check return value, raise exception.
939 void ShowPosition(long pos);
941 // Clipboard operations
946 bool CanCopy() const;
948 bool CanPaste() const;
954 bool CanUndo() const;
955 bool CanRedo() const;
958 void SetInsertionPoint(long pos);
959 void SetInsertionPointEnd();
960 long GetInsertionPoint() const;
961 long GetLastPosition() const;
963 void SetSelection(long from, long to);
965 void SetEditable(bool editable);
972 void write(const wxString& text) {
973 self->AppendText(text);
977 // TODO: replace this when the method is really added to wxTextCtrl
979 wxString GetString(long from, long to) {
980 return self->GetValue().Mid(from, to - from);
985 //----------------------------------------------------------------------
987 class wxScrollBar : public wxControl {
989 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
990 const wxPoint& pos = wxDefaultPosition,
991 const wxSize& size = wxDefaultSize,
992 long style = wxSB_HORIZONTAL,
993 const wxValidator& validator = wxDefaultValidator,
994 const wxString& name = wxPyScrollBarNameStr);
995 %name(wxPreScrollBar)wxScrollBar();
997 bool Create(wxWindow* parent, wxWindowID id = -1,
998 const wxPoint& pos = wxDefaultPosition,
999 const wxSize& size = wxDefaultSize,
1000 long style = wxSB_HORIZONTAL,
1001 const wxValidator& validator = wxDefaultValidator,
1002 const wxString& name = wxPyScrollBarNameStr);
1004 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1005 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
1009 int GetThumbPosition();
1011 %name(GetThumbLength) int GetThumbSize(); // to match the docs
1015 void SetThumbPosition(int viewStart);
1016 void SetScrollbar(int position, int thumbSize,
1017 int range, int pageSize,
1018 bool refresh = TRUE);
1021 //----------------------------------------------------------------------
1023 class wxSpinButton : public wxControl {
1025 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
1026 const wxPoint& pos = wxDefaultPosition,
1027 const wxSize& size = wxDefaultSize,
1028 long style = wxSP_HORIZONTAL,
1029 const wxString& name = wxPySPIN_BUTTON_NAME);
1030 %name(wxPreSpinButton)wxSpinButton();
1032 bool Create(wxWindow* parent, wxWindowID id = -1,
1033 const wxPoint& pos = wxDefaultPosition,
1034 const wxSize& size = wxDefaultSize,
1035 long style = wxSP_HORIZONTAL,
1036 const wxString& name = wxPySPIN_BUTTON_NAME);
1038 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1039 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
1044 void SetRange(int min, int max);
1045 void SetValue(int value);
1048 //----------------------------------------------------------------------
1050 class wxStaticBitmap : public wxControl {
1052 wxStaticBitmap(wxWindow* parent, wxWindowID id,
1053 const wxBitmap& bitmap,
1054 const wxPoint& pos = wxDefaultPosition,
1055 const wxSize& size = wxDefaultSize,
1057 const wxString& name = wxPyStaticBitmapNameStr);
1058 %name(wxPreStaticBitmap)wxStaticBitmap();
1060 bool Create(wxWindow* parent, wxWindowID id,
1061 const wxBitmap& bitmap,
1062 const wxPoint& pos = wxDefaultPosition,
1063 const wxSize& size = wxDefaultSize,
1065 const wxString& name = wxPyStaticBitmapNameStr);
1067 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1068 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
1070 wxBitmap GetBitmap();
1071 void SetBitmap(const wxBitmap& bitmap);
1072 void SetIcon(const wxIcon& icon);
1075 //----------------------------------------------------------------------
1077 class wxRadioBox : public wxControl {
1079 wxRadioBox(wxWindow* parent, wxWindowID id,
1080 const wxString& label,
1081 const wxPoint& point = wxDefaultPosition,
1082 const wxSize& size = wxDefaultSize,
1083 int LCOUNT = 0, wxString* choices = NULL,
1084 int majorDimension = 0,
1085 long style = wxRA_HORIZONTAL,
1086 const wxValidator& validator = wxDefaultValidator,
1087 const wxString& name = wxPyRadioBoxNameStr);
1088 %name(wxPreRadioBox)wxRadioBox();
1090 bool Create(wxWindow* parent, wxWindowID id,
1091 const wxString& label,
1092 const wxPoint& point = wxDefaultPosition,
1093 const wxSize& size = wxDefaultSize,
1094 int LCOUNT = 0, wxString* choices = NULL,
1095 int majorDimension = 0,
1096 long style = wxRA_HORIZONTAL,
1097 const wxValidator& validator = wxDefaultValidator,
1098 const wxString& name = wxPyRadioBoxNameStr);
1100 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1101 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
1103 void Enable(bool enable);
1104 %name(EnableItem)void Enable(int n, bool enable);
1105 int FindString(const wxString& string);
1107 wxString GetString(int n);
1108 void SetString(int n, const wxString& label);
1109 %pragma(python) addtoclass = "
1110 GetItemLabel = GetString
1111 SetItemLabel = SetString
1114 int GetColumnCount();
1116 int GetNextItem(int item, wxDirection dir, long style);
1120 wxString GetStringSelection();
1122 %pragma(python) addtoclass = "Number = GetCount"
1124 void SetSelection(int n);
1125 void SetStringSelection(const wxString& string);
1126 void Show(bool show);
1127 %name(ShowItem)void Show(int item, bool show);
1130 //----------------------------------------------------------------------
1132 class wxRadioButton : public wxControl {
1134 wxRadioButton(wxWindow* parent, wxWindowID id,
1135 const wxString& label,
1136 const wxPoint& pos = wxDefaultPosition,
1137 const wxSize& size = wxDefaultSize,
1139 const wxValidator& validator = wxDefaultValidator,
1140 const wxString& name = wxPyRadioButtonNameStr);
1141 %name(wxPreRadioButton)wxRadioButton();
1143 bool Create(wxWindow* parent, wxWindowID id,
1144 const wxString& label,
1145 const wxPoint& pos = wxDefaultPosition,
1146 const wxSize& size = wxDefaultSize,
1148 const wxValidator& validator = wxDefaultValidator,
1149 const wxString& name = wxPyRadioButtonNameStr);
1151 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1152 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
1155 void SetValue(bool value);
1158 //----------------------------------------------------------------------
1160 class wxSlider : public wxControl {
1162 wxSlider(wxWindow* parent, wxWindowID id,
1163 int value, int minValue, int maxValue,
1164 const wxPoint& point = wxDefaultPosition,
1165 const wxSize& size = wxDefaultSize,
1166 long style = wxSL_HORIZONTAL,
1167 const wxValidator& validator = wxDefaultValidator,
1168 const wxString& name = wxPySliderNameStr);
1169 %name(wxPreSlider)wxSlider();
1171 bool Create(wxWindow* parent, wxWindowID id,
1172 int value, int minValue, int maxValue,
1173 const wxPoint& point = wxDefaultPosition,
1174 const wxSize& size = wxDefaultSize,
1175 long style = wxSL_HORIZONTAL,
1176 const wxValidator& validator = wxDefaultValidator,
1177 const wxString& name = wxPySliderNameStr);
1179 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1180 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
1190 int GetThumbLength();
1193 void SetRange(int minValue, int maxValue);
1194 void SetTickFreq(int n, int pos);
1195 void SetLineSize(int lineSize);
1196 void SetPageSize(int pageSize);
1197 void SetSelection(int startPos, int endPos);
1198 void SetThumbLength(int len);
1199 void SetTick(int tickPos);
1200 void SetValue(int value);
1204 //----------------------------------------------------------------------
1206 class wxSpinCtrl : public wxSpinButton {
1208 wxSpinCtrl(wxWindow *parent,
1210 const wxString& value = wxPyEmptyString,
1211 const wxPoint& pos = wxDefaultPosition,
1212 const wxSize& size = wxDefaultSize,
1213 long style = wxSP_ARROW_KEYS,
1214 int min = 0, int max = 100, int initial = 0,
1215 const wxString& name = wxPySpinCtrlNameStr);
1216 %name(wxPreSpinCtrl)wxSpinCtrl();
1218 bool Create(wxWindow *parent,
1220 const wxString& value = wxPyEmptyString,
1221 const wxPoint& pos = wxDefaultPosition,
1222 const wxSize& size = wxDefaultSize,
1223 long style = wxSP_ARROW_KEYS,
1224 int min = 0, int max = 100, int initial = 0,
1225 const wxString& name = wxPySpinCtrlNameStr);
1227 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1228 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
1233 void SetRange(int min, int max);
1234 void SetValue(int value);
1237 void SetSelection(long from, long to) {
1241 void SetSelection(long from, long to);
1246 //----------------------------------------------------------------------
1249 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1251 class wxToggleButton : public wxControl {
1253 wxToggleButton(wxWindow *parent,
1255 const wxString& label,
1256 const wxPoint& pos = wxDefaultPosition,
1257 const wxSize& size = wxDefaultSize,
1259 const wxValidator& validator = wxDefaultValidator,
1260 const wxString& name = wxPyCheckBoxNameStr);
1261 %name(wxPreToggleButton)wxToggleButton();
1263 bool Create(wxWindow *parent,
1265 const wxString& label,
1266 const wxPoint& pos = wxDefaultPosition,
1267 const wxSize& size = wxDefaultSize,
1269 const wxValidator& validator = wxDefaultValidator,
1270 const wxString& name = wxPyCheckBoxNameStr);
1272 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1273 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
1275 void SetValue(bool value);
1276 bool GetValue() const ;
1277 void SetLabel(const wxString& label);
1283 //----------------------------------------------------------------------
1284 //----------------------------------------------------------------------
1285 //----------------------------------------------------------------------