Improve underline changes of wxTextCtrl

Get rid of m_fontUnderlined, use m_fontUnderlineType instead.
Bugfixes in wxMSW, wxGTK and wxOSX code.
Show more underline usage in the text sample.
This commit is contained in:
Maarten Bent
2019-07-06 13:47:00 +02:00
parent f99ae84d7c
commit 4afea28aab
7 changed files with 126 additions and 128 deletions

View File

@@ -271,7 +271,7 @@ enum wxTextAttrLineSpacing
};
enum wxTextAttrUnderlineType
{
{
wxTEXT_ATTR_UNDERLINE_NONE,
wxTEXT_ATTR_UNDERLINE_SOLID,
wxTEXT_ATTR_UNDERLINE_DOUBLE,
@@ -328,12 +328,10 @@ public:
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 SetFontUnderline(/*bool underlined, */wxTextAttrUnderlineType type = wxTEXT_ATTR_UNDERLINE_NONE, const wxColour& colour = wxNullColour)
void SetFontUnderlined(bool underlined) { SetFontUnderlined(underlined ? wxTEXT_ATTR_UNDERLINE_SOLID : wxTEXT_ATTR_UNDERLINE_NONE); }
void SetFontUnderlined(wxTextAttrUnderlineType type, const wxColour& colour = wxNullColour)
{
if( type != wxTEXT_ATTR_UNDERLINE_NONE )
m_flags |= wxTEXT_ATTR_FONT_UNDERLINE;
// m_fontUnderlined = underlined;
m_flags |= wxTEXT_ATTR_FONT_UNDERLINE;
m_fontUnderlineType = type;
m_colUnderline = colour;
}
@@ -375,7 +373,7 @@ public:
int GetFontSize() const { return m_fontSize; }
wxFontStyle GetFontStyle() const { return m_fontStyle; }
wxFontWeight GetFontWeight() const { return m_fontWeight; }
bool GetFontUnderlined() const { return m_fontUnderlined; }
bool GetFontUnderlined() const { return m_fontUnderlineType != wxTEXT_ATTR_UNDERLINE_NONE; }
wxTextAttrUnderlineType GetUnderlineType() const { return m_fontUnderlineType; }
const wxColour& GetUnderlineColour() const { return m_colUnderline; }
bool GetFontStrikethrough() const { return m_fontStrikethrough; }
@@ -414,8 +412,7 @@ public:
bool HasFontPointSize() const { return HasFlag(wxTEXT_ATTR_FONT_POINT_SIZE); }
bool HasFontPixelSize() const { return HasFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); }
bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); }
bool HasFontUnderlined() const { return m_fontUnderlined; }
bool HasFontUnderline() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); }
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); }
@@ -527,7 +524,6 @@ private:
wxFontStyle m_fontStyle;
wxFontWeight m_fontWeight;
wxFontFamily m_fontFamily;
bool m_fontUnderlined;
wxTextAttrUnderlineType m_fontUnderlineType;
wxColour m_colUnderline;
bool m_fontStrikethrough;