wxCocoa: Basic support for font underlining:
* Make wxWindow::SetFont call wxWindowBase::SetFont. * Make wxDC::SetFont store the font in existing m_font. * Make wxFont::GetUnderlined return the m_underlined flag. * Implement underlining in wxDC::DoDrawText Copyright 2007, Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47598 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
be2ad872dc
commit
e7e97a594d
@ -83,7 +83,7 @@ public:
|
||||
virtual void StartPage(void) {};
|
||||
virtual void EndPage(void) {};
|
||||
|
||||
virtual void SetFont(const wxFont& font) {}
|
||||
virtual void SetFont(const wxFont& font);
|
||||
virtual void SetPen(const wxPen& pen);
|
||||
virtual void SetBrush(const wxBrush& brush);
|
||||
virtual void SetBackground(const wxBrush& brush);
|
||||
|
@ -315,11 +315,25 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||
NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0];
|
||||
layoutLocation.x = 0.0;
|
||||
layoutLocation.y *= -1.0;
|
||||
|
||||
// Save the location as is for underlining
|
||||
NSPoint underlineLocation = layoutLocation;
|
||||
|
||||
// Offset the location by the baseline for drawing the glyphs.
|
||||
layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0];
|
||||
|
||||
if(m_backgroundMode==wxSOLID)
|
||||
[sm_cocoaNSLayoutManager drawBackgroundForGlyphRange:glyphRange atPoint:NSZeroPoint];
|
||||
[sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation];
|
||||
|
||||
int underlineStyle = GetFont().GetUnderlined() ? NSUnderlineStyleSingle : NSUnderlineStyleNone;
|
||||
NSRange lineGlyphRange;
|
||||
NSRect lineRect = [sm_cocoaNSLayoutManager lineFragmentRectForGlyphAtIndex:0 effectiveRange:&lineGlyphRange];
|
||||
|
||||
[sm_cocoaNSLayoutManager underlineGlyphRange:glyphRange underlineType:underlineStyle
|
||||
lineFragmentRect:lineRect lineFragmentGlyphRange:lineGlyphRange
|
||||
containerOrigin:underlineLocation];
|
||||
|
||||
[context restoreGraphicsState];
|
||||
}
|
||||
|
||||
@ -386,6 +400,11 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc,
|
||||
{
|
||||
}
|
||||
|
||||
void wxDC::SetFont(const wxFont& font)
|
||||
{
|
||||
m_font = font;
|
||||
}
|
||||
|
||||
void wxDC::SetPen(const wxPen& pen)
|
||||
{
|
||||
m_pen = pen;
|
||||
|
@ -60,7 +60,10 @@ int wxFont::GetPointSize() const
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
{
|
||||
return false;
|
||||
if(M_FONTDATA)
|
||||
return M_FONTDATA->m_underlined;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int wxFont::GetStyle() const
|
||||
|
@ -1031,8 +1031,8 @@ void wxWindow::DoSetVirtualSize( int x, int y )
|
||||
|
||||
bool wxWindow::SetFont(const wxFont& font)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
// FIXME: We may need to handle wx font inheritance.
|
||||
return wxWindowBase::SetFont(font);
|
||||
}
|
||||
|
||||
#if 0 // these are used when debugging the algorithm.
|
||||
|
Loading…
Reference in New Issue
Block a user