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