+ int verMaj, verMin;
+ wxGetOsVersion(&verMaj, &verMin);
+ if ( verMaj < 4 )
+ {
+ // NT 3.5
+ useDefault = TRUE;
+ }
+ else if ( verMaj == 4 )
+ {
+ // Win95/NT 4.0
+ useDefault = index > wxSYS_COLOUR_INFOBK;
+ }
+ else if ( verMaj == 5 && verMin == 0 )
+ {
+ // Win98/Win2K
+ useDefault = index > wxSYS_COLOUR_GRADIENTINACTIVECAPTION;
+ }
+ else // >= 5.1
+ {
+ // 5.1 is Windows XP
+ useDefault = FALSE;
+ // Determine if we are using flat menus, only then allow wxSYS_COLOUR_MENUBAR
+ if ( index == wxSYS_COLOUR_MENUBAR )
+ {
+ BOOL isFlat ;
+ if ( SystemParametersInfo( SPI_GETFLATMENU , 0 ,&isFlat, 0 ) )
+ {
+ if ( !isFlat )
+ index = wxSYS_COLOUR_MENU ;
+ }
+ }
+ }
+#else
+ useDefault = TRUE;
+#endif // __WIN32__
+
+ if ( useDefault )
+ {
+ // special handling for MENUBAR colour: we use this in wxToolBar
+ // and wxStatusBar to have correct bg colour under Windows XP
+ // (which uses COLOR_MENUBAR for them) but they should still look
+ // correctly under previous Windows versions as well
+ if ( index == wxSYS_COLOUR_MENUBAR )
+ {
+ index = wxSYS_COLOUR_3DFACE;
+ }
+ else // replace with default colour
+ {
+ int n = index - wxSYS_COLOUR_BTNHIGHLIGHT;
+
+ wxASSERT_MSG( n < WXSIZEOF(s_defaultSysColors),
+ _T("forgot tp update the default colours array") );
+
+ colSys = s_defaultSysColors[n];
+ hasCol = TRUE;
+ }
+ }
+ }
+
+ if ( !hasCol )
+ {
+ colSys = ::GetSysColor(index);
+ }
+
+ return wxRGBToColour(colSys);
+}
+
+// ----------------------------------------------------------------------------
+// fonts
+// ----------------------------------------------------------------------------
+
+wxFont wxCreateFontFromStockObject(int index)
+{
+ wxFont font;
+
+ 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)
+{
+ // 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.
+#ifdef __WIN32__
+ SM_CMOUSEBUTTONS,
+#else
+ -1,