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