]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/font.h
Applied rowspan patch #15276 (dghart)
[wxWidgets.git] / include / wx / x11 / font.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/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 class wxXFont;
16
17 // Font
18 class WXDLLIMPEXP_CORE wxFont : public wxFontBase
19 {
20 public:
21 // ctors and such
22 wxFont() { }
23
24 wxFont(const wxFontInfo& info)
25 {
26 Create(info.GetPointSize(),
27 info.GetFamily(),
28 info.GetStyle(),
29 info.GetWeight(),
30 info.IsUnderlined(),
31 info.GetFaceName(),
32 info.GetEncoding());
33
34 if ( info.IsUsingSizeInPixels() )
35 SetPixelSize(info.GetPixelSize());
36 }
37
38 #if FUTURE_WXWIN_COMPATIBILITY_3_0
39 wxFont(int size,
40 int family,
41 int style,
42 int weight,
43 bool underlined = false,
44 const wxString& face = wxEmptyString,
45 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
46 {
47 (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
48 }
49 #endif
50
51 wxFont(int size,
52 wxFontFamily family,
53 wxFontStyle style,
54 wxFontWeight weight,
55 bool underlined = false,
56 const wxString& face = wxEmptyString,
57 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
58 {
59 Create(size, family, style, weight, underlined, face, encoding);
60 }
61
62 wxFont(const wxSize& pixelSize,
63 wxFontFamily family,
64 wxFontStyle style,
65 wxFontWeight weight,
66 bool underlined = false,
67 const wxString& face = wxEmptyString,
68 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
69 {
70 Create(10, family, style, weight, underlined, face, encoding);
71 SetPixelSize(pixelSize);
72 }
73
74 bool Create(int size,
75 wxFontFamily family,
76 wxFontStyle style,
77 wxFontWeight weight,
78 bool underlined = false,
79 const wxString& face = wxEmptyString,
80 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
81
82 wxFont(const wxNativeFontInfo& info);
83
84 // FIXME: I added the ! to make it compile;
85 // is this right? - JACS
86 #if !wxUSE_UNICODE
87 bool Create(const wxString& fontname,
88 wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
89 #endif
90 // DELETEME: no longer seems to be implemented.
91 // bool Create(const wxNativeFontInfo& fontinfo);
92
93 virtual ~wxFont();
94
95 // implement base class pure virtuals
96 virtual int GetPointSize() const;
97 virtual wxFontStyle GetStyle() const;
98 virtual wxFontWeight GetWeight() const;
99 virtual bool GetUnderlined() const;
100 virtual wxString GetFaceName() const;
101 virtual wxFontEncoding GetEncoding() const;
102 virtual const wxNativeFontInfo *GetNativeFontInfo() const;
103
104 virtual bool IsFixedWidth() const;
105
106 virtual void SetPointSize(int pointSize);
107 virtual void SetFamily(wxFontFamily family);
108 virtual void SetStyle(wxFontStyle style);
109 virtual void SetWeight(wxFontWeight weight);
110 virtual bool SetFaceName(const wxString& faceName);
111 virtual void SetUnderlined(bool underlined);
112 virtual void SetEncoding(wxFontEncoding encoding);
113
114 wxDECLARE_COMMON_FONT_METHODS();
115
116 // Implementation
117
118 #if wxUSE_PANGO
119 #else
120 // Find an existing, or create a new, XFontStruct
121 // based on this wxFont and the given scale. Append the
122 // font to list in the private data for future reference.
123
124 // TODO This is a fairly basic implementation, that doesn't
125 // allow for different facenames, and also doesn't do a mapping
126 // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
127 // and the fonts that are available on a particular system.
128 // Maybe we need to scan the user's machine to build up a profile
129 // of the fonts and a mapping file.
130
131 // Return font struct, and optionally the Motif font list
132 wxXFont *GetInternalFont(double scale = 1.0,
133 WXDisplay* display = NULL) const;
134
135 // Helper function for convenient access of the above.
136 WXFontStructPtr GetFontStruct(double scale = 1.0,
137 WXDisplay* display = NULL) const;
138 #endif
139
140 protected:
141 virtual wxGDIRefData *CreateGDIRefData() const;
142 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
143
144 virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
145 virtual wxFontFamily DoGetFamily() const;
146
147 void Unshare();
148
149 private:
150 DECLARE_DYNAMIC_CLASS(wxFont)
151 };
152
153 #endif
154 // _WX_FONT_H_