]>
Commit | Line | Data |
---|---|---|
7beba2fc VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/fontutil.h | |
3 | // Purpose: font-related helper functions | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 05.11.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // General note: this header is private to wxWindows and is not supposed to be | |
13 | // included by user code. The functions declared here are implemented in | |
14 | // msw/fontutil.cpp for Windows, unix/fontutil.cpp for GTK/Motif &c. | |
15 | ||
16 | #ifndef _WX_FONTUTIL_H_ | |
17 | #define _WX_FONTUTIL_H_ | |
18 | ||
19 | #ifdef __GNUG__ | |
20 | #pragma interface "fontutil.h" | |
21 | #endif | |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // headers | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | #include "wx/font.h" // for wxFont and wxFontEncoding | |
28 | ||
09fcd889 | 29 | #if defined(__WXMSW__) |
ab5fe833 VZ |
30 | #include <windows.h> |
31 | #include "wx/msw/winundef.h" | |
09fcd889 VZ |
32 | #endif |
33 | ||
7beba2fc VZ |
34 | // ---------------------------------------------------------------------------- |
35 | // types | |
36 | // ---------------------------------------------------------------------------- | |
37 | ||
7826e2dd VZ |
38 | // wxNativeFontInfo is platform-specific font representation: this struct |
39 | // should be considered as opaque font description only used by the native | |
40 | // functions, the user code can only get the objects of this type from | |
41 | // somewhere and pass it somewhere else (possibly save them somewhere using | |
42 | // ToString() and restore them using FromString()) | |
ab5fe833 VZ |
43 | // |
44 | // NB: it is a POD currently for max efficiency but if it continues to grow | |
45 | // further it might make sense to make it a real class with virtual methods | |
7826e2dd | 46 | struct WXDLLEXPORT wxNativeFontInfo |
7beba2fc | 47 | { |
563f868d | 48 | #if defined(__WXGTK__) || defined(__WXMOTIF__) |
ab5fe833 VZ |
49 | // the components of the XLFD |
50 | wxString fontElements[14]; | |
51 | ||
52 | // the full XLFD | |
7826e2dd | 53 | wxString xFontName; |
ab5fe833 VZ |
54 | |
55 | // init the elements from an XLFD, return TRUE if ok | |
56 | bool FromXFontName(const wxString& xFontName); | |
57 | ||
58 | // generate an XLFD using the fontElements | |
59 | wxString GetXFontName() const; | |
09fcd889 VZ |
60 | #elif defined(__WXMSW__) |
61 | LOGFONT lf; | |
cc95f4f9 DW |
62 | #elif defined(__WXPM__) |
63 | // OS/2 native structures that define a font | |
64 | FATTRS fa; | |
65 | FONTMETRICS fm; | |
66 | FACENAMEDESC fn; | |
7826e2dd VZ |
67 | #else // other platforms |
68 | // | |
69 | // This is a generic implementation that should work on all ports | |
70 | // without specific support by the port. | |
71 | // | |
ef243e70 | 72 | #define wxNO_NATIVE_FONTINFO |
ab5fe833 | 73 | |
7826e2dd | 74 | int pointSize; |
7936354d | 75 | wxFontFamily family; |
ab5fe833 VZ |
76 | wxFontStyle style; |
77 | wxFontWeight weight; | |
7826e2dd VZ |
78 | bool underlined; |
79 | wxString faceName; | |
80 | wxFontEncoding encoding; | |
81 | #endif // platforms | |
82 | ||
ab5fe833 VZ |
83 | // default ctor (default copy ctor is ok) |
84 | wxNativeFontInfo() { Init(); } | |
85 | ||
86 | // reset to the default state | |
87 | void Init(); | |
88 | ||
7936354d | 89 | // accessors and modifiers for the font elements |
ab5fe833 VZ |
90 | int GetPointSize() const; |
91 | wxFontStyle GetStyle() const; | |
92 | wxFontWeight GetWeight() const; | |
93 | bool GetUnderlined() const; | |
94 | wxString GetFaceName() const; | |
7936354d | 95 | wxFontFamily GetFamily() const; |
ab5fe833 VZ |
96 | wxFontEncoding GetEncoding() const; |
97 | ||
98 | void SetPointSize(int pointsize); | |
99 | void SetStyle(wxFontStyle style); | |
100 | void SetWeight(wxFontWeight weight); | |
101 | void SetUnderlined(bool underlined); | |
102 | void SetFaceName(wxString facename); | |
7936354d | 103 | void SetFamily(wxFontFamily family); |
ab5fe833 VZ |
104 | void SetEncoding(wxFontEncoding encoding); |
105 | ||
7826e2dd VZ |
106 | // it is important to be able to serialize wxNativeFontInfo objects to be |
107 | // able to store them (in config file, for example) | |
7beba2fc VZ |
108 | bool FromString(const wxString& s); |
109 | wxString ToString() const; | |
ab5fe833 VZ |
110 | |
111 | // we also want to present the native font descriptions to the user in some | |
112 | // human-readable form (it is not platform independent neither, but can | |
113 | // hopefully be understood by the user) | |
114 | bool FromUserString(const wxString& s); | |
115 | wxString ToUserString() const; | |
7beba2fc VZ |
116 | }; |
117 | ||
118 | // ---------------------------------------------------------------------------- | |
119 | // font-related functions (common) | |
120 | // ---------------------------------------------------------------------------- | |
121 | ||
122 | // translate a wxFontEncoding into native encoding parameter (defined above), | |
123 | // returning TRUE if an (exact) macth could be found, FALSE otherwise (without | |
124 | // attempting any substitutions) | |
125 | extern bool wxGetNativeFontEncoding(wxFontEncoding encoding, | |
126 | wxNativeEncodingInfo *info); | |
127 | ||
128 | // test for the existence of the font described by this facename/encoding, | |
129 | // return TRUE if such font(s) exist, FALSE otherwise | |
130 | extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info); | |
131 | ||
132 | // ---------------------------------------------------------------------------- | |
133 | // font-related functions (X and GTK) | |
134 | // ---------------------------------------------------------------------------- | |
135 | ||
136 | #ifdef _WX_X_FONTLIKE | |
137 | #include "wx/unix/fontutil.h" | |
138 | #endif // X || GDK | |
139 | ||
1e6feb95 VZ |
140 | // ---------------------------------------------------------------------------- |
141 | // font-related functions (MGL) | |
142 | // ---------------------------------------------------------------------------- | |
143 | ||
144 | #ifdef __WXMGL__ | |
145 | #include "wx/mgl/fontutil.h" | |
146 | #endif // __WXMGL__ | |
147 | ||
7beba2fc | 148 | #endif // _WX_FONTUTIL_H_ |