]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
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} | |
7c913512 | 12 | |
23324ae1 FM |
13 | wxFontMapper manages user-definable correspondence between logical font |
14 | names and the fonts present on the machine. | |
7c913512 | 15 | |
23324ae1 FM |
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. | |
7c913512 | 20 | |
23324ae1 FM |
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. | |
7c913512 | 25 | |
23324ae1 | 26 | In case everything else fails (i.e. there is no record in config file |
7c913512 FM |
27 | and "interactive" is @false or user denied to choose any replacement), |
28 | the class queries wxEncodingConverter | |
23324ae1 | 29 | for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them. |
7c913512 | 30 | |
23324ae1 FM |
31 | @library{wxcore} |
32 | @category{misc} | |
7c913512 | 33 | |
23324ae1 FM |
34 | @seealso |
35 | wxEncodingConverter, @ref overview_nonenglishoverview "Writing non-English | |
36 | applications" | |
37 | */ | |
7c913512 | 38 | class wxFontMapper |
23324ae1 FM |
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. | |
4cc4bfaf | 54 | Be careful when using this function with @a interactive set to @true |
23324ae1 FM |
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, | |
4cc4bfaf | 62 | bool interactive = true); |
23324ae1 FM |
63 | |
64 | /** | |
65 | Get the current font mapper object. If there is no current object, creates | |
66 | one. | |
67 | ||
4cc4bfaf | 68 | @see Set() |
23324ae1 | 69 | */ |
4cc4bfaf | 70 | static wxFontMapper* Get(); |
23324ae1 FM |
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 | |
7c913512 | 75 | encoding name, i.e. the same string as returned by |
23324ae1 FM |
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. | |
23324ae1 FM |
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, | |
4cc4bfaf | 93 | bool interactive = true); |
7c913512 FM |
94 | bool GetAltForEncoding(wxFontEncoding encoding, |
95 | wxFontEncoding* alt_encoding, | |
96 | const wxString& facename = wxEmptyString, | |
4cc4bfaf | 97 | bool interactive = true); |
23324ae1 FM |
98 | //@} |
99 | ||
100 | /** | |
7c913512 FM |
101 | Returns the @e n-th supported encoding. Together with |
102 | GetSupportedEncodingsCount() | |
23324ae1 FM |
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 | |
7c913512 | 115 | intentionally less general than |
23324ae1 FM |
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 | |
7c913512 | 118 | restoring objects previously serialized using |
23324ae1 FM |
119 | GetEncodingName(). |
120 | */ | |
121 | static wxFontEncoding GetEncodingFromName(const wxString& encoding); | |
122 | ||
123 | /** | |
7c913512 | 124 | Return internal string identifier for the encoding (see also |
23324ae1 FM |
125 | wxFontMapper::GetEncodingDescription) |
126 | ||
4cc4bfaf | 127 | @see GetEncodingFromName() |
23324ae1 FM |
128 | */ |
129 | static wxString GetEncodingName(wxFontEncoding encoding); | |
130 | ||
131 | /** | |
7c913512 | 132 | Returns the number of the font encodings supported by this class. Together with |
23324ae1 FM |
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 | ||
4cc4bfaf | 150 | @see Get() |
23324ae1 | 151 | */ |
4cc4bfaf | 152 | static wxFontMapper* Set(wxFontMapper* mapper); |
23324ae1 FM |
153 | |
154 | /** | |
155 | Set the config object to use (may be @NULL to use default). | |
7c913512 | 156 | By default, the global one (from wxConfigBase::Get() will be used) |
23324ae1 FM |
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 | }; |