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