]>
Commit | Line | Data |
---|---|---|
6762286d SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: 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 | ||
f1c40652 SC |
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 | ||
6762286d SC |
34 | class WXDLLIMPEXP_CORE wxFont : public wxFontBase |
35 | { | |
36 | public: | |
37 | // ctors and such | |
38 | wxFont() { } | |
39 | ||
f7946add KO |
40 | #if wxOSX_USE_COCOA |
41 | wxFont(WX_NSFont nsfont); | |
42 | #endif | |
43 | ||
6762286d SC |
44 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 |
45 | wxFont(int size, | |
46 | int family, | |
47 | int style, | |
48 | int weight, | |
49 | bool underlined = false, | |
50 | const wxString& face = wxEmptyString, | |
51 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
52 | { | |
53 | (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); | |
54 | } | |
5c6eb3a8 | 55 | #endif |
6762286d SC |
56 | |
57 | wxFont(int size, | |
58 | wxFontFamily family, | |
59 | wxFontStyle style, | |
60 | wxFontWeight weight, | |
61 | bool underlined = false, | |
62 | const wxString& face = wxEmptyString, | |
63 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
64 | { | |
65 | Create(size, family, style, weight, underlined, face, encoding); | |
66 | } | |
03647350 | 67 | |
b5791cc7 FM |
68 | wxFont(const wxSize& pixelSize, |
69 | wxFontFamily family, | |
70 | wxFontStyle style, | |
71 | wxFontWeight weight, | |
72 | bool underlined = false, | |
73 | const wxString& face = wxEmptyString, | |
74 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
75 | { | |
76 | Create(10, family, style, weight, underlined, face, encoding); | |
77 | SetPixelSize(pixelSize); | |
78 | } | |
03647350 | 79 | |
6762286d SC |
80 | bool Create(int size, |
81 | wxFontFamily family, | |
82 | wxFontStyle style, | |
83 | wxFontWeight weight, | |
84 | bool underlined = false, | |
85 | const wxString& face = wxEmptyString, | |
86 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
87 | ||
88 | wxFont(const wxNativeFontInfo& info) | |
89 | { | |
90 | (void)Create(info); | |
91 | } | |
92 | ||
93 | wxFont(const wxString& fontDesc); | |
94 | ||
95 | bool Create(const wxNativeFontInfo& info); | |
96 | ||
f1c40652 | 97 | bool CreateSystemFont(wxOSXSystemFont font); |
03647350 | 98 | |
6762286d SC |
99 | virtual ~wxFont(); |
100 | ||
101 | // implement base class pure virtuals | |
102 | virtual int GetPointSize() const; | |
103 | virtual wxSize GetPixelSize() const; | |
104 | virtual wxFontFamily GetFamily() const; | |
105 | virtual wxFontStyle GetStyle() const; | |
106 | virtual wxFontWeight GetWeight() const; | |
107 | virtual bool GetUnderlined() const; | |
108 | virtual wxString GetFaceName() const; | |
109 | virtual wxFontEncoding GetEncoding() const; | |
110 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; | |
111 | ||
112 | virtual void SetPointSize(int pointSize); | |
113 | virtual void SetFamily(wxFontFamily family); | |
114 | virtual void SetStyle(wxFontStyle style); | |
115 | virtual void SetWeight(wxFontWeight weight); | |
116 | virtual bool SetFaceName(const wxString& faceName); | |
117 | virtual void SetUnderlined(bool underlined); | |
118 | virtual void SetEncoding(wxFontEncoding encoding); | |
119 | ||
f76c0758 | 120 | wxDECLARE_COMMON_FONT_METHODS(); |
6762286d SC |
121 | |
122 | // implementation only from now on | |
123 | // ------------------------------- | |
124 | ||
125 | virtual bool RealizeResource(); | |
126 | ||
6762286d SC |
127 | // Mac-specific, risks to change, don't use in portable code |
128 | ||
f1c40652 SC |
129 | #if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT |
130 | wxUint16 MacGetThemeFontID() const ; | |
aa6208d9 | 131 | |
6762286d SC |
132 | // 'old' Quickdraw accessors |
133 | short MacGetFontNum() const; | |
6762286d | 134 | wxByte MacGetFontStyle() const; |
f1c40652 | 135 | #endif |
6762286d | 136 | |
f1c40652 | 137 | #if wxOSX_USE_COCOA_OR_CARBON |
aa6208d9 | 138 | CGFontRef OSXGetCGFont() const; |
6762286d | 139 | #endif |
f1c40652 | 140 | |
6762286d | 141 | #if wxOSX_USE_CORE_TEXT |
aa6208d9 | 142 | CTFontRef OSXGetCTFont() const; |
6762286d | 143 | #endif |
f1c40652 | 144 | |
beb2638a | 145 | #if wxOSX_USE_ATSU_TEXT |
f1c40652 | 146 | // Returns an ATSUStyle not ATSUStyle* |
6762286d | 147 | void* MacGetATSUStyle() const ; |
aa6208d9 SC |
148 | void* OSXGetATSUStyle() const { return MacGetATSUStyle() ; } |
149 | ||
6f283573 SC |
150 | #if WXWIN_COMPATIBILITY_2_8 |
151 | wxDEPRECATED( wxUint32 MacGetATSUFontID() const ); | |
152 | wxDEPRECATED( wxUint32 MacGetATSUAdditionalQDStyles() const ); | |
153 | #endif | |
6762286d SC |
154 | #endif |
155 | ||
f1c40652 | 156 | #if wxOSX_USE_COCOA |
aa6208d9 SC |
157 | WX_NSFont OSXGetNSFont() const; |
158 | static WX_NSFont OSXCreateNSFont(wxOSXSystemFont font, wxNativeFontInfo* info); | |
159 | static WX_NSFont OSXCreateNSFont(const wxNativeFontInfo* info); | |
f7946add | 160 | static void SetNativeInfoFromNSFont(WX_NSFont nsfont, wxNativeFontInfo* info); |
f1c40652 SC |
161 | #endif |
162 | ||
163 | #if wxOSX_USE_IPHONE | |
aa6208d9 | 164 | WX_UIFont OSXGetUIFont() const; |
b4ff8b3e SC |
165 | static WX_UIFont OSXCreateUIFont(wxOSXSystemFont font, wxNativeFontInfo* info); |
166 | static WX_UIFont OSXCreateUIFont(const wxNativeFontInfo* info); | |
f1c40652 SC |
167 | #endif |
168 | ||
6762286d | 169 | protected: |
c443ff6f SC |
170 | virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); |
171 | ||
6762286d SC |
172 | virtual wxGDIRefData *CreateGDIRefData() const; |
173 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
174 | ||
175 | private: | |
6762286d SC |
176 | |
177 | DECLARE_DYNAMIC_CLASS(wxFont) | |
178 | }; | |
179 | ||
180 | #endif // _WX_FONT_H_ |