]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fontutil.h
compilation fixes for !wxUSE_STREAMS
[wxWidgets.git] / include / wx / fontutil.h
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
29 #if defined(__WXMSW__)
30 #include <windows.h>
31 #include "wx/msw/winundef.h"
32 #endif
33
34 // ----------------------------------------------------------------------------
35 // types
36 // ----------------------------------------------------------------------------
37
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())
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
46 struct WXDLLEXPORT wxNativeFontInfo
47 {
48 #if defined(__WXGTK__) // || defined(__WXMOTIF__)
49 // TODO: wxMotif should use this too but motif/font.cpp
50 // must be updated for this!
51 // the components of the XLFD
52 wxString fontElements[14];
53
54 // the full XLFD
55 wxString xFontName;
56
57 // init the elements from an XLFD, return TRUE if ok
58 bool FromXFontName(const wxString& xFontName);
59
60 // generate an XLFD using the fontElements
61 wxString GetXFontName() const;
62 #elif defined(__WXMSW__)
63 LOGFONT lf;
64 #else // other platforms
65 //
66 // This is a generic implementation that should work on all ports
67 // without specific support by the port.
68 //
69 #define wxNO_NATIVE_FONTINFO
70
71 int pointSize;
72 wxFontFamily family;
73 wxFontStyle style;
74 wxFontWeight weight;
75 bool underlined;
76 wxString faceName;
77 wxFontEncoding encoding;
78 #endif // platforms
79
80 // default ctor (default copy ctor is ok)
81 wxNativeFontInfo() { Init(); }
82
83 // reset to the default state
84 void Init();
85
86 // accessors and modifiers for the font elements
87 int GetPointSize() const;
88 wxFontStyle GetStyle() const;
89 wxFontWeight GetWeight() const;
90 bool GetUnderlined() const;
91 wxString GetFaceName() const;
92 wxFontFamily GetFamily() const;
93 wxFontEncoding GetEncoding() const;
94
95 void SetPointSize(int pointsize);
96 void SetStyle(wxFontStyle style);
97 void SetWeight(wxFontWeight weight);
98 void SetUnderlined(bool underlined);
99 void SetFaceName(wxString facename);
100 void SetFamily(wxFontFamily family);
101 void SetEncoding(wxFontEncoding encoding);
102
103 // it is important to be able to serialize wxNativeFontInfo objects to be
104 // able to store them (in config file, for example)
105 bool FromString(const wxString& s);
106 wxString ToString() const;
107
108 // we also want to present the native font descriptions to the user in some
109 // human-readable form (it is not platform independent neither, but can
110 // hopefully be understood by the user)
111 bool FromUserString(const wxString& s);
112 wxString ToUserString() const;
113 };
114
115 // ----------------------------------------------------------------------------
116 // font-related functions (common)
117 // ----------------------------------------------------------------------------
118
119 // translate a wxFontEncoding into native encoding parameter (defined above),
120 // returning TRUE if an (exact) macth could be found, FALSE otherwise (without
121 // attempting any substitutions)
122 extern bool wxGetNativeFontEncoding(wxFontEncoding encoding,
123 wxNativeEncodingInfo *info);
124
125 // test for the existence of the font described by this facename/encoding,
126 // return TRUE if such font(s) exist, FALSE otherwise
127 extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
128
129 // ----------------------------------------------------------------------------
130 // font-related functions (X and GTK)
131 // ----------------------------------------------------------------------------
132
133 #ifdef _WX_X_FONTLIKE
134 #include "wx/unix/fontutil.h"
135 #endif // X || GDK
136
137 // ----------------------------------------------------------------------------
138 // font-related functions (MGL)
139 // ----------------------------------------------------------------------------
140
141 #ifdef __WXMGL__
142 #include "wx/mgl/fontutil.h"
143 #endif // __WXMGL__
144
145 #endif // _WX_FONTUTIL_H_