]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't create the fonts until after they are needed (after the App
authorRobin Dunn <robin@alldunn.com>
Sun, 18 Jan 2004 03:05:02 +0000 (03:05 +0000)
committerRobin Dunn <robin@alldunn.com>
Sun, 18 Jan 2004 03:05:02 +0000 (03:05 +0000)
object has been created.)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25226 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wx/tools/XRCed/globals.py
wxPython/wx/tools/XRCed/panel.py
wxPython/wx/tools/XRCed/tools.py
wxPython/wx/tools/XRCed/xrced.py

index 86a402ceb11d1f288a9fcd9d98e91f3cca236fd8..74ac8bd28f9d5dfb06e81a760de480576394e607 100644 (file)
@@ -10,11 +10,6 @@ import sys
 
 # Global constants
 
 
 # Global constants
 
-sysFont = wxSystemSettings_GetFont(wxSYS_SYSTEM_FONT)
-labelFont = wxFont(sysFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxBOLD)
-modernFont = wxFont(sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
-smallerFont = wxFont(sysFont.GetPointSize()-2, wxDEFAULT, wxNORMAL, wxNORMAL)
-
 progname = 'XRCed'
 version = '0.1.2-1'
 
 progname = 'XRCed'
 version = '0.1.2-1'
 
@@ -37,4 +32,25 @@ class Globals:
     currentXXX = None
     currentEncoding = sys.getdefaultencoding() # wxLocale_GetSystemEncodingName()
 
     currentXXX = None
     currentEncoding = sys.getdefaultencoding() # wxLocale_GetSystemEncodingName()
 
+    def _makeFonts(self):
+        self._sysFont = wxSystemSettings_GetFont(wxSYS_SYSTEM_FONT)
+        self._labelFont = wxFont(self._sysFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxBOLD)
+        self._modernFont = wxFont(self._sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
+        self._smallerFont = wxFont(self._sysFont.GetPointSize()-2, wxDEFAULT, wxNORMAL, wxNORMAL)
+        
+    def sysFont(self):
+        if not hasattr(self, "_sysFont"): self._makeFonts()
+        return self._sysFont
+    def labelFont(self):
+        if not hasattr(self, "_labelFont"): self._makeFonts()
+        return self._labelFont
+    def modernFont(self):
+        if not hasattr(self, "_modernFont"): self._makeFonts()
+        return self._modernFont
+    def smallerFont(self):
+        if not hasattr(self, "_smallerFont"): self._makeFonts()
+        return self._smallerFont
+    
+        
+
 g = Globals()
 g = Globals()
index 4d1cdcaaa96e19407f9ef790de74318facf678e1..f58014800ec1cf02a2dc7acf49f1c76bdb5d51e9 100644 (file)
@@ -261,7 +261,7 @@ class PropPage(ParamPage):
     def __init__(self, parent, label, xxx):
         ParamPage.__init__(self, parent, xxx)
         self.box = wxStaticBox(self, -1, label)
     def __init__(self, parent, label, xxx):
         ParamPage.__init__(self, parent, xxx)
         self.box = wxStaticBox(self, -1, label)
-        self.box.SetFont(labelFont)
+        self.box.SetFont(g.labelFont())
         topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
         sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
         sizer.AddGrowableCol(1)
         topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
         sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
         sizer.AddGrowableCol(1)
@@ -334,7 +334,7 @@ class StylePage(ParamPage):
     def __init__(self, parent, label, xxx):
         ParamPage.__init__(self, parent, xxx)
         box = wxStaticBox(self, -1, label)
     def __init__(self, parent, label, xxx):
         ParamPage.__init__(self, parent, xxx)
         box = wxStaticBox(self, -1, label)
-        box.SetFont(labelFont)
+        box.SetFont(g.labelFont())
         topSizer = wxStaticBoxSizer(box, wxVERTICAL)
         sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
         sizer.AddGrowableCol(1)
         topSizer = wxStaticBoxSizer(box, wxVERTICAL)
         sizer = wxFlexGridSizer(len(xxx.styles), 2, 1, 1)
         sizer.AddGrowableCol(1)
index 061e4496c7c82a4652ef726de1105c329f291120..7d852d0ef682c0410881044fabc1b61f9f5735e3 100644 (file)
@@ -114,7 +114,7 @@ class Tools(wxPanel):
     def AddGroup(self, name):
         # Each group is inside box
         box = wxStaticBox(self, -1, name, style=wxWANTS_CHARS)
     def AddGroup(self, name):
         # Each group is inside box
         box = wxStaticBox(self, -1, name, style=wxWANTS_CHARS)
-        box.SetFont(smallerFont)
+        box.SetFont(g.smallerFont())
         boxSizer = wxStaticBoxSizer(box, wxVERTICAL)
         boxSizer.Add((0, 4))
         self.curSizer = wxGridSizer(0, 3)
         boxSizer = wxStaticBoxSizer(box, wxVERTICAL)
         boxSizer.Add((0, 4))
         self.curSizer = wxGridSizer(0, 3)
index 8b44b5e2cf6dc41a368d9ff03a09c429f8457633..82b35c6e8fd5f00903a85afea6fd60ff648b18f9 100644 (file)
@@ -65,10 +65,10 @@ class ScrolledMessageDialog(wxDialog):
         wxDialog.__init__(self, parent, -1, caption, pos, size)
         text = wxTextCtrl(self, -1, msg, wxDefaultPosition,
                              wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
         wxDialog.__init__(self, parent, -1, caption, pos, size)
         text = wxTextCtrl(self, -1, msg, wxDefaultPosition,
                              wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
-        text.SetFont(modernFont)
+        text.SetFont(g.modernFont())
         dc = wxWindowDC(text)
         # !!! possible bug - GetTextExtent without font returns sysfont dims
         dc = wxWindowDC(text)
         # !!! possible bug - GetTextExtent without font returns sysfont dims
-        w, h = dc.GetFullTextExtent(' ', modernFont)[:2]
+        w, h = dc.GetFullTextExtent(' ', g.modernFont())[:2]
         ok = wxButton(self, wxID_OK, "OK")
         text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
         text.SetSize((w * 80 + 30, h * 40))
         ok = wxButton(self, wxID_OK, "OK")
         text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
         text.SetSize((w * 80 + 30, h * 40))