#include "wx/settings.h"
#include "wx/window.h"
#include "wx/msw/private.h"
+#include "wx/module.h"
+#include "wx/fontutil.h"
// ----------------------------------------------------------------------------
// private classes
// singleton class so it can't be done in the dtor)
class wxSystemSettingsModule : public wxModule
{
+ friend class wxSystemSettings;
public:
virtual bool OnInit();
virtual void OnExit();
void wxSystemSettingsModule::OnExit()
{
delete gs_fontDefault;
+ gs_fontDefault = NULL;
}
// ----------------------------------------------------------------------------
}
}
-wxFont wxSystemSettings::GetSystemFont(int index)
+wxFont wxCreateFontFromStockObject(int 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;
HFONT hFont = (HFONT) ::GetStockObject(index);
LOGFONT lf;
if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
{
- font = wxCreateFontFromLogFont(&lf);
+ 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("stock font not found") );
}
+ return font;
+}
+
+wxFont wxSystemSettings::GetSystemFont(int 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 )
{
// Get a system metric, e.g. scrollbar size
int wxSystemSettings::GetSystemMetric(int index)
{
+#ifdef __WXMICROWIN__
+ // TODO: probably use wxUniv themes functionality
+ return 0;
+#else
switch ( index)
{
#ifdef __WIN32__
default:
return 0;
}
+#endif
+ // __WXMICROWIN__
}