Add wxFont ctor taking a single flags argument instead of style/weight/...
[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 bool Create(int size,
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 return DoCreate(size, wxDefaultSize, false, family, style,
60 weight, underlined, face, encoding);
61 }
62
63 #if FUTURE_WXWIN_COMPATIBILITY_3_0
64 wxFont(const wxSize& pixelSize,
65 int family,
66 int style,
67 int weight,
68 bool underlined = false,
69 const wxString& face = wxEmptyString,
70 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
71 {
72 (void)Create(pixelSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight,
73 underlined, face, encoding);
74 }
75 #endif
76
77 wxFont(const wxSize& pixelSize,
78 wxFontFamily family,
79 wxFontStyle style,
80 wxFontWeight weight,
81 bool underlined = false,
82 const wxString& face = wxEmptyString,
83 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
84 {
85 (void)Create(pixelSize, family, style, weight,
86 underlined, face, encoding);
87 }
88
89 wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
90 {
91 Create(info, hFont);
92 }
93
94 wxFont(int pointSize,
95 wxFontFamily family,
96 int flags = wxFONTFLAG_DEFAULT,
97 const wxString& face = wxEmptyString,
98 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
99
100 wxFont(const wxString& fontDesc);
101
102
103 bool Create(const wxSize& pixelSize,
104 wxFontFamily family,
105 wxFontStyle style,
106 wxFontWeight weight,
107 bool underlined = false,
108 const wxString& face = wxEmptyString,
109 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
110 {
111 return DoCreate(-1, pixelSize, true, family, style,
112 weight, underlined, face, encoding);
113 }
114
115 bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
116
117 virtual ~wxFont();
118
119 // implement base class pure virtuals
120 virtual int GetPointSize() const;
121 virtual wxSize GetPixelSize() const;
122 virtual bool IsUsingSizeInPixels() const;
123 virtual wxFontStyle GetStyle() const;
124 virtual wxFontWeight GetWeight() const;
125 virtual bool GetUnderlined() const;
126 virtual wxString GetFaceName() const;
127 virtual wxFontEncoding GetEncoding() const;
128 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
129
130 virtual void SetPointSize(int pointSize);
131 virtual void SetPixelSize(const wxSize& pixelSize);
132 virtual void SetFamily(wxFontFamily family);
133 virtual void SetStyle(wxFontStyle style);
134 virtual void SetWeight(wxFontWeight weight);
135 virtual bool SetFaceName(const wxString& faceName);
136 virtual void SetUnderlined(bool underlined);
137 virtual void SetEncoding(wxFontEncoding encoding);
138
139 wxDECLARE_COMMON_FONT_METHODS();
140
141 virtual bool IsFixedWidth() const;
142
143 // implementation only from now on
144 // -------------------------------
145
146 virtual bool IsFree() const;
147 virtual bool RealizeResource();
148 virtual WXHANDLE GetResourceHandle() const;
149 virtual bool FreeResource(bool force = false);
150
151 // for consistency with other wxMSW classes
152 WXHFONT GetHFONT() const;
153
154 protected:
155 // real font creation function, used in all cases
156 bool DoCreate(int size,
157 const wxSize& pixelSize,
158 bool sizeUsingPixels,
159 wxFontFamily family,
160 wxFontStyle style,
161 wxFontWeight weight,
162 bool underlined = false,
163 const wxString& face = wxEmptyString,
164 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
165
166 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
167 virtual wxFontFamily DoGetFamily() const;
168
169 // implement wxObject virtuals which are used by AllocExclusive()
170 virtual wxGDIRefData *CreateGDIRefData() const;
171 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
172
173 private:
174 DECLARE_DYNAMIC_CLASS(wxFont)
175 };
176
177 #endif // _WX_FONT_H_