]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fontmap.h
Made geometry classes link.
[wxWidgets.git] / include / wx / fontmap.h
CommitLineData
3c1866e8
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/fontmap.h
3// Purpose: wxFontMapper class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 04.11.99
7// RCS-ID: $Id$
8// Copyright: (c) Vadim Zeitlin
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_FONTMAPPER_H_
13#define _WX_FONTMAPPER_H_
14
15#ifdef __GNUG__
16 #pragma interface "fontmap.h"
17#endif
18
19// ----------------------------------------------------------------------------
20// headers
21// ----------------------------------------------------------------------------
22
f6bcfd97
BP
23#include "wx/fontenc.h" // for wxFontEncoding
24#if wxUSE_GUI
25 #include "wx/fontutil.h" // for wxNativeEncodingInfo
26#endif // wxUSE_GUI
3c1866e8 27
f6bcfd97
BP
28#if wxUSE_CONFIG
29 class WXDLLEXPORT wxConfigBase;
30#endif // wxUSE_CONFIG
31
32#if wxUSE_GUI
33 class WXDLLEXPORT wxWindow;
34#endif // wxUSE_GUI
3c1866e8
VZ
35
36// ----------------------------------------------------------------------------
37// wxFontMapper manages user-definable correspondence between logical font
38// names and the fonts present on the machine.
39//
40// The default implementations of all functions will ask the user if they are
41// not capable of finding the answer themselves and store the answer in a
42// config file (configurable via SetConfigXXX functions). This behaviour may
43// be disabled by giving the value of FALSE to "interactive" parameter.
44// However, the functions will always consult the config file to allow the
45// user-defined values override the default logic and there is no way to
46// disable this - which shouldn't be ever needed because if "interactive" was
47// never TRUE, the config file is never created anyhow.
48// ----------------------------------------------------------------------------
49
50class WXDLLEXPORT wxFontMapper
51{
52public:
53 // default ctor
54 wxFontMapper();
55
56 // virtual dtor for a base class
57 virtual ~wxFontMapper();
58
f6bcfd97 59#if wxUSE_GUI
7beba2fc
VZ
60 // find an alternative for the given encoding (which is supposed to not be
61 // available on this system). If successful, return TRUE and fill info
62 // structure with the parameters required to create the font, otherwise
63 // return FALSE
64 virtual bool GetAltForEncoding(wxFontEncoding encoding,
65 wxNativeEncodingInfo *info,
6648cd46 66 const wxString& facename = wxEmptyString,
7beba2fc
VZ
67 bool interactive = TRUE);
68
6648cd46
VS
69 // version better suitable for 'public' use. Returns wxFontEcoding
70 // that can be used it wxFont ctor
71 bool GetAltForEncoding(wxFontEncoding encoding,
72 wxFontEncoding *alt_encoding,
73 const wxString& facename = wxEmptyString,
74 bool interactive = TRUE);
75
76 // checks whether given encoding is available in given face or not.
77 // If no facename is given,
78 virtual bool IsEncodingAvailable(wxFontEncoding encoding,
79 const wxString& facename = wxEmptyString);
f6bcfd97 80#endif // wxUSE_GUI
6648cd46 81
3c1866e8
VZ
82 // returns the encoding for the given charset (in the form of RFC 2046) or
83 // wxFONTENCODING_SYSTEM if couldn't decode it
84 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
85 bool interactive = TRUE);
86
7beba2fc
VZ
87 // encoding names
88 // --------------
89
90 // return internal string identifier for the encoding (see also
91 // GetEncodingDescription())
92 static wxString GetEncodingName(wxFontEncoding encoding);
93
94 // return user-readable string describing the given encoding
95 //
96 // NB: hard-coded now, but might change later (read it from config?)
97 static wxString GetEncodingDescription(wxFontEncoding encoding);
98
3c1866e8
VZ
99 // configure the appearance of the dialogs we may popup
100 // ----------------------------------------------------
101
f6bcfd97 102#if wxUSE_GUI
7beba2fc
VZ
103 // the parent window for modal dialogs
104 void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
105
106 // the title for the dialogs (note that default is quite reasonable)
3c1866e8 107 void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
f6bcfd97 108#endif // wxUSE_GUI
3c1866e8
VZ
109
110 // functions which allow to configure the config object used: by default,
111 // the global one (from wxConfigBase::Get() will be used) and the default
112 // root path for the config settings is the string returned by
113 // GetDefaultConfigPath()
114 // ----------------------------------------------------------------------
115
f6bcfd97 116#if wxUSE_CONFIG
3c1866e8
VZ
117 // set the config object to use (may be NULL to use default)
118 void SetConfig(wxConfigBase *config) { m_config = config; }
119
120 // set the root config path to use (should be an absolute path)
121 void SetConfigPath(const wxString& prefix);
122
123 // return default config path
124 static const wxChar *GetDefaultConfigPath();
f6bcfd97 125#endif
3c1866e8
VZ
126
127protected:
f6bcfd97
BP
128
129#if wxUSE_CONFIG
3c1866e8
VZ
130 // get the config object we're using - if it wasn't set explicitly, this
131 // function will use wxConfig::Get() to get the global one
132 wxConfigBase *GetConfig();
133
134 // gets the root path for our settings - if itwasn't set explicitly, use
135 // GetDefaultConfigPath()
136 const wxString& GetConfigPath();
f6bcfd97 137#endif
3c1866e8
VZ
138
139 // change to the given (relative) path in the config, return TRUE if ok
140 // (then GetConfig() will return something !NULL), FALSE if no config
141 // object
142 //
143 // caller should provide a pointer to the string variable which should be
144 // later passed to RestorePath()
145 bool ChangePath(const wxString& pathNew, wxString *pathOld);
146
147 // restore the config path after use
148 void RestorePath(const wxString& pathOld);
149
f6bcfd97 150#if wxUSE_GUI
7beba2fc
VZ
151 // GetAltForEncoding() helper: tests for the existence of the given
152 // encoding and saves the result in config if ok - this results in the
153 // following (desired) behaviour: when an unknown/unavailable encoding is
154 // requested for the first time, the user is asked about a replacement,
155 // but if he doesn't choose any and the default logic finds one, it will
156 // be saved in the config so that the user won't be asked about it any
157 // more
158 bool TestAltEncoding(const wxString& configEntry,
159 wxFontEncoding encReplacement,
160 wxNativeEncodingInfo *info);
f6bcfd97 161#endif // wxUSE_GUI
7beba2fc 162
f6bcfd97 163#if wxUSE_CONFIG
3c1866e8
VZ
164 // config object and path (in it) to use
165 wxConfigBase *m_config;
f6bcfd97
BP
166#endif
167
3c1866e8
VZ
168 wxString m_configRootPath;
169
f6bcfd97 170#if wxUSE_GUI
3c1866e8
VZ
171 // the title for our dialogs
172 wxString m_titleDialog;
173
174 // the parent window for our dialogs
175 wxWindow *m_windowParent;
f6bcfd97 176#endif // wxUSE_GUI
7beba2fc
VZ
177
178 friend class wxFontMapperPathChanger;
3c1866e8
VZ
179};
180
7beba2fc
VZ
181// ----------------------------------------------------------------------------
182// global variables
183// ----------------------------------------------------------------------------
184
185// the default font mapper for wxWindows programs
186WXDLLEXPORT_DATA(extern wxFontMapper *) wxTheFontMapper;
187
3c1866e8 188#endif // _WX_FONTMAPPER_H_