]>
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 | |
65571936 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FONT_H_ | |
13 | #define _WX_FONT_H_ | |
14 | ||
b0b2263b MB |
15 | #if __WXMOTIF20__ && !__WXLESSTIF__ |
16 | #define wxMOTIF_NEW_FONT_HANDLING 0 // safe default, change to 1 to enable | |
17 | #else | |
18 | #define wxMOTIF_NEW_FONT_HANDLING 0 | |
996994c7 MB |
19 | #endif |
20 | ||
a2e91a93 VZ |
21 | class wxXFont; |
22 | ||
93ccaed8 | 23 | // Font |
94c7b088 | 24 | class WXDLLIMPEXP_CORE wxFont : public wxFontBase |
f97c9854 JS |
25 | { |
26 | public: | |
93ccaed8 VZ |
27 | // ctors and such |
28 | wxFont() { Init(); } | |
29 | wxFont(const wxFont& font) { Init(); Ref(font); } | |
9045ad9d | 30 | |
93ccaed8 | 31 | wxFont(int size, |
83df96d6 JS |
32 | int family, |
33 | int style, | |
34 | int weight, | |
96be256b | 35 | bool underlined = false, |
83df96d6 JS |
36 | const wxString& face = wxEmptyString, |
37 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
93ccaed8 VZ |
38 | { |
39 | Init(); | |
9045ad9d | 40 | |
93ccaed8 VZ |
41 | (void)Create(size, family, style, weight, underlined, face, encoding); |
42 | } | |
9045ad9d | 43 | |
98c9fc2d | 44 | wxFont(const wxNativeFontInfo& info); |
9045ad9d | 45 | |
93ccaed8 | 46 | bool Create(int size, |
83df96d6 JS |
47 | int family, |
48 | int style, | |
49 | int weight, | |
96be256b | 50 | bool underlined = false, |
83df96d6 JS |
51 | const wxString& face = wxEmptyString, |
52 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
9045ad9d | 53 | |
563f868d GD |
54 | // wxMOTIF-specific |
55 | bool Create(const wxString& fontname, | |
83df96d6 | 56 | wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); |
563f868d | 57 | bool Create(const wxNativeFontInfo& fontinfo); |
9045ad9d | 58 | |
93ccaed8 | 59 | virtual ~wxFont(); |
9045ad9d | 60 | |
93ccaed8 VZ |
61 | // assignment |
62 | wxFont& operator=(const wxFont& font); | |
9045ad9d | 63 | |
93ccaed8 VZ |
64 | // implement base class pure virtuals |
65 | virtual int GetPointSize() const; | |
66 | virtual int GetFamily() const; | |
67 | virtual int GetStyle() const; | |
68 | virtual int GetWeight() const; | |
69 | virtual bool GetUnderlined() const; | |
70 | virtual wxString GetFaceName() const; | |
71 | virtual wxFontEncoding GetEncoding() const; | |
3bf5a59b | 72 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; |
9045ad9d | 73 | |
93ccaed8 VZ |
74 | virtual void SetPointSize(int pointSize); |
75 | virtual void SetFamily(int family); | |
76 | virtual void SetStyle(int style); | |
77 | virtual void SetWeight(int weight); | |
78 | virtual void SetFaceName(const wxString& faceName); | |
79 | virtual void SetUnderlined(bool underlined); | |
80 | virtual void SetEncoding(wxFontEncoding encoding); | |
9045ad9d | 81 | |
93ccaed8 | 82 | // Implementation |
9045ad9d | 83 | |
93ccaed8 VZ |
84 | // Find an existing, or create a new, XFontStruct |
85 | // based on this wxFont and the given scale. Append the | |
86 | // font to list in the private data for future reference. | |
9045ad9d | 87 | |
93ccaed8 VZ |
88 | // TODO This is a fairly basic implementation, that doesn't |
89 | // allow for different facenames, and also doesn't do a mapping | |
90 | // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) | |
91 | // and the fonts that are available on a particular system. | |
92 | // Maybe we need to scan the user's machine to build up a profile | |
93 | // of the fonts and a mapping file. | |
9045ad9d | 94 | |
93ccaed8 | 95 | // Return font struct, and optionally the Motif font list |
a2e91a93 | 96 | wxXFont *GetInternalFont(double scale = 1.0, |
83df96d6 | 97 | WXDisplay* display = NULL) const; |
9045ad9d | 98 | |
93ccaed8 | 99 | // These two are helper functions for convenient access of the above. |
996994c7 | 100 | #if !wxMOTIF_NEW_FONT_HANDLING |
93ccaed8 | 101 | WXFontStructPtr GetFontStruct(double scale = 1.0, |
83df96d6 | 102 | WXDisplay* display = NULL) const; |
93ccaed8 | 103 | WXFontList GetFontList(double scale = 1.0, |
83df96d6 | 104 | WXDisplay* display = NULL) const; |
996994c7 MB |
105 | #else |
106 | WXFontSet GetFontSet(double scale, WXDisplay* display = NULL) const; | |
107 | #endif | |
108 | #if __WXMOTIF20__ // && !__WXLESSTIF__ for 2.7 | |
da494b40 MB |
109 | WXRenderTable GetRenderTable(WXDisplay* display) const; |
110 | #endif | |
996994c7 | 111 | // returns either a XmFontList or XmRenderTable, depending |
da494b40 MB |
112 | // on Motif version |
113 | WXFontType GetFontType(WXDisplay* display) const; | |
73608949 MB |
114 | // like the function above but does a copy for XmFontList |
115 | WXFontType GetFontTypeC(WXDisplay* display) const; | |
da494b40 | 116 | static WXString GetFontTag(); |
9b6dbb09 | 117 | protected: |
9045ad9d VZ |
118 | virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info ); |
119 | ||
93ccaed8 VZ |
120 | // common part of all ctors |
121 | void Init(); | |
9045ad9d | 122 | |
93ccaed8 | 123 | // VZ: IMHO, we don't need it at all... |
96be256b | 124 | bool RealizeResource() { return true; } |
93ccaed8 | 125 | void Unshare(); |
9045ad9d | 126 | |
93ccaed8 VZ |
127 | private: |
128 | DECLARE_DYNAMIC_CLASS(wxFont) | |
9b6dbb09 JS |
129 | }; |
130 | ||
131 | #endif | |
83df96d6 | 132 | // _WX_FONT_H_ |