]> git.saurik.com Git - wxWidgets.git/blob - interface/fontmap.h
Fix AdjustForOverflow to use item->CalcMin, not item->GetSize
[wxWidgets.git] / interface / fontmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontmap.h
3 // Purpose: interface of wxFontMapper
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 @see wxEncodingConverter, @ref overview_nonenglishoverview "Writing non-English
35 applications"
36 */
37 class wxFontMapper
38 {
39 public:
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.
53 Be careful when using this function with @a interactive set to @true
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,
61 bool interactive = true);
62
63 /**
64 Get the current font mapper object. If there is no current object, creates
65 one.
66
67 @see Set()
68 */
69 static wxFontMapper* Get();
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
74 encoding name, i.e. the same string as returned by
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.
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,
92 bool interactive = true);
93 bool GetAltForEncoding(wxFontEncoding encoding,
94 wxFontEncoding* alt_encoding,
95 const wxString& facename = wxEmptyString,
96 bool interactive = true);
97 //@}
98
99 /**
100 Returns the @e n-th supported encoding. Together with
101 GetSupportedEncodingsCount()
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
114 intentionally less general than
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
117 restoring objects previously serialized using
118 GetEncodingName().
119 */
120 static wxFontEncoding GetEncodingFromName(const wxString& encoding);
121
122 /**
123 Return internal string identifier for the encoding (see also
124 wxFontMapper::GetEncodingDescription)
125
126 @see GetEncodingFromName()
127 */
128 static wxString GetEncodingName(wxFontEncoding encoding);
129
130 /**
131 Returns the number of the font encodings supported by this class. Together with
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
149 @see Get()
150 */
151 static wxFontMapper* Set(wxFontMapper* mapper);
152
153 /**
154 Set the config object to use (may be @NULL to use default).
155 By default, the global one (from wxConfigBase::Get() will be used)
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 };
176