]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fontutil.h
removed mark #pragmas
[wxWidgets.git] / include / wx / fontutil.h
CommitLineData
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
371a5b4e 9// Licence: wxWindows licence
7beba2fc
VZ
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
12028905 19#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
7beba2fc
VZ
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
e4ffab29
MB
34struct WXDLLEXPORT wxNativeEncodingInfo;
35
53f6aab7
VZ
36#if defined(_WX_X_FONTLIKE)
37
38// the symbolic names for the XLFD fields (with examples for their value)
409d5a58
VZ
39//
40// NB: we suppose that the font always starts with the empty token (font name
41// registry field) as we never use nor generate it anyhow
53f6aab7
VZ
42enum wxXLFDField
43{
44 wxXLFD_FOUNDRY, // adobe
45 wxXLFD_FAMILY, // courier, times, ...
46 wxXLFD_WEIGHT, // black, bold, demibold, medium, regular, light
47 wxXLFD_SLANT, // r/i/o (roman/italique/oblique)
48 wxXLFD_SETWIDTH, // condensed, expanded, ...
49 wxXLFD_ADDSTYLE, // whatever - usually nothing
50 wxXLFD_PIXELSIZE, // size in pixels
51 wxXLFD_POINTSIZE, // size in points
52 wxXLFD_RESX, // 72, 75, 100, ...
53 wxXLFD_RESY,
54 wxXLFD_SPACING, // m/p/c (monospaced/proportional/character cell)
55 wxXLFD_AVGWIDTH, // average width in 1/10 pixels
56 wxXLFD_REGISTRY, // iso8859, rawin, koi8, ...
57 wxXLFD_ENCODING, // 1, r, r, ...
58 wxXLFD_MAX
59};
60
61#endif // _WX_X_FONTLIKE
62
7beba2fc
VZ
63// ----------------------------------------------------------------------------
64// types
65// ----------------------------------------------------------------------------
66
7826e2dd
VZ
67// wxNativeFontInfo is platform-specific font representation: this struct
68// should be considered as opaque font description only used by the native
69// functions, the user code can only get the objects of this type from
70// somewhere and pass it somewhere else (possibly save them somewhere using
71// ToString() and restore them using FromString())
ab5fe833
VZ
72//
73// NB: it is a POD currently for max efficiency but if it continues to grow
74// further it might make sense to make it a real class with virtual methods
7826e2dd 75struct WXDLLEXPORT wxNativeFontInfo
7beba2fc 76{
2b5f62a0
VZ
77#if wxUSE_PANGO
78 PangoFontDescription *description;
79#elif defined(_WX_X_FONTLIKE)
409d5a58
VZ
80 // the members can't be accessed directly as we only parse the
81 // xFontName on demand
53f6aab7 82private:
ab5fe833 83 // the components of the XLFD
53f6aab7 84 wxString fontElements[wxXLFD_MAX];
ab5fe833
VZ
85
86 // the full XLFD
7826e2dd 87 wxString xFontName;
ab5fe833 88
409d5a58
VZ
89 // true until SetXFontName() is called
90 bool m_isDefault;
91
92 // return true if we have already initialized fontElements
93 inline bool HasElements() const;
94
95public:
ab5fe833
VZ
96 // init the elements from an XLFD, return TRUE if ok
97 bool FromXFontName(const wxString& xFontName);
98
409d5a58
VZ
99 // return false if we were never initialized with a valid XLFD
100 bool IsDefault() const { return m_isDefault; }
101
102 // return the XLFD (using the fontElements if necessary)
ab5fe833 103 wxString GetXFontName() const;
53f6aab7
VZ
104
105 // get the given XFLD component
106 wxString GetXFontComponent(wxXLFDField field) const;
409d5a58
VZ
107
108 // change the font component
109 void SetXFontComponent(wxXLFDField field, const wxString& value);
110
111 // set the XFLD
112 void SetXFontName(const wxString& xFontName);
09fcd889
VZ
113#elif defined(__WXMSW__)
114 LOGFONT lf;
cc95f4f9
DW
115#elif defined(__WXPM__)
116 // OS/2 native structures that define a font
117 FATTRS fa;
118 FONTMETRICS fm;
119 FACENAMEDESC fn;
7826e2dd
VZ
120#else // other platforms
121 //
122 // This is a generic implementation that should work on all ports
123 // without specific support by the port.
124 //
ef243e70 125 #define wxNO_NATIVE_FONTINFO
ab5fe833 126
7826e2dd 127 int pointSize;
7936354d 128 wxFontFamily family;
ab5fe833
VZ
129 wxFontStyle style;
130 wxFontWeight weight;
7826e2dd
VZ
131 bool underlined;
132 wxString faceName;
133 wxFontEncoding encoding;
134#endif // platforms
135
ab5fe833
VZ
136 // default ctor (default copy ctor is ok)
137 wxNativeFontInfo() { Init(); }
138
139 // reset to the default state
140 void Init();
141
7936354d 142 // accessors and modifiers for the font elements
ab5fe833
VZ
143 int GetPointSize() const;
144 wxFontStyle GetStyle() const;
145 wxFontWeight GetWeight() const;
146 bool GetUnderlined() const;
147 wxString GetFaceName() const;
7936354d 148 wxFontFamily GetFamily() const;
ab5fe833
VZ
149 wxFontEncoding GetEncoding() const;
150
151 void SetPointSize(int pointsize);
152 void SetStyle(wxFontStyle style);
153 void SetWeight(wxFontWeight weight);
154 void SetUnderlined(bool underlined);
155 void SetFaceName(wxString facename);
7936354d 156 void SetFamily(wxFontFamily family);
ab5fe833
VZ
157 void SetEncoding(wxFontEncoding encoding);
158
7826e2dd
VZ
159 // it is important to be able to serialize wxNativeFontInfo objects to be
160 // able to store them (in config file, for example)
7beba2fc
VZ
161 bool FromString(const wxString& s);
162 wxString ToString() const;
ab5fe833
VZ
163
164 // we also want to present the native font descriptions to the user in some
165 // human-readable form (it is not platform independent neither, but can
166 // hopefully be understood by the user)
167 bool FromUserString(const wxString& s);
168 wxString ToUserString() const;
7beba2fc
VZ
169};
170
171// ----------------------------------------------------------------------------
172// font-related functions (common)
173// ----------------------------------------------------------------------------
174
175// translate a wxFontEncoding into native encoding parameter (defined above),
176// returning TRUE if an (exact) macth could be found, FALSE otherwise (without
177// attempting any substitutions)
178extern bool wxGetNativeFontEncoding(wxFontEncoding encoding,
179 wxNativeEncodingInfo *info);
180
181// test for the existence of the font described by this facename/encoding,
182// return TRUE if such font(s) exist, FALSE otherwise
183extern bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
184
185// ----------------------------------------------------------------------------
186// font-related functions (X and GTK)
187// ----------------------------------------------------------------------------
188
189#ifdef _WX_X_FONTLIKE
190 #include "wx/unix/fontutil.h"
191#endif // X || GDK
192
1e6feb95
VZ
193// ----------------------------------------------------------------------------
194// font-related functions (MGL)
195// ----------------------------------------------------------------------------
196
197#ifdef __WXMGL__
198 #include "wx/mgl/fontutil.h"
199#endif // __WXMGL__
200
7beba2fc 201#endif // _WX_FONTUTIL_H_