add the wxFont(const wxSize& pixelSize, ...) ctor to all ports; add some wxCHECK_MSGs...
[wxWidgets.git] / include / wx / msw / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/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 #include "wx/gdicmn.h"
16
17 // ----------------------------------------------------------------------------
18 // wxFont
19 // ----------------------------------------------------------------------------
20
21 class WXDLLIMPEXP_CORE wxFont : public wxFontBase
22 {
23 public:
24 // ctors and such
25 wxFont() { }
26
27 #if FUTURE_WXWIN_COMPATIBILITY_3_0
28 wxFont(int size,
29 int family,
30 int style,
31 int weight,
32 bool underlined = false,
33 const wxString& face = wxEmptyString,
34 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
35 {
36 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
37 }
38 #endif
39
40 wxFont(int size,
41 wxFontFamily family,
42 wxFontStyle style,
43 wxFontWeight weight,
44 bool underlined = false,
45 const wxString& face = wxEmptyString,
46 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
47 {
48 Create(size, family, style, weight, underlined, face, encoding);
49 }
50
51 wxFont(const wxSize& pixelSize,
52 wxFontFamily family,
53 wxFontStyle style,
54 wxFontWeight weight,
55 bool underlined = false,
56 const wxString& face = wxEmptyString,
57 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
58 {
59 Create(10, family, style, weight, underlined, face, encoding);
60 SetPixelSize(pixelSize);
61 }
62
63 bool Create(int size,
64 wxFontFamily family,
65 wxFontStyle style,
66 wxFontWeight weight,
67 bool underlined = false,
68 const wxString& face = wxEmptyString,
69 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
70 {
71 return DoCreate(size, wxDefaultSize, false, family, style,
72 weight, underlined, face, encoding);
73 }
74
75 #if FUTURE_WXWIN_COMPATIBILITY_3_0
76 wxFont(const wxSize& pixelSize,
77 int family,
78 int style,
79 int weight,
80 bool underlined = false,
81 const wxString& face = wxEmptyString,
82 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
83 {
84 (void)Create(pixelSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight,
85 underlined, face, encoding);
86 }
87 #endif
88
89 wxFont(const wxSize& pixelSize,
90 wxFontFamily family,
91 wxFontStyle style,
92 wxFontWeight weight,
93 bool underlined = false,
94 const wxString& face = wxEmptyString,
95 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
96 {
97 (void)Create(pixelSize, family, style, weight,
98 underlined, face, encoding);
99 }
100
101 wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
102 {
103 Create(info, hFont);
104 }
105
106 wxFont(const wxString& fontDesc);
107
108
109 bool Create(const wxSize& pixelSize,
110 wxFontFamily family,
111 wxFontStyle style,
112 wxFontWeight weight,
113 bool underlined = false,
114 const wxString& face = wxEmptyString,
115 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
116 {
117 return DoCreate(-1, pixelSize, true, family, style,
118 weight, underlined, face, encoding);
119 }
120
121 bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
122
123 virtual ~wxFont();
124
125 // wxFontBase overridden functions
126 virtual wxString GetNativeFontInfoDesc() const;
127 virtual wxString GetNativeFontInfoUserDesc() const;
128
129 // implement base class pure virtuals
130 virtual int GetPointSize() const;
131 virtual wxSize GetPixelSize() const;
132 virtual bool IsUsingSizeInPixels() const;
133 virtual wxFontFamily GetFamily() const;
134 virtual wxFontStyle GetStyle() const;
135 virtual wxFontWeight GetWeight() const;
136 virtual bool GetUnderlined() const;
137 virtual wxString GetFaceName() const;
138 virtual wxFontEncoding GetEncoding() const;
139 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
140
141 virtual void SetPointSize(int pointSize);
142 virtual void SetPixelSize(const wxSize& pixelSize);
143 virtual void SetFamily(wxFontFamily family);
144 virtual void SetStyle(wxFontStyle style);
145 virtual void SetWeight(wxFontWeight weight);
146 virtual bool SetFaceName(const wxString& faceName);
147 virtual void SetUnderlined(bool underlined);
148 virtual void SetEncoding(wxFontEncoding encoding);
149
150 WXDECLARE_COMPAT_SETTERS
151
152 virtual bool IsFixedWidth() const;
153
154 // implementation only from now on
155 // -------------------------------
156
157 virtual bool IsFree() const;
158 virtual bool RealizeResource();
159 virtual WXHANDLE GetResourceHandle() const;
160 virtual bool FreeResource(bool force = false);
161
162 // for consistency with other wxMSW classes
163 WXHFONT GetHFONT() const;
164
165 protected:
166 // real font creation function, used in all cases
167 bool DoCreate(int size,
168 const wxSize& pixelSize,
169 bool sizeUsingPixels,
170 wxFontFamily family,
171 wxFontStyle style,
172 wxFontWeight weight,
173 bool underlined = false,
174 const wxString& face = wxEmptyString,
175 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
176
177 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
178
179 // implement wxObject virtuals which are used by AllocExclusive()
180 virtual wxGDIRefData *CreateGDIRefData() const;
181 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
182
183 private:
184 DECLARE_DYNAMIC_CLASS(wxFont)
185 };
186
187 #endif // _WX_FONT_H_