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:
@@ -162,7 +162,6 @@ void wxTextAttr::Init()
|
||||
m_fontSize = 12;
|
||||
m_fontStyle = wxFONTSTYLE_NORMAL;
|
||||
m_fontWeight = wxFONTWEIGHT_NORMAL;
|
||||
m_fontUnderlined = false;
|
||||
m_fontUnderlineType = wxTEXT_ATTR_UNDERLINE_NONE;
|
||||
m_fontStrikethrough = false;
|
||||
m_fontEncoding = wxFONTENCODING_DEFAULT;
|
||||
@@ -194,7 +193,6 @@ void wxTextAttr::Copy(const wxTextAttr& attr)
|
||||
m_fontSize = attr.m_fontSize;
|
||||
m_fontStyle = attr.m_fontStyle;
|
||||
m_fontWeight = attr.m_fontWeight;
|
||||
m_fontUnderlined = attr.m_fontUnderlined;
|
||||
m_fontUnderlineType = attr.m_fontUnderlineType;
|
||||
m_colUnderline = attr.m_colUnderline;
|
||||
m_fontStrikethrough = attr.m_fontStrikethrough;
|
||||
@@ -261,8 +259,7 @@ bool wxTextAttr::operator== (const wxTextAttr& attr) const
|
||||
(!HasFontSize() || (GetFontSize() == attr.GetFontSize())) &&
|
||||
(!HasFontItalic() || (GetFontStyle() == attr.GetFontStyle())) &&
|
||||
(!HasFontWeight() || (GetFontWeight() == attr.GetFontWeight())) &&
|
||||
(!HasFontUnderlined() || (GetFontUnderlined() == attr.GetFontUnderlined())) &&
|
||||
( ( GetUnderlineType() == attr.GetUnderlineType() ) && ( GetUnderlineColour() == attr.GetUnderlineColour() ) ) &&
|
||||
(!HasFontUnderlined() || ((GetUnderlineType() == attr.GetUnderlineType()) && (GetUnderlineColour() == attr.GetUnderlineColour()) )) &&
|
||||
(!HasFontStrikethrough() || (GetFontStrikethrough() == attr.GetFontStrikethrough())) &&
|
||||
(!HasFontFaceName() || (GetFontFaceName() == attr.GetFontFaceName())) &&
|
||||
(!HasFontEncoding() || (GetFontEncoding() == attr.GetFontEncoding())) &&
|
||||
@@ -332,7 +329,8 @@ bool wxTextAttr::EqPartial(const wxTextAttr& attr, bool weakTest) const
|
||||
if (HasFontItalic() && attr.HasFontItalic() && GetFontStyle() != attr.GetFontStyle())
|
||||
return false;
|
||||
|
||||
if (HasFontUnderlined() && attr.HasFontUnderlined() && GetFontUnderlined() != attr.GetFontUnderlined())
|
||||
if (HasFontUnderlined() && attr.HasFontUnderlined() &&
|
||||
( (GetUnderlineType() != attr.GetUnderlineType()) || (GetUnderlineColour() != attr.GetUnderlineColour()) ))
|
||||
return false;
|
||||
|
||||
if (HasFontStrikethrough() && attr.HasFontStrikethrough() && GetFontStrikethrough() != attr.GetFontStrikethrough())
|
||||
@@ -507,7 +505,7 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
|
||||
m_fontWeight = font.GetWeight();
|
||||
|
||||
if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
|
||||
m_fontUnderlined = font.GetUnderlined();
|
||||
m_fontUnderlineType = font.GetUnderlined() ? wxTEXT_ATTR_UNDERLINE_SOLID : wxTEXT_ATTR_UNDERLINE_NONE;
|
||||
|
||||
if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
|
||||
m_fontStrikethrough = font.GetStrikethrough();
|
||||
@@ -576,8 +574,10 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
|
||||
|
||||
if (style.HasFontUnderlined())
|
||||
{
|
||||
if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined()))
|
||||
destStyle.SetFontUnderlined(style.GetFontUnderlined());
|
||||
if (!(compareWith && compareWith->HasFontUnderlined() &&
|
||||
compareWith->GetUnderlineType() == style.GetUnderlineType() &&
|
||||
compareWith->GetUnderlineColour() == style.GetUnderlineColour()))
|
||||
destStyle.SetFontUnderlined(style.GetUnderlineType(), style.GetUnderlineColour());
|
||||
}
|
||||
|
||||
if (style.HasFontStrikethrough())
|
||||
@@ -796,7 +796,8 @@ wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr,
|
||||
}
|
||||
|
||||
wxTextAttr newAttr(colFg, colBg, font);
|
||||
newAttr.SetFontUnderline( /*attr.GetFontUnderlined(), */attr.GetUnderlineType(), attr.GetUnderlineColour());
|
||||
if (attr.HasFontUnderlined())
|
||||
newAttr.SetFontUnderlined(attr.GetUnderlineType(), attr.GetUnderlineColour());
|
||||
|
||||
if (attr.HasAlignment())
|
||||
newAttr.SetAlignment(attr.GetAlignment());
|
||||
|
||||
Reference in New Issue
Block a user