]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/gdiobj.cpp
76156134e021d06944aa8e76b287e675ec18293e
[wxWidgets.git] / src / osx / carbon / gdiobj.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/gdiobj.cpp
3 // Purpose: wxGDIObject class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/gdiobj.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/gdicmn.h"
18 #include "wx/module.h"
19 #endif
20
21 #include "wx/link.h"
22 #include "wx/mac/private.h"
23
24 // Linker will discard entire object file without this
25 wxFORCE_LINK_THIS_MODULE(gdiobj)
26
27 class wxStockGDIMac: public wxStockGDI, public wxModule
28 {
29 public:
30 virtual const wxFont* GetFont(Item item);
31
32 virtual bool OnInit();
33 virtual void OnExit();
34
35 private:
36 typedef wxStockGDI super;
37 DECLARE_DYNAMIC_CLASS(wxStockGDIMac)
38 };
39
40 IMPLEMENT_DYNAMIC_CLASS(wxStockGDIMac, wxModule)
41
42 bool wxStockGDIMac::OnInit()
43 {
44 // Override default instance
45 ms_instance = this;
46 return true;
47 }
48
49 void wxStockGDIMac::OnExit()
50 {
51 }
52
53 const wxFont* wxStockGDIMac::GetFont(Item item)
54 {
55 wxFont* font = static_cast<wxFont*>(ms_stockObject[item]);
56 if (font == NULL)
57 {
58 switch (item)
59 {
60 case FONT_NORMAL:
61 font = new wxFont;
62 font->MacCreateFromThemeFont(kThemeSystemFont);
63 break;
64 case FONT_SMALL:
65 font = new wxFont;
66 font->MacCreateFromThemeFont(kThemeSmallSystemFont);
67 break;
68 default:
69 font = const_cast<wxFont*>(super::GetFont(item));
70 break;
71 }
72 ms_stockObject[item] = font;
73 }
74 return font;
75 }