X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8698cfea93ad298a57b6946ab2670e1106b9bb52..db414879d45f5da2be534a0f523b0506f2ab1183:/include/wx/textctrl.h diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 8638f13303..d5aa2324ef 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -171,11 +171,12 @@ enum wxTextAttrFlags wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, wxTEXT_ATTR_FONT_ITALIC = 0x00000020, wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, + wxTEXT_ATTR_FONT_STRIKETHROUGH = 0x08000000, 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_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_STRIKETHROUGH | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), wxTEXT_ATTR_ALIGNMENT = 0x00000080, wxTEXT_ATTR_LEFT_INDENT = 0x00000100, @@ -298,8 +299,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; + // Partial equality test + bool EqPartial(const wxTextAttr& attr) const; // Get attributes from font. bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT); @@ -317,6 +318,7 @@ public: 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 SetFontStrikethrough(bool strikethrough) { m_fontStrikethrough = strikethrough; m_flags |= wxTEXT_ATTR_FONT_STRIKETHROUGH; } 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; } @@ -355,6 +357,7 @@ public: wxFontStyle GetFontStyle() const { return m_fontStyle; } wxFontWeight GetFontWeight() const { return m_fontWeight; } bool GetFontUnderlined() const { return m_fontUnderlined; } + bool GetFontStrikethrough() const { return m_fontStrikethrough; } const wxString& GetFontFaceName() const { return m_fontFaceName; } wxFontEncoding GetFontEncoding() const { return m_fontEncoding; } wxFontFamily GetFontFamily() const { return m_fontFamily; } @@ -379,8 +382,8 @@ public: int GetOutlineLevel() const { return m_outlineLevel; } // 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 HasTextColour() const { return m_colText.IsOk() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; } + bool HasBackgroundColour() const { return m_colBack.IsOk() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; } 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); } @@ -389,6 +392,7 @@ public: bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); } bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); } bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } + bool HasFontStrikethrough() const { return HasFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH); } 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); } @@ -411,6 +415,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); } @@ -422,11 +428,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 // @@ -498,6 +504,7 @@ private: wxFontWeight m_fontWeight; wxFontFamily m_fontFamily; bool m_fontUnderlined; + bool m_fontStrikethrough; wxString m_fontFaceName; // Character style @@ -572,6 +579,11 @@ public: virtual long XYToPosition(long x, long y) const = 0; virtual bool PositionToXY(long pos, long *x, long *y) const = 0; + // translate the given position (which is just an index in the text control) + // to client coordinates + wxPoint PositionToCoords(long pos) const; + + virtual void ShowPosition(long pos) = 0; // find the character at position given in pixels @@ -590,6 +602,13 @@ protected: virtual bool DoLoadFile(const wxString& file, int fileType); virtual bool DoSaveFile(const wxString& file, int fileType); + // Return true if the given position is valid, i.e. positive and less than + // the last position. + virtual bool IsValidPosition(long pos) const = 0; + + // Default stub implementation of PositionToCoords() always returns + // wxDefaultPosition. + virtual wxPoint DoPositionToCoords(long pos) const; // the name of the last file loaded with LoadFile() which will be used by // SaveFile() by default @@ -623,6 +642,12 @@ public: wxTextEntryBase::SetValue(value); } +protected: + virtual bool IsValidPosition(long pos) const + { + return pos >= 0 && pos <= GetLastPosition(); + } + private: wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface); }; @@ -718,8 +743,11 @@ protected: int overflow(int i); #endif // wxHAS_TEXT_WINDOW_STREAM - virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file, int fileType); + // Another wxTextAreaBase override. + virtual bool IsValidPosition(long pos) const + { + return pos >= 0 && pos <= GetLastPosition(); + } // implement the wxTextEntry pure virtual method virtual wxWindow *GetEditableWindow() { return this; } @@ -752,8 +780,6 @@ protected: #include "wx/cocoa/textctrl.h" #elif defined(__WXPM__) #include "wx/os2/textctrl.h" -#elif defined(__WXPALMOS__) - #include "wx/palmos/textctrl.h" #endif // ----------------------------------------------------------------------------