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