]> git.saurik.com Git - wxWidgets.git/blob - interface/fontmap.h
f3591f369fcfae0bb1f04de7a1d919bd94230a7a
[wxWidgets.git] / interface / fontmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontmap.h
3 // Purpose: documentation for wxFontMapper class
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxFontMapper
11 @wxheader{fontmap.h}
12
13 wxFontMapper manages user-definable correspondence between logical font
14 names and the fonts present on the machine.
15
16 The default implementations of all functions will ask the user if they are
17 not capable of finding the answer themselves and store the answer in a
18 config file (configurable via SetConfigXXX functions). This behaviour may
19 be disabled by giving the value of @false to "interactive" parameter.
20
21 However, the functions will always consult the config file to allow the
22 user-defined values override the default logic and there is no way to
23 disable this - which shouldn't be ever needed because if "interactive" was
24 never @true, the config file is never created anyhow.
25
26 In case everything else fails (i.e. there is no record in config file
27 and "interactive" is @false or user denied to choose any replacement),
28 the class queries wxEncodingConverter
29 for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them.
30
31 @library{wxcore}
32 @category{misc}
33
34 @seealso
35 wxEncodingConverter, @ref overview_nonenglishoverview "Writing non-English
36 applications"
37 */
38 class wxFontMapper
39 {
40 public:
41 /**
42 Default ctor.
43 */
44 wxFontMapper();
45
46 /**
47 Virtual dtor for a base class.
48 */
49 ~wxFontMapper();
50
51 /**
52 Returns the encoding for the given charset (in the form of RFC 2046) or
53 @c wxFONTENCODING_SYSTEM if couldn't decode it.
54 Be careful when using this function with @a interactive set to @true
55 (default value) as the function then may show a dialog box to the user which
56 may lead to unexpected reentrancies and may also take a significantly longer
57 time than a simple function call. For these reasons, it is almost always a bad
58 idea to call this function from the event handlers for repeatedly generated
59 events such as @c EVT_PAINT.
60 */
61 wxFontEncoding CharsetToEncoding(const wxString& charset,
62 bool interactive = true);
63
64 /**
65 Get the current font mapper object. If there is no current object, creates
66 one.
67
68 @see Set()
69 */
70 static wxFontMapper* Get();
71
72 /**
73 Returns the array of all possible names for the given encoding. The array is
74 @NULL-terminated. IF it isn't empty, the first name in it is the canonical
75 encoding name, i.e. the same string as returned by
76 GetEncodingName().
77 */
78 static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
79
80 //@{
81 /**
82 Find an alternative for the given encoding (which is supposed to not be
83 available on this system). If successful, return @true and fill info
84 structure with the parameters required to create the font, otherwise
85 return @false.
86 The first form is for wxWidgets' internal use while the second one
87 is better suitable for general use -- it returns wxFontEncoding which
88 can consequently be passed to wxFont constructor.
89 */
90 bool GetAltForEncoding(wxFontEncoding encoding,
91 wxNativeEncodingInfo* info,
92 const wxString& facename = wxEmptyString,
93 bool interactive = true);
94 bool GetAltForEncoding(wxFontEncoding encoding,
95 wxFontEncoding* alt_encoding,
96 const wxString& facename = wxEmptyString,
97 bool interactive = true);
98 //@}
99
100 /**
101 Returns the @e n-th supported encoding. Together with
102 GetSupportedEncodingsCount()
103 this method may be used to get all supported encodings.
104 */
105 static wxFontEncoding GetEncoding(size_t n);
106
107 /**
108 Return user-readable string describing the given encoding.
109 */
110 static wxString GetEncodingDescription(wxFontEncoding encoding);
111
112 /**
113 Return the encoding corresponding to the given internal name. This function is
114 the inverse of GetEncodingName() and is
115 intentionally less general than
116 CharsetToEncoding(), i.e. it doesn't
117 try to make any guesses nor ever asks the user. It is meant just as a way of
118 restoring objects previously serialized using
119 GetEncodingName().
120 */
121 static wxFontEncoding GetEncodingFromName(const wxString& encoding);
122
123 /**
124 Return internal string identifier for the encoding (see also
125 wxFontMapper::GetEncodingDescription)
126
127 @see GetEncodingFromName()
128 */
129 static wxString GetEncodingName(wxFontEncoding encoding);
130
131 /**
132 Returns the number of the font encodings supported by this class. Together with
133 GetEncoding() this method may be used to get
134 all supported encodings.
135 */
136 static size_t GetSupportedEncodingsCount();
137
138 /**
139 Check whether given encoding is available in given face or not.
140 If no facename is given, find @e any font in this encoding.
141 */
142 bool IsEncodingAvailable(wxFontEncoding encoding,
143 const wxString& facename = wxEmptyString);
144
145 /**
146 Set the current font mapper object and return previous one (may be @NULL).
147 This method is only useful if you want to plug-in an alternative font mapper
148 into wxWidgets.
149
150 @see Get()
151 */
152 static wxFontMapper* Set(wxFontMapper* mapper);
153
154 /**
155 Set the config object to use (may be @NULL to use default).
156 By default, the global one (from wxConfigBase::Get() will be used)
157 and the default root path for the config settings is the string returned by
158 GetDefaultConfigPath().
159 */
160 void SetConfig(wxConfigBase* config);
161
162 /**
163 Set the root config path to use (should be an absolute path).
164 */
165 void SetConfigPath(const wxString& prefix);
166
167 /**
168 The parent window for modal dialogs.
169 */
170 void SetDialogParent(wxWindow* parent);
171
172 /**
173 The title for the dialogs (note that default is quite reasonable).
174 */
175 void SetDialogTitle(const wxString& title);
176 };