]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/font.h
added wxListAttr::AssignFrom()
[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 WXDLLEXPORT wxFont : public wxFontBase
22 {
23 public:
24 // ctors and such
25 wxFont() { Init(); }
26 wxFont(const wxFont& font) : wxFontBase(font) { Init(); Ref(font); }
27
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 Init();
37
38 (void)Create(size, family, style, weight, underlined, face, encoding);
39 }
40
41 wxFont(const wxSize& pixelSize,
42 int family,
43 int style,
44 int weight,
45 bool underlined = false,
46 const wxString& face = wxEmptyString,
47 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
48 {
49 Init();
50
51 (void)Create(pixelSize, family, style, weight,
52 underlined, face, encoding);
53 }
54
55 wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
56 {
57 Init();
58
59 Create(info, hFont);
60 }
61
62 wxFont(const wxString& fontDesc);
63
64 bool Create(int size,
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 return DoCreate(size, wxDefaultSize, false, family, style,
73 weight, underlined, face, encoding);
74 }
75
76 bool Create(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 return DoCreate(-1, pixelSize, true, family, style,
85 weight, underlined, face, encoding);
86 }
87
88 bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
89
90 virtual ~wxFont();
91
92 // assignment
93 wxFont& operator=(const wxFont& font);
94
95 // implement base class pure virtuals
96 virtual int GetPointSize() const;
97 virtual wxSize GetPixelSize() const;
98 virtual bool IsUsingSizeInPixels() const;
99 virtual int GetFamily() const;
100 virtual int GetStyle() const;
101 virtual int GetWeight() const;
102 virtual bool GetUnderlined() const;
103 virtual wxString GetFaceName() const;
104 virtual wxFontEncoding GetEncoding() const;
105 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
106
107 virtual void SetPointSize(int pointSize);
108 virtual void SetPixelSize(const wxSize& pixelSize);
109 virtual void SetFamily(int family);
110 virtual void SetStyle(int style);
111 virtual void SetWeight(int weight);
112 virtual void SetFaceName(const wxString& faceName);
113 virtual void SetUnderlined(bool underlined);
114 virtual void SetEncoding(wxFontEncoding encoding);
115
116 virtual bool IsFixedWidth() const;
117
118 // implementation only from now on
119 // -------------------------------
120
121 virtual bool IsFree() const;
122 virtual bool RealizeResource();
123 virtual WXHANDLE GetResourceHandle() const;
124 virtual bool FreeResource(bool force = false);
125
126 // for consistency with other wxMSW classes
127 WXHFONT GetHFONT() const;
128
129 /*
130 virtual bool UseResource();
131 virtual bool ReleaseResource();
132 */
133
134 protected:
135 // real font creation function, used in all cases
136 bool DoCreate(int size,
137 const wxSize& pixelSize,
138 bool sizeUsingPixels,
139 int family,
140 int style,
141 int weight,
142 bool underlined = false,
143 const wxString& face = wxEmptyString,
144 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
145
146 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
147
148 // common part of all ctors
149 void Init();
150
151 void Unshare();
152
153 private:
154 DECLARE_DYNAMIC_CLASS(wxFont)
155 };
156
157 #endif // _WX_FONT_H_