]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fontcmn.cpp
compilation fix
[wxWidgets.git] / src / common / fontcmn.cpp
index 812c56c42c473c0777c75e5afb78d03a6e6ab90c..e973ffbc0d0924395040bc25efbdca8402298fb7 100644 (file)
@@ -32,6 +32,9 @@
     #include "wx/font.h"
 #endif // WX_PRECOMP
 
+#include "wx/gdicmn.h"
+#include "wx/fontutil.h" // for wxNativeFontInfo
+
 #include "wx/tokenzr.h"
 
 // ============================================================================
@@ -62,28 +65,38 @@ wxFont *wxFontBase::New(const wxNativeFontInfo& info)
     return new wxFont(info);
 }
 
-wxNativeFontInfo wxFontBase::GetNativeFontInfo() const
+/* static */
+wxFont *wxFontBase::New(const wxString& strNativeFontDesc)
 {
-#if !defined(__WXGTK__)
     wxNativeFontInfo fontInfo;
+    if ( !fontInfo.FromString(strNativeFontDesc) )
+        return new wxFont(*wxNORMAL_FONT);
 
-    fontInfo.pointSize = GetPointSize();
-    fontInfo.family = GetFamily();
-    fontInfo.style = GetStyle();
-    fontInfo.weight = GetWeight();
-    fontInfo.underlined = GetUnderlined();
-    fontInfo.faceName = GetFaceName();
-    fontInfo.encoding = GetEncoding();
+    return New(fontInfo);
+}
+
+wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const
+{
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
+    wxNativeFontInfo *fontInfo = new wxNativeFontInfo;
+
+    fontInfo->pointSize = GetPointSize();
+    fontInfo->family = GetFamily();
+    fontInfo->style = GetStyle();
+    fontInfo->weight = GetWeight();
+    fontInfo->underlined = GetUnderlined();
+    fontInfo->faceName = GetFaceName();
+    fontInfo->encoding = GetEncoding();
 
     return fontInfo;
 #else
-    return wxNullNativeFontInfo;
+    return (wxNativeFontInfo *)NULL;
 #endif
 }
 
 void wxFontBase::SetNativeFontInfo(const wxNativeFontInfo& info)
 {
-#if !defined(__WXGTK__)
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
     SetPointSize(info.pointSize);
     SetFamily(info.family);
     SetStyle(info.style);
@@ -94,6 +107,19 @@ void wxFontBase::SetNativeFontInfo(const wxNativeFontInfo& info)
 #endif
 }
 
+wxString wxFontBase::GetNativeFontInfoDesc() const
+{
+    wxString fontDesc;
+    wxNativeFontInfo *fontInfo = GetNativeFontInfo();
+    if ( fontInfo )
+    {
+        fontDesc = fontInfo->ToString();
+        delete fontInfo;
+    }
+
+    return fontDesc;
+}
+
 wxFont& wxFont::operator=(const wxFont& font)
 {
     if ( this != &font )
@@ -155,7 +181,7 @@ wxString wxFontBase::GetWeightString() const
     }
 }
 
-#if !defined(__WXGTK__)
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
 
 // ----------------------------------------------------------------------------
 // wxNativeFontInfo
@@ -164,7 +190,7 @@ wxString wxFontBase::GetWeightString() const
 // These are the generic forms of FromString()/ToString.
 //
 // convert to/from the string representation: format is
-//      pointsize;family;style;weight;underlined;facename;encoding
+//      version;pointsize;family;style;weight;underlined;facename;encoding
 
 bool wxNativeFontInfo::FromString(const wxString& s)
 {
@@ -173,6 +199,11 @@ bool wxNativeFontInfo::FromString(const wxString& s)
     wxStringTokenizer tokenizer(s, _T(";"));
 
     wxString token = tokenizer.GetNextToken();
+    //
+    //  Ignore the version for now
+    //
+    
+    token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
     pointSize = (int)l;
@@ -195,7 +226,7 @@ bool wxNativeFontInfo::FromString(const wxString& s)
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    underlined = (int)l;
+    underlined = l != 0;
 
     faceName = tokenizer.GetNextToken();
     if( !faceName )
@@ -213,7 +244,8 @@ wxString wxNativeFontInfo::ToString() const
 {
     wxString s;
 
-    s.Printf("%d;%d;%d;%d;%d;%s;%d",
+    s.Printf(_T("%d;%d;%d;%d;%d;%d;%s;%d"),
+             0,                                 // version
              pointSize,
              family,
              style,
@@ -225,5 +257,5 @@ wxString wxNativeFontInfo::ToString() const
     return s;
 }
 
-#endif
+#endif // generic wxNativeFontInfo implementation