]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/font.h
d5e277f979c0b0e86c09bcf215a736f9a9f3c390
[wxWidgets.git] / include / wx / osx / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/font.h
3 // Purpose: wxFont class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FONT_H_
13 #define _WX_FONT_H_
14
15 // ----------------------------------------------------------------------------
16 // wxFont
17 // ----------------------------------------------------------------------------
18
19 // font styles
20 enum wxOSXSystemFont
21 {
22 wxOSX_SYSTEM_FONT_NONE = 0,
23 wxOSX_SYSTEM_FONT_NORMAL,
24 wxOSX_SYSTEM_FONT_BOLD,
25 wxOSX_SYSTEM_FONT_SMALL,
26 wxOSX_SYSTEM_FONT_SMALL_BOLD,
27 wxOSX_SYSTEM_FONT_MINI,
28 wxOSX_SYSTEM_FONT_MINI_BOLD,
29 wxOSX_SYSTEM_FONT_LABELS,
30 wxOSX_SYSTEM_FONT_VIEWS
31 };
32
33
34 class WXDLLIMPEXP_CORE wxFont : public wxFontBase
35 {
36 public:
37 // ctors and such
38 wxFont() { }
39
40 wxFont(const wxFontInfo& info)
41 {
42 Create(info.GetPointSize(),
43 info.GetFamily(),
44 info.GetStyle(),
45 info.GetWeight(),
46 info.IsUnderlined(),
47 info.GetFaceName(),
48 info.GetEncoding());
49
50 if ( info.IsUsingSizeInPixels() )
51 SetPixelSize(info.GetPixelSize());
52 }
53
54 wxFont( wxOSXSystemFont systemFont );
55
56 #if wxOSX_USE_COCOA
57 wxFont(WX_NSFont nsfont);
58 #endif
59
60 #if FUTURE_WXWIN_COMPATIBILITY_3_0
61 wxFont(int size,
62 int family,
63 int style,
64 int weight,
65 bool underlined = false,
66 const wxString& face = wxEmptyString,
67 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
68 {
69 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
70 }
71 #endif
72
73 wxFont(int size,
74 wxFontFamily family,
75 wxFontStyle style,
76 wxFontWeight weight,
77 bool underlined = false,
78 const wxString& face = wxEmptyString,
79 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
80 {
81 Create(size, family, style, weight, underlined, face, encoding);
82 }
83
84 wxFont(const wxSize& pixelSize,
85 wxFontFamily family,
86 wxFontStyle style,
87 wxFontWeight weight,
88 bool underlined = false,
89 const wxString& face = wxEmptyString,
90 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
91 {
92 Create(10, family, style, weight, underlined, face, encoding);
93 SetPixelSize(pixelSize);
94 }
95
96 bool Create(int size,
97 wxFontFamily family,
98 wxFontStyle style,
99 wxFontWeight weight,
100 bool underlined = false,
101 const wxString& face = wxEmptyString,
102 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
103
104 wxFont(const wxNativeFontInfo& info)
105 {
106 (void)Create(info);
107 }
108
109 wxFont(const wxString& fontDesc);
110
111 bool Create(const wxNativeFontInfo& info);
112
113 virtual ~wxFont();
114
115 // implement base class pure virtuals
116 virtual int GetPointSize() const;
117 virtual wxSize GetPixelSize() const;
118 virtual wxFontStyle GetStyle() const;
119 virtual wxFontWeight GetWeight() const;
120 virtual bool GetUnderlined() const;
121 virtual wxString GetFaceName() const;
122 virtual wxFontEncoding GetEncoding() const;
123 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
124
125 virtual bool IsFixedWidth() const;
126
127 virtual void SetPointSize(int pointSize);
128 virtual void SetFamily(wxFontFamily family);
129 virtual void SetStyle(wxFontStyle style);
130 virtual void SetWeight(wxFontWeight weight);
131 virtual bool SetFaceName(const wxString& faceName);
132 virtual void SetUnderlined(bool underlined);
133 virtual void SetEncoding(wxFontEncoding encoding);
134
135 wxDECLARE_COMMON_FONT_METHODS();
136
137 // implementation only from now on
138 // -------------------------------
139
140 virtual bool RealizeResource();
141
142 // Mac-specific, risks to change, don't use in portable code
143
144 #if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
145 wxUint16 MacGetThemeFontID() const ;
146
147 // 'old' Quickdraw accessors
148 short MacGetFontNum() const;
149 wxByte MacGetFontStyle() const;
150 #endif
151
152 #if wxOSX_USE_COCOA_OR_CARBON
153 CGFontRef OSXGetCGFont() const;
154 #endif
155
156 #if wxOSX_USE_CORE_TEXT
157 CTFontRef OSXGetCTFont() const;
158 #endif
159
160 #if wxOSX_USE_ATSU_TEXT
161 // Returns an ATSUStyle not ATSUStyle*
162 void* MacGetATSUStyle() const ;
163 void* OSXGetATSUStyle() const { return MacGetATSUStyle() ; }
164
165 wxDEPRECATED( wxUint32 MacGetATSUFontID() const );
166 wxDEPRECATED( wxUint32 MacGetATSUAdditionalQDStyles() const );
167 #endif
168
169 #if wxOSX_USE_COCOA
170 WX_NSFont OSXGetNSFont() const;
171 static WX_NSFont OSXCreateNSFont(wxOSXSystemFont font, wxNativeFontInfo* info);
172 static WX_NSFont OSXCreateNSFont(const wxNativeFontInfo* info);
173 static void SetNativeInfoFromNSFont(WX_NSFont nsfont, wxNativeFontInfo* info);
174 #endif
175
176 #if wxOSX_USE_IPHONE
177 WX_UIFont OSXGetUIFont() const;
178 static WX_UIFont OSXCreateUIFont(wxOSXSystemFont font, wxNativeFontInfo* info);
179 static WX_UIFont OSXCreateUIFont(const wxNativeFontInfo* info);
180 #endif
181
182 protected:
183 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
184 virtual wxFontFamily DoGetFamily() const;
185
186 virtual wxGDIRefData *CreateGDIRefData() const;
187 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
188
189 private:
190
191 DECLARE_DYNAMIC_CLASS(wxFont)
192 };
193
194 #endif // _WX_FONT_H_