]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/fontdlg.cpp
wxMenuItem::IsChecked() corrected
[wxWidgets.git] / src / msw / fontdlg.cpp
index d2c23a9d410b806d9958e65a71e2ee8d0687f3f9..b15c904cc83232feb1056c3e90a0fff9fe881b9f 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows licence
+// Licence:       wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
@@ -31,7 +31,7 @@
 
 #include <windows.h>
 
-#ifndef __WIN32__
+#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
 #include <commdlg.h>
 #endif
 
@@ -149,7 +149,7 @@ void wxFillLogFont(LOGFONT *logFont, wxFont *font)
                          break;
       case wxDEFAULT:
       default:           ff_family = FF_SWISS;
-                         ff_face = "MS Sans Serif" ; 
+                         ff_face = "MS Sans Serif" ;
     }
 
     if (font->GetStyle() == wxITALIC || font->GetStyle() == wxSLANT)
@@ -174,7 +174,7 @@ void wxFillLogFont(LOGFONT *logFont, wxFont *font)
     // up fonts. So, set ppInch to a constant 96 dpi.
     ppInch = 96;
 
-#if FONT_SIZE_COMPATIBILITY
+#if wxFONT_SIZE_COMPATIBILITY
     // Incorrect, but compatible with old wxWindows behaviour
     int nHeight = (font->GetPointSize()*ppInch/72);
 #else
@@ -194,88 +194,135 @@ void wxFillLogFont(LOGFONT *logFont, wxFont *font)
     logFont->lfItalic = ff_italic;
     logFont->lfUnderline = (BYTE)ff_underline;
     logFont->lfStrikeOut = 0;
-    logFont->lfCharSet = ANSI_CHARSET;
+    logFont->lfCharSet = wxCharsetFromEncoding(font->GetEncoding());
     logFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
     logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
     logFont->lfQuality = PROOF_QUALITY;
     logFont->lfPitchAndFamily = DEFAULT_PITCH | ff_family;
-    strcpy(logFont->lfFaceName, ff_face);
+    wxStrcpy(logFont->lfFaceName, ff_face);
 }
 
-wxFont wxCreateFontFromLogFont(LOGFONT *logFont) // , bool createNew)
+wxFont wxCreateFontFromLogFont(LOGFONT *logFont)
 {
-  int fontFamily = wxSWISS;
-  int fontStyle = wxNORMAL;
-  int fontWeight = wxNORMAL;
-  int fontPoints = 10;
-  bool fontUnderline = FALSE;
-  char *fontFace = NULL;
-
-//  int lfFamily = logFont->lfPitchAndFamily & 0xF0;
-  int lfFamily = logFont->lfPitchAndFamily;
-  if (lfFamily & FIXED_PITCH)
-    lfFamily -= FIXED_PITCH;
-  if (lfFamily & VARIABLE_PITCH)
-    lfFamily -= VARIABLE_PITCH;
-  
-  switch (lfFamily)
-  {
-    case FF_ROMAN:
-      fontFamily = wxROMAN;
-      break;
-    case FF_SWISS:
-      fontFamily = wxSWISS;
-      break;
-    case FF_SCRIPT:
-      fontFamily = wxSCRIPT;
-      break;
-    case FF_MODERN:
-      fontFamily = wxMODERN;
-      break;
-    case FF_DECORATIVE:
-      fontFamily = wxDECORATIVE;
-      break;
-    default:
-      fontFamily = wxSWISS;
-      break;
-  }
-  switch (logFont->lfWeight)
-  {
-    case FW_LIGHT:
-      fontWeight = wxLIGHT;
-      break;
-    case FW_NORMAL:
-      fontWeight = wxNORMAL;
-      break;
-    case FW_BOLD:
-      fontWeight = wxBOLD;
-      break;
-    default:
-      fontWeight = wxNORMAL;
-      break;
-  }
-  if (logFont->lfItalic)
-    fontStyle = wxITALIC;
-  else
-    fontStyle = wxNORMAL;
-
-  if (logFont->lfUnderline)
-    fontUnderline = TRUE;
-    
-  if  (logFont->lfFaceName)
-    fontFace = logFont->lfFaceName;
-
-  HDC dc2 = ::GetDC(NULL);
-
-  if ( logFont->lfHeight < 0 )
-       logFont->lfHeight = - logFont->lfHeight;
-  fontPoints = abs(72*logFont->lfHeight/GetDeviceCaps(dc2, LOGPIXELSY));
-  ::ReleaseDC(NULL, dc2);
-
-//  if ( createNew )
-       return wxFont(fontPoints, fontFamily, fontStyle, fontWeight, fontUnderline, fontFace);
-//  else
-//     return wxTheFontList->FindOrCreateFont(fontPoints, fontFamily, fontStyle, fontWeight, fontUnderline, fontFace);
+    int fontFamily = wxSWISS;
+    int fontStyle = wxNORMAL;
+    int fontWeight = wxNORMAL;
+    int fontPoints = 10;
+    bool fontUnderline = FALSE;
+    wxChar *fontFace = NULL;
+
+    int lfFamily = logFont->lfPitchAndFamily;
+    if (lfFamily & FIXED_PITCH)
+        lfFamily -= FIXED_PITCH;
+    if (lfFamily & VARIABLE_PITCH)
+        lfFamily -= VARIABLE_PITCH;
+
+    switch (lfFamily)
+    {
+        case FF_ROMAN:
+            fontFamily = wxROMAN;
+            break;
+        case FF_SWISS:
+            fontFamily = wxSWISS;
+            break;
+        case FF_SCRIPT:
+            fontFamily = wxSCRIPT;
+            break;
+        case FF_MODERN:
+            fontFamily = wxMODERN;
+            break;
+        case FF_DECORATIVE:
+            fontFamily = wxDECORATIVE;
+            break;
+        default:
+            fontFamily = wxSWISS;
+            break;
+    }
+    switch (logFont->lfWeight)
+    {
+        case FW_LIGHT:
+            fontWeight = wxLIGHT;
+            break;
+        case FW_NORMAL:
+            fontWeight = wxNORMAL;
+            break;
+        case FW_BOLD:
+            fontWeight = wxBOLD;
+            break;
+        default:
+            fontWeight = wxNORMAL;
+            break;
+    }
+    if (logFont->lfItalic)
+        fontStyle = wxITALIC;
+    else
+        fontStyle = wxNORMAL;
+
+    if (logFont->lfUnderline)
+        fontUnderline = TRUE;
+
+    if  (logFont->lfFaceName)
+        fontFace = logFont->lfFaceName;
+
+    wxFontEncoding fontEncoding;
+    switch ( logFont->lfCharSet )
+    {
+        default:
+            wxFAIL_MSG(wxT("unsupported charset"));
+            // fall through
+
+        case ANSI_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_1;
+            break;
+
+        case EASTEUROPE_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_2;
+            break;
+
+        case BALTIC_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_4;
+            break;
+
+        case RUSSIAN_CHARSET:
+            fontEncoding = wxFONTENCODING_CP1251;
+            break;
+
+        case ARABIC_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_6;
+            break;
+
+        case GREEK_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_7;
+            break;
+
+        case HEBREW_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_8;
+            break;
+
+        case TURKISH_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_9;
+            break;
+
+        case THAI_CHARSET:
+            fontEncoding = wxFONTENCODING_ISO8859_11;
+            break;
+
+
+        case OEM_CHARSET:
+            fontEncoding = wxFONTENCODING_CP437;
+            break;
+    }
+
+    HDC dc2 = ::GetDC(NULL);
+
+    if ( logFont->lfHeight < 0 )
+        logFont->lfHeight = - logFont->lfHeight;
+    fontPoints = abs(72*logFont->lfHeight/GetDeviceCaps(dc2, LOGPIXELSY));
+    ::ReleaseDC(NULL, dc2);
+
+    return wxFont(fontPoints, fontFamily, fontStyle,
+                  fontWeight, fontUnderline, fontFace,
+                  fontEncoding);
 }