]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/font.h
Add conversions to/from long long to wxUniChar.
[wxWidgets.git] / include / wx / motif / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/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 #if __WXMOTIF20__ && !__WXLESSTIF__
16 #define wxMOTIF_USE_RENDER_TABLE 1
17 #else
18 #define wxMOTIF_USE_RENDER_TABLE 0
19 #endif
20 #define wxMOTIF_NEW_FONT_HANDLING wxMOTIF_USE_RENDER_TABLE
21
22 class wxXFont;
23
24 // Font
25 class WXDLLIMPEXP_CORE wxFont : public wxFontBase
26 {
27 public:
28 // ctors and such
29 wxFont() { }
30
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
45 wxFont(const wxNativeFontInfo& info);
46
47 #if FUTURE_WXWIN_COMPATIBILITY_3_0
48 wxFont(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 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
57 }
58 #endif
59
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 }
70
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 }
82
83 bool Create(int size,
84 wxFontFamily family,
85 wxFontStyle style,
86 wxFontWeight weight,
87 bool underlined = false,
88 const wxString& face = wxEmptyString,
89 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
90
91 // wxMOTIF-specific
92 bool Create(const wxString& fontname,
93 wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
94 bool Create(const wxNativeFontInfo& fontinfo);
95
96 virtual ~wxFont();
97
98 // implement base class pure virtuals
99 virtual int GetPointSize() const;
100 virtual wxFontStyle GetStyle() const;
101 virtual wxFontWeight GetWeight() const;
102 virtual bool GetUnderlined() const;
103 virtual wxString GetFaceName() const;
104 virtual wxFontEncoding GetEncoding() const;
105 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
106
107 virtual void SetPointSize(int pointSize);
108 virtual void SetFamily(wxFontFamily family);
109 virtual void SetStyle(wxFontStyle style);
110 virtual void SetWeight(wxFontWeight weight);
111 virtual bool SetFaceName(const wxString& faceName);
112 virtual void SetUnderlined(bool underlined);
113 virtual void SetEncoding(wxFontEncoding encoding);
114
115 wxDECLARE_COMMON_FONT_METHODS();
116
117 // Implementation
118
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.
122
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.
129
130 // Return font struct, and optionally the Motif font list
131 wxXFont *GetInternalFont(double scale = 1.0,
132 WXDisplay* display = NULL) const;
133
134 // These two are helper functions for convenient access of the above.
135 #if wxMOTIF_USE_RENDER_TABLE
136 WXFontSet GetFontSet(double scale, WXDisplay* display = NULL) const;
137 WXRenderTable GetRenderTable(WXDisplay* display) const;
138 #else // if !wxMOTIF_USE_RENDER_TABLE
139 WXFontStructPtr GetFontStruct(double scale = 1.0,
140 WXDisplay* display = NULL) const;
141 WXFontList GetFontList(double scale = 1.0,
142 WXDisplay* display = NULL) const;
143 #endif // !wxMOTIF_USE_RENDER_TABLE
144 // returns either a XmFontList or XmRenderTable, depending
145 // on Motif version
146 WXFontType GetFontType(WXDisplay* display) const;
147 // like the function above but does a copy for XmFontList
148 WXFontType GetFontTypeC(WXDisplay* display) const;
149 static WXString GetFontTag();
150
151 protected:
152 virtual wxGDIRefData *CreateGDIRefData() const;
153 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
154
155 virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
156 virtual wxFontFamily DoGetFamily() const;
157
158 void Unshare();
159
160 private:
161 DECLARE_DYNAMIC_CLASS(wxFont)
162 };
163
164 #endif // _WX_FONT_H_