From: Robert Roebling Date: Sun, 5 Jan 2003 22:59:44 +0000 (+0000) Subject: Removed usage of GetInternalFont() from GTK 2.0. This X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/bbd006c0cef461b829f51db586880c380c8785a2?hp=60d85ccb3d3ebda7af4dcc9833867d18a5652418 Removed usage of GetInternalFont() from GTK 2.0. This also removes any usage of GdkFont. I left the actual deprecated method so that the change can be bckported without binary incompatible changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 6ecc0ace44..5f1953872d 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1492,6 +1492,10 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, if (!m_window) return; +#ifdef __WXGTK20__ + // implement later without GdkFont for GTK 2.0 + return; +#endif GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index 23a8b2b1f0..3d22f9a805 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -906,23 +906,18 @@ extern GdkFont *GtkGetDefaultGuiFont() GdkFont *wxFont::GetInternalFont( float scale ) const { +#ifdef __WXGTK20__ + // Deprecated for GTK 2.0 and should be removed + // in the 2.5 tree. + wxFAIL_MSG( wxT("No longer used") ); + + return (GdkFont *) NULL; + +#else // GTK 1.x GdkFont *font = (GdkFont *) NULL; wxCHECK_MSG( Ok(), font, wxT("invalid font") ) -#ifdef __WXGTK20__ - if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT)) - { - font = GtkGetDefaultGuiFont(); - } - else - { - PangoFontDescription * - font_description = GetNativeFontInfo()->description; - - font = gdk_font_from_description( font_description ); - } -#else // GTK 1.x long int_scale = long(scale * 100.0 + 0.5); // key for fontlist int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100); @@ -971,12 +966,12 @@ GdkFont *wxFont::GetInternalFont( float scale ) const list[int_scale] = font; } } -#endif // GTK 2.0/1.x // it's quite useless to make it a wxCHECK because we're going to crash // anyhow... wxASSERT_MSG( font, wxT("could not load any font?") ); return font; +#endif // GTK 2.0/1.x } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5208da0f59..feb8f2ffce 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3420,9 +3420,31 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.height / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return font->ascent + font->descent; +#endif } int wxWindowGTK::GetCharWidth() const @@ -3431,9 +3453,31 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.width / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return gdk_string_width( font, "H" ); +#endif } void wxWindowGTK::GetTextExtent( const wxString& string, diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 6ecc0ace44..5f1953872d 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -1492,6 +1492,10 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, if (!m_window) return; +#ifdef __WXGTK20__ + // implement later without GdkFont for GTK 2.0 + return; +#endif GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index 23a8b2b1f0..3d22f9a805 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -906,23 +906,18 @@ extern GdkFont *GtkGetDefaultGuiFont() GdkFont *wxFont::GetInternalFont( float scale ) const { +#ifdef __WXGTK20__ + // Deprecated for GTK 2.0 and should be removed + // in the 2.5 tree. + wxFAIL_MSG( wxT("No longer used") ); + + return (GdkFont *) NULL; + +#else // GTK 1.x GdkFont *font = (GdkFont *) NULL; wxCHECK_MSG( Ok(), font, wxT("invalid font") ) -#ifdef __WXGTK20__ - if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT)) - { - font = GtkGetDefaultGuiFont(); - } - else - { - PangoFontDescription * - font_description = GetNativeFontInfo()->description; - - font = gdk_font_from_description( font_description ); - } -#else // GTK 1.x long int_scale = long(scale * 100.0 + 0.5); // key for fontlist int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100); @@ -971,12 +966,12 @@ GdkFont *wxFont::GetInternalFont( float scale ) const list[int_scale] = font; } } -#endif // GTK 2.0/1.x // it's quite useless to make it a wxCHECK because we're going to crash // anyhow... wxASSERT_MSG( font, wxT("could not load any font?") ); return font; +#endif // GTK 2.0/1.x } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 5208da0f59..feb8f2ffce 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -3420,9 +3420,31 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.height / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return font->ascent + font->descent; +#endif } int wxWindowGTK::GetCharWidth() const @@ -3431,9 +3453,31 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.width / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return gdk_string_width( font, "H" ); +#endif } void wxWindowGTK::GetTextExtent( const wxString& string,