Implement strike-through support in wxFont in wxOSX.
Implement support for this attribute in wxOSX too. Closes #16547. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -109,3 +109,4 @@ wxOSX/Cocoa:
|
||||
|
||||
- Add support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP
|
||||
events (Igor Korot).
|
||||
- Implement strike-through support in wxFont (Igor Korot).
|
||||
|
@@ -104,6 +104,7 @@ public:
|
||||
virtual wxFontStyle GetStyle() const;
|
||||
virtual wxFontWeight GetWeight() const;
|
||||
virtual bool GetUnderlined() const;
|
||||
virtual bool GetStrikethrough() const;
|
||||
virtual wxString GetFaceName() const;
|
||||
virtual wxFontEncoding GetEncoding() const;
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||
@@ -116,6 +117,7 @@ public:
|
||||
virtual void SetWeight(wxFontWeight weight);
|
||||
virtual bool SetFaceName(const wxString& faceName);
|
||||
virtual void SetUnderlined(bool underlined);
|
||||
virtual void SetStrikethrough(bool strikethrough);
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
wxDECLARE_COMMON_FONT_METHODS();
|
||||
|
@@ -114,7 +114,7 @@ enum wxFontFlag
|
||||
/// Underlined style (not underlined by default).
|
||||
wxFONTFLAG_UNDERLINED = 1 << 6,
|
||||
|
||||
/// Strike-through style (only supported in wxMSW and wxGTK currently).
|
||||
/// Strike-through style (implemented in MSW, GTK, and OSX)
|
||||
wxFONTFLAG_STRIKETHROUGH = 1 << 7,
|
||||
|
||||
/// the mask of all currently used flags
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
/**
|
||||
Use a strike-through version of the font.
|
||||
|
||||
Currently this is only implemented in wxMSW and wxGTK.
|
||||
Currently this is only implemented in wxMSW, wxGTK and OSX.
|
||||
*/
|
||||
wxFontInfo& Strikethrough(bool strikethrough = true);
|
||||
|
||||
@@ -810,7 +810,7 @@ public:
|
||||
/**
|
||||
Returns stricken-through version of this font.
|
||||
|
||||
Currently stricken-through fonts are only supported in wxMSW and wxGTK.
|
||||
Currently stricken-through fonts are only supported in wxMSW, wxGTK and OSX.
|
||||
|
||||
@see MakeStrikethrough()
|
||||
|
||||
@@ -872,7 +872,7 @@ public:
|
||||
/**
|
||||
Changes this font to be stricken-through.
|
||||
|
||||
Currently stricken-through fonts are only supported in wxMSW and wxGTK.
|
||||
Currently stricken-through fonts are only supported in wxMSW, wxGTK and OSX.
|
||||
|
||||
@see Strikethrough()
|
||||
|
||||
@@ -1076,7 +1076,7 @@ public:
|
||||
/**
|
||||
Sets strike-through attribute of the font.
|
||||
|
||||
Currently stricken-through fonts are only supported in wxMSW and wxGTK.
|
||||
Currently stricken-through fonts are only supported in wxMSW, wxGTK and OSX.
|
||||
|
||||
@param strikethrough
|
||||
@true to add strike-through style, @false to remove it.
|
||||
|
@@ -103,6 +103,15 @@ public:
|
||||
|
||||
wxFontWeight GetWeight() const { return m_info.GetWeight(); }
|
||||
|
||||
void SetStrikethrough( bool s )
|
||||
{
|
||||
if ( m_info.m_strikethrough != s )
|
||||
{
|
||||
m_info.SetStrikethrough( s );
|
||||
Free();
|
||||
}
|
||||
}
|
||||
|
||||
void SetUnderlined( bool u )
|
||||
{
|
||||
if ( m_info.m_underlined != u )
|
||||
@@ -113,6 +122,7 @@ public:
|
||||
}
|
||||
|
||||
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
||||
bool GetStrikethrough() const { return m_info.GetStrikethrough(); }
|
||||
|
||||
void SetFaceName( const wxString& facename )
|
||||
{
|
||||
@@ -719,6 +729,13 @@ void wxFont::SetUnderlined(bool underlined)
|
||||
M_FONTDATA->SetUnderlined( underlined );
|
||||
}
|
||||
|
||||
void wxFont::SetStrikethrough(bool strikethrough)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetStrikethrough( strikethrough );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -783,6 +800,13 @@ bool wxFont::GetUnderlined() const
|
||||
return M_FONTDATA->GetUnderlined();
|
||||
}
|
||||
|
||||
bool wxFont::GetStrikethrough() const
|
||||
{
|
||||
wxCHECK_MSG( M_FONTDATA != NULL, false, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->GetStrikethrough();
|
||||
}
|
||||
|
||||
wxString wxFont::GetFaceName() const
|
||||
{
|
||||
wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
|
||||
@@ -1248,7 +1272,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
|
||||
bool wxNativeFontInfo::GetStrikethrough() const
|
||||
{
|
||||
return false;
|
||||
return m_strikethrough;
|
||||
}
|
||||
|
||||
|
||||
@@ -1317,8 +1341,9 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_)
|
||||
// not reflected in native descriptors
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetStrikethrough(bool WXUNUSED(strikethrough))
|
||||
void wxNativeFontInfo::SetStrikethrough(bool strikethrough)
|
||||
{
|
||||
m_strikethrough = strikethrough;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::UpdateNamesMap(const wxString& familyName, CTFontDescriptorRef descr)
|
||||
|
@@ -834,12 +834,15 @@ public:
|
||||
wxColour GetColour() const { return m_colour ; }
|
||||
|
||||
bool GetUnderlined() const { return m_underlined ; }
|
||||
bool GetStrikethrough() const { return m_strikethrough; }
|
||||
|
||||
#if wxOSX_USE_IPHONE
|
||||
UIFont* GetUIFont() const { return m_uiFont; }
|
||||
#endif
|
||||
private :
|
||||
wxColour m_colour;
|
||||
bool m_underlined;
|
||||
bool m_underlined,
|
||||
m_strikethrough;
|
||||
#if wxOSX_USE_ATSU_TEXT
|
||||
ATSUStyle m_macATSUIStyle;
|
||||
#endif
|
||||
@@ -853,6 +856,7 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
|
||||
{
|
||||
m_colour = col;
|
||||
m_underlined = font.GetUnderlined();
|
||||
m_strikethrough = font.GetStrikethrough();
|
||||
|
||||
m_ctFont.reset( wxMacCreateCTFont( font ) );
|
||||
#if wxOSX_USE_IPHONE
|
||||
@@ -2314,6 +2318,16 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo
|
||||
CGContextSetLineWidth(m_cgContext, 1.0);
|
||||
CGContextStrokeLineSegments(m_cgContext, points, 2);
|
||||
}
|
||||
if ( fref->GetStrikethrough() )
|
||||
{
|
||||
CGFloat width = CTLineGetTypographicBounds(line, NULL, NULL, NULL);
|
||||
CGFloat height = CTFontGetSize( font );
|
||||
CGPoint points[] = { {0.0, height / 2}, {width, height / 2} };
|
||||
CGContextSetStrokeColorWithColor(m_cgContext, col);
|
||||
CGContextSetShouldAntialias(m_cgContext, false);
|
||||
CGContextSetLineWidth(m_cgContext, 1.0);
|
||||
CGContextStrokeLineSegments(m_cgContext, points, 2);
|
||||
}
|
||||
|
||||
CGContextRestoreGState(m_cgContext);
|
||||
CGContextSetTextMatrix(m_cgContext, textMatrix);
|
||||
|
Reference in New Issue
Block a user