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
|
- Add support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP
|
||||||
events (Igor Korot).
|
events (Igor Korot).
|
||||||
|
- Implement strike-through support in wxFont (Igor Korot).
|
||||||
|
@@ -104,6 +104,7 @@ public:
|
|||||||
virtual wxFontStyle GetStyle() const;
|
virtual wxFontStyle GetStyle() const;
|
||||||
virtual wxFontWeight GetWeight() const;
|
virtual wxFontWeight GetWeight() const;
|
||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
|
virtual bool GetStrikethrough() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
@@ -116,6 +117,7 @@ public:
|
|||||||
virtual void SetWeight(wxFontWeight weight);
|
virtual void SetWeight(wxFontWeight weight);
|
||||||
virtual bool SetFaceName(const wxString& faceName);
|
virtual bool SetFaceName(const wxString& faceName);
|
||||||
virtual void SetUnderlined(bool underlined);
|
virtual void SetUnderlined(bool underlined);
|
||||||
|
virtual void SetStrikethrough(bool strikethrough);
|
||||||
virtual void SetEncoding(wxFontEncoding encoding);
|
virtual void SetEncoding(wxFontEncoding encoding);
|
||||||
|
|
||||||
wxDECLARE_COMMON_FONT_METHODS();
|
wxDECLARE_COMMON_FONT_METHODS();
|
||||||
|
@@ -114,7 +114,7 @@ enum wxFontFlag
|
|||||||
/// Underlined style (not underlined by default).
|
/// Underlined style (not underlined by default).
|
||||||
wxFONTFLAG_UNDERLINED = 1 << 6,
|
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,
|
wxFONTFLAG_STRIKETHROUGH = 1 << 7,
|
||||||
|
|
||||||
/// the mask of all currently used flags
|
/// the mask of all currently used flags
|
||||||
@@ -384,7 +384,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Use a strike-through version of the font.
|
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);
|
wxFontInfo& Strikethrough(bool strikethrough = true);
|
||||||
|
|
||||||
@@ -810,7 +810,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns stricken-through version of this font.
|
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()
|
@see MakeStrikethrough()
|
||||||
|
|
||||||
@@ -872,7 +872,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Changes this font to be stricken-through.
|
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()
|
@see Strikethrough()
|
||||||
|
|
||||||
@@ -1076,7 +1076,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Sets strike-through attribute of the font.
|
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
|
@param strikethrough
|
||||||
@true to add strike-through style, @false to remove it.
|
@true to add strike-through style, @false to remove it.
|
||||||
|
@@ -103,6 +103,15 @@ public:
|
|||||||
|
|
||||||
wxFontWeight GetWeight() const { return m_info.GetWeight(); }
|
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 )
|
void SetUnderlined( bool u )
|
||||||
{
|
{
|
||||||
if ( m_info.m_underlined != u )
|
if ( m_info.m_underlined != u )
|
||||||
@@ -113,6 +122,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
||||||
|
bool GetStrikethrough() const { return m_info.GetStrikethrough(); }
|
||||||
|
|
||||||
void SetFaceName( const wxString& facename )
|
void SetFaceName( const wxString& facename )
|
||||||
{
|
{
|
||||||
@@ -719,6 +729,13 @@ void wxFont::SetUnderlined(bool underlined)
|
|||||||
M_FONTDATA->SetUnderlined( underlined );
|
M_FONTDATA->SetUnderlined( underlined );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFont::SetStrikethrough(bool strikethrough)
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_FONTDATA->SetStrikethrough( strikethrough );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -783,6 +800,13 @@ bool wxFont::GetUnderlined() const
|
|||||||
return M_FONTDATA->GetUnderlined();
|
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
|
wxString wxFont::GetFaceName() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
|
wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
|
||||||
@@ -1248,7 +1272,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
|
|
||||||
bool wxNativeFontInfo::GetStrikethrough() const
|
bool wxNativeFontInfo::GetStrikethrough() const
|
||||||
{
|
{
|
||||||
return false;
|
return m_strikethrough;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1317,8 +1341,9 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_)
|
|||||||
// not reflected in native descriptors
|
// 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)
|
void wxNativeFontInfo::UpdateNamesMap(const wxString& familyName, CTFontDescriptorRef descr)
|
||||||
|
@@ -834,12 +834,15 @@ public:
|
|||||||
wxColour GetColour() const { return m_colour ; }
|
wxColour GetColour() const { return m_colour ; }
|
||||||
|
|
||||||
bool GetUnderlined() const { return m_underlined ; }
|
bool GetUnderlined() const { return m_underlined ; }
|
||||||
|
bool GetStrikethrough() const { return m_strikethrough; }
|
||||||
|
|
||||||
#if wxOSX_USE_IPHONE
|
#if wxOSX_USE_IPHONE
|
||||||
UIFont* GetUIFont() const { return m_uiFont; }
|
UIFont* GetUIFont() const { return m_uiFont; }
|
||||||
#endif
|
#endif
|
||||||
private :
|
private :
|
||||||
wxColour m_colour;
|
wxColour m_colour;
|
||||||
bool m_underlined;
|
bool m_underlined,
|
||||||
|
m_strikethrough;
|
||||||
#if wxOSX_USE_ATSU_TEXT
|
#if wxOSX_USE_ATSU_TEXT
|
||||||
ATSUStyle m_macATSUIStyle;
|
ATSUStyle m_macATSUIStyle;
|
||||||
#endif
|
#endif
|
||||||
@@ -853,6 +856,7 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
|
|||||||
{
|
{
|
||||||
m_colour = col;
|
m_colour = col;
|
||||||
m_underlined = font.GetUnderlined();
|
m_underlined = font.GetUnderlined();
|
||||||
|
m_strikethrough = font.GetStrikethrough();
|
||||||
|
|
||||||
m_ctFont.reset( wxMacCreateCTFont( font ) );
|
m_ctFont.reset( wxMacCreateCTFont( font ) );
|
||||||
#if wxOSX_USE_IPHONE
|
#if wxOSX_USE_IPHONE
|
||||||
@@ -2314,6 +2318,16 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo
|
|||||||
CGContextSetLineWidth(m_cgContext, 1.0);
|
CGContextSetLineWidth(m_cgContext, 1.0);
|
||||||
CGContextStrokeLineSegments(m_cgContext, points, 2);
|
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);
|
CGContextRestoreGState(m_cgContext);
|
||||||
CGContextSetTextMatrix(m_cgContext, textMatrix);
|
CGContextSetTextMatrix(m_cgContext, textMatrix);
|
||||||
|
Reference in New Issue
Block a user