X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/44cc96a80c09c8572e1315be66d29f6d610cbf78..98f8e6666b4622a7dc96292f9dfb215af81573d7:/include/wx/textctrl.h diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 75ad314bc1..eb7c2140ce 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Name: wx/textctrl.h -// Purpose: wxTextCtrlBase class - the interface of wxTextCtrl +// Purpose: wxTextAttr and wxTextCtrlBase class - the interface of wxTextCtrl // Author: Vadim Zeitlin // Modified by: // Created: 13.07.99 @@ -25,13 +25,11 @@ #include "wx/dynarray.h" // wxArrayInt #include "wx/gdicmn.h" // wxPoint -// Open Watcom 1.3 does allow only ios::rdbuf() while -// we want something with streambuf parameter -// Also, can't use streambuf if making or using a DLL :-( - +// some compilers don't have standard compliant rdbuf() (and MSVC has it only +// in its new iostream library, not in the old one used with iostream.h) #if defined(__WATCOMC__) || \ defined(__MWERKS__) || \ - (defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL))) + ((defined(__VISUALC5__) || defined(__VISUALC6__)) && wxUSE_IOSTREAMH) #define wxHAS_TEXT_WINDOW_STREAM 0 #elif wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" @@ -55,7 +53,7 @@ typedef long wxTextCoord; // constants // ---------------------------------------------------------------------------- -extern WXDLLEXPORT_DATA(const wxChar) wxTextCtrlNameStr[]; +extern WXDLLIMPEXP_DATA_CORE(const char) wxTextCtrlNameStr[]; // this is intentionally not enum to avoid warning fixes with // typecasting from enum type to wxTextCoord @@ -67,7 +65,6 @@ const wxTextCoord wxInvalidTextCoord = -2; // ---------------------------------------------------------------------------- #define wxTE_NO_VSCROLL 0x0002 -#define wxTE_AUTO_SCROLL 0x0008 #define wxTE_READONLY 0x0010 #define wxTE_MULTILINE 0x0020 @@ -110,6 +107,11 @@ const wxTextCoord wxInvalidTextCoord = -2; #define wxTE_LINEWRAP wxTE_CHARWRAP #endif // WXWIN_COMPATIBILITY_2_6 +#if WXWIN_COMPATIBILITY_2_8 + // this style is (or at least should be) on by default now, don't use it + #define wxTE_AUTO_SCROLL 0 +#endif // WXWIN_COMPATIBILITY_2_8 + // 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 #define wxTE_RICH2 0x8000 @@ -159,102 +161,121 @@ enum wxTextAttrAlignment }; // Flags to indicate which attributes are being applied - -#define wxTEXT_ATTR_TEXT_COLOUR 0x00000001 -#define wxTEXT_ATTR_BACKGROUND_COLOUR 0x00000002 -#define wxTEXT_ATTR_FONT_FACE 0x00000004 -#define wxTEXT_ATTR_FONT_SIZE 0x00000008 -#define wxTEXT_ATTR_FONT_WEIGHT 0x00000010 -#define wxTEXT_ATTR_FONT_ITALIC 0x00000020 -#define wxTEXT_ATTR_FONT_UNDERLINE 0x00000040 -#define wxTEXT_ATTR_FONT_ENCODING 0x02000000 -#define 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 ) -#define wxTEXT_ATTR_ALIGNMENT 0x00000080 -#define wxTEXT_ATTR_LEFT_INDENT 0x00000100 -#define wxTEXT_ATTR_RIGHT_INDENT 0x00000200 -#define wxTEXT_ATTR_TABS 0x00000400 - -#define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800 -#define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000 -#define wxTEXT_ATTR_LINE_SPACING 0x00002000 -#define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000 -#define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000 -#define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000 -#define wxTEXT_ATTR_BULLET_STYLE 0x00020000 -#define wxTEXT_ATTR_BULLET_NUMBER 0x00040000 -#define wxTEXT_ATTR_BULLET_TEXT 0x00080000 -#define wxTEXT_ATTR_BULLET_NAME 0x00100000 -#define wxTEXT_ATTR_URL 0x00200000 -#define wxTEXT_ATTR_PAGE_BREAK 0x00400000 -#define wxTEXT_ATTR_EFFECTS 0x00800000 -#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000 - -/*! - * Character and paragraph combined styles - */ - -#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL) - -#define 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) - -#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) +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, + 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_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, + + 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 + */ + + wxTEXT_ATTR_CHARACTER = \ + (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS| \ + wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL), + + 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|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL|wxTEXT_ATTR_PAGE_BREAK), + + wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) +}; /*! * Styles for wxTextAttr::SetBulletStyle */ - -#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 -#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 -#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 -#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 -#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 -#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 -#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 -#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 - -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 +enum wxTextAttrBulletStyle +{ + wxTEXT_ATTR_BULLET_STYLE_NONE = 0x00000000, + wxTEXT_ATTR_BULLET_STYLE_ARABIC = 0x00000001, + wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER = 0x00000002, + wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER = 0x00000004, + wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER = 0x00000008, + wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER = 0x00000010, + wxTEXT_ATTR_BULLET_STYLE_SYMBOL = 0x00000020, + wxTEXT_ATTR_BULLET_STYLE_BITMAP = 0x00000040, + wxTEXT_ATTR_BULLET_STYLE_PARENTHESES = 0x00000080, + wxTEXT_ATTR_BULLET_STYLE_PERIOD = 0x00000100, + wxTEXT_ATTR_BULLET_STYLE_STANDARD = 0x00000200, + wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS = 0x00000400, + wxTEXT_ATTR_BULLET_STYLE_OUTLINE = 0x00000800, + + wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT = 0x00000000, + wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT = 0x00001000, + wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE = 0x00002000 +}; /*! * Styles for wxTextAttr::SetTextEffects */ - -#define wxTEXT_ATTR_EFFECT_NONE 0x00000000 -#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 -#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 -#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 -#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 -#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 -#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 -#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 -#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 -#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 -#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 +enum wxTextAttrEffects +{ + wxTEXT_ATTR_EFFECT_NONE = 0x00000000, + wxTEXT_ATTR_EFFECT_CAPITALS = 0x00000001, + wxTEXT_ATTR_EFFECT_SMALL_CAPITALS = 0x00000002, + wxTEXT_ATTR_EFFECT_STRIKETHROUGH = 0x00000004, + wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH = 0x00000008, + wxTEXT_ATTR_EFFECT_SHADOW = 0x00000010, + wxTEXT_ATTR_EFFECT_EMBOSS = 0x00000020, + wxTEXT_ATTR_EFFECT_OUTLINE = 0x00000040, + wxTEXT_ATTR_EFFECT_ENGRAVE = 0x00000080, + wxTEXT_ATTR_EFFECT_SUPERSCRIPT = 0x00000100, + wxTEXT_ATTR_EFFECT_SUBSCRIPT = 0x00000200 +}; /*! * Line spacing values */ - -#define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 -#define wxTEXT_ATTR_LINE_SPACING_HALF 15 -#define wxTEXT_ATTR_LINE_SPACING_TWICE 20 +enum wxTextAttrLineSpacing +{ + wxTEXT_ATTR_LINE_SPACING_NORMAL = 10, + wxTEXT_ATTR_LINE_SPACING_HALF = 15, + wxTEXT_ATTR_LINE_SPACING_TWICE = 20 +}; // ---------------------------------------------------------------------------- // wxTextAttr: a structure containing the visual attributes of a text // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxTextAttr +class WXDLLIMPEXP_CORE wxTextAttr { public: // ctors @@ -277,11 +298,8 @@ public: // Equality test bool operator== (const wxTextAttr& attr) const; - // Partial equality test taking flags into account - bool EqPartial(const wxTextAttr& attr, int flags) const; - - // Create font from font attributes. - wxFont CreateFont() const; + // Partial equality test + bool EqPartial(const wxTextAttr& attr) const; // Get attributes from font. bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT); @@ -295,11 +313,12 @@ public: void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; } void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags |= wxTEXT_ATTR_FONT_SIZE; } - void SetFontStyle(int fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; } - void SetFontWeight(int fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; } + void SetFontStyle(wxFontStyle fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; } + void SetFontWeight(wxFontWeight fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; } void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; } void SetFontUnderlined(bool underlined) { m_fontUnderlined = underlined; m_flags |= wxTEXT_ATTR_FONT_UNDERLINE; } void SetFontEncoding(wxFontEncoding encoding) { m_fontEncoding = encoding; m_flags |= wxTEXT_ATTR_FONT_ENCODING; } + void SetFontFamily(wxFontFamily family) { m_fontFamily = family; m_flags |= wxTEXT_ATTR_FONT_FAMILY; } // Set font void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT) { GetFontAttributes(font, flags); } @@ -333,19 +352,21 @@ public: long GetFlags() const { return m_flags; } int GetFontSize() const { return m_fontSize; } - int GetFontStyle() const { return m_fontStyle; } - int GetFontWeight() const { return m_fontWeight; } + wxFontStyle GetFontStyle() const { return m_fontStyle; } + wxFontWeight GetFontWeight() const { return m_fontWeight; } bool GetFontUnderlined() const { return m_fontUnderlined; } const wxString& GetFontFaceName() const { return m_fontFaceName; } wxFontEncoding GetFontEncoding() const { return m_fontEncoding; } + wxFontFamily GetFontFamily() const { return m_fontFamily; } - wxFont GetFont() const { return CreateFont(); } + wxFont GetFont() const; const wxString& GetCharacterStyleName() const { return m_characterStyleName; } const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } const wxString& GetListStyleName() const { return m_listStyleName; } int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; } int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; } + int GetLineSpacing() const { return m_lineSpacing; } int GetBulletStyle() const { return m_bulletStyle; } int GetBulletNumber() const { return m_bulletNumber; } @@ -360,7 +381,7 @@ public: // accessors bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; } bool HasBackgroundColour() const { return m_colBack.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; } - bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) || HasFlag(wxTEXT_ATTR_ALIGNMENT) ; } + bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) && HasFlag(wxTEXT_ATTR_ALIGNMENT) ; } bool HasTabs() const { return HasFlag(wxTEXT_ATTR_TABS) ; } bool HasLeftIndent() const { return HasFlag(wxTEXT_ATTR_LEFT_INDENT); } bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); } @@ -370,6 +391,7 @@ public: bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } bool HasFontFaceName() const { return HasFlag(wxTEXT_ATTR_FONT_FACE); } bool HasFontEncoding() const { return HasFlag(wxTEXT_ATTR_FONT_ENCODING); } + bool HasFontFamily() const { return HasFlag(wxTEXT_ATTR_FONT_FAMILY); } bool HasFont() const { return HasFlag(wxTEXT_ATTR_FONT); } bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } @@ -389,6 +411,8 @@ public: bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } bool HasFlag(long flag) const { return (m_flags & flag) != 0; } + void RemoveFlag(long flag) { m_flags &= ~flag; } + void AddFlag(long flag) { m_flags |= flag; } // Is this a character style? bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); } @@ -400,11 +424,11 @@ public: return GetFlags() == 0; } - // Merges the given attributes. Does not affect 'this'. If compareWith + // Merges the given attributes. If compareWith // is non-NULL, then it will be used to mask out those attributes that are the same in style // and compareWith, for situations where we don't want to explicitly set inherited attributes. bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL); - + // merges the attributes of the base and the overlay objects and returns // the result; the parameter attributes take precedence // @@ -472,8 +496,9 @@ private: wxColour m_colText, m_colBack; int m_fontSize; - int m_fontStyle; - int m_fontWeight; + wxFontStyle m_fontStyle; + wxFontWeight m_fontWeight; + wxFontFamily m_fontFamily; bool m_fontUnderlined; wxString m_fontFaceName; @@ -559,11 +584,13 @@ public: virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const; + virtual wxString GetValue() const = 0; + virtual void SetValue(const wxString& value) = 0; protected: // implementation of loading/saving - virtual bool DoLoadFile(const wxString& file, int fileType) = 0; - virtual bool DoSaveFile(const wxString& file, int fileType) = 0; + virtual bool DoLoadFile(const wxString& file, int fileType); + virtual bool DoSaveFile(const wxString& file, int fileType); // the name of the last file loaded with LoadFile() which will be used by @@ -574,7 +601,7 @@ protected: wxTextAttr m_defaultStyle; - DECLARE_NO_COPY_CLASS(wxTextAreaBase) + wxDECLARE_NO_COPY_CLASS(wxTextAreaBase); }; // this class defines wxTextCtrl interface, wxTextCtrlBase actually implements @@ -588,15 +615,25 @@ class WXDLLIMPEXP_CORE wxTextCtrlIface : public wxTextAreaBase, public: wxTextCtrlIface() { } + // wxTextAreaBase overrides + virtual wxString GetValue() const + { + return wxTextEntryBase::GetValue(); + } + virtual void SetValue(const wxString& value) + { + wxTextEntryBase::SetValue(value); + } + private: - DECLARE_NO_COPY_CLASS(wxTextCtrlIface) + wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface); }; // ---------------------------------------------------------------------------- // wxTextCtrl: a single or multiple line text zone where user can edit text // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxTextCtrlBase : public wxControl, +class WXDLLIMPEXP_CORE wxTextCtrlBase : public wxControl, #if wxHAS_TEXT_WINDOW_STREAM public wxSTD streambuf, #endif @@ -620,20 +657,16 @@ public: wxTextCtrl& operator<<(const wxString& s); wxTextCtrl& operator<<(int i); wxTextCtrl& operator<<(long i); - wxTextCtrl& operator<<(float f); + wxTextCtrl& operator<<(float f) { return *this << double(f); } wxTextCtrl& operator<<(double d); - wxTextCtrl& operator<<(const wxChar c); + wxTextCtrl& operator<<(char c) { return *this << wxString(c); } + wxTextCtrl& operator<<(wchar_t c) { return *this << wxString(c); } // insert the character which would have resulted from this key event, // return true if anything has been inserted virtual bool EmulateKeyPress(const wxKeyEvent& event); - // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does and - // return true if the event was processed - static bool SendTextUpdatedEvent(wxWindow *win); - bool SendTextUpdatedEvent() { return SendTextUpdatedEvent(this); } - // do the window-specific processing after processing the update event virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); @@ -659,6 +692,28 @@ public: virtual bool GetStyle(long position, wxTextAttr& style); virtual bool SetDefaultStyle(const wxTextAttr& style); + // wxTextAreaBase overrides + virtual wxString GetValue() const + { + return wxTextEntry::GetValue(); + } + virtual void SetValue(const wxString& value) + { + wxTextEntry::SetValue(value); + } + + // wxWindow overrides + virtual wxVisualAttributes GetDefaultAttributes() const + { + return GetClassDefaultAttributes(GetWindowVariant()); + } + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) + { + return GetCompositeControlsDefaultAttributes(variant); + } + protected: // override streambuf method #if wxHAS_TEXT_WINDOW_STREAM @@ -668,8 +723,10 @@ protected: virtual bool DoLoadFile(const wxString& file, int fileType); virtual bool DoSaveFile(const wxString& file, int fileType); + // implement the wxTextEntry pure virtual method + virtual wxWindow *GetEditableWindow() { return this; } - DECLARE_NO_COPY_CLASS(wxTextCtrlBase) + wxDECLARE_NO_COPY_CLASS(wxTextCtrlBase); DECLARE_ABSTRACT_CLASS(wxTextCtrlBase) }; @@ -692,36 +749,39 @@ protected: #elif defined(__WXGTK__) #include "wx/gtk1/textctrl.h" #elif defined(__WXMAC__) - #include "wx/mac/textctrl.h" + #include "wx/osx/textctrl.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/textctrl.h" #elif defined(__WXPM__) #include "wx/os2/textctrl.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/textctrl.h" #endif // ---------------------------------------------------------------------------- // wxTextCtrl events // ---------------------------------------------------------------------------- -#if !WXWIN_COMPATIBILITY_EVENT_TYPES +class WXDLLIMPEXP_FWD_CORE wxTextUrlEvent; -BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14) -END_DECLARE_EVENT_TYPES() +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_ENTER, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_URL, wxTextUrlEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_TEXT_MAXLEN, wxCommandEvent); -#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES - -class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent +class WXDLLIMPEXP_CORE wxTextUrlEvent : public wxCommandEvent { public: wxTextUrlEvent(int winid, const wxMouseEvent& evtMouse, long start, long end) - : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid) - , m_evtMouse(evtMouse), m_start(start), m_end(end) + : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid), + m_evtMouse(evtMouse), m_start(start), m_end(end) { } + wxTextUrlEvent(const wxTextUrlEvent& event) + : wxCommandEvent(event), + m_evtMouse(event.m_evtMouse), + m_start(event.m_start), + m_end(event.m_end) { } // get the mouse event which happend over the URL const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; } @@ -732,6 +792,8 @@ public: // get the end of the URL long GetURLEnd() const { return m_end; } + virtual wxEvent *Clone() const { return new wxTextUrlEvent(*this); } + protected: // the corresponding mouse event wxMouseEvent m_evtMouse; @@ -741,7 +803,7 @@ protected: m_end; private: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent) + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTextUrlEvent) public: // for wxWin RTTI only, don't use @@ -752,7 +814,7 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); #define wxTextEventHandler(func) wxCommandEventHandler(func) #define wxTextUrlEventHandler(func) \ - (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTextUrlEventFunction, &func) + wxEVENT_HANDLER_CAST(wxTextUrlEventFunction, func) #define wx__DECLARE_TEXTEVT(evt, id, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextEventHandler(fn)) @@ -772,7 +834,7 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); // C++ stream to the wxTextCtrl given to its ctor during its lifetime. // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxStreamToTextRedirector +class WXDLLIMPEXP_CORE wxStreamToTextRedirector { private: void Init(wxTextCtrl *text)