X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7de202a64d19bb125d338b179948402bcd48dc24..a90280fe1ac7b78563d44afffd1d3b0b521b5cd6:/interface/wx/textctrl.h diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index 1130fc7913..e9ac22eab8 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -7,9 +7,8 @@ ///////////////////////////////////////////////////////////////////////////// - /** - The following values can be passed to wxTextAttr::SetAlignment to determine paragraph alignment. + One of the following values can be passed to wxTextAttr::SetAlignment to determine paragraph alignment. */ enum wxTextAttrAlignment { @@ -32,55 +31,75 @@ enum wxTextAttrFlags { wxTEXT_ATTR_TEXT_COLOUR = 0x00000001, wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002, + wxTEXT_ATTR_FONT_FACE = 0x00000004, wxTEXT_ATTR_FONT_SIZE = 0x00000008, wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, wxTEXT_ATTR_FONT_ITALIC = 0x00000020, wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, wxTEXT_ATTR_FONT_ENCODING = 0x02000000, + wxTEXT_ATTR_FONT_FAMILY = 0x04000000, + + /** + Defined as the combination of all @c wxTEXT_ATTR_FONT_* values above. + */ wxTEXT_ATTR_FONT = \ ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ - wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING ), + wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), wxTEXT_ATTR_ALIGNMENT = 0x00000080, wxTEXT_ATTR_LEFT_INDENT = 0x00000100, wxTEXT_ATTR_RIGHT_INDENT = 0x00000200, wxTEXT_ATTR_TABS = 0x00000400, - wxTEXT_ATTR_PARA_SPACING_AFTER = 0x00000800, wxTEXT_ATTR_PARA_SPACING_BEFORE = 0x00001000, wxTEXT_ATTR_LINE_SPACING = 0x00002000, wxTEXT_ATTR_CHARACTER_STYLE_NAME = 0x00004000, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME = 0x00008000, wxTEXT_ATTR_LIST_STYLE_NAME = 0x00010000, + wxTEXT_ATTR_BULLET_STYLE = 0x00020000, wxTEXT_ATTR_BULLET_NUMBER = 0x00040000, wxTEXT_ATTR_BULLET_TEXT = 0x00080000, wxTEXT_ATTR_BULLET_NAME = 0x00100000, + + /** + Defined as the combination of all @c wxTEXT_ATTR_BULLET_* values above. + */ + wxTEXT_ATTR_BULLET = \ + ( wxTEXT_ATTR_BULLET_STYLE | wxTEXT_ATTR_BULLET_NUMBER | wxTEXT_ATTR_BULLET_TEXT | \ + wxTEXT_ATTR_BULLET_NAME ), + wxTEXT_ATTR_URL = 0x00200000, wxTEXT_ATTR_PAGE_BREAK = 0x00400000, wxTEXT_ATTR_EFFECTS = 0x00800000, wxTEXT_ATTR_OUTLINE_LEVEL = 0x01000000, /** - Character and paragraph combined styles + Combines the styles @c wxTEXT_ATTR_FONT, @c wxTEXT_ATTR_EFFECTS, @c wxTEXT_ATTR_BACKGROUND_COLOUR, + @c wxTEXT_ATTR_TEXT_COLOUR, @c wxTEXT_ATTR_CHARACTER_STYLE_NAME, @c wxTEXT_ATTR_URL. */ wxTEXT_ATTR_CHARACTER = \ - (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS| \ + (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS| \ wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL), + /** + Combines all the styles regarding text paragraphs. + */ wxTEXT_ATTR_PARAGRAPH = \ (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\ wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\ - wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\ - wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL), + wxTEXT_ATTR_BULLET|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL), + /** + Combines all previous values. + */ wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) }; /** - Styles for wxTextAttr::SetBulletStyle + Styles for wxTextAttr::SetBulletStyle. They can be combined together as a bitlist. */ enum wxTextAttrBulletStyle { @@ -106,7 +125,7 @@ enum wxTextAttrBulletStyle }; /** - Styles for wxTextAttr::SetTextEffects(). + Styles for wxTextAttr::SetTextEffects(). They can be combined together as a bitlist. Of these, only wxTEXT_ATTR_EFFECT_CAPITALS and wxTEXT_ATTR_EFFECT_STRIKETHROUGH are implemented. */ @@ -126,7 +145,7 @@ enum wxTextAttrEffects }; /** - Line spacing values; see wxTextAttr::SetLineSpacing(). + Convenience line spacing values; see wxTextAttr::SetLineSpacing(). */ enum wxTextAttrLineSpacing { @@ -206,6 +225,27 @@ public: */ wxFont CreateFont() const; + /** + Copies all defined/valid properties from overlay to current object. + */ + void Merge(const wxTextAttr& overlay); + + /** + Creates a new @c wxTextAttr which is a merge of @a base and @a overlay. + + Properties defined in @a overlay take precedence over those in @a base. + Properties undefined/invalid in both are undefined in the result. + */ + static wxTextAttr Merge(const wxTextAttr& base, + const wxTextAttr& overlay); + + + /** + @name GetXXX functions + */ + + //@{ + /** Returns the alignment flags. See ::wxTextAttrAlignment for a list of available styles. @@ -256,12 +296,12 @@ public: Returns the bullet text, which could be a symbol, or (for example) cached outline text. */ - const wxString GetBulletText() const; + const wxString& GetBulletText() const; /** Returns the name of the character style. */ - const wxString GetCharacterStyleName() const; + const wxString& GetCharacterStyleName() const; /** Returns flags indicating which attributes are applicable. @@ -293,7 +333,12 @@ public: /** Returns the font face name. */ - const wxString GetFontFaceName() const; + const wxString& GetFontFaceName() const; + + /** + Returns the font family. + */ + wxFontFamily GetFontFamily() const; /** Returns the font size in points. @@ -303,7 +348,7 @@ public: /** Returns the font style. */ - int GetFontStyle() const; + wxFontStyle GetFontStyle() const; /** Returns @true if the font is underlined. @@ -313,7 +358,7 @@ public: /** Returns the font weight. */ - int GetFontWeight() const; + wxFontWeight GetFontWeight() const; /** Returns the left indent in tenths of a millimetre. @@ -333,12 +378,12 @@ public: /** Returns the name of the list style. */ - const wxString GetListStyleName() const; + const wxString& GetListStyleName() const; /** Returns the outline level. */ - bool GetOutlineLevel() const; + int GetOutlineLevel() const; /** Returns the space in tenths of a millimeter after the paragraph. @@ -353,7 +398,7 @@ public: /** Returns the name of the paragraph style. */ - const wxString GetParagraphStyleName() const; + const wxString& GetParagraphStyleName() const; /** Returns the right indent in tenths of a millimeter. @@ -366,12 +411,12 @@ public: Each stop is measured from the left margin and therefore each value must be larger than the last. */ - const wxArrayInt GetTabs() const; + const wxArrayInt& GetTabs() const; /** Returns the text foreground colour. */ - const wxColour GetTextColour() const; + const wxColour& GetTextColour() const; /** Returns the text effect bits of interest. @@ -392,7 +437,17 @@ public: hand cursor over it, and wxRichTextCtrl generates a wxTextUrlEvent when the content is clicked. */ - const wxString GetURL() const; + const wxString& GetURL() const; + + //@} + + + + /** + @name HasXXX and IsXXX functions + */ + + //@{ /** Returns @true if the attribute object specifies alignment. @@ -451,6 +506,11 @@ public: */ bool HasFontFaceName() const; + /** + Returns @true if the attribute object specifies a font family. + */ + bool HasFontFamily() const; + /** Returns @true if the attribute object specifies italic style. */ @@ -557,19 +617,14 @@ public: */ bool IsParagraphStyle() const; - /** - Copies all defined/valid properties from overlay to current object. - */ - void Merge(const wxTextAttr& overlay); + //@} + /** - Creates a new @c wxTextAttr which is a merge of @a base and @a overlay. + @name SetXXX functions + */ - Properties defined in @a overlay take precedence over those in @a base. - Properties undefined/invalid in both are undefined in the result. - */ - static wxTextAttr Merge(const wxTextAttr& base, - const wxTextAttr& overlay); + //@{ /** Sets the paragraph alignment. See ::wxTextAttrAlignment enumeration values. @@ -616,7 +671,7 @@ public: Sets the bullet text, which could be a symbol, or (for example) cached outline text. */ - void SetBulletText(const wxString text); + void SetBulletText(const wxString& text); /** Sets the character style name. @@ -633,7 +688,7 @@ public: Sets the attributes for the given font. Note that wxTextAttr does not store an actual wxFont object. */ - void SetFont(const wxFont& font); + void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT); /** Sets the font encoding. @@ -641,10 +696,15 @@ public: void SetFontEncoding(wxFontEncoding encoding); /** - Sets the paragraph alignment. + Sets the font face name. */ void SetFontFaceName(const wxString& faceName); + /** + Sets the font family. + */ + void SetFontFamily(wxFontFamily family); + /** Sets the font size in points. */ @@ -653,7 +713,7 @@ public: /** Sets the font style (normal, italic or slanted). */ - void SetFontStyle(int fontStyle); + void SetFontStyle(wxFontStyle fontStyle); /** Sets the font underlining. @@ -663,7 +723,7 @@ public: /** Sets the font weight. */ - void SetFontWeight(int fontWeight); + void SetFontWeight(wxFontWeight fontWeight); /** Sets the left indent and left subindent in tenths of a millimetre. @@ -772,6 +832,9 @@ public: */ void SetURL(const wxString& url); + //@} + + /** Assignment from a wxTextAttr object. */ @@ -1001,7 +1064,7 @@ public: @library{wxcore} @category{ctrl} - + @appearance{textctrl.png} @see wxTextCtrl::Create, wxValidator */ @@ -1044,7 +1107,7 @@ public: @see Create(), wxValidator */ wxTextCtrl(wxWindow* parent, wxWindowID id, - const wxString& value = "", + const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, @@ -1069,7 +1132,7 @@ public: @see WriteText() */ - void AppendText(const wxString& text); + virtual void AppendText(const wxString& text); /** Call this function to enable auto-completion of the text typed in a @@ -1087,7 +1150,7 @@ public: @see AutoCompleteFileNames() */ - bool AutoComplete(const wxArrayString& choices); + virtual bool AutoComplete(const wxArrayString& choices); /** Call this function to enable auto-completion of the text typed in a @@ -1105,17 +1168,17 @@ public: @see AutoComplete() */ - bool AutoCompleteFileNames(); + virtual bool AutoCompleteFileNames(); /** Returns @true if the selection can be copied to the clipboard. */ - virtual bool CanCopy(); + virtual bool CanCopy() const; /** Returns @true if the selection can be cut to the clipboard. */ - virtual bool CanCut(); + virtual bool CanCut() const; /** Returns @true if the contents of the clipboard can be pasted into the @@ -1124,19 +1187,19 @@ public: On some platforms (Motif, GTK) this is an approximation and returns @true if the control is editable, @false otherwise. */ - virtual bool CanPaste(); + virtual bool CanPaste() const; /** Returns @true if there is a redo facility available and the last operation can be redone. */ - virtual bool CanRedo(); + virtual bool CanRedo() const; /** Returns @true if there is an undo facility available and the last operation can be undone. */ - virtual bool CanUndo(); + virtual bool CanUndo() const; /** Sets the new text control value. @@ -1181,10 +1244,9 @@ public: non-default constructor. */ bool Create(wxWindow* parent, wxWindowID id, - const wxString& value = "", + const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, + const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); @@ -1217,7 +1279,7 @@ public: @see SetDefaultStyle() */ - const wxTextAttr GetDefaultStyle() const; + virtual const wxTextAttr& GetDefaultStyle() const; /** Returns the insertion point, or cursor, position. @@ -1326,7 +1388,7 @@ public: If there is no selection, the returned string is empty. */ - virtual wxString GetStringSelection(); + virtual wxString GetStringSelection() const; /** Returns the style at this position in the text control. @@ -1477,6 +1539,9 @@ public: Removes the text starting at the first given position up to (but not including) the character at the last position. + This function puts the current insertion point position at @a to as a + side effect. + @param from The first position. @param to @@ -1488,6 +1553,9 @@ public: Replaces the text starting at the first position up to (but not including) the character at the last position with the given text. + This function puts the current insertion point position at @a to as a + side effect. + @param from The first position. @param to @@ -1508,7 +1576,7 @@ public: @return @true if the operation was successful, @false otherwise. */ - bool SaveFile(const wxString& filename, + bool SaveFile(const wxString& filename = wxEmptyString, int fileType = wxTEXT_TYPE_ANY); /** @@ -1545,7 +1613,7 @@ public: @see IsEditable() */ - virtual void SetEditable(const bool editable); + virtual void SetEditable(bool editable); /** Sets the insertion point at the given position. @@ -1637,7 +1705,7 @@ public: /** Sets the new text control value. - + It also marks the control as not-modified which means that IsModified() would return @false immediately after the call to SetValue(). @@ -1772,7 +1840,7 @@ public: @param ostr The C++ stream to redirect, cout is used if it is @NULL */ - wxStreamToTextRedirector(wxTextCtrl text, ostream* ostr = NULL); + wxStreamToTextRedirector(wxTextCtrl *text, ostream* ostr); /** When a wxStreamToTextRedirector object is destroyed, the redirection is ended