]> git.saurik.com Git - wxWidgets.git/commitdiff
Changed font generation to follow new pattern of other ports more closely.
authorStefan Neis <Stefan.Neis@t-online.de>
Sun, 27 Aug 2006 16:27:50 +0000 (16:27 +0000)
committerStefan Neis <Stefan.Neis@t-online.de>
Sun, 27 Aug 2006 16:27:50 +0000 (16:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40877 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/gdiobj.cpp [deleted file]
src/os2/settings.cpp

diff --git a/src/os2/gdiobj.cpp b/src/os2/gdiobj.cpp
deleted file mode 100644 (file)
index 85d8e90..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name:        src/os2/gdiobj.cpp
-// Purpose:     wxGDIObject class
-// Author:      AUTHOR
-// Modified by:
-// Created:     ??/??/98
-// RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/gdiobj.h"
-
-#ifndef WX_PRECOMP
-    #include "wx/font.h"
-    #include "wx/gdicmn.h"
-#endif
-
-class wxStockGDIPM: public wxStockGDI
-{
-public:
-    wxStockGDIPM();
-
-    virtual const wxFont* GetFont(Item item);
-
-private:
-    typedef wxStockGDI super;
-};
-
-static wxStockGDIPM gs_wxStockGDIPM_instance;
-
-wxStockGDIPM::wxStockGDIPM()
-{
-    // Override default instance
-    ms_instance = this;
-}
-
-const wxFont* wxStockGDIPM::GetFont(Item item)
-{
-    wxFont* font = wx_static_cast(wxFont*, ms_stockObject[item]);
-    if (font == NULL)
-    {
-        const int fontSize = 12;
-        switch (item)
-        {
-        case FONT_NORMAL:
-            font = new wxFont(fontSize, wxMODERN, wxNORMAL, wxBOLD);
-            break;
-        case FONT_SMALL:
-            font = new wxFont(fontSize - 4, wxSWISS, wxNORMAL, wxNORMAL);
-            break;
-        default:
-            font = wx_const_cast(wxFont*, super::GetFont(item));
-            break;
-        }
-        ms_stockObject[item] = font;
-    }
-    return font;
-}
index f828647041c929921677bed98876f37beb73872b..b07f9e15dae0596f0e8bc54e045ef7c7b3aa9c26 100644 (file)
@@ -16,6 +16,7 @@
     #include <stdio.h>
     #include "wx/pen.h"
     #include "wx/brush.h"
+    #include "wx/fontutil.h"
     #include "wx/gdicmn.h"
     #include "wx/window.h"
     #include "wx/settings.h"
@@ -69,6 +70,7 @@ void wxSystemSettingsModule::OnExit()
     sm_optionNames.Clear();
     sm_optionValues.Clear();
     delete gs_fontDefault;
+    gs_fontDefault = NULL;
 }
 
 wxColour wxSystemSettingsNative::GetColour(
@@ -200,39 +202,50 @@ wxColour wxSystemSettingsNative::GetColour(
     return(vCol);
 } // end of wxSystemSettingsNative::GetColour
 
+// ----------------------------------------------------------------------------
+// fonts
+// ----------------------------------------------------------------------------
+
+wxFont wxCreateFontFromStockObject(int index)
+{
+    wxFont font;
+
+    FONTMETRICS metrics;
+    HPS hPS = ::WinGetScreenPS(HWND_DESKTOP);
+    if (::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &metrics))
+    {
+        wxNativeFontInfo info;
+        info.fm = metrics;
+        font.Create(info);
+    }
+    else // GetStockObject() failed
+    {
+        wxFAIL_MSG( _T("stock font not found") );
+    }
+
+    return font;
+}
+
 wxFont wxSystemSettingsNative::GetFont(
   wxSystemFont                      index
 )
 {
-    // TODO
-    switch (index)
+    const bool isDefaultRequested = index == wxSYS_DEFAULT_GUI_FONT;
+    if ( isDefaultRequested )
     {
-        case wxSYS_DEVICE_DEFAULT_FONT:
-        {
-            break;
-        }
-        case wxSYS_DEFAULT_PALETTE:
-        {
-            break;
-        }
-        case wxSYS_SYSTEM_FIXED_FONT:
-        {
-            break;
-        }
-        case wxSYS_SYSTEM_FONT:
-        {
-            break;
-        }
-        default:
-        case wxSYS_DEFAULT_GUI_FONT:
-        {
-            break;
-        }
+        if ( gs_fontDefault )
+            return *gs_fontDefault;
+    }
+
+    wxFont font = wxCreateFontFromStockObject(index);
+
+    if ( isDefaultRequested )
+    {
+        // if we got here it means we hadn't cached it yet - do now
+        gs_fontDefault = new wxFont(font);
     }
-    if(wxSWISS_FONT)
-         return *wxSWISS_FONT;
 
-    return wxNullFont;
+    return font;
 }
 
 // Get a system metric, e.g. scrollbar size