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:
Václav Slavík
2004-06-27 13:10:29 +00:00
parent 3912b3f8f7
commit 1dbeee5774
3 changed files with 43 additions and 2 deletions

View File

@@ -136,6 +136,7 @@ wxGTK:
- implemented wxColourDialog as native dialog
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
- added support for wxCHK_3STATE style (GTK2 only)
- implemented text underlining under GTK2
wxMotif:

View File

@@ -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_fontdesc, wxT("no Pango font description") );
bool underlined = m_font.Ok() && m_font.GetUnderlined();
#if wxUSE_UNICODE
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
#else
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
#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;
@@ -1520,6 +1534,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
// Draw 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 height = h;

View File

@@ -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_fontdesc, wxT("no Pango font description") );
bool underlined = m_font.Ok() && m_font.GetUnderlined();
#if wxUSE_UNICODE
const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
#else
const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
#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;
@@ -1520,6 +1534,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
// Draw 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 height = h;