]>
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. | |
54 | ||
55 | Be careful when using this function with @e interactive set to @true | |
56 | (default value) as the function then may show a dialog box to the user which | |
57 | may lead to unexpected reentrancies and may also take a significantly longer | |
58 | time than a simple function call. For these reasons, it is almost always a bad | |
59 | idea to call this function from the event handlers for repeatedly generated | |
60 | events such as @c EVT_PAINT. | |
61 | */ | |
62 | wxFontEncoding CharsetToEncoding(const wxString& charset, | |
63 | bool interactive = @true); | |
64 | ||
65 | /** | |
66 | Get the current font mapper object. If there is no current object, creates | |
67 | one. | |
68 | ||
69 | @sa Set() | |
70 | */ | |
71 | #define static wxFontMapper * Get() /* implementation is private */ | |
72 | ||
73 | /** | |
74 | Returns the array of all possible names for the given encoding. The array is | |
75 | @NULL-terminated. IF it isn't empty, the first name in it is the canonical | |
7c913512 | 76 | encoding name, i.e. the same string as returned by |
23324ae1 FM |
77 | GetEncodingName(). |
78 | */ | |
79 | static const wxChar** GetAllEncodingNames(wxFontEncoding encoding); | |
80 | ||
81 | //@{ | |
82 | /** | |
83 | Find an alternative for the given encoding (which is supposed to not be | |
84 | available on this system). If successful, return @true and fill info | |
85 | structure with the parameters required to create the font, otherwise | |
86 | return @false. | |
87 | ||
88 | The first form is for wxWidgets' internal use while the second one | |
89 | is better suitable for general use -- it returns wxFontEncoding which | |
90 | can consequently be passed to wxFont constructor. | |
91 | */ | |
92 | bool GetAltForEncoding(wxFontEncoding encoding, | |
93 | wxNativeEncodingInfo* info, | |
94 | const wxString& facename = wxEmptyString, | |
95 | bool interactive = @true); | |
7c913512 FM |
96 | bool GetAltForEncoding(wxFontEncoding encoding, |
97 | wxFontEncoding* alt_encoding, | |
98 | const wxString& facename = wxEmptyString, | |
99 | bool interactive = @true); | |
23324ae1 FM |
100 | //@} |
101 | ||
102 | /** | |
7c913512 FM |
103 | Returns the @e n-th supported encoding. Together with |
104 | GetSupportedEncodingsCount() | |
23324ae1 FM |
105 | this method may be used to get all supported encodings. |
106 | */ | |
107 | static wxFontEncoding GetEncoding(size_t n); | |
108 | ||
109 | /** | |
110 | Return user-readable string describing the given encoding. | |
111 | */ | |
112 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
113 | ||
114 | /** | |
115 | Return the encoding corresponding to the given internal name. This function is | |
116 | the inverse of GetEncodingName() and is | |
7c913512 | 117 | intentionally less general than |
23324ae1 FM |
118 | CharsetToEncoding(), i.e. it doesn't |
119 | try to make any guesses nor ever asks the user. It is meant just as a way of | |
7c913512 | 120 | restoring objects previously serialized using |
23324ae1 FM |
121 | GetEncodingName(). |
122 | */ | |
123 | static wxFontEncoding GetEncodingFromName(const wxString& encoding); | |
124 | ||
125 | /** | |
7c913512 | 126 | Return internal string identifier for the encoding (see also |
23324ae1 FM |
127 | wxFontMapper::GetEncodingDescription) |
128 | ||
129 | @sa GetEncodingFromName() | |
130 | */ | |
131 | static wxString GetEncodingName(wxFontEncoding encoding); | |
132 | ||
133 | /** | |
7c913512 | 134 | Returns the number of the font encodings supported by this class. Together with |
23324ae1 FM |
135 | GetEncoding() this method may be used to get |
136 | all supported encodings. | |
137 | */ | |
138 | static size_t GetSupportedEncodingsCount(); | |
139 | ||
140 | /** | |
141 | Check whether given encoding is available in given face or not. | |
142 | If no facename is given, find @e any font in this encoding. | |
143 | */ | |
144 | bool IsEncodingAvailable(wxFontEncoding encoding, | |
145 | const wxString& facename = wxEmptyString); | |
146 | ||
147 | /** | |
148 | Set the current font mapper object and return previous one (may be @NULL). | |
149 | This method is only useful if you want to plug-in an alternative font mapper | |
150 | into wxWidgets. | |
151 | ||
152 | @sa Get() | |
153 | */ | |
154 | #define static wxFontMapper * Set(wxFontMapper * mapper) /* implementation is private */ | |
155 | ||
156 | /** | |
157 | Set the config object to use (may be @NULL to use default). | |
158 | ||
7c913512 | 159 | By default, the global one (from wxConfigBase::Get() will be used) |
23324ae1 FM |
160 | and the default root path for the config settings is the string returned by |
161 | GetDefaultConfigPath(). | |
162 | */ | |
163 | void SetConfig(wxConfigBase* config); | |
164 | ||
165 | /** | |
166 | Set the root config path to use (should be an absolute path). | |
167 | */ | |
168 | void SetConfigPath(const wxString& prefix); | |
169 | ||
170 | /** | |
171 | The parent window for modal dialogs. | |
172 | */ | |
173 | void SetDialogParent(wxWindow* parent); | |
174 | ||
175 | /** | |
176 | The title for the dialogs (note that default is quite reasonable). | |
177 | */ | |
178 | void SetDialogTitle(const wxString& title); | |
179 | }; |