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