]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/font.cpp
compilation fixes - wxGTK compiles but not links
[wxWidgets.git] / src / msw / font.cpp
index 39f7d08a7e515d3cbdb8592cf2506f73e76e4942..a2a73706edc3ebbec09d367ef5a995b7fd1cad8f 100644 (file)
@@ -41,6 +41,7 @@
 #include "wx/tokenzr.h"
 
 #include "wx/msw/private.h"
+#include "wx/tokenzr.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
 
@@ -290,42 +291,42 @@ bool wxNativeFontInfo::FromString(const wxString& s)
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfItalic = l;
+    lf.lfItalic = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfUnderline = l;
+    lf.lfUnderline = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfStrikeOut = l;
+    lf.lfStrikeOut = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfCharSet = l;
+    lf.lfCharSet = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfOutPrecision = l;
+    lf.lfOutPrecision = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfClipPrecision = l;
+    lf.lfClipPrecision = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfQuality = l;
+    lf.lfQuality = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if ( !token.ToLong(&l) )
         return FALSE;
-    lf.lfPitchAndFamily = l;
+    lf.lfPitchAndFamily = (BYTE)l;
 
     token = tokenizer.GetNextToken();
     if(!token)
@@ -450,7 +451,7 @@ bool wxFont::RealizeResource()
     return TRUE;
 }
 
-bool wxFont::FreeResource(bool force)
+bool wxFont::FreeResource(bool WXUNUSED(force))
 {
     if ( GetResourceHandle() )
     {
@@ -644,11 +645,115 @@ wxFontEncoding wxFont::GetEncoding() const
     return M_FONTDATA->m_encoding;
 }
 
-wxNativeFontInfo *wxFont::GetNativeFontInfo() const
+// ----------------------------------------------------------------------------
+// wxNativeFontInfo
+// ----------------------------------------------------------------------------
+
+bool wxNativeFontInfo::FromString(const wxString& s)
 {
-    if( M_FONTDATA->m_nativeFontInfoOk )
-        return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
+    long l;
+
+    wxStringTokenizer tokenizer(s, _T(";"));
+
+    wxString token = tokenizer.GetNextToken();
+    //
+    //  Ignore the version for now
+    //
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfHeight = l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfWidth = l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfEscapement = l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfOrientation = l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfWeight = l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfItalic = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfUnderline = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfStrikeOut = (BYTE)l;
 
-    return 0;
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfCharSet = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfOutPrecision = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfClipPrecision = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfQuality = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if ( !token.ToLong(&l) )
+        return FALSE;
+    lf.lfPitchAndFamily = (BYTE)l;
+
+    token = tokenizer.GetNextToken();
+    if(!token)
+        return FALSE;
+    wxStrcpy(lf.lfFaceName, token.c_str());
+
+    return TRUE;
+}
+
+wxString wxNativeFontInfo::ToString() const
+{
+    wxString s;
+
+    s.Printf(_T("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
+             0, // version, in case we want to change the format later
+             lf.lfHeight,
+             lf.lfWidth,
+             lf.lfEscapement,
+             lf.lfOrientation,
+             lf.lfWeight,
+             lf.lfItalic,
+             lf.lfUnderline,
+             lf.lfStrikeOut,
+             lf.lfCharSet,
+             lf.lfOutPrecision,
+             lf.lfClipPrecision,
+             lf.lfQuality,
+             lf.lfPitchAndFamily,
+             lf.lfFaceName);
+
+    return s;
 }