From 8fbdfa4faf61ecc4177d9952d3f3718cf4514ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 20 Nov 2001 23:48:03 +0000 Subject: [PATCH] optimized default GUI font loading git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mgl/settings.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/mgl/settings.cpp b/src/mgl/settings.cpp index 4e6b6d28f8..b99f6e5ee5 100644 --- a/src/mgl/settings.cpp +++ b/src/mgl/settings.cpp @@ -14,6 +14,31 @@ #include "wx/settings.h" #include "wx/colour.h" #include "wx/font.h" +#include "wx/module.h" + +// ---------------------------------------------------------------------------- +// global data +// ---------------------------------------------------------------------------- + +static wxFont *gs_fontDefault = NULL; + +class wxSystemSettingsModule : public wxModule +{ +public: + virtual bool OnInit() { return TRUE; } + virtual void OnExit() + { + delete gs_fontDefault; + gs_fontDefault = NULL; + } + +private: + DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule) + + wxColour wxSystemSettings::GetSystemColour(int WXUNUSED(index)) { @@ -21,10 +46,25 @@ wxColour wxSystemSettings::GetSystemColour(int WXUNUSED(index)) return wxColour(0,0,0); } -wxFont wxSystemSettings::GetSystemFont(int WXUNUSED(index)) +wxFont wxSystemSettings::GetSystemFont(int index) { + bool isDefaultRequested = (index == wxSYS_DEFAULT_GUI_FONT); + + if ( isDefaultRequested && gs_fontDefault ) + { + return *gs_fontDefault; + } + // FIXME_MGL - return wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, FALSE, "Arial"); + wxFont font(10, wxSWISS, wxNORMAL, wxNORMAL, FALSE, "Arial"); + + if ( isDefaultRequested ) + { + // if we got here it means we hadn't cached it yet - do now + gs_fontDefault = new wxFont(font); + } + + return font; } int wxSystemSettings::GetSystemMetric(int WXUNUSED(index))