]>
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__ |
eb9d223a | 16 | #define wxMOTIF_USE_RENDER_TABLE 1 |
b0b2263b | 17 | #else |
eb9d223a | 18 | #define wxMOTIF_USE_RENDER_TABLE 0 |
996994c7 | 19 | #endif |
105fbe1f | 20 | #define wxMOTIF_NEW_FONT_HANDLING wxMOTIF_USE_RENDER_TABLE |
996994c7 | 21 | |
a2e91a93 VZ |
22 | class wxXFont; |
23 | ||
93ccaed8 | 24 | // Font |
94c7b088 | 25 | class WXDLLIMPEXP_CORE wxFont : public wxFontBase |
f97c9854 JS |
26 | { |
27 | public: | |
93ccaed8 | 28 | // ctors and such |
f8855e47 | 29 | wxFont() { } |
9045ad9d | 30 | |
b960795e VZ |
31 | wxFont(const wxFontInfo& info) |
32 | { | |
33 | Create(info.GetPointSize(), | |
34 | info.GetFamily(), | |
35 | info.GetStyle(), | |
36 | info.GetWeight(), | |
37 | info.IsUnderlined(), | |
38 | info.GetFaceName(), | |
39 | info.GetEncoding()); | |
40 | ||
41 | if ( info.IsUsingSizeInPixels() ) | |
42 | SetPixelSize(info.GetPixelSize()); | |
43 | } | |
44 | ||
0c14b6c3 FM |
45 | wxFont(const wxNativeFontInfo& info); |
46 | ||
47 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
93ccaed8 | 48 | wxFont(int size, |
0c14b6c3 FM |
49 | int family, |
50 | int style, | |
51 | int weight, | |
52 | bool underlined = false, | |
53 | const wxString& face = wxEmptyString, | |
54 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
93ccaed8 | 55 | { |
0c14b6c3 | 56 | (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding); |
93ccaed8 | 57 | } |
0c14b6c3 | 58 | #endif |
9045ad9d | 59 | |
0c14b6c3 FM |
60 | wxFont(int size, |
61 | wxFontFamily family, | |
62 | wxFontStyle style, | |
63 | wxFontWeight weight, | |
64 | bool underlined = false, | |
65 | const wxString& face = wxEmptyString, | |
66 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
67 | { | |
68 | Create(size, family, style, weight, underlined, face, encoding); | |
69 | } | |
03647350 | 70 | |
b5791cc7 FM |
71 | wxFont(const wxSize& pixelSize, |
72 | wxFontFamily family, | |
73 | wxFontStyle style, | |
74 | wxFontWeight weight, | |
75 | bool underlined = false, | |
76 | const wxString& face = wxEmptyString, | |
77 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
78 | { | |
79 | Create(10, family, style, weight, underlined, face, encoding); | |
80 | SetPixelSize(pixelSize); | |
81 | } | |
03647350 | 82 | |
93ccaed8 | 83 | bool Create(int size, |
0c14b6c3 FM |
84 | wxFontFamily family, |
85 | wxFontStyle style, | |
86 | wxFontWeight weight, | |
87 | bool underlined = false, | |
88 | const wxString& face = wxEmptyString, | |
89 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
9045ad9d | 90 | |
563f868d GD |
91 | // wxMOTIF-specific |
92 | bool Create(const wxString& fontname, | |
83df96d6 | 93 | wxFontEncoding fontenc = wxFONTENCODING_DEFAULT); |
563f868d | 94 | bool Create(const wxNativeFontInfo& fontinfo); |
9045ad9d | 95 | |
93ccaed8 | 96 | virtual ~wxFont(); |
9045ad9d | 97 | |
93ccaed8 VZ |
98 | // implement base class pure virtuals |
99 | virtual int GetPointSize() const; | |
0c14b6c3 FM |
100 | virtual wxFontStyle GetStyle() const; |
101 | virtual wxFontWeight GetWeight() const; | |
93ccaed8 VZ |
102 | virtual bool GetUnderlined() const; |
103 | virtual wxString GetFaceName() const; | |
104 | virtual wxFontEncoding GetEncoding() const; | |
3bf5a59b | 105 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; |
9045ad9d | 106 | |
93ccaed8 | 107 | virtual void SetPointSize(int pointSize); |
0c14b6c3 FM |
108 | virtual void SetFamily(wxFontFamily family); |
109 | virtual void SetStyle(wxFontStyle style); | |
110 | virtual void SetWeight(wxFontWeight weight); | |
85ab460e | 111 | virtual bool SetFaceName(const wxString& faceName); |
93ccaed8 VZ |
112 | virtual void SetUnderlined(bool underlined); |
113 | virtual void SetEncoding(wxFontEncoding encoding); | |
9045ad9d | 114 | |
f76c0758 | 115 | wxDECLARE_COMMON_FONT_METHODS(); |
0c14b6c3 | 116 | |
93ccaed8 | 117 | // Implementation |
9045ad9d | 118 | |
93ccaed8 VZ |
119 | // Find an existing, or create a new, XFontStruct |
120 | // based on this wxFont and the given scale. Append the | |
121 | // font to list in the private data for future reference. | |
9045ad9d | 122 | |
93ccaed8 VZ |
123 | // TODO This is a fairly basic implementation, that doesn't |
124 | // allow for different facenames, and also doesn't do a mapping | |
125 | // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.) | |
126 | // and the fonts that are available on a particular system. | |
127 | // Maybe we need to scan the user's machine to build up a profile | |
128 | // of the fonts and a mapping file. | |
9045ad9d | 129 | |
93ccaed8 | 130 | // Return font struct, and optionally the Motif font list |
a2e91a93 | 131 | wxXFont *GetInternalFont(double scale = 1.0, |
83df96d6 | 132 | WXDisplay* display = NULL) const; |
9045ad9d | 133 | |
93ccaed8 | 134 | // These two are helper functions for convenient access of the above. |
eb9d223a | 135 | #if wxMOTIF_USE_RENDER_TABLE |
105fbe1f | 136 | WXFontSet GetFontSet(double scale, WXDisplay* display = NULL) const; |
eb9d223a MB |
137 | WXRenderTable GetRenderTable(WXDisplay* display) const; |
138 | #else // if !wxMOTIF_USE_RENDER_TABLE | |
105fbe1f MB |
139 | WXFontStructPtr GetFontStruct(double scale = 1.0, |
140 | WXDisplay* display = NULL) const; | |
93ccaed8 | 141 | WXFontList GetFontList(double scale = 1.0, |
83df96d6 | 142 | WXDisplay* display = NULL) const; |
105fbe1f | 143 | #endif // !wxMOTIF_USE_RENDER_TABLE |
996994c7 | 144 | // returns either a XmFontList or XmRenderTable, depending |
da494b40 MB |
145 | // on Motif version |
146 | WXFontType GetFontType(WXDisplay* display) const; | |
73608949 MB |
147 | // like the function above but does a copy for XmFontList |
148 | WXFontType GetFontTypeC(WXDisplay* display) const; | |
da494b40 | 149 | static WXString GetFontTag(); |
8f884a0d | 150 | |
9b6dbb09 | 151 | protected: |
8f884a0d VZ |
152 | virtual wxGDIRefData *CreateGDIRefData() const; |
153 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
154 | ||
9045ad9d | 155 | virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info ); |
59b7da02 | 156 | virtual wxFontFamily DoGetFamily() const; |
9045ad9d | 157 | |
93ccaed8 | 158 | void Unshare(); |
9045ad9d | 159 | |
93ccaed8 VZ |
160 | private: |
161 | DECLARE_DYNAMIC_CLASS(wxFont) | |
9b6dbb09 JS |
162 | }; |
163 | ||
8f884a0d | 164 | #endif // _WX_FONT_H_ |