]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/font.cpp
Added checks for wxUSE_IOSTREAMH to #include the correct header file based on setup...
[wxWidgets.git] / src / gtk1 / font.cpp
index c58aca2e818c1a1ba41929c0ed121fe9fdc9b85d..940b38d81aa1be78f189ecfb2416092228e5c48b 100644 (file)
@@ -146,21 +146,6 @@ wxFontRefData::~wxFontRefData()
     }
 }
 
-// ----------------------------------------------------------------------------
-// wxNativeFontInfo
-// ----------------------------------------------------------------------------
-
-bool wxNativeFontInfo::FromString(const wxString& s)
-{
-    xFontName = s;
-    return TRUE;
-}
-
-wxString wxNativeFontInfo::ToString() const
-{
-    return xFontName;
-}
-
 // ----------------------------------------------------------------------------
 // wxFont
 // ----------------------------------------------------------------------------
@@ -169,15 +154,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
 
 void wxFont::Init()
 {
-    if (wxTheFontList)
-        wxTheFontList->Append( this );
 }
 
 wxFont::wxFont(const wxNativeFontInfo& info)
 {
     Init();
 
-    Create(info.ToString());
+    Create(info.xFontName);
 }
 
 bool wxFont::Create(const wxNativeFontInfo& info)
@@ -201,11 +184,9 @@ bool wxFont::Create( int pointSize,
 
 bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
 {
-    Init();
-
     if( !fontname )
     {
-         *this = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT);
+         *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT);
          return TRUE;
     }
 
@@ -320,14 +301,17 @@ void wxFont::Unshare()
 
 wxFont::~wxFont()
 {
-    if (wxTheFontList)
-        wxTheFontList->DeleteObject( this );
 }
 
 // ----------------------------------------------------------------------------
 // accessors
 // ----------------------------------------------------------------------------
 
+bool wxFont::HasNativeFont() const
+{
+    return !M_FONTDATA->m_nativeFontInfo.xFontName.empty();
+}
+
 int wxFont::GetPointSize() const
 {
     wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
@@ -388,6 +372,21 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const
     return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
 }
 
+bool wxFont::IsFixedWidth() const
+{
+    wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+
+    if ( HasNativeFont() )
+    {
+        // the monospace fonts are supposed to have "M" in the spacing field
+        wxString spacing = M_FONTDATA->
+                            m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING);
+
+        return spacing.Upper() == _T('M');
+    }
+
+    return wxFontBase::IsFixedWidth();
+}
 
 // ----------------------------------------------------------------------------
 // change font attributes
@@ -479,6 +478,12 @@ GdkFont *GtkGetDefaultGuiFont()
         }
         gtk_widget_destroy( widget );
     }
+    else
+    {
+        // already have it, but ref it once more before returning
+        gdk_font_ref(g_systemDefaultGuiFont);
+    }
+
     return g_systemDefaultGuiFont;
 }
 
@@ -502,7 +507,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const
     }
     else
     {
-        if (*this == wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT))
+        if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT))
         {
             font = GtkGetDefaultGuiFont();
         }