implemented underlined text drawing for GTK2
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -136,6 +136,7 @@ wxGTK:
|
|||||||
- implemented wxColourDialog as native dialog
|
- implemented wxColourDialog as native dialog
|
||||||
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
||||||
- added support for wxCHK_3STATE style (GTK2 only)
|
- added support for wxCHK_3STATE style (GTK2 only)
|
||||||
|
- implemented text underlining under GTK2
|
||||||
|
|
||||||
wxMotif:
|
wxMotif:
|
||||||
|
|
||||||
|
@@ -1467,13 +1467,27 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
wxCHECK_RET( m_layout, wxT("no Pango layout") );
|
wxCHECK_RET( m_layout, wxT("no Pango layout") );
|
||||||
wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
|
wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
|
||||||
|
|
||||||
|
bool underlined = m_font.Ok() && m_font.GetUnderlined();
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
|
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
|
||||||
#else
|
#else
|
||||||
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
|
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
|
||||||
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
|
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
|
||||||
#endif
|
#endif
|
||||||
pango_layout_set_text( m_layout, (const char*) data, strlen( (const char*) data ));
|
size_t datalen = strlen((const char*)data);
|
||||||
|
pango_layout_set_text( m_layout, (const char*) 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);
|
||||||
|
}
|
||||||
|
|
||||||
int w,h;
|
int w,h;
|
||||||
|
|
||||||
@@ -1521,6 +1535,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
|
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (underlined)
|
||||||
|
{
|
||||||
|
// undo underline attributes setting:
|
||||||
|
pango_layout_set_attributes(m_layout, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
wxCoord width = w;
|
wxCoord width = w;
|
||||||
wxCoord height = h;
|
wxCoord height = h;
|
||||||
|
|
||||||
|
@@ -1467,13 +1467,27 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
wxCHECK_RET( m_layout, wxT("no Pango layout") );
|
wxCHECK_RET( m_layout, wxT("no Pango layout") );
|
||||||
wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
|
wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
|
||||||
|
|
||||||
|
bool underlined = m_font.Ok() && m_font.GetUnderlined();
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
|
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
|
||||||
#else
|
#else
|
||||||
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
|
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
|
||||||
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
|
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
|
||||||
#endif
|
#endif
|
||||||
pango_layout_set_text( m_layout, (const char*) data, strlen( (const char*) data ));
|
size_t datalen = strlen((const char*)data);
|
||||||
|
pango_layout_set_text( m_layout, (const char*) 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);
|
||||||
|
}
|
||||||
|
|
||||||
int w,h;
|
int w,h;
|
||||||
|
|
||||||
@@ -1521,6 +1535,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
|
gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (underlined)
|
||||||
|
{
|
||||||
|
// undo underline attributes setting:
|
||||||
|
pango_layout_set_attributes(m_layout, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
wxCoord width = w;
|
wxCoord width = w;
|
||||||
wxCoord height = h;
|
wxCoord height = h;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user