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