]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/font.h
Add more checks for Intel compiler.
[wxWidgets.git] / include / wx / cocoa / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/font.h
3 // Purpose: wxFont class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
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
18 DECLARE_WXCOCOA_OBJC_CLASS(NSFont);
19
20 // Internal class that bridges us with code like wxSystemSettings
21 class wxCocoaFontFactory;
22 // We have c-tors/methods taking pointers of these
23 class wxFontRefData;
24
25 /*! @discussion
26 wxCocoa's implementation of wxFont is very incomplete. In particular,
27 a lot of work needs to be done on wxNativeFontInfo which is currently
28 using the totally generic implementation.
29
30 See the documentation in src/cocoa/font.mm for more implementatoin details.
31 */
32 class WXDLLIMPEXP_CORE wxFont : public wxFontBase
33 {
34 friend class wxCocoaFontFactory;
35 public:
36 /*! @abstract Default construction of invalid font for 2-step construct then Create process.
37 */
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 /*! @abstract Platform-independent construction with individual properties
55 */
56 #if FUTURE_WXWIN_COMPATIBILITY_3_0
57 wxFont(int size,
58 int family,
59 int style,
60 int weight,
61 bool underlined = FALSE,
62 const wxString& face = wxEmptyString,
63 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
64 {
65 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
66 }
67 #endif
68 wxFont(int size,
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 (void)Create(size, family, style, weight, underlined, face, encoding);
77 }
78
79 wxFont(const wxSize& pixelSize,
80 wxFontFamily family,
81 wxFontStyle style,
82 wxFontWeight weight,
83 bool underlined = false,
84 const wxString& face = wxEmptyString,
85 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
86 {
87 Create(10, family, style, weight, underlined, face, encoding);
88 SetPixelSize(pixelSize);
89 }
90
91 /*! @abstract Construction with opaque wxNativeFontInfo
92 */
93 wxFont(const wxNativeFontInfo& info)
94 {
95 (void)Create(info);
96 }
97
98 /*! @abstract Construction with platform-dependent font descriptor string.
99 @param fontDesc Usually the result of wxNativeFontInfo::ToUserString()
100 */
101 wxFont(const wxString& fontDesc);
102
103 // NOTE: Copy c-tor and assignment from wxObject is fine
104
105 bool Create(int size,
106 wxFontFamily family,
107 wxFontStyle style,
108 wxFontWeight weight,
109 bool underlined = FALSE,
110 const wxString& face = wxEmptyString,
111 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
112
113 bool Create(const wxNativeFontInfo& info);
114
115 virtual ~wxFont();
116
117 // implement base class pure virtuals
118 virtual int GetPointSize() const;
119 virtual wxFontStyle GetStyle() const;
120 virtual wxFontWeight GetWeight() const;
121 virtual bool GetUnderlined() const;
122 virtual wxString GetFaceName() const;
123 virtual wxFontEncoding GetEncoding() const;
124 virtual const wxNativeFontInfo *GetNativeFontInfo() 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 /*! @abstract Defined on some ports (not including this one) in wxGDIObject
140 @discussion
141 The intention here I suppose is to allow one to create a wxFont without yet
142 creating the underlying native object. There's no point not to create the
143 NSFont immediately in wxCocoa so this is useless.
144 This method came from the stub code copied in the early days of wxCocoa.
145 FIXME(1): Remove this in trunk. FIXME(2): Is it really a good idea for this to
146 be part of the public API for wxGDIObject?
147 */
148 virtual bool RealizeResource();
149
150 protected:
151 /*! @abstract Internal constructor with ref data
152 @discussion
153 Takes ownership of @a refData. That is, it is assumed that refData has either just been
154 created using new (which initializes its m_refCount to 1) or if you are sharing a ref that
155 you have called IncRef on it before passing it to this method.
156 */
157 explicit wxFont(wxFontRefData *refData)
158 { Create(refData); }
159 bool Create(wxFontRefData *refData);
160
161 virtual wxGDIRefData *CreateGDIRefData() const;
162 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
163
164 virtual wxFontFamily DoGetFamily() const;
165
166 private:
167 DECLARE_DYNAMIC_CLASS(wxFont)
168 };
169
170 #endif
171 // _WX_FONT_H_