]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/settings.cpp
Applied part of [ 1575767 ] Init/size/check fixes for sockets
[wxWidgets.git] / src / os2 / settings.cpp
index 2f42f126e1dfc4af5aebabf6a5035b81e88bb93e..8370e46b16ba2a52f4882733b9c2ecdf93052ac0 100644 (file)
 #include "wx/wxprec.h"
 
 #ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/defs.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/gdicmn.h"
+    #include <stdio.h>
+    #include "wx/pen.h"
+    #include "wx/brush.h"
+    #include "wx/gdicmn.h"
+    #include "wx/window.h"
+    #include "wx/settings.h"
+    #include "wx/module.h"
 #endif
 
-#include "wx/module.h"
-#include "wx/settings.h"
-#include "wx/window.h"
+#include "wx/fontutil.h"
+
 #include "wx/os2/private.h"
 
 // the module which is used to clean up wxSystemSettings data (this is a
@@ -70,6 +71,7 @@ void wxSystemSettingsModule::OnExit()
     sm_optionNames.Clear();
     sm_optionValues.Clear();
     delete gs_fontDefault;
+    gs_fontDefault = NULL;
 }
 
 wxColour wxSystemSettingsNative::GetColour(
@@ -201,39 +203,50 @@ wxColour wxSystemSettingsNative::GetColour(
     return(vCol);
 } // end of wxSystemSettingsNative::GetColour
 
+// ----------------------------------------------------------------------------
+// fonts
+// ----------------------------------------------------------------------------
+
+wxFont wxCreateFontFromStockObject(int WXUNUSED(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
@@ -289,6 +302,7 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index,
         // TODO case wxSYS_SWAP_BUTTONS:
 
         default:
+            break;
     }
     return -1;  // unsupported metric
 }
@@ -300,8 +314,11 @@ bool wxSystemSettingsNative::HasFeature( wxSystemFeature index )
         case wxSYS_CAN_ICONIZE_FRAME:
             return true;
 
-        case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
-            return false;
+        // TODO case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
+        // TODO case wxSYS_TABLET_PRESENT:
+
+        default:
+            break;
     }
 
     return false;