]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.h | |
3 | // Purpose: wxFont class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
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 | #ifdef __GNUG__ | |
93ccaed8 | 16 | #pragma interface "font.h" |
9b6dbb09 JS |
17 | #endif |
18 | ||
93ccaed8 VZ |
19 | // Font |
20 | class wxFont : public wxFontBase | |
f97c9854 JS |
21 | { |
22 | public: | |
93ccaed8 VZ |
23 | // ctors and such |
24 | wxFont() { Init(); } | |
25 | wxFont(const wxFont& font) { Init(); Ref(font); } | |
26 | ||
27 | wxFont(int size, | |
28 | int family, | |
29 | int style, | |
30 | int weight, | |
31 | bool underlined = FALSE, | |
32 | const wxString& face = wxEmptyString, | |
33 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
34 | { | |
35 | Init(); | |
36 | ||
37 | (void)Create(size, family, style, weight, underlined, face, encoding); | |
38 | } | |
39 | ||
30764ab5 VZ |
40 | wxFont(const wxNativeFontInfo& info) |
41 | { | |
42 | Init(); | |
43 | ||
44 | (void)Create(info.pointSize, info.family, info.style, info.weight, | |
45 | info.underlined, info.faceName, info.encoding); | |
46 | } | |
47 | ||
93ccaed8 VZ |
48 | bool Create(int size, |
49 | int family, | |
50 | int style, | |
51 | int weight, | |
52 | bool underlined = FALSE, | |
53 | const wxString& face = wxEmptyString, | |
54 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
55 | ||
56 | virtual ~wxFont(); | |
57 | ||
58 | // assignment | |
59 | wxFont& operator=(const wxFont& font); | |
60 | ||
61 | // implement base class pure virtuals | |
62 | virtual int GetPointSize() const; | |
63 | virtual int GetFamily() const; | |
64 | virtual int GetStyle() const; | |
65 | virtual int GetWeight() const; | |
66 | virtual bool GetUnderlined() const; | |
67 | virtual wxString GetFaceName() const; | |
68 | virtual wxFontEncoding GetEncoding() const; | |
69 | ||
70 | virtual void SetPointSize(int pointSize); | |
71 | virtual void SetFamily(int family); | |
72 | virtual void SetStyle(int style); | |
73 | virtual void SetWeight(int weight); | |
74 | virtual void SetFaceName(const wxString& faceName); | |
75 | virtual void SetUnderlined(bool underlined); | |
76 | virtual void SetEncoding(wxFontEncoding encoding); | |
77 | ||
78 | // Implementation | |
79 | ||
80 | // Find an existing, or create a new, XFontStruct | |
81 | // based on this wxFont and the given scale. Append the | |
82 | // font to list in the private data for future reference. | |
83 | ||
84 | // TODO This is a fairly basic implementation, that doesn't | |
85 | // allow for different facenames, and also doesn't do a mapping | |
86 | // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) | |
87 | // and the fonts that are available on a particular system. | |
88 | // Maybe we need to scan the user's machine to build up a profile | |
89 | // of the fonts and a mapping file. | |
90 | ||
91 | // Return font struct, and optionally the Motif font list | |
92 | class wxXFont* GetInternalFont(double scale = 1.0, | |
93 | WXDisplay* display = NULL) const; | |
94 | ||
95 | // These two are helper functions for convenient access of the above. | |
96 | WXFontStructPtr GetFontStruct(double scale = 1.0, | |
97 | WXDisplay* display = NULL) const; | |
98 | WXFontList GetFontList(double scale = 1.0, | |
99 | WXDisplay* display = NULL) const; | |
f97c9854 | 100 | |
9b6dbb09 | 101 | protected: |
93ccaed8 VZ |
102 | // common part of all ctors |
103 | void Init(); | |
9b6dbb09 | 104 | |
93ccaed8 VZ |
105 | // VZ: IMHO, we don't need it at all... |
106 | bool RealizeResource() { return TRUE; } | |
107 | void Unshare(); | |
9b6dbb09 | 108 | |
93ccaed8 VZ |
109 | private: |
110 | DECLARE_DYNAMIC_CLASS(wxFont) | |
9b6dbb09 JS |
111 | }; |
112 | ||
113 | #endif | |
114 | // _WX_FONT_H_ |