Add strikethrough support for fonts defined in XRC

Handle this attribute as well as "underlined" for completeness.
This commit is contained in:
Vadim Zeitlin
2018-09-15 13:51:36 +02:00
parent ca164bb4ca
commit f085981601
5 changed files with 14 additions and 1 deletions

View File

@@ -115,6 +115,7 @@ All (GUI):
- Support strike-through in wxDataViewItem attributes (approach, Igor Korot). - Support strike-through in wxDataViewItem attributes (approach, Igor Korot).
- Allow distinguishing between user- and script-opened windows in wxWebView. - Allow distinguishing between user- and script-opened windows in wxWebView.
- Allow binding to events generated by their items in submenus too. - Allow binding to events generated by their items in submenus too.
- Add strikethrough support for fonts defined in XRC.
wxGTK: wxGTK:

View File

@@ -422,6 +422,9 @@ and can be one of the following "sub-properties":
(default: default).} (default: default).}
@row3col{underlined, @ref overview_xrcformat_type_bool, @row3col{underlined, @ref overview_xrcformat_type_bool,
Whether the font should be underlined (default: 0).} Whether the font should be underlined (default: 0).}
@row3col{strikethrough, @ref overview_xrcformat_type_bool,
Whether the strikethrough font should be used (default: 0). This property
is only supported since wxWidgets 3.1.2.}
@row3col{face, , @row3col{face, ,
Comma-separated list of face names; the first one available is used Comma-separated list of face names; the first one available is used
(default: unspecified).} (default: unspecified).}

View File

@@ -462,6 +462,7 @@ t_font = (
[xrc:p="o"] element family {_, ("roman" | "script" | "decorative" | "swiss" | [xrc:p="o"] element family {_, ("roman" | "script" | "decorative" | "swiss" |
"modern" | "teletype") }* & "modern" | "teletype") }* &
[xrc:p="o"] element underlined {_, t_bool }* & [xrc:p="o"] element underlined {_, t_bool }* &
[xrc:p="o"] element strikethrough{_, t_bool }* &
[xrc:p="o"] element face {_, t_text }* & [xrc:p="o"] element face {_, t_text }* &
[xrc:p="o"] element encoding {_, t_text }* & [xrc:p="o"] element encoding {_, t_text }* &
[xrc:p="o"] element sysfont {_, ("wxSYS_OEM_FIXED_FONT" | "wxSYS_ANSI_FIXED_FONT" | [xrc:p="o"] element sysfont {_, ("wxSYS_OEM_FIXED_FONT" | "wxSYS_ANSI_FIXED_FONT" |

View File

@@ -1099,7 +1099,7 @@ lay them out using wxSizers, absolute positioning, everything you like!
<flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL</flag> <flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL</flag>
<border>5</border> <border>5</border>
<object class="wxStaticText" name="wxID_STATIC"> <object class="wxStaticText" name="wxID_STATIC">
<label>Slightly larger font:</label> <label>Slightly larger strikethrough font:</label>
</object> </object>
</object> </object>
<object class="sizeritem"> <object class="sizeritem">
@@ -1109,6 +1109,7 @@ lay them out using wxSizers, absolute positioning, everything you like!
<label>It was a dark and stormy night.</label> <label>It was a dark and stormy night.</label>
<font> <font>
<size>12.5</size> <size>12.5</size>
<strikethrough>1</strikethrough>
</font> </font>
</object> </object>
</object> </object>

View File

@@ -2349,6 +2349,10 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
bool hasUnderlined = HasParam(wxT("underlined")); bool hasUnderlined = HasParam(wxT("underlined"));
bool underlined = hasUnderlined ? GetBool(wxT("underlined"), false) : false; bool underlined = hasUnderlined ? GetBool(wxT("underlined"), false) : false;
// strikethrough
bool hasStrikethrough = HasParam(wxT("strikethrough"));
bool strikethrough = hasStrikethrough ? GetBool(wxT("strikethrough"), false) : false;
// family and facename // family and facename
wxFontFamily ifamily = wxFONTFAMILY_DEFAULT; wxFontFamily ifamily = wxFONTFAMILY_DEFAULT;
bool hasFamily = HasParam(wxT("family")); bool hasFamily = HasParam(wxT("family"));
@@ -2466,6 +2470,8 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
font.SetNumericWeight(iweight); font.SetNumericWeight(iweight);
if (hasUnderlined) if (hasUnderlined)
font.SetUnderlined(underlined); font.SetUnderlined(underlined);
if (hasStrikethrough)
font.SetStrikethrough(strikethrough);
if (hasFamily) if (hasFamily)
font.SetFamily(ifamily); font.SetFamily(ifamily);
if (hasFacename) if (hasFacename)
@@ -2481,6 +2487,7 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
.Style(istyle) .Style(istyle)
.Weight(iweight) .Weight(iweight)
.Underlined(underlined) .Underlined(underlined)
.Strikethrough(strikethrough)
.Encoding(enc) .Encoding(enc)
; ;
} }