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) {
462 wxPyClientData* data = (wxPyClientData*)self->wxItemContainer::GetClientObject(n);
464 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
467 Py_INCREF(data->m_obj);
475 void SetClientData(int n, PyObject* clientData) {
476 wxPyClientData* data = new wxPyClientData(clientData);
478 self->wxItemContainer::SetClientObject(n, data);
480 self->SetClientObject(n, data);
490 // MSW's version derives from wxChoice
492 class wxComboBox : public wxChoice {
494 wxComboBox(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);
502 %name(wxPreComboBox)wxComboBox();
504 bool Create(wxWindow* parent, wxWindowID id,
505 const wxString& value = wxPyEmptyString,
506 const wxPoint& pos = wxDefaultPosition,
507 const wxSize& size = wxDefaultSize,
508 int LCOUNT=0, wxString* choices=NULL,
510 const wxValidator& validator = wxDefaultValidator,
511 const wxString& name = wxPyComboBoxNameStr);
513 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
514 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
518 long GetInsertionPoint();
519 long GetLastPosition();
522 void Replace(long from, long to, const wxString& text);
523 void Remove(long from, long to);
524 void SetInsertionPoint(long pos);
525 void SetInsertionPointEnd();
526 void SetSelection(int n);
527 %name(SetMark)void SetSelection(long from, long to);
528 void SetValue(const wxString& text);
529 void SetEditable(bool editable);
534 //----------------------------------------------------------------------
536 class wxGauge : public wxControl {
538 wxGauge(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);
544 %name(wxPreGauge)wxGauge();
546 bool Create(wxWindow* parent, wxWindowID id, int range,
547 const wxPoint& pos = wxDefaultPosition,
548 const wxSize& size = wxDefaultSize,
549 long style = wxGA_HORIZONTAL,
550 const wxValidator& validator = wxDefaultValidator,
551 const wxString& name = wxPyGaugeNameStr);
553 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
554 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
558 int GetShadowWidth();
560 bool IsVertical() const;
561 void SetBezelFace(int width);
562 void SetRange(int range);
563 void SetShadowWidth(int width);
564 void SetValue(int pos);
567 //----------------------------------------------------------------------
569 class wxStaticBox : public wxControl {
571 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
572 const wxPoint& pos = wxDefaultPosition,
573 const wxSize& size = wxDefaultSize,
575 const wxString& name = wxPyStaticBoxNameStr);
576 %name(wxPreStaticBox)wxStaticBox();
578 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
579 const wxPoint& pos = wxDefaultPosition,
580 const wxSize& size = wxDefaultSize,
582 const wxString& name = wxPyStaticBoxNameStr);
584 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
585 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
589 //----------------------------------------------------------------------
592 class wxStaticLine : public wxControl {
594 wxStaticLine( wxWindow *parent, wxWindowID id,
595 const wxPoint &pos = wxDefaultPosition,
596 const wxSize &size = wxDefaultSize,
597 long style = wxLI_HORIZONTAL,
598 const wxString& name = wxPyStaticTextNameStr);
599 %name(wxPreStaticLine)wxStaticLine();
601 bool Create( wxWindow *parent, wxWindowID id,
602 const wxPoint &pos = wxDefaultPosition,
603 const wxSize &size = wxDefaultSize,
604 long style = wxLI_HORIZONTAL,
605 const wxString& name = wxPyStaticTextNameStr);
607 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
608 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
612 //----------------------------------------------------------------------
614 class wxStaticText : public wxControl {
616 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
617 const wxPoint& pos = wxDefaultPosition,
618 const wxSize& size = wxDefaultSize,
620 const wxString& name = wxPyStaticTextNameStr);
621 %name(wxPreStaticText)wxStaticText();
623 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
624 const wxPoint& pos = wxDefaultPosition,
625 const wxSize& size = wxDefaultSize,
627 const wxString& name = wxPyStaticTextNameStr);
629 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
630 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
633 void SetLabel(const wxString& label);
636 //----------------------------------------------------------------------
638 class wxListBox : public wxControlWithItems {
640 wxListBox(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);
647 %name(wxPreListBox)wxListBox();
649 bool Create(wxWindow* parent, wxWindowID id,
650 const wxPoint& pos = wxDefaultPosition,
651 const wxSize& size = wxDefaultSize,
652 int LCOUNT, wxString* choices = NULL,
654 const wxValidator& validator = wxDefaultValidator,
655 const wxString& name = wxPyListBoxNameStr);
657 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
658 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
661 void Deselect(int n);
663 // int GetSelections(int **selections);
665 PyObject* GetSelections() {
667 self->GetSelections(lst);
668 PyObject *tup = PyTuple_New(lst.GetCount());
669 for(size_t i=0; i<lst.GetCount(); i++) {
670 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
677 void InsertItems(int LCOUNT, wxString* choices, int pos);
679 bool IsSelected(const int n);
680 bool Selected(const int n);
681 void Set(int LCOUNT, wxString* choices);
682 void SetFirstItem(int n);
683 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
684 void SetSelection(int n, bool select = TRUE);
685 void SetString(int n, const wxString& string);
686 void SetStringSelection(const wxString& string, bool select = TRUE);
690 //----------------------------------------------------------------------
692 class wxCheckListBox : public wxListBox {
694 wxCheckListBox(wxWindow *parent, wxWindowID id,
695 const wxPoint& pos = wxDefaultPosition,
696 const wxSize& size = wxDefaultSize,
698 wxString* choices = NULL,
700 const wxValidator& validator = wxDefaultValidator,
701 const wxString& name = wxPyListBoxNameStr);
702 %name(wxPreCheckListBox)wxCheckListBox();
704 bool Create(wxWindow *parent, wxWindowID id,
705 const wxPoint& pos = wxDefaultPosition,
706 const wxSize& size = wxDefaultSize,
708 wxString* choices = NULL,
710 const wxValidator& validator = wxDefaultValidator,
711 const wxString& name = wxPyListBoxNameStr);
713 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
714 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
716 bool IsChecked(int uiIndex);
717 void Check(int uiIndex, int bCheck = TRUE);
718 void InsertItems(int LCOUNT, wxString* choices, int pos);
724 // return the index of the item at this position or wxNOT_FOUND
725 int HitTest(const wxPoint& pt) const;
726 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
730 //----------------------------------------------------------------------
753 // Flags to indicate which attributes are being applied
754 wxTEXT_ATTR_TEXT_COLOUR,
755 wxTEXT_ATTR_BACKGROUND_COLOUR,
756 wxTEXT_ATTR_FONT_FACE,
757 wxTEXT_ATTR_FONT_SIZE,
758 wxTEXT_ATTR_FONT_WEIGHT,
759 wxTEXT_ATTR_FONT_ITALIC,
760 wxTEXT_ATTR_FONT_UNDERLINE,
762 wxTEXT_ATTR_ALIGNMENT,
763 wxTEXT_ATTR_LEFT_INDENT,
764 wxTEXT_ATTR_RIGHT_INDENT,
770 enum wxTextAttrAlignment
772 wxTEXT_ALIGNMENT_DEFAULT,
773 wxTEXT_ALIGNMENT_LEFT,
774 wxTEXT_ALIGNMENT_CENTRE,
775 wxTEXT_ALIGNMENT_CENTER,
776 wxTEXT_ALIGNMENT_RIGHT,
777 wxTEXT_ALIGNMENT_JUSTIFIED
787 wxTextAttr(const wxColour& colText = wxNullColour,
788 const wxColour& colBack = wxNullColour,
789 const wxFont& font = wxNullFont,
790 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
796 void SetTextColour(const wxColour& colText);
797 void SetBackgroundColour(const wxColour& colBack);
798 void SetFont(const wxFont& font);
799 void SetAlignment(wxTextAttrAlignment alignment);
800 void SetTabs(const wxArrayInt& tabs);
801 void SetLeftIndent(int indent);
802 void SetRightIndent(int indent);
803 void SetFlags(long flags);
806 bool HasTextColour() const;
807 bool HasBackgroundColour() const;
808 bool HasFont() const;
809 bool HasAlignment() const;
810 bool HasTabs() const;
811 bool HasLeftIndent() const;
812 bool HasRightIndent() const;
813 bool HasFlag(long flag) const;
815 wxColour GetTextColour() const;
816 wxColour GetBackgroundColour() const;
817 wxFont GetFont() const;
818 wxTextAttrAlignment GetAlignment();
819 const wxArrayInt& GetTabs() const;
820 long GetLeftIndent() const;
821 long GetRightIndent() const;
822 long GetFlags() const;
825 // returns false if we have any attributes set, true otherwise
828 // return the attribute having the valid font and colours: it uses the
829 // attributes set in attr and falls back first to attrDefault and then to
830 // the text control font/colours for those attributes which are not set
831 static wxTextAttr Combine(const wxTextAttr& attr,
832 const wxTextAttr& attrDef,
833 const wxTextCtrl *text);
838 class wxTextCtrl : public wxControl {
840 wxTextCtrl(wxWindow* parent, wxWindowID id,
841 const wxString& value = wxPyEmptyString,
842 const wxPoint& pos = wxDefaultPosition,
843 const wxSize& size = wxDefaultSize,
845 const wxValidator& validator = wxDefaultValidator,
846 const wxString& name = wxPyTextCtrlNameStr);
847 %name(wxPreTextCtrl)wxTextCtrl();
849 bool Create(wxWindow* parent, wxWindowID id,
850 const wxString& value = wxPyEmptyString,
851 const wxPoint& pos = wxDefaultPosition,
852 const wxSize& size = wxDefaultSize,
854 const wxValidator& validator = wxDefaultValidator,
855 const wxString& name = wxPyTextCtrlNameStr);
857 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
858 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
861 wxString GetValue() const;
862 void SetValue(const wxString& value);
864 wxString GetRange(long from, long to);
866 int GetLineLength(long lineNo) const;
867 wxString GetLineText(long lineNo) const;
868 int GetNumberOfLines() const;
870 bool IsModified() const;
871 bool IsEditable() const;
873 // If the return values from and to are the same, there is no selection.
874 void GetSelection(long* OUTPUT, long* OUTPUT) const;
875 wxString GetStringSelection();
878 void Replace(long from, long to, const wxString& value);
879 void Remove(long from, long to);
881 // load/save the controls contents from/to the file
882 bool LoadFile(const wxString& file);
883 bool SaveFile(const wxString& file = wxPyEmptyString);
885 // sets the dirty flag
886 virtual void MarkDirty() = 0;
888 // clears the dirty flag
891 // set the max number of characters which may be entered in a single line
893 void SetMaxLength(unsigned long len);
895 // writing text inserts it at the current position, appending always
896 // inserts it at the end
897 void WriteText(const wxString& text);
898 void AppendText(const wxString& text);
900 // insert the character which would have resulted from this key event,
901 // return TRUE if anything has been inserted
902 bool EmulateKeyPress(const wxKeyEvent& event);
904 // text control under some platforms supports the text styles: these
905 // methods allow to apply the given text style to the given selection or to
906 // set/get the style which will be used for all appended text
907 bool SetStyle(long start, long end, const wxTextAttr& style);
908 bool SetDefaultStyle(const wxTextAttr& style);
909 const wxTextAttr& GetDefaultStyle() const;
910 bool GetStyle(long position, wxTextAttr& style);
912 // translate between the position (which is just an index in the text ctrl
913 // considering all its contents as a single strings) and (x, y) coordinates
914 // which represent column and line.
915 long XYToPosition(long x, long y) const;
916 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
918 //bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
919 // TODO: check return value, raise exception.
921 void ShowPosition(long pos);
923 // Clipboard operations
928 bool CanCopy() const;
930 bool CanPaste() const;
936 bool CanUndo() const;
937 bool CanRedo() const;
940 void SetInsertionPoint(long pos);
941 void SetInsertionPointEnd();
942 long GetInsertionPoint() const;
943 long GetLastPosition() const;
945 void SetSelection(long from, long to);
947 void SetEditable(bool editable);
954 void write(const wxString& text) {
955 self->AppendText(text);
959 // TODO: replace this when the method is really added to wxTextCtrl
961 wxString GetString(long from, long to) {
962 return self->GetValue().Mid(from, to - from);
967 //----------------------------------------------------------------------
969 class wxScrollBar : public wxControl {
971 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
972 const wxPoint& pos = wxDefaultPosition,
973 const wxSize& size = wxDefaultSize,
974 long style = wxSB_HORIZONTAL,
975 const wxValidator& validator = wxDefaultValidator,
976 const wxString& name = wxPyScrollBarNameStr);
977 %name(wxPreScrollBar)wxScrollBar();
979 bool Create(wxWindow* parent, wxWindowID id = -1,
980 const wxPoint& pos = wxDefaultPosition,
981 const wxSize& size = wxDefaultSize,
982 long style = wxSB_HORIZONTAL,
983 const wxValidator& validator = wxDefaultValidator,
984 const wxString& name = wxPyScrollBarNameStr);
986 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
987 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
991 int GetThumbPosition();
993 %name(GetThumbLength) int GetThumbSize(); // to match the docs
997 void SetThumbPosition(int viewStart);
998 void SetScrollbar(int position, int thumbSize,
999 int range, int pageSize,
1000 bool refresh = TRUE);
1003 //----------------------------------------------------------------------
1005 class wxSpinButton : public wxControl {
1007 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
1008 const wxPoint& pos = wxDefaultPosition,
1009 const wxSize& size = wxDefaultSize,
1010 long style = wxSP_HORIZONTAL,
1011 const wxString& name = wxPySPIN_BUTTON_NAME);
1012 %name(wxPreSpinButton)wxSpinButton();
1014 bool Create(wxWindow* parent, wxWindowID id = -1,
1015 const wxPoint& pos = wxDefaultPosition,
1016 const wxSize& size = wxDefaultSize,
1017 long style = wxSP_HORIZONTAL,
1018 const wxString& name = wxPySPIN_BUTTON_NAME);
1020 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1021 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
1026 void SetRange(int min, int max);
1027 void SetValue(int value);
1030 //----------------------------------------------------------------------
1032 class wxStaticBitmap : public wxControl {
1034 wxStaticBitmap(wxWindow* parent, wxWindowID id,
1035 const wxBitmap& bitmap,
1036 const wxPoint& pos = wxDefaultPosition,
1037 const wxSize& size = wxDefaultSize,
1039 const wxString& name = wxPyStaticBitmapNameStr);
1040 %name(wxPreStaticBitmap)wxStaticBitmap();
1042 bool Create(wxWindow* parent, wxWindowID id,
1043 const wxBitmap& bitmap,
1044 const wxPoint& pos = wxDefaultPosition,
1045 const wxSize& size = wxDefaultSize,
1047 const wxString& name = wxPyStaticBitmapNameStr);
1049 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1050 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
1052 wxBitmap GetBitmap();
1053 void SetBitmap(const wxBitmap& bitmap);
1054 void SetIcon(const wxIcon& icon);
1057 //----------------------------------------------------------------------
1059 class wxRadioBox : public wxControl {
1061 wxRadioBox(wxWindow* parent, wxWindowID id,
1062 const wxString& label,
1063 const wxPoint& point = wxDefaultPosition,
1064 const wxSize& size = wxDefaultSize,
1065 int LCOUNT = 0, wxString* choices = NULL,
1066 int majorDimension = 0,
1067 long style = wxRA_HORIZONTAL,
1068 const wxValidator& validator = wxDefaultValidator,
1069 const wxString& name = wxPyRadioBoxNameStr);
1070 %name(wxPreRadioBox)wxRadioBox();
1072 bool Create(wxWindow* parent, wxWindowID id,
1073 const wxString& label,
1074 const wxPoint& point = wxDefaultPosition,
1075 const wxSize& size = wxDefaultSize,
1076 int LCOUNT = 0, wxString* choices = NULL,
1077 int majorDimension = 0,
1078 long style = wxRA_HORIZONTAL,
1079 const wxValidator& validator = wxDefaultValidator,
1080 const wxString& name = wxPyRadioBoxNameStr);
1082 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1083 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
1085 void Enable(bool enable);
1086 %name(EnableItem)void Enable(int n, bool enable);
1087 int FindString(const wxString& string);
1089 wxString GetString(int n);
1090 void SetString(int n, const wxString& label);
1091 %pragma(python) addtoclass = "
1092 GetItemLabel = GetString
1093 SetItemLabel = SetString
1096 int GetColumnCount();
1098 int GetNextItem(int item, wxDirection dir, long style);
1102 wxString GetStringSelection();
1104 %pragma(python) addtoclass = "Number = GetCount"
1106 void SetSelection(int n);
1107 void SetStringSelection(const wxString& string);
1108 void Show(bool show);
1109 %name(ShowItem)void Show(int item, bool show);
1112 //----------------------------------------------------------------------
1114 class wxRadioButton : public wxControl {
1116 wxRadioButton(wxWindow* parent, wxWindowID id,
1117 const wxString& label,
1118 const wxPoint& pos = wxDefaultPosition,
1119 const wxSize& size = wxDefaultSize,
1121 const wxValidator& validator = wxDefaultValidator,
1122 const wxString& name = wxPyRadioButtonNameStr);
1123 %name(wxPreRadioButton)wxRadioButton();
1125 bool Create(wxWindow* parent, wxWindowID id,
1126 const wxString& label,
1127 const wxPoint& pos = wxDefaultPosition,
1128 const wxSize& size = wxDefaultSize,
1130 const wxValidator& validator = wxDefaultValidator,
1131 const wxString& name = wxPyRadioButtonNameStr);
1133 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1134 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
1137 void SetValue(bool value);
1140 //----------------------------------------------------------------------
1142 class wxSlider : public wxControl {
1144 wxSlider(wxWindow* parent, wxWindowID id,
1145 int value, int minValue, int maxValue,
1146 const wxPoint& point = wxDefaultPosition,
1147 const wxSize& size = wxDefaultSize,
1148 long style = wxSL_HORIZONTAL,
1149 const wxValidator& validator = wxDefaultValidator,
1150 const wxString& name = wxPySliderNameStr);
1151 %name(wxPreSlider)wxSlider();
1153 bool Create(wxWindow* parent, wxWindowID id,
1154 int value, int minValue, int maxValue,
1155 const wxPoint& point = wxDefaultPosition,
1156 const wxSize& size = wxDefaultSize,
1157 long style = wxSL_HORIZONTAL,
1158 const wxValidator& validator = wxDefaultValidator,
1159 const wxString& name = wxPySliderNameStr);
1161 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1162 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
1172 int GetThumbLength();
1175 void SetRange(int minValue, int maxValue);
1176 void SetTickFreq(int n, int pos);
1177 void SetLineSize(int lineSize);
1178 void SetPageSize(int pageSize);
1179 void SetSelection(int startPos, int endPos);
1180 void SetThumbLength(int len);
1181 void SetTick(int tickPos);
1182 void SetValue(int value);
1186 //----------------------------------------------------------------------
1188 class wxSpinCtrl : public wxSpinButton {
1190 wxSpinCtrl(wxWindow *parent,
1192 const wxString& value = wxPyEmptyString,
1193 const wxPoint& pos = wxDefaultPosition,
1194 const wxSize& size = wxDefaultSize,
1195 long style = wxSP_ARROW_KEYS,
1196 int min = 0, int max = 100, int initial = 0,
1197 const wxString& name = wxPySpinCtrlNameStr);
1198 %name(wxPreSpinCtrl)wxSpinCtrl();
1200 bool Create(wxWindow *parent,
1202 const wxString& value = wxPyEmptyString,
1203 const wxPoint& pos = wxDefaultPosition,
1204 const wxSize& size = wxDefaultSize,
1205 long style = wxSP_ARROW_KEYS,
1206 int min = 0, int max = 100, int initial = 0,
1207 const wxString& name = wxPySpinCtrlNameStr);
1209 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1210 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
1215 void SetRange(int min, int max);
1216 void SetValue(int value);
1219 void SetSelection(long from, long to) {
1223 void SetSelection(long from, long to);
1228 //----------------------------------------------------------------------
1231 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1233 class wxToggleButton : public wxControl {
1235 wxToggleButton(wxWindow *parent,
1237 const wxString& label,
1238 const wxPoint& pos = wxDefaultPosition,
1239 const wxSize& size = wxDefaultSize,
1241 const wxValidator& validator = wxDefaultValidator,
1242 const wxString& name = wxPyCheckBoxNameStr);
1243 %name(wxPreToggleButton)wxToggleButton();
1245 bool Create(wxWindow *parent,
1247 const wxString& label,
1248 const wxPoint& pos = wxDefaultPosition,
1249 const wxSize& size = wxDefaultSize,
1251 const wxValidator& validator = wxDefaultValidator,
1252 const wxString& name = wxPyCheckBoxNameStr);
1254 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1255 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
1257 void SetValue(bool value);
1258 bool GetValue() const ;
1259 void SetLabel(const wxString& label);
1265 //----------------------------------------------------------------------
1266 //----------------------------------------------------------------------
1267 //----------------------------------------------------------------------