X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/gtk/font.cpp diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index 2fd0ad6f5f..f62f55b840 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -3,7 +3,7 @@ // Purpose: // Author: Robert Roebling // Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Copyright: (c) 1998 Robert Roebling and Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,10 +15,13 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "font.h" #endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + #include "wx/font.h" #include "wx/fontutil.h" #include "wx/cmndata.h" @@ -83,6 +86,11 @@ public: #endif // GTK 2.0/1.x } +#ifndef __WXGTK20__ + // reinitilize the font with the gived XFLD + void ReInit(const wxString& fontname); +#endif + // setters: all of them also take care to modify m_nativeFontInfo if we // have it so as to not lose the information not carried by our fields void SetPointSize(int pointSize); @@ -95,7 +103,7 @@ public: void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } bool GetNoAntiAliasing() { return m_noAA; } - + // and this one also modifies all the other font data fields void SetNativeFontInfo(const wxNativeFontInfo& info); @@ -158,7 +166,7 @@ private: }; // ---------------------------------------------------------------------------- -// wxFontRefData +// wxFontRefData // ---------------------------------------------------------------------------- void wxFontRefData::Init(int pointSize, @@ -185,7 +193,7 @@ void wxFontRefData::Init(int pointSize, m_underlined = underlined; m_encoding = encoding; - + m_noAA = FALSE; #ifdef __WXGTK20__ @@ -215,7 +223,7 @@ void wxFontRefData::Init(int pointSize, break; } } - + SetStyle( m_style ); SetPointSize( m_pointSize ); SetWeight( m_weight ); @@ -407,8 +415,11 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data ) m_encoding = data.m_encoding; m_noAA = data.m_noAA; - - m_nativeFontInfo = data.m_nativeFontInfo; + + // Forces a copy of the internal data. wxNativeFontInfo should probably + // have a copy ctor and assignment operator to fix this properly but that + // would break binary compatibility... + m_nativeFontInfo.FromString(data.m_nativeFontInfo.ToString()); } wxFontRefData::wxFontRefData(int size, int family, int style, @@ -431,6 +442,15 @@ wxFontRefData::wxFontRefData(const wxString& fontname) InitFromNative(); } +#ifndef __WXGTK20__ +void wxFontRefData::ReInit(const wxString& fontname) +{ + m_nativeFontInfo.SetXFontName(fontname); + + InitFromNative(); +} +#endif + void wxFontRefData::ClearGdkFonts() { #ifndef __WXGTK20__ @@ -774,7 +794,7 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const { wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") ); -#ifndef __WXGTK20__ // ??? +#ifndef __WXGTK20__ if ( M_FONTDATA->m_nativeFontInfo.GetXFontName().empty() ) GetInternalFont(); #endif @@ -853,7 +873,7 @@ void wxFont::SetEncoding(wxFontEncoding encoding) M_FONTDATA->SetEncoding(encoding); } -void wxFont::SetNativeFontInfo( const wxNativeFontInfo& info ) +void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& info ) { Unshare(); @@ -871,6 +891,7 @@ void wxFont::SetNoAntiAliasing( bool no ) // get internal representation of font // ---------------------------------------------------------------------------- +#ifndef __WXGTK20__ static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL; // this is also used from tbargtk.cpp and tooltip.cpp, hence extern @@ -882,13 +903,13 @@ extern GdkFont *GtkGetDefaultGuiFont() GtkStyle *def = gtk_rc_get_style( widget ); if (def) { - g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) ); + g_systemDefaultGuiFont = gdk_font_ref( def->font ); } else { def = gtk_widget_get_default_style(); if (def) - g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) ); + g_systemDefaultGuiFont = gdk_font_ref( def->font ); } gtk_widget_destroy( widget ); } @@ -907,19 +928,6 @@ GdkFont *wxFont::GetInternalFont( float scale ) const 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); @@ -958,7 +966,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const &xfontname); if ( font ) { - M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname); + M_FONTDATA->ReInit(xfontname); } } } @@ -968,7 +976,6 @@ 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... @@ -976,4 +983,5 @@ GdkFont *wxFont::GetInternalFont( float scale ) const return font; } +#endif // not GTK 2.0