X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dd9f7fea29e3f8bb61861f52984b7943512346ac..f27895d28959ea2d8ddf4c2c5b5ad3958bcaadb4:/wxPython/src/_textctrl.i?ds=sidebyside diff --git a/wxPython/src/_textctrl.i b/wxPython/src/_textctrl.i index c43785aaa3..630ba209ba 100644 --- a/wxPython/src/_textctrl.i +++ b/wxPython/src/_textctrl.i @@ -15,9 +15,7 @@ //--------------------------------------------------------------------------- -%{ - DECLARE_DEF_STRING(TextCtrlNameStr); -%} +MAKE_CONST_WXSTRING(TextCtrlNameStr); //--------------------------------------------------------------------------- %newgroup @@ -54,17 +52,25 @@ enum { // doesn't have focus - use this style to force it to always show it wxTE_NOHIDESEL, - // use wxHSCROLL to not wrap text at all, wxTE_LINEWRAP to wrap it at any - // position and wxTE_WORDWRAP to wrap at words boundary + // use wxHSCROLL (wxTE_DONTWRAP) to not wrap text at all, wxTE_CHARWRAP to + // wrap it at any position and wxTE_WORDWRAP to wrap at words boundary + // + // if no wrapping style is given at all, the control wraps at word boundary wxTE_DONTWRAP, - wxTE_LINEWRAP, + wxTE_CHARWRAP, wxTE_WORDWRAP, + wxTE_BESTWRAP, // force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for // wxTE_RICH controls - can be used together with or instead of wxTE_RICH wxTE_RICH2, + + wxTE_CAPITALIZE, }; +%pythoncode { TE_LINEWRAP = TE_CHARWRAP } + + enum wxTextAttrAlignment { @@ -92,29 +98,55 @@ enum { wxTEXT_ATTR_TABS }; +enum wxTextCtrlHitTestResult +{ + wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented + wxTE_HT_BEFORE, // either to the left or upper + wxTE_HT_ON_TEXT, // directly on + wxTE_HT_BELOW, // below [the last line] + wxTE_HT_BEYOND // after [the end of line] +}; + + +enum { + wxOutOfRangeTextCoord, + wxInvalidTextCoord, + + wxTEXT_TYPE_ANY +}; + //--------------------------------------------------------------------------- // wxTextAttr: a structure containing the visual attributes of a text class wxTextAttr { public: - %nokwargs wxTextAttr; - wxTextAttr(); - wxTextAttr(const wxColour& colText, + wxTextAttr(const wxColour& colText = wxNullColour, const wxColour& colBack = wxNullColour, const wxFont& font = wxNullFont, wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); - + ~wxTextAttr(); + // operations void Init(); + // merges the attributes of the base and the overlay objects and returns + // the result; the parameter attributes take precedence + // + // WARNING: the order of arguments is the opposite of Combine() + static wxTextAttr Merge(const wxTextAttr& base, const wxTextAttr& overlay); + +// // merges the attributes of this object and overlay +// void Merge(const wxTextAttr& overlay); + + // setters void SetTextColour(const wxColour& colText); void SetBackgroundColour(const wxColour& colBack); void SetFont(const wxFont& font, long flags = wxTEXT_ATTR_FONT); void SetAlignment(wxTextAttrAlignment alignment); void SetTabs(const wxArrayInt& tabs); - void SetLeftIndent(int indent); + void SetLeftIndent(int indent, int subIndent=0); void SetRightIndent(int indent); void SetFlags(long flags); @@ -134,6 +166,7 @@ public: wxTextAttrAlignment GetAlignment() const; const wxArrayInt& GetTabs() const; long GetLeftIndent() const; + long GetLeftSubIndent() const; long GetRightIndent() const; long GetFlags() const; @@ -146,28 +179,43 @@ public: static wxTextAttr Combine(const wxTextAttr& attr, const wxTextAttr& attrDef, const wxTextCtrl *text); + + %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`"); + %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`"); + %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`"); + %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`"); + %property(LeftIndent, GetLeftIndent, SetLeftIndent, doc="See `GetLeftIndent` and `SetLeftIndent`"); + %property(LeftSubIndent, GetLeftSubIndent, doc="See `GetLeftSubIndent`"); + %property(RightIndent, GetRightIndent, SetRightIndent, doc="See `GetRightIndent` and `SetRightIndent`"); + %property(Tabs, GetTabs, SetTabs, doc="See `GetTabs` and `SetTabs`"); + %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`"); }; //--------------------------------------------------------------------------- // wxTextCtrl: a single or multiple line text zone where user can enter and // edit text +MustHaveApp(wxTextCtrl); class wxTextCtrl : public wxControl { public: - %addtofunc wxTextCtrl "self._setOORInfo(self)" - %addtofunc wxTextCtrl() "" + %pythonAppend wxTextCtrl "self._setOORInfo(self)" + %pythonAppend wxTextCtrl() "" + %typemap(out) wxTextCtrl*; // turn off this typemap - wxTextCtrl(wxWindow* parent, wxWindowID id, + wxTextCtrl(wxWindow* parent, wxWindowID id=-1, const wxString& value = wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxPyTextCtrlNameStr); - %name(PreTextCtrl)wxTextCtrl(); + %RenameCtor(PreTextCtrl, wxTextCtrl()); + + // Turn it back on again + %typemap(out) wxTextCtrl* { $result = wxPyMake_wxObject($1, $owner); } - bool Create(wxWindow* parent, wxWindowID id, + bool Create(wxWindow* parent, wxWindowID id=-1, const wxString& value = wxPyEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -179,6 +227,10 @@ public: virtual wxString GetValue() const; virtual void SetValue(const wxString& value); + virtual bool IsEmpty() const; + + virtual void ChangeValue(const wxString &value); + virtual wxString GetRange(long from, long to) const; virtual int GetLineLength(long lineNo) const; @@ -192,8 +244,11 @@ public: bool IsSingleLine() const; bool IsMultiLine() const; - // If the return values from and to are the same, there is no selection. - virtual void GetSelection(long* OUTPUT, long* OUTPUT) const; + + DocDeclAStr( + virtual void, GetSelection(long* OUTPUT, long* OUTPUT) const, + "GetSelection() -> (from, to)", + "If the return values from and to are the same, there is no selection.", ""); virtual wxString GetStringSelection() const; @@ -204,13 +259,14 @@ public: virtual void Remove(long from, long to); // load/save the controls contents from/to the file - virtual bool LoadFile(const wxString& file); - virtual bool SaveFile(const wxString& file = wxPyEmptyString); + virtual bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY); + virtual bool SaveFile(const wxString& file = wxPyEmptyString, int fileType = wxTEXT_TYPE_ANY); // sets/clears the dirty flag virtual void MarkDirty(); virtual void DiscardEdits(); - + void SetModified(bool modified); + // set the max number of characters which may be entered in a single line // text control virtual void SetMaxLength(unsigned long len); @@ -236,10 +292,32 @@ public: // considering all its contents as a single strings) and (x, y) coordinates // which represent column and line. virtual long XYToPosition(long x, long y) const; - virtual /*bool*/ void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const; + DocDeclA( + virtual /*bool*/ void, PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const, + "PositionToXY(long pos) -> (x, y)"); virtual void ShowPosition(long pos); + + DocDeclAStr( + virtual wxTextCtrlHitTestResult, HitTest(const wxPoint& pt, + long* OUTPUT, long* OUTPUT) const, + "HitTest(Point pt) -> (result, col, row)", + "Find the row, col coresponding to the character at the point given in +pixels. NB: pt is in device coords but is not adjusted for the client +area origin nor scrolling.", ""); + + + DocDeclAStrName( + virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const, + "HitTestPos(Point pt) -> (result, position)", + "Find the character position in the text coresponding to the point +given in pixels. NB: pt is in device coords but is not adjusted for +the client area origin nor scrolling. ", "", + HitTestPos); + + + // Clipboard operations virtual void Copy(); virtual void Cut(); @@ -266,9 +344,12 @@ public: virtual void SelectAll(); virtual void SetEditable(bool editable); + // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does + void SendTextUpdatedEvent(); + #ifdef __WXMSW__ // Caret handling (Windows only) - bool ShowNativeCaret(bool show = True); + bool ShowNativeCaret(bool show = true); bool HideNativeCaret(); #endif @@ -286,6 +367,16 @@ public: } } + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + + %property(DefaultStyle, GetDefaultStyle, SetDefaultStyle, doc="See `GetDefaultStyle` and `SetDefaultStyle`"); + %property(InsertionPoint, GetInsertionPoint, SetInsertionPoint, doc="See `GetInsertionPoint` and `SetInsertionPoint`"); + %property(LastPosition, GetLastPosition, doc="See `GetLastPosition`"); + %property(NumberOfLines, GetNumberOfLines, doc="See `GetNumberOfLines`"); + %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`"); + %property(StringSelection, GetStringSelection, doc="See `GetStringSelection`"); + %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`"); }; //--------------------------------------------------------------------------- @@ -311,6 +402,10 @@ public: // get the end of the URL long GetURLEnd() const; + + %property(MouseEvent, GetMouseEvent, doc="See `GetMouseEvent`"); + %property(URLEnd, GetURLEnd, doc="See `GetURLEnd`"); + %property(URLStart, GetURLStart, doc="See `GetURLStart`"); };