- case wxSYS_BORDER_X:
- return ::GetSystemMetrics(SM_CXBORDER);
- case wxSYS_BORDER_Y:
- return ::GetSystemMetrics(SM_CYBORDER);
- case wxSYS_CURSOR_X:
- return ::GetSystemMetrics(SM_CXCURSOR);
- case wxSYS_CURSOR_Y:
- return ::GetSystemMetrics(SM_CYCURSOR);
- case wxSYS_DCLICK_X:
- return ::GetSystemMetrics(SM_CXDOUBLECLK);
- case wxSYS_DCLICK_Y:
- return ::GetSystemMetrics(SM_CYDOUBLECLK);
+ HFONT hFont = (HFONT) ::GetStockObject(index);
+ if ( hFont )
+ {
+ LOGFONT lf;
+ if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
+ {
+ wxNativeFontInfo info;
+ info.lf = lf;
+ // Under MicroWindows we pass the HFONT as well
+ // because it's hard to convert HFONT -> LOGFONT -> HFONT
+ // It's OK to delete stock objects, the delete will be ignored.
+#ifdef __WXMICROWIN__
+ font.Create(info, (WXHFONT) hFont);
+#else
+ font.Create(info);
+#endif
+ }
+ else
+ {
+ wxFAIL_MSG( _T("failed to get LOGFONT") );
+ }
+ }
+ else // GetStockObject() failed
+ {
+ wxFAIL_MSG( _T("stock font not found") );
+ }
+
+ return font;
+}
+
+wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
+{
+ // this one is special: we don't get it from GetStockObject()
+ if ( index == wxSYS_ICONTITLE_FONT )
+ {
+ LOGFONT lf;
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
+ return wxCreateFontFromLogFont(&lf);
+ }
+
+ // wxWindow ctor calls GetSystemFont(wxSYS_DEFAULT_GUI_FONT) so we're
+ // called fairly often - this is why we cache this particular font
+ bool isDefaultRequested = index == wxSYS_DEFAULT_GUI_FONT;
+ if ( isDefaultRequested && 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);
+ }
+
+ return font;
+}
+
+// ----------------------------------------------------------------------------
+// system metrics/features
+// ----------------------------------------------------------------------------
+
+// TODO: some of the "metrics" clearly should be features now that we have
+// HasFeature()!
+
+// the conversion table from wxSystemMetric enum to GetSystemMetrics() param
+//
+// if the constant is not defined, put -1 in the table to indicate that it is
+// unknown
+static const int gs_metricsMap[] =
+{
+ -1, // wxSystemMetric enums start at 1, so give a dummy value for pos 0.
+#if defined(__WIN32__) && !defined(__WXWINCE__)
+ SM_CMOUSEBUTTONS,
+#else
+ -1,
+#endif
+
+ SM_CXBORDER,
+ SM_CYBORDER,
+ SM_CXCURSOR,
+ SM_CYCURSOR,
+ SM_CXDOUBLECLK,
+ SM_CYDOUBLECLK,