]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/font.h
01e7a41c76ab8be2dfa89b9d511373fc5e7e6c15
[wxWidgets.git] / include / wx / msw / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "font.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // wxFont
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxFont : public wxFontBase
24 {
25 public:
26 // ctors and such
27 wxFont() { Init(); }
28 wxFont(const wxFont& font) : wxFontBase(font) { Init(); Ref(font); }
29
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 Init();
39
40 (void)Create(size, wxSize(0, 0), FALSE, family, style, weight,
41 underlined, face, encoding);
42 }
43
44 wxFont(const wxSize& pixelSize,
45 int family,
46 int style,
47 int weight,
48 bool underlined = false,
49 const wxString& face = wxEmptyString,
50 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
51 {
52 Init();
53
54 (void)Create(0, pixelSize, TRUE, family, style, weight, underlined,
55 face, encoding);
56 }
57
58 wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
59 {
60 Init();
61
62 Create(info, hFont);
63 }
64
65 wxFont(const wxString& fontDesc);
66
67 bool Create(int size,
68 const wxSize& pixelSize,
69 bool sizeUsingPixels,
70 int family,
71 int style,
72 int weight,
73 bool underlined = false,
74 const wxString& face = wxEmptyString,
75 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
76
77 bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
78
79 virtual ~wxFont();
80
81 // assignment
82 wxFont& operator=(const wxFont& font);
83
84 // implement base class pure virtuals
85 virtual int GetPointSize() const;
86 virtual wxSize GetPixelSize() const;
87 virtual bool IsUsingSizeInPixels() const;
88 virtual int GetFamily() const;
89 virtual int GetStyle() const;
90 virtual int GetWeight() const;
91 virtual bool GetUnderlined() const;
92 virtual wxString GetFaceName() const;
93 virtual wxFontEncoding GetEncoding() const;
94 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
95
96 virtual void SetPointSize(int pointSize);
97 virtual void SetPixelSize(const wxSize& pixelSize);
98 virtual void SetFamily(int family);
99 virtual void SetStyle(int style);
100 virtual void SetWeight(int weight);
101 virtual void SetFaceName(const wxString& faceName);
102 virtual void SetUnderlined(bool underlined);
103 virtual void SetEncoding(wxFontEncoding encoding);
104
105 virtual bool IsFixedWidth() const;
106
107 // implementation only from now on
108 // -------------------------------
109
110 virtual bool IsFree() const;
111 virtual bool RealizeResource();
112 virtual WXHANDLE GetResourceHandle() const;
113 virtual bool FreeResource(bool force = false);
114
115 // for consistency with other wxMSW classes
116 WXHFONT GetHFONT() const;
117
118 /*
119 virtual bool UseResource();
120 virtual bool ReleaseResource();
121 */
122
123 protected:
124 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
125
126 // common part of all ctors
127 void Init();
128
129 void Unshare();
130
131 private:
132 DECLARE_DYNAMIC_CLASS(wxFont)
133 };
134
135 #endif
136 // _WX_FONT_H_