From f69e200970580080565c8aadc10893c29e46abeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 1 Jul 2004 08:56:25 +0000 Subject: [PATCH] set descent in GetTextExtend; use PANGO_PIXELS instead of dividing by PANGO_SCALE git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dcclient.cpp | 6 ++++-- src/gtk/window.cpp | 16 +++++++++------- src/gtk1/dcclient.cpp | 6 ++++-- src/gtk1/window.cpp | 16 +++++++++------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index ef602b5ea8..707f88fbc5 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1736,8 +1736,10 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, *height = (wxCoord) h; if (descent) { - // Do something about metrics here. TODO. - *descent = 0; + PangoLayoutIter *iter = pango_layout_get_iter(m_layout); + int baseline = pango_layout_iter_get_baseline(iter); + pango_layout_iter_free(iter); + *descent = h - PANGO_PIXELS(baseline); } if (externalLeading) *externalLeading = 0; // ?? diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b46e2c11a7..2aa4d322f3 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3484,7 +3484,7 @@ int wxWindowGTK::GetCharHeight() const g_object_unref( G_OBJECT( layout ) ); - return (int) (rect.height / PANGO_SCALE); + return (int) PANGO_PIXELS(rect.height); #else GdkFont *gfont = font.GetInternalFont( 1.0 ); @@ -3518,7 +3518,7 @@ int wxWindowGTK::GetCharWidth() const g_object_unref( G_OBJECT( layout ) ); - return (int) (rect.width / PANGO_SCALE); + return (int) PANGO_PIXELS(rect.width); #else GdkFont *gfont = font.GetInternalFont( 1.0 ); @@ -3569,17 +3569,19 @@ void wxWindowGTK::GetTextExtent( const wxString& string, pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); #endif } - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + PangoLayoutLine *line = pango_layout_get_line(layout, 0); PangoRectangle rect; pango_layout_line_get_extents(line, NULL, &rect); - if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE); - if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE); + if (x) (*x) = (wxCoord) PANGO_PIXELS(rect.width); + if (y) (*y) = (wxCoord) PANGO_PIXELS(rect.height); if (descent) { - // Do something about metrics here - (*descent) = 0; + PangoLayoutIter *iter = pango_layout_get_iter(layout); + int baseline = pango_layout_iter_get_baseline(iter); + pango_layout_iter_free(iter); + *descent = *y - PANGO_PIXELS(baseline); } if (externalLeading) (*externalLeading) = 0; // ?? diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index ef602b5ea8..707f88fbc5 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -1736,8 +1736,10 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, *height = (wxCoord) h; if (descent) { - // Do something about metrics here. TODO. - *descent = 0; + PangoLayoutIter *iter = pango_layout_get_iter(m_layout); + int baseline = pango_layout_iter_get_baseline(iter); + pango_layout_iter_free(iter); + *descent = h - PANGO_PIXELS(baseline); } if (externalLeading) *externalLeading = 0; // ?? diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index b46e2c11a7..2aa4d322f3 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -3484,7 +3484,7 @@ int wxWindowGTK::GetCharHeight() const g_object_unref( G_OBJECT( layout ) ); - return (int) (rect.height / PANGO_SCALE); + return (int) PANGO_PIXELS(rect.height); #else GdkFont *gfont = font.GetInternalFont( 1.0 ); @@ -3518,7 +3518,7 @@ int wxWindowGTK::GetCharWidth() const g_object_unref( G_OBJECT( layout ) ); - return (int) (rect.width / PANGO_SCALE); + return (int) PANGO_PIXELS(rect.width); #else GdkFont *gfont = font.GetInternalFont( 1.0 ); @@ -3569,17 +3569,19 @@ void wxWindowGTK::GetTextExtent( const wxString& string, pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); #endif } - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + PangoLayoutLine *line = pango_layout_get_line(layout, 0); PangoRectangle rect; pango_layout_line_get_extents(line, NULL, &rect); - if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE); - if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE); + if (x) (*x) = (wxCoord) PANGO_PIXELS(rect.width); + if (y) (*y) = (wxCoord) PANGO_PIXELS(rect.height); if (descent) { - // Do something about metrics here - (*descent) = 0; + PangoLayoutIter *iter = pango_layout_get_iter(layout); + int baseline = pango_layout_iter_get_baseline(iter); + pango_layout_iter_free(iter); + *descent = *y - PANGO_PIXELS(baseline); } if (externalLeading) (*externalLeading) = 0; // ??