Fixes to wxFont strike-through support in wxOSX.

Don't create strike-through fonts by default.

Also add support for strike-through in wxCarbon.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-14 11:17:54 +00:00
parent c3dd247c1e
commit 79fb4e2250
3 changed files with 36 additions and 7 deletions

View File

@@ -121,9 +121,14 @@ public:
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, wxFontWeight weight,
bool underlined, bool underlined,
bool strikethrough,
const wxString& faceName, const wxString& faceName,
wxFontEncoding encoding) wxFontEncoding encoding)
{ Init(size,family,style,weight,underlined,faceName,encoding); } {
Init(size, family, style, weight,
underlined, strikethrough,
faceName, encoding);
}
~wxNativeFontInfo() { Free(); } ~wxNativeFontInfo() { Free(); }
@@ -144,6 +149,7 @@ public:
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, wxFontWeight weight,
bool underlined, bool underlined,
bool strikethrough,
const wxString& faceName , const wxString& faceName ,
wxFontEncoding encoding); wxFontEncoding encoding);

View File

@@ -39,7 +39,7 @@ public:
{ {
Init(); Init();
m_info.Init(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, m_info.Init(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
false, wxEmptyString, wxFONTENCODING_DEFAULT); false, false, wxEmptyString, wxFONTENCODING_DEFAULT);
} }
wxFontRefData(const wxFontRefData& data); wxFontRefData(const wxFontRefData& data);
@@ -639,7 +639,7 @@ bool wxFont::Create(int pointSize,
wxNativeFontInfo info; wxNativeFontInfo info;
info.Init(pointSize, family, style, weight, info.Init(pointSize, family, style, weight,
underlined, faceName, encoding); underlined, false, faceName, encoding);
m_refData = new wxFontRefData(info); m_refData = new wxFontRefData(info);
@@ -1025,6 +1025,7 @@ void wxNativeFontInfo::Init()
m_style = wxFONTSTYLE_NORMAL; m_style = wxFONTSTYLE_NORMAL;
m_weight = wxFONTWEIGHT_NORMAL; m_weight = wxFONTWEIGHT_NORMAL;
m_underlined = false; m_underlined = false;
m_strikethrough = false;
m_faceName.clear(); m_faceName.clear();
m_encoding = wxFont::GetDefaultEncoding(); m_encoding = wxFont::GetDefaultEncoding();
m_descriptorValid = false; m_descriptorValid = false;
@@ -1087,6 +1088,8 @@ void wxNativeFontInfo::EnsureValid()
m_qdFontStyle |= italic; m_qdFontStyle |= italic;
if (m_underlined) if (m_underlined)
m_qdFontStyle |= underline; m_qdFontStyle |= underline;
if (m_strikethrough)
m_qdFontStyle |= strikethrough;
// we try to get as much styles as possible into ATSU // we try to get as much styles as possible into ATSU
@@ -1122,6 +1125,7 @@ void wxNativeFontInfo::Init(const wxNativeFontInfo& info)
m_style = info.m_style; m_style = info.m_style;
m_weight = info.m_weight; m_weight = info.m_weight;
m_underlined = info.m_underlined; m_underlined = info.m_underlined;
m_strikethrough = info.m_strikethrough;
m_faceName = info.m_faceName; m_faceName = info.m_faceName;
m_encoding = info.m_encoding; m_encoding = info.m_encoding;
m_descriptorValid = info.m_descriptorValid; m_descriptorValid = info.m_descriptorValid;
@@ -1132,6 +1136,7 @@ void wxNativeFontInfo::Init(int size,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, wxFontWeight weight,
bool underlined, bool underlined,
bool strikethrough,
const wxString& faceName, const wxString& faceName,
wxFontEncoding encoding) wxFontEncoding encoding)
{ {
@@ -1150,6 +1155,7 @@ void wxNativeFontInfo::Init(int size,
m_style = style; m_style = style;
m_weight = weight; m_weight = weight;
m_underlined = underlined; m_underlined = underlined;
m_strikethrough = strikethrough;
m_faceName = faceName; m_faceName = faceName;
if ( encoding == wxFONTENCODING_DEFAULT ) if ( encoding == wxFONTENCODING_DEFAULT )
encoding = wxFont::GetDefaultEncoding(); encoding = wxFont::GetDefaultEncoding();
@@ -1169,11 +1175,14 @@ void wxNativeFontInfo::Free()
bool wxNativeFontInfo::FromString(const wxString& s) bool wxNativeFontInfo::FromString(const wxString& s)
{ {
long l; long l, version;
wxStringTokenizer tokenizer(s, wxT(";")); wxStringTokenizer tokenizer(s, wxT(";"));
wxString token = tokenizer.GetNextToken(); wxString token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return false;
version = l;
// //
// Ignore the version for now // Ignore the version for now
// //
@@ -1203,6 +1212,18 @@ bool wxNativeFontInfo::FromString(const wxString& s)
return false; return false;
m_underlined = l != 0; m_underlined = l != 0;
if ( version == 0L )
{
m_strikethrough = false;
}
else
{
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return false;
m_strikethrough = l != 0;
}
m_faceName = tokenizer.GetNextToken(); m_faceName = tokenizer.GetNextToken();
#ifndef __WXMAC__ #ifndef __WXMAC__
@@ -1222,13 +1243,14 @@ wxString wxNativeFontInfo::ToString() const
{ {
wxString s; wxString s;
s.Printf(wxT("%d;%d;%d;%d;%d;%d;%s;%d"), s.Printf(wxT("%d;%d;%d;%d;%d;%d;%d;%s;%d"),
0, // version 1, // version
m_pointSize, m_pointSize,
m_family, m_family,
(int)m_style, (int)m_style,
(int)m_weight, (int)m_weight,
m_underlined, m_underlined,
m_strikethrough,
m_faceName.GetData(), m_faceName.GetData(),
(int)m_encoding); (int)m_encoding);

View File

@@ -130,6 +130,7 @@ void wxFont::SetNativeInfoFromNSFont(WX_NSFont theFont, wxNativeFontInfo* info)
wxFontStyle fontstyle = wxFONTSTYLE_NORMAL; wxFontStyle fontstyle = wxFONTSTYLE_NORMAL;
wxFontWeight fontweight = wxFONTWEIGHT_NORMAL; wxFontWeight fontweight = wxFONTWEIGHT_NORMAL;
bool underlined = false; bool underlined = false;
bool strikethrough = false;
int size = (int) ([theFont pointSize]+0.5); int size = (int) ([theFont pointSize]+0.5);
@@ -143,7 +144,7 @@ void wxFont::SetNativeInfoFromNSFont(WX_NSFont theFont, wxNativeFontInfo* info)
if ( theTraits & NSItalicFontMask ) if ( theTraits & NSItalicFontMask )
fontstyle = wxFONTSTYLE_ITALIC ; fontstyle = wxFONTSTYLE_ITALIC ;
info->Init(size,fontFamily,fontstyle,fontweight,underlined, info->Init(size,fontFamily,fontstyle,fontweight,underlined, strikethrough,
wxCFStringRef::AsString([theFont familyName]), wxFONTENCODING_DEFAULT); wxCFStringRef::AsString([theFont familyName]), wxFONTENCODING_DEFAULT);
} }