]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/gdiobj.cpp
define MIIM_BITMAP &c in wx/msw/missing.h instead of msw/menu.cpp as menuitem.cpp...
[wxWidgets.git] / src / osx / carbon / gdiobj.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/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/osx/private.h"
23 #include "wx/font.h"
24
25 // Linker will discard entire object file without this
26 wxFORCE_LINK_THIS_MODULE(gdiobj)
27
28 class wxStockGDIMac: public wxStockGDI, public wxModule
29 {
30 public:
31 virtual const wxFont* GetFont(Item item);
32
33 virtual bool OnInit();
34 virtual void OnExit();
35
36 private:
37 typedef wxStockGDI super;
38 DECLARE_DYNAMIC_CLASS(wxStockGDIMac)
39 };
40
41 IMPLEMENT_DYNAMIC_CLASS(wxStockGDIMac, wxModule)
42
43 bool wxStockGDIMac::OnInit()
44 {
45 // Override default instance
46 ms_instance = this;
47 return true;
48 }
49
50 void wxStockGDIMac::OnExit()
51 {
52 }
53
54 extern wxFont* CreateNormalFont();
55 extern wxFont* CreateSmallFont();
56
57 const wxFont* wxStockGDIMac::GetFont(Item item)
58 {
59 wxFont* font = static_cast<wxFont*>(ms_stockObject[item]);
60 if (font == NULL)
61 {
62 switch (item)
63 {
64 #if wxOSX_USE_COCOA_OR_CARBON
65 case FONT_NORMAL:
66 font = new wxFont;
67 #if wxOSX_USE_ATSU_TEXT
68 font->MacCreateFromThemeFont(kThemeSystemFont);
69 #else
70 font->MacCreateFromUIFont(kCTFontSystemFontType);
71 #endif
72 break;
73 case FONT_SMALL:
74 font = new wxFont;
75 #if wxOSX_USE_ATSU_TEXT
76 font->MacCreateFromThemeFont(kThemeSmallSystemFont);
77 #else
78 font->MacCreateFromUIFont(kCTFontSmallSystemFontType);
79 #endif
80 break;
81 #else
82 case FONT_NORMAL:
83 font = CreateNormalFont() ;
84 break;
85 case FONT_SMALL:
86 font = CreateSmallFont();
87 break;
88 #endif
89 default:
90 font = const_cast<wxFont*>(super::GetFont(item));
91 break;
92 }
93 ms_stockObject[item] = font;
94 }
95 return font;
96 }