X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db0ff83efbd6105c04d5ab84c85094e887e97b9a..71aba8333cc915afff9e740c944f7fa7247abacb:/wxPython/src/controls.i diff --git a/wxPython/src/controls.i b/wxPython/src/controls.i index 64e69048f4..461262b48e 100644 --- a/wxPython/src/controls.i +++ b/wxPython/src/controls.i @@ -49,6 +49,7 @@ //---------------------------------------------------------------------- %readonly +// See also wxPy_ReinitStockObjects in helpers.cpp wxValidator wxDefaultValidator; %readwrite @@ -92,12 +93,12 @@ public: // wxControl(wxWindow *parent, - wxWindowID id, - const wxPoint& pos=wxDefaultPosition, - const wxSize& size=wxDefaultSize, - long style=0, - const wxValidator& validator=wxDefaultValidator, - const wxString& name=wxPyControlNameStr); + wxWindowID id, + const wxPoint& pos=wxDefaultPosition, + const wxSize& size=wxDefaultSize, + long style=0, + const wxValidator& validator=wxDefaultValidator, + const wxString& name=wxPyControlNameStr); // %name(wxPreControl)wxControl(); @@ -323,7 +324,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& val = wxDefaultValidator, + const wxValidator& validator = wxDefaultValidator, const wxString& name = wxPyCheckBoxNameStr); %name(wxPreCheckBox)wxCheckBox(); @@ -331,13 +332,14 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& val = wxDefaultValidator, + const wxValidator& validator = wxDefaultValidator, const wxString& name = wxPyCheckBoxNameStr); %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)" bool GetValue(); + bool IsChecked(); void SetValue(const bool state); }; @@ -380,11 +382,11 @@ public: //---------------------------------------------------------------------- -// wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or -// even wxControlWithItems, so we have to duplicate the methods -// here... +// wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or even +// wxControlWithItems, so we have to duplicate the methods here... +// wxMac's inheritace is weird too so we'll fake it with this one too. -#ifdef __WXGTK__ +#ifndef __WXMSW__ class wxComboBox : public wxControl { public: @@ -456,7 +458,11 @@ public: } PyObject* GetClientData(int n) { +#ifdef __WXMAC__ + wxPyClientData* data = (wxPyClientData*)self->wxItemContainer::GetClientObject(n); +#else wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n); +#endif if (data) { Py_INCREF(data->m_obj); return data->m_obj; @@ -468,7 +474,11 @@ public: void SetClientData(int n, PyObject* clientData) { wxPyClientData* data = new wxPyClientData(clientData); +#ifdef __WXMAC__ + self->wxItemContainer::SetClientObject(n, data); +#else self->SetClientObject(n, data); +#endif } } @@ -476,8 +486,8 @@ public: -#else // For all but wxGTK - +#else +// MSW's version derives from wxChoice class wxComboBox : public wxChoice { public: @@ -709,10 +719,65 @@ public: #ifndef __WXMAC__ int GetItemHeight(); #endif + + // return the index of the item at this position or wxNOT_FOUND + int HitTest(const wxPoint& pt) const; + %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const; + }; //---------------------------------------------------------------------- +enum { + // Styles + wxTE_NO_VSCROLL, + wxTE_AUTO_SCROLL, + wxTE_READONLY, + wxTE_MULTILINE, + wxTE_PROCESS_TAB, + wxTE_LEFT, + wxTE_CENTER, + wxTE_RIGHT, + wxTE_CENTRE, + wxTE_RICH, + wxTE_PROCESS_ENTER, + wxTE_PASSWORD, + wxTE_AUTO_URL, + wxTE_NOHIDESEL, + wxTE_DONTWRAP, + wxTE_LINEWRAP, + wxTE_WORDWRAP, + wxTE_RICH2, + + // Flags to indicate which attributes are being applied + wxTEXT_ATTR_TEXT_COLOUR, + wxTEXT_ATTR_BACKGROUND_COLOUR, + wxTEXT_ATTR_FONT_FACE, + wxTEXT_ATTR_FONT_SIZE, + wxTEXT_ATTR_FONT_WEIGHT, + wxTEXT_ATTR_FONT_ITALIC, + wxTEXT_ATTR_FONT_UNDERLINE, + wxTEXT_ATTR_FONT, + wxTEXT_ATTR_ALIGNMENT, + wxTEXT_ATTR_LEFT_INDENT, + wxTEXT_ATTR_RIGHT_INDENT, + wxTEXT_ATTR_TABS, + +}; + + +enum wxTextAttrAlignment +{ + wxTEXT_ALIGNMENT_DEFAULT, + wxTEXT_ALIGNMENT_LEFT, + wxTEXT_ALIGNMENT_CENTRE, + wxTEXT_ALIGNMENT_CENTER, + wxTEXT_ALIGNMENT_RIGHT, + wxTEXT_ALIGNMENT_JUSTIFIED +}; + + + class wxTextAttr { @@ -720,22 +785,41 @@ public: // ctors wxTextAttr(const wxColour& colText = wxNullColour, const wxColour& colBack = wxNullColour, - const wxFont& font = wxNullFont); + const wxFont& font = wxNullFont, + wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); ~wxTextAttr(); + void Init(); + // setters void SetTextColour(const wxColour& colText); void SetBackgroundColour(const wxColour& colBack); void SetFont(const wxFont& font); + void SetAlignment(wxTextAttrAlignment alignment); + void SetTabs(const wxArrayInt& tabs); + void SetLeftIndent(int indent); + void SetRightIndent(int indent); + void SetFlags(long flags); // accessors bool HasTextColour() const; bool HasBackgroundColour() const; bool HasFont() const; + bool HasAlignment() const; + bool HasTabs() const; + bool HasLeftIndent() const; + bool HasRightIndent() const; + bool HasFlag(long flag) const; wxColour GetTextColour() const; wxColour GetBackgroundColour() const; wxFont GetFont() const; + wxTextAttrAlignment GetAlignment(); + const wxArrayInt& GetTabs() const; + long GetLeftIndent() const; + long GetRightIndent() const; + long GetFlags() const; + // returns false if we have any attributes set, true otherwise bool IsDefault(); @@ -819,6 +903,7 @@ public: bool SetStyle(long start, long end, const wxTextAttr& style); bool SetDefaultStyle(const wxTextAttr& style); const wxTextAttr& GetDefaultStyle() const; + bool GetStyle(long position, wxTextAttr& style); // translate between the position (which is just an index in the text ctrl // considering all its contents as a single strings) and (x, y) coordinates @@ -857,6 +942,10 @@ public: void SelectAll(); void SetEditable(bool editable); + bool IsSingleLine(); + bool IsMultiLine(); + + %addmethods { void write(const wxString& text) { self->AppendText(text); @@ -866,7 +955,7 @@ public: // TODO: replace this when the method is really added to wxTextCtrl %addmethods { wxString GetString(long from, long to) { - return self->GetValue().Mid(from, to-from); + return self->GetValue().Mid(from, to - from); } } }; @@ -994,18 +1083,15 @@ public: int FindString(const wxString& string); wxString GetString(int n); - -#ifdef __WXGTK__ - %name(GetItemLabel)wxString GetLabel( int item ); - %name(SetItemLabel)void SetLabel( int item, const wxString& label ); -#else void SetString(int n, const wxString& label); %pragma(python) addtoclass = " GetItemLabel = GetString SetItemLabel = SetString " +#ifndef __WXGTK__ int GetColumnCount(); int GetRowCount(); + int GetNextItem(int item, wxDirection dir, long style); #endif int GetSelection(); @@ -1124,7 +1210,14 @@ public: int GetValue(); void SetRange(int min, int max); void SetValue(int value); - +#ifdef __WXGTK__ + %addmethods { + void SetSelection(long from, long to) { + } + } +#else + void SetSelection(long from, long to); +#endif };