]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/font.h
change grow box implementation - was incorrectly getting the focus in panels before
[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 wxNativeFontInfo& info);
32
33 #if FUTURE_WXWIN_COMPATIBILITY_3_0
34 wxFont(int size,
35 int family,
36 int style,
37 int weight,
38 bool underlined = false,
39 const wxString& face = wxEmptyString,
40 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
41 {
42 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
43 }
44 #endif
45
46 wxFont(int size,
47 wxFontFamily family,
48 wxFontStyle style,
49 wxFontWeight weight,
50 bool underlined = false,
51 const wxString& face = wxEmptyString,
52 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
53 {
54 Create(size, family, style, weight, underlined, face, encoding);
55 }
56
57 wxFont(const wxSize& pixelSize,
58 wxFontFamily family,
59 wxFontStyle style,
60 wxFontWeight weight,
61 bool underlined = false,
62 const wxString& face = wxEmptyString,
63 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
64 {
65 Create(10, family, style, weight, underlined, face, encoding);
66 SetPixelSize(pixelSize);
67 }
68
69 bool Create(int size,
70 wxFontFamily family,
71 wxFontStyle style,
72 wxFontWeight weight,
73 bool underlined = false,
74 const wxString& face = wxEmptyString,
75 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
76
77 // wxMOTIF-specific
78 bool Create(const wxString& fontname,
79 wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
80 bool Create(const wxNativeFontInfo& fontinfo);
81
82 virtual ~wxFont();
83
84 // implement base class pure virtuals
85 virtual int GetPointSize() const;
86 virtual wxFontFamily GetFamily() const;
87 virtual wxFontStyle GetStyle() const;
88 virtual wxFontWeight GetWeight() const;
89 virtual bool GetUnderlined() const;
90 virtual wxString GetFaceName() const;
91 virtual wxFontEncoding GetEncoding() const;
92 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
93
94 virtual void SetPointSize(int pointSize);
95 virtual void SetFamily(wxFontFamily family);
96 virtual void SetStyle(wxFontStyle style);
97 virtual void SetWeight(wxFontWeight weight);
98 virtual bool SetFaceName(const wxString& faceName);
99 virtual void SetUnderlined(bool underlined);
100 virtual void SetEncoding(wxFontEncoding encoding);
101
102 wxDECLARE_COMMON_FONT_METHODS();
103
104 // Implementation
105
106 // Find an existing, or create a new, XFontStruct
107 // based on this wxFont and the given scale. Append the
108 // font to list in the private data for future reference.
109
110 // TODO This is a fairly basic implementation, that doesn't
111 // allow for different facenames, and also doesn't do a mapping
112 // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
113 // and the fonts that are available on a particular system.
114 // Maybe we need to scan the user's machine to build up a profile
115 // of the fonts and a mapping file.
116
117 // Return font struct, and optionally the Motif font list
118 wxXFont *GetInternalFont(double scale = 1.0,
119 WXDisplay* display = NULL) const;
120
121 // These two are helper functions for convenient access of the above.
122 #if wxMOTIF_USE_RENDER_TABLE
123 WXFontSet GetFontSet(double scale, WXDisplay* display = NULL) const;
124 WXRenderTable GetRenderTable(WXDisplay* display) const;
125 #else // if !wxMOTIF_USE_RENDER_TABLE
126 WXFontStructPtr GetFontStruct(double scale = 1.0,
127 WXDisplay* display = NULL) const;
128 WXFontList GetFontList(double scale = 1.0,
129 WXDisplay* display = NULL) const;
130 #endif // !wxMOTIF_USE_RENDER_TABLE
131 // returns either a XmFontList or XmRenderTable, depending
132 // on Motif version
133 WXFontType GetFontType(WXDisplay* display) const;
134 // like the function above but does a copy for XmFontList
135 WXFontType GetFontTypeC(WXDisplay* display) const;
136 static WXString GetFontTag();
137
138 protected:
139 virtual wxGDIRefData *CreateGDIRefData() const;
140 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
141
142 virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
143
144 void Unshare();
145
146 private:
147 DECLARE_DYNAMIC_CLASS(wxFont)
148 };
149
150 #endif // _WX_FONT_H_