]>
Commit | Line | Data |
---|---|---|
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 | wxFont(const wxFontInfo& info); | |
28 | ||
29 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
30 | wxFont(int size, | |
31 | int family, | |
32 | int style, | |
33 | int weight, | |
34 | bool underlined = false, | |
35 | const wxString& face = wxEmptyString, | |
36 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
37 | { | |
38 | (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); | |
39 | } | |
40 | #endif | |
41 | ||
42 | wxFont(int size, | |
43 | wxFontFamily family, | |
44 | wxFontStyle style, | |
45 | wxFontWeight weight, | |
46 | bool underlined = false, | |
47 | const wxString& face = wxEmptyString, | |
48 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
49 | { | |
50 | Create(size, family, style, weight, underlined, face, encoding); | |
51 | } | |
52 | ||
53 | bool Create(int size, | |
54 | wxFontFamily family, | |
55 | wxFontStyle style, | |
56 | wxFontWeight weight, | |
57 | bool underlined = false, | |
58 | const wxString& face = wxEmptyString, | |
59 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
60 | { | |
61 | return DoCreate(size, wxDefaultSize, false, family, style, | |
62 | weight, underlined, face, encoding); | |
63 | } | |
64 | ||
65 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
66 | wxFont(const wxSize& pixelSize, | |
67 | int family, | |
68 | int style, | |
69 | int weight, | |
70 | bool underlined = false, | |
71 | const wxString& face = wxEmptyString, | |
72 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
73 | { | |
74 | (void)Create(pixelSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, | |
75 | underlined, face, encoding); | |
76 | } | |
77 | #endif | |
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 | (void)Create(pixelSize, family, style, weight, | |
88 | underlined, face, encoding); | |
89 | } | |
90 | ||
91 | wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0) | |
92 | { | |
93 | Create(info, hFont); | |
94 | } | |
95 | ||
96 | wxFont(const wxString& fontDesc); | |
97 | ||
98 | ||
99 | bool Create(const wxSize& pixelSize, | |
100 | wxFontFamily family, | |
101 | wxFontStyle style, | |
102 | wxFontWeight weight, | |
103 | bool underlined = false, | |
104 | const wxString& face = wxEmptyString, | |
105 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
106 | { | |
107 | return DoCreate(-1, pixelSize, true, family, style, | |
108 | weight, underlined, face, encoding); | |
109 | } | |
110 | ||
111 | bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0); | |
112 | ||
113 | virtual ~wxFont(); | |
114 | ||
115 | // implement base class pure virtuals | |
116 | virtual int GetPointSize() const; | |
117 | virtual wxSize GetPixelSize() const; | |
118 | virtual bool IsUsingSizeInPixels() const; | |
119 | virtual wxFontStyle GetStyle() const; | |
120 | virtual wxFontWeight GetWeight() const; | |
121 | virtual bool GetUnderlined() const; | |
122 | virtual bool GetStrikethrough() const; | |
123 | virtual wxString GetFaceName() const; | |
124 | virtual wxFontEncoding GetEncoding() const; | |
125 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; | |
126 | ||
127 | virtual void SetPointSize(int pointSize); | |
128 | virtual void SetPixelSize(const wxSize& pixelSize); | |
129 | virtual void SetFamily(wxFontFamily family); | |
130 | virtual void SetStyle(wxFontStyle style); | |
131 | virtual void SetWeight(wxFontWeight weight); | |
132 | virtual bool SetFaceName(const wxString& faceName); | |
133 | virtual void SetUnderlined(bool underlined); | |
134 | virtual void SetStrikethrough(bool strikethrough); | |
135 | virtual void SetEncoding(wxFontEncoding encoding); | |
136 | ||
137 | wxDECLARE_COMMON_FONT_METHODS(); | |
138 | ||
139 | virtual bool IsFixedWidth() const; | |
140 | ||
141 | // implementation only from now on | |
142 | // ------------------------------- | |
143 | ||
144 | virtual bool IsFree() const; | |
145 | virtual bool RealizeResource(); | |
146 | virtual WXHANDLE GetResourceHandle() const; | |
147 | virtual bool FreeResource(bool force = false); | |
148 | ||
149 | // for consistency with other wxMSW classes | |
150 | WXHFONT GetHFONT() const; | |
151 | ||
152 | protected: | |
153 | // real font creation function, used in all cases | |
154 | bool DoCreate(int size, | |
155 | const wxSize& pixelSize, | |
156 | bool sizeUsingPixels, | |
157 | wxFontFamily family, | |
158 | wxFontStyle style, | |
159 | wxFontWeight weight, | |
160 | bool underlined = false, | |
161 | const wxString& face = wxEmptyString, | |
162 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
163 | ||
164 | virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); | |
165 | virtual wxFontFamily DoGetFamily() const; | |
166 | ||
167 | // implement wxObject virtuals which are used by AllocExclusive() | |
168 | virtual wxGDIRefData *CreateGDIRefData() const; | |
169 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
170 | ||
171 | private: | |
172 | DECLARE_DYNAMIC_CLASS(wxFont) | |
173 | }; | |
174 | ||
175 | #endif // _WX_FONT_H_ |