]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/font.h
don't pass NULL pointer to printf(), this crashes Solaris printf
[wxWidgets.git] / include / wx / msw / font.h
CommitLineData
2bda0e17
KB
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$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_FONT_H_
13#define _WX_FONT_H_
2bda0e17 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
0c5d3e1c 16 #pragma interface "font.h"
2bda0e17
KB
17#endif
18
88899f6b
RL
19#include <wx/gdicmn.h>
20
0c5d3e1c
VZ
21// ----------------------------------------------------------------------------
22// wxFont
23// ----------------------------------------------------------------------------
24
25class WXDLLEXPORT wxFont : public wxFontBase
2bda0e17 26{
2bda0e17 27public:
0c5d3e1c
VZ
28 // ctors and such
29 wxFont() { Init(); }
4dddb8a2 30 wxFont(const wxFont& font) : wxFontBase(font) { Init(); Ref(font); }
0c5d3e1c
VZ
31
32 wxFont(int size,
33 int family,
34 int style,
35 int weight,
dabbc6a5 36 bool underlined = false,
0c5d3e1c
VZ
37 const wxString& face = wxEmptyString,
38 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
39 {
40 Init();
41
df455719 42 (void)Create(size, family, style, weight, underlined, face, encoding);
544229d1
VZ
43 }
44
45 wxFont(const wxSize& pixelSize,
46 int family,
47 int style,
48 int weight,
49 bool underlined = false,
50 const wxString& face = wxEmptyString,
51 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
52 {
53 Init();
54
df455719
VZ
55 (void)Create(pixelSize, family, style, weight,
56 underlined, face, encoding);
0c5d3e1c
VZ
57 }
58
04ef50df 59 wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
30764ab5
VZ
60 {
61 Init();
62
04ef50df 63 Create(info, hFont);
30764ab5
VZ
64 }
65
76e23cdb
VZ
66 wxFont(const wxString& fontDesc);
67
0c5d3e1c
VZ
68 bool Create(int size,
69 int family,
70 int style,
71 int weight,
dabbc6a5 72 bool underlined = false,
0c5d3e1c 73 const wxString& face = wxEmptyString,
df455719
VZ
74 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
75 {
76 return DoCreate(size, wxDefaultSize, false, family, style,
77 weight, underlined, face, encoding);
78 }
79
80 bool Create(const wxSize& pixelSize,
81 int family,
82 int style,
83 int weight,
84 bool underlined = false,
85 const wxString& face = wxEmptyString,
86 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
87 {
88 return DoCreate(-1, pixelSize, true, family, style,
89 weight, underlined, face, encoding);
90 }
0c5d3e1c 91
04ef50df 92 bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
76e23cdb 93
0c5d3e1c
VZ
94 virtual ~wxFont();
95
74b31181
VZ
96 // assignment
97 wxFont& operator=(const wxFont& font);
98
0c5d3e1c
VZ
99 // implement base class pure virtuals
100 virtual int GetPointSize() const;
544229d1
VZ
101 virtual wxSize GetPixelSize() const;
102 virtual bool IsUsingSizeInPixels() const;
0c5d3e1c
VZ
103 virtual int GetFamily() const;
104 virtual int GetStyle() const;
105 virtual int GetWeight() const;
106 virtual bool GetUnderlined() const;
107 virtual wxString GetFaceName() const;
108 virtual wxFontEncoding GetEncoding() const;
3bf5a59b 109 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
0c5d3e1c
VZ
110
111 virtual void SetPointSize(int pointSize);
544229d1 112 virtual void SetPixelSize(const wxSize& pixelSize);
0c5d3e1c
VZ
113 virtual void SetFamily(int family);
114 virtual void SetStyle(int style);
115 virtual void SetWeight(int weight);
116 virtual void SetFaceName(const wxString& faceName);
117 virtual void SetUnderlined(bool underlined);
118 virtual void SetEncoding(wxFontEncoding encoding);
119
9cf8de4c
VZ
120 virtual bool IsFixedWidth() const;
121
0c5d3e1c
VZ
122 // implementation only from now on
123 // -------------------------------
124
0c5d3e1c
VZ
125 virtual bool IsFree() const;
126 virtual bool RealizeResource();
2b5f62a0 127 virtual WXHANDLE GetResourceHandle() const;
dabbc6a5 128 virtual bool FreeResource(bool force = false);
f6bcfd97 129
2b5f62a0 130 // for consistency with other wxMSW classes
f6bcfd97
BP
131 WXHFONT GetHFONT() const;
132
0c5d3e1c
VZ
133 /*
134 virtual bool UseResource();
135 virtual bool ReleaseResource();
136 */
b823f5a1
JS
137
138protected:
df455719
VZ
139 // real font creation function, used in all cases
140 bool DoCreate(int size,
141 const wxSize& pixelSize,
142 bool sizeUsingPixels,
143 int family,
144 int style,
145 int weight,
146 bool underlined = false,
147 const wxString& face = wxEmptyString,
148 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
149
9045ad9d
VZ
150 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
151
0c5d3e1c
VZ
152 // common part of all ctors
153 void Init();
154
155 void Unshare();
156
157private:
158 DECLARE_DYNAMIC_CLASS(wxFont)
2bda0e17
KB
159};
160
161#endif
bbcdf8bc 162 // _WX_FONT_H_