Add support for stricken-through fonts.

Support stricken-through fonts in wxMSW and wxGTK (including special support
in wxStaticText and wxTextCtrl).

Closes #9907.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70446 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-01-23 11:28:28 +00:00
parent 0634700a96
commit c7a49742ec
18 changed files with 361 additions and 101 deletions

View File

@@ -113,6 +113,8 @@ wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, (wxFontWeight)wxNORMAL,
wxT("Helpstring"), wxT("group")) // wxFontWeight
wxPROPERTY( Underlined, bool, SetUnderlined, GetUnderlined, false, 0 /*flags*/, \
wxT("Helpstring"), wxT("group"))
wxPROPERTY( Strikethrough, bool, SetStrikethrough, GetStrikethrough, false, 0, \
wxT("Helpstring"), wxT("group"))
wxPROPERTY( Face, wxString, SetFaceName, GetFaceName, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group"))
wxPROPERTY( Encoding, wxFontEncoding, SetEncoding, GetEncoding, \
@@ -307,6 +309,7 @@ void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
SetStyle(info.style);
SetWeight(info.weight);
SetUnderlined(info.underlined);
SetStrikethrough(info.strikethrough);
SetFaceName(info.faceName);
SetEncoding(info.encoding);
#else
@@ -394,6 +397,7 @@ bool wxFontBase::operator==(const wxFont& font) const
GetStyle() == font.GetStyle() &&
GetWeight() == font.GetWeight() &&
GetUnderlined() == font.GetUnderlined() &&
GetStrikethrough() == font.GetStrikethrough() &&
GetFaceName().IsSameAs(font.GetFaceName(), false) &&
GetEncoding() == font.GetEncoding()
);
@@ -533,6 +537,19 @@ wxFont wxFont::Underlined() const
return font;
}
wxFont wxFont::Strikethrough() const
{
wxFont font(*this);
font.MakeStrikethrough();
return font;
}
wxFont& wxFont::MakeStrikethrough()
{
SetStrikethrough(true);
return *this;
}
wxFont& wxFont::Scale(float x)
{
SetPointSize(int(x*GetPointSize() + 0.5));
@@ -577,19 +594,22 @@ void wxNativeFontInfo::SetFaceName(const wxArrayString& facenames)
// These are the generic forms of FromString()/ToString.
//
// convert to/from the string representation: format is
// version;pointsize;family;style;weight;underlined;facename;encoding
// convert to/from the string representation: the general format is
// "version;the rest..." with currently defined versions being:
//
// 0;pointsize;family;style;weight;underlined;facename;encoding
// 1;pointsize;family;style;weight;underlined;strikethrough;facename;encoding
bool wxNativeFontInfo::FromString(const wxString& s)
{
long l;
short version;
wxStringTokenizer tokenizer(s, wxT(";"));
wxString token = tokenizer.GetNextToken();
//
// Ignore the version for now
//
if ( !token.ToLong(&version) || version < 0 || version > 1 )
return false;
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
@@ -616,6 +636,14 @@ bool wxNativeFontInfo::FromString(const wxString& s)
return false;
underlined = l != 0;
if ( version == 1 )
{
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return false;
strikethrough = l != 0;
}
faceName = tokenizer.GetNextToken();
#ifndef __WXMAC__
@@ -635,13 +663,14 @@ wxString wxNativeFontInfo::ToString() const
{
wxString s;
s.Printf(wxT("%d;%d;%d;%d;%d;%d;%s;%d"),
0, // version
s.Printf(wxT("%d;%d;%d;%d;%d;%d;%d;%s;%d"),
1, // version
pointSize,
family,
(int)style,
(int)weight,
underlined,
strikethrough,
faceName.GetData(),
(int)encoding);
@@ -655,6 +684,7 @@ void wxNativeFontInfo::Init()
style = wxFONTSTYLE_NORMAL;
weight = wxFONTWEIGHT_NORMAL;
underlined = false;
strikethrough = false;
faceName.clear();
encoding = wxFONTENCODING_DEFAULT;
}
@@ -679,6 +709,11 @@ bool wxNativeFontInfo::GetUnderlined() const
return underlined;
}
bool wxNativeFontInfo::GetStrikethrough() const
{
return strikethrough;
}
wxString wxNativeFontInfo::GetFaceName() const
{
return faceName;
@@ -714,6 +749,11 @@ void wxNativeFontInfo::SetUnderlined(bool underlined_)
underlined = underlined_;
}
void wxNativeFontInfo::SetStrikethrough(bool strikethrough_)
{
strikethrough = strikethrough_;
}
bool wxNativeFontInfo::SetFaceName(const wxString& facename_)
{
faceName = facename_;
@@ -750,6 +790,11 @@ wxString wxNativeFontInfo::ToUserString() const
desc << _("underlined");
}
if ( GetStrikethrough() )
{
desc << _("strikethrough");
}
switch ( GetWeight() )
{
default:
@@ -922,6 +967,10 @@ bool wxNativeFontInfo::FromUserString(const wxString& s)
{
SetUnderlined(true);
}
else if ( token == wxT("strikethrough") || token == _("strikethrough") )
{
SetStrikethrough(true);
}
else if ( token == wxT("light") || token == _("light") )
{
SetWeight(wxFONTWEIGHT_LIGHT);

View File

@@ -403,6 +403,10 @@ wxFont wxTextAttr::GetFont() const
if (HasFontUnderlined())
underlined = GetFontUnderlined();
bool strikethrough = false;
if ( HasFontStrikethrough() )
strikethrough = GetFontStrikethrough();
wxString fontFaceName;
if (HasFontFaceName())
fontFaceName = GetFontFaceName();
@@ -416,6 +420,8 @@ wxFont wxTextAttr::GetFont() const
fontFamily = GetFontFamily();
wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding);
if ( strikethrough )
font.SetStrikethrough( true );
return font;
}
@@ -437,6 +443,9 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
m_fontUnderlined = font.GetUnderlined();
if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
m_fontStrikethrough = font.GetStrikethrough();
if (flags & wxTEXT_ATTR_FONT_FACE)
m_fontFaceName = font.GetFaceName();
@@ -500,6 +509,12 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
destStyle.SetFontUnderlined(style.GetFontUnderlined());
}
if (style.HasFontStrikethrough())
{
if (!(compareWith && compareWith->HasFontStrikethrough() && compareWith->GetFontStrikethrough() == style.GetFontStrikethrough()))
destStyle.SetFontStrikethrough(style.GetFontStrikethrough());
}
if (style.HasFontFaceName())
{
if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName()))

View File

@@ -26,6 +26,8 @@
#include "wx/gtk/private.h"
#include "wx/gtk/private/object.h"
using wxGTKPrivate::SetPangoAttrsForFont;
//-----------------------------------------------------------------------------
// local defines
//-----------------------------------------------------------------------------
@@ -1408,33 +1410,8 @@ void wxWindowDCImpl::DoDrawText(const wxString& text,
}
pango_layout_set_text(m_layout, data, datalen);
if (underlined)
{
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
a->start_index = 0;
a->end_index = datalen;
pango_attr_list_insert(attrs, a);
if (needshack)
{
// dummy colour for the leading space
a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
a->start_index = 0;
a->end_index = 1;
pango_attr_list_insert(attrs, a);
// dummy colour for the trailing space
a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
a->start_index = datalen - 1;
a->end_index = datalen;
pango_attr_list_insert(attrs, a);
}
pango_layout_set_attributes(m_layout, attrs);
pango_attr_list_unref(attrs);
}
const bool
setAttrs = SetPangoAttrsForFont(m_font, m_layout, datalen, needshack);
int oldSize = 0;
const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001;
@@ -1473,7 +1450,7 @@ void wxWindowDCImpl::DoDrawText(const wxString& text,
// actually apply unscaled font
pango_layout_set_font_description( m_layout, m_fontdesc );
}
if (underlined)
if (setAttrs)
{
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);
@@ -1499,16 +1476,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord
y = YLOG2DEV(y);
pango_layout_set_text(m_layout, wxGTK_CONV(text), -1);
if (m_font.GetUnderlined())
{
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
pango_attr_list_insert(attrs, a);
pango_layout_set_attributes(m_layout, attrs);
pango_attr_list_unref(attrs);
}
SetPangoAttrsForFont( m_font, m_layout );
int oldSize = 0;
const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001;
if (isScaled)
@@ -1561,7 +1529,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord
gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x+minX, y+minY,
m_layout, NULL, bg_col);
if (m_font.GetUnderlined())
if (m_font.GetUnderlined() || m_font.GetStrikethrough())
pango_layout_set_attributes(m_layout, NULL);
// clean up the transformation matrix
@@ -2304,6 +2272,62 @@ int wxWindowDCImpl::GetDepth() const
return gdk_drawable_get_depth(m_gdkwindow);
}
bool
wxGTKPrivate::SetPangoAttrsForFont(const wxFont& font,
PangoLayout *layout,
size_t len,
bool addDummyAttrs)
{
if ( !font.IsOk() || !(font.GetUnderlined() || font.GetStrikethrough()) )
return false;
PangoAttrList* attrs = pango_attr_list_new();
if ( font.GetUnderlined() )
{
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
if ( len )
{
a->start_index = 0;
a->end_index = len;
}
pango_attr_list_insert(attrs, a);
// Add dummy attributes (use colour as it's invisible anyhow for 0
// width spaces) to ensure that the spaces in the beginning/end of the
// string are underlined too.
if ( addDummyAttrs )
{
wxASSERT_MSG( len > 2, "Must have 0-width spaces at string ends" );
a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
a->start_index = 0;
a->end_index = 1;
pango_attr_list_insert(attrs, a);
a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
a->start_index = len - 1;
a->end_index = len;
pango_attr_list_insert(attrs, a);
}
}
if ( font.GetStrikethrough() )
{
PangoAttribute *a = pango_attr_strikethrough_new( TRUE );
if ( len )
{
a->start_index = 0;
a->end_index = len;
}
pango_attr_list_insert(attrs, a);
}
pango_layout_set_attributes(layout, attrs);
pango_attr_list_unref(attrs);
return true;
}
//-----------------------------------------------------------------------------
// wxClientDCImpl

View File

@@ -52,6 +52,7 @@ public:
wxFontStyle style = wxFONTSTYLE_NORMAL,
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
bool underlined = false,
bool strikethrough = false,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
@@ -69,6 +70,7 @@ public:
void SetStyle(wxFontStyle style);
void SetWeight(wxFontWeight weight);
void SetUnderlined(bool underlined);
void SetStrikethrough(bool strikethrough);
bool SetFaceName(const wxString& facename);
void SetEncoding(wxFontEncoding encoding);
@@ -82,6 +84,7 @@ protected:
wxFontStyle style,
wxFontWeight weight,
bool underlined,
bool strikethrough,
const wxString& faceName,
wxFontEncoding encoding);
@@ -90,7 +93,7 @@ protected:
private:
bool m_underlined;
bool m_strikethrough;
// The native font info: basically a PangoFontDescription
wxNativeFontInfo m_nativeFontInfo;
@@ -108,6 +111,7 @@ void wxFontRefData::Init(int pointSize,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
bool strikethrough,
const wxString& faceName,
wxFontEncoding WXUNUSED(encoding))
{
@@ -115,6 +119,7 @@ void wxFontRefData::Init(int pointSize,
family = wxFONTFAMILY_SWISS;
m_underlined = underlined;
m_strikethrough = strikethrough;
// Create native font info
m_nativeFontInfo.description = pango_font_description_new();
@@ -149,12 +154,14 @@ void wxFontRefData::InitFromNative()
// Pango description are never underlined
m_underlined = false;
m_strikethrough = false;
}
wxFontRefData::wxFontRefData( const wxFontRefData& data )
: wxGDIRefData()
{
m_underlined = data.m_underlined;
m_strikethrough = data.m_strikethrough;
// Forces a copy of the internal data. wxNativeFontInfo should probably
// have a copy ctor and assignment operator to fix this properly but that
@@ -163,11 +170,11 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data )
}
wxFontRefData::wxFontRefData(int size, wxFontFamily family, wxFontStyle style,
wxFontWeight weight, bool underlined,
wxFontWeight weight, bool underlined, bool strikethrough,
const wxString& faceName,
wxFontEncoding encoding)
{
Init(size, family, style, weight, underlined, faceName, encoding);
Init(size, family, style, weight, underlined, strikethrough, faceName, encoding);
}
wxFontRefData::wxFontRefData(const wxString& nativeFontInfoString)
@@ -244,6 +251,11 @@ void wxFontRefData::SetUnderlined(bool underlined)
// here we just need to save the underlined attribute
}
void wxFontRefData::SetStrikethrough(bool strikethrough)
{
m_strikethrough = strikethrough;
}
bool wxFontRefData::SetFaceName(const wxString& facename)
{
return m_nativeFontInfo.SetFaceName(facename);
@@ -287,7 +299,7 @@ wxFont::wxFont(int pointSize,
GetStyleFromFlags(flags),
GetWeightFromFlags(flags),
GetUnderlinedFromFlags(flags),
face, encoding);
false, face, encoding);
}
bool wxFont::Create( int pointSize,
@@ -301,7 +313,7 @@ bool wxFont::Create( int pointSize,
UnRef();
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, face, encoding);
underlined, false, face, encoding);
return true;
}
@@ -369,6 +381,13 @@ bool wxFont::GetUnderlined() const
return M_FONTDATA->m_underlined;
}
bool wxFont::GetStrikethrough() const
{
wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
return M_FONTDATA->m_strikethrough;
}
wxFontEncoding wxFont::GetEncoding() const
{
wxCHECK_MSG( IsOk(), wxFONTENCODING_SYSTEM, wxT("invalid font") );
@@ -438,6 +457,13 @@ void wxFont::SetUnderlined(bool underlined)
M_FONTDATA->SetUnderlined(underlined);
}
void wxFont::SetStrikethrough(bool strikethrough)
{
AllocExclusive();
M_FONTDATA->SetStrikethrough(strikethrough);
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
AllocExclusive();

View File

@@ -1592,23 +1592,13 @@ void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wx
double xx = XLOG2DEV(x);
double yy = YLOG2DEV(y);
bool underlined = m_font.IsOk() && m_font.GetUnderlined();
const wxScopedCharBuffer data(text.utf8_str());
size_t datalen = strlen(data);
pango_layout_set_text( m_layout, data, datalen);
if (underlined)
{
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
a->start_index = 0;
a->end_index = datalen;
pango_attr_list_insert(attrs, a);
pango_layout_set_attributes(m_layout, attrs);
pango_attr_list_unref(attrs);
}
const bool
setAttrs = wxGTKPrivate::SetPangoAttrsForFont(m_font, m_layout, datalen);
if (m_textForegroundColour.IsOk())
{
@@ -1656,7 +1646,7 @@ void wxGnomePrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wx
gs_libGnomePrint->gnome_print_grestore( m_gpc );
if (underlined)
if (setAttrs)
{
// undo underline attributes setting:
pango_layout_set_attributes(m_layout, NULL);

View File

@@ -1738,24 +1738,13 @@ void wxGtkPrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCo
angle = -angle;
bool underlined = m_font.IsOk() && m_font.GetUnderlined();
const wxScopedCharBuffer data = text.utf8_str();
size_t datalen = strlen(data);
pango_layout_set_text( m_layout, data, datalen);
if (underlined)
{
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
a->start_index = 0;
a->end_index = datalen;
pango_attr_list_insert(attrs, a);
pango_layout_set_attributes(m_layout, attrs);
pango_attr_list_unref(attrs);
}
const bool
setAttrs = wxGTKPrivate::SetPangoAttrsForFont(m_font, m_layout, datalen);
if (m_textForegroundColour.IsOk())
{
unsigned char red = m_textForegroundColour.Red();
@@ -1816,7 +1805,7 @@ void wxGtkPrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCo
cairo_restore( m_cairo );
if (underlined)
if (setAttrs)
{
// Undo underline attributes setting
pango_layout_set_attributes(m_layout, NULL);

View File

@@ -153,31 +153,48 @@ bool wxStaticText::DoSetLabelMarkup(const wxString& markup)
bool wxStaticText::SetFont( const wxFont &font )
{
const bool wasUnderlined = GetFont().GetUnderlined();
const bool wasStrickenThrough = GetFont().GetStrikethrough();
bool ret = wxControl::SetFont(font);
if ( font.GetUnderlined() != wasUnderlined )
{
// the underlines for mnemonics are incompatible with using attributes
// so turn them off when setting underlined font and restore them when
// unsetting it
gtk_label_set_use_underline(GTK_LABEL(m_widget), wasUnderlined);
const bool isUnderlined = GetFont().GetUnderlined();
const bool isStrickenThrough = GetFont().GetStrikethrough();
if ( wasUnderlined )
if ( (isUnderlined != wasUnderlined) ||
(isStrickenThrough != wasStrickenThrough) )
{
// We need to update the Pango attributes used for the text.
if ( isUnderlined || isStrickenThrough )
{
// it's not underlined any more, remove the attributes we set
gtk_label_set_attributes(GTK_LABEL(m_widget), NULL);
}
else // the text is underlined now
{
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
a->start_index = 0;
a->end_index = (guint)-1;
pango_attr_list_insert(attrs, a);
PangoAttrList* const attrs = pango_attr_list_new();
if ( isUnderlined )
{
PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
a->start_index = 0;
a->end_index = (guint)-1;
pango_attr_list_insert(attrs, a);
}
if ( isStrickenThrough )
{
PangoAttribute *a = pango_attr_strikethrough_new( TRUE );
a->start_index = 0;
a->end_index = (guint) -1;
pango_attr_list_insert(attrs, a);
}
gtk_label_set_attributes(GTK_LABEL(m_widget), attrs);
pango_attr_list_unref(attrs);
}
else // No special attributes any more.
{
// Just remove any attributes we had set.
gtk_label_set_attributes(GTK_LABEL(m_widget), NULL);
}
// The underlines for mnemonics are incompatible with using attributes
// so turn them off when setting underlined font.
gtk_label_set_use_underline(GTK_LABEL(m_widget), !isUnderlined);
}
// adjust the label size to the new label unless disabled

View File

@@ -110,6 +110,18 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text,
NULL );
gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
}
if ( font.GetStrikethrough() )
{
g_snprintf(buf, sizeof(buf), "WXFONTSTRIKETHROUGH");
tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
buf );
if (!tag)
tag = gtk_text_buffer_create_tag( text_buffer, buf,
"strikethrough-set", TRUE,
"strikethrough", TRUE,
NULL );
gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
}
}
if (attr.HasTextColour())

View File

@@ -63,7 +63,7 @@ public:
wxFontRefData()
{
Init(-1, wxSize(0,0), false, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL, false, wxEmptyString,
wxFONTWEIGHT_NORMAL, false, false, wxEmptyString,
wxFONTENCODING_DEFAULT);
}
@@ -74,11 +74,12 @@ public:
wxFontStyle style,
wxFontWeight weight,
bool underlined,
bool strikethrough,
const wxString& faceName,
wxFontEncoding encoding)
{
Init(size, pixelSize, sizeUsingPixels, family, style, weight,
underlined, faceName, encoding);
underlined, strikethrough, faceName, encoding);
}
wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
@@ -134,6 +135,11 @@ public:
return m_nativeFontInfo.GetUnderlined();
}
bool GetStrikethrough() const
{
return m_nativeFontInfo.GetStrikethrough();
}
wxString GetFaceName() const
{
wxString facename = m_nativeFontInfo.GetFaceName();
@@ -225,6 +231,13 @@ public:
m_nativeFontInfo.SetUnderlined(underlined);
}
void SetStrikethrough(bool strikethrough)
{
Free();
m_nativeFontInfo.SetStrikethrough(strikethrough);
}
void SetEncoding(wxFontEncoding encoding)
{
Free();
@@ -262,6 +275,7 @@ protected:
wxFontStyle style,
wxFontWeight weight,
bool underlined,
bool strikethrough,
const wxString& faceName,
wxFontEncoding encoding);
@@ -336,6 +350,7 @@ void wxFontRefData::Init(int pointSize,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
bool strikethrough,
const wxString& faceName,
wxFontEncoding encoding)
{
@@ -350,6 +365,7 @@ void wxFontRefData::Init(int pointSize,
SetStyle(style);
SetWeight(weight);
SetUnderlined(underlined);
SetStrikethrough(strikethrough);
// set the family/facename
SetFamily(family);
@@ -463,6 +479,11 @@ bool wxNativeFontInfo::GetUnderlined() const
return lf.lfUnderline != 0;
}
bool wxNativeFontInfo::GetStrikethrough() const
{
return lf.lfStrikeOut != 0;
}
wxString wxNativeFontInfo::GetFaceName() const
{
return lf.lfFaceName;
@@ -583,6 +604,11 @@ void wxNativeFontInfo::SetUnderlined(bool underlined)
lf.lfUnderline = underlined;
}
void wxNativeFontInfo::SetStrikethrough(bool strikethrough)
{
lf.lfStrikeOut = strikethrough;
}
bool wxNativeFontInfo::SetFaceName(const wxString& facename)
{
wxStrlcpy(lf.lfFaceName, facename.c_str(), WXSIZEOF(lf.lfFaceName));
@@ -789,7 +815,7 @@ wxFont::wxFont(int pointSize,
GetStyleFromFlags(flags),
GetWeightFromFlags(flags),
GetUnderlinedFromFlags(flags),
face, encoding);
false, face, encoding);
}
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
@@ -822,7 +848,7 @@ bool wxFont::DoCreate(int pointSize,
m_refData = new wxFontRefData(pointSize, pixelSize, sizeUsingPixels,
family, style, weight,
underlined, faceName, encoding);
underlined, false, faceName, encoding);
return RealizeResource();
}
@@ -944,6 +970,13 @@ void wxFont::SetUnderlined(bool underlined)
M_FONTDATA->SetUnderlined(underlined);
}
void wxFont::SetStrikethrough(bool strikethrough)
{
AllocExclusive();
M_FONTDATA->SetStrikethrough(strikethrough);
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
AllocExclusive();
@@ -1009,6 +1042,13 @@ bool wxFont::GetUnderlined() const
return M_FONTDATA->GetUnderlined();
}
bool wxFont::GetStrikethrough() const
{
wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
return M_FONTDATA->GetStrikethrough();
}
wxString wxFont::GetFaceName() const
{
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );