]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/font.h
Use SelectAll() instead of SetSelection(-1, -1).
[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( wxOSXSystemFont systemFont );
41
42 #if wxOSX_USE_COCOA
43 wxFont(WX_NSFont nsfont);
44 #endif
45
46 #if FUTURE_WXWIN_COMPATIBILITY_3_0
47 wxFont(int size,
48 int family,
49 int style,
50 int weight,
51 bool underlined = false,
52 const wxString& face = wxEmptyString,
53 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
54 {
55 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
56 }
57 #endif
58
59 wxFont(int size,
60 wxFontFamily family,
61 wxFontStyle style,
62 wxFontWeight weight,
63 bool underlined = false,
64 const wxString& face = wxEmptyString,
65 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
66 {
67 Create(size, family, style, weight, underlined, face, encoding);
68 }
69
70 wxFont(const wxSize& pixelSize,
71 wxFontFamily family,
72 wxFontStyle style,
73 wxFontWeight weight,
74 bool underlined = false,
75 const wxString& face = wxEmptyString,
76 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
77 {
78 Create(10, family, style, weight, underlined, face, encoding);
79 SetPixelSize(pixelSize);
80 }
81
82 wxFont(int pointSize,
83 wxFontFamily family,
84 int flags = wxFONTFLAG_DEFAULT,
85 const wxString& face = wxEmptyString,
86 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
87 {
88 Create(pointSize, family,
89 GetStyleFromFlags(flags),
90 GetWeightFromFlags(flags),
91 GetUnderlinedFromFlags(flags),
92 face, encoding);
93 }
94
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
112 virtual ~wxFont();
113
114 // implement base class pure virtuals
115 virtual int GetPointSize() const;
116 virtual wxSize GetPixelSize() const;
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
124 virtual bool IsFixedWidth() const;
125
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
134 wxDECLARE_COMMON_FONT_METHODS();
135
136 // implementation only from now on
137 // -------------------------------
138
139 virtual bool RealizeResource();
140
141 // Mac-specific, risks to change, don't use in portable code
142
143 #if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
144 wxUint16 MacGetThemeFontID() const ;
145
146 // 'old' Quickdraw accessors
147 short MacGetFontNum() const;
148 wxByte MacGetFontStyle() const;
149 #endif
150
151 #if wxOSX_USE_COCOA_OR_CARBON
152 CGFontRef OSXGetCGFont() const;
153 #endif
154
155 #if wxOSX_USE_CORE_TEXT
156 CTFontRef OSXGetCTFont() const;
157 #endif
158
159 #if wxOSX_USE_ATSU_TEXT
160 // Returns an ATSUStyle not ATSUStyle*
161 void* MacGetATSUStyle() const ;
162 void* OSXGetATSUStyle() const { return MacGetATSUStyle() ; }
163
164 wxDEPRECATED( wxUint32 MacGetATSUFontID() const );
165 wxDEPRECATED( wxUint32 MacGetATSUAdditionalQDStyles() const );
166 #endif
167
168 #if wxOSX_USE_COCOA
169 WX_NSFont OSXGetNSFont() const;
170 static WX_NSFont OSXCreateNSFont(wxOSXSystemFont font, wxNativeFontInfo* info);
171 static WX_NSFont OSXCreateNSFont(const wxNativeFontInfo* info);
172 static void SetNativeInfoFromNSFont(WX_NSFont nsfont, wxNativeFontInfo* info);
173 #endif
174
175 #if wxOSX_USE_IPHONE
176 WX_UIFont OSXGetUIFont() const;
177 static WX_UIFont OSXCreateUIFont(wxOSXSystemFont font, wxNativeFontInfo* info);
178 static WX_UIFont OSXCreateUIFont(const wxNativeFontInfo* info);
179 #endif
180
181 protected:
182 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
183 virtual wxFontFamily DoGetFamily() const;
184
185 virtual wxGDIRefData *CreateGDIRefData() const;
186 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
187
188 private:
189
190 DECLARE_DYNAMIC_CLASS(wxFont)
191 };
192
193 #endif // _WX_FONT_H_