]> git.saurik.com Git - wxWidgets.git/blob - src/mac/fontutil.cpp
Don't leave behind trails from glowing OS X button (By extending invisible button...
[wxWidgets.git] / src / mac / fontutil.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/fontutil.cpp
3 // Purpose: font-related helper functions for wxMSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.11.99
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "fontutil.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/string.h"
33 #include "wx/log.h"
34 #include "wx/intl.h"
35 #endif //WX_PRECOMP
36
37 #include "wx/fontutil.h"
38 #include "wx/fontmap.h"
39 #include "wx/encinfo.h"
40
41 #include "wx/tokenzr.h"
42
43 // ============================================================================
44 // implementation
45 // ============================================================================
46
47 // ----------------------------------------------------------------------------
48 // wxNativeEncodingInfo
49 // ----------------------------------------------------------------------------
50
51 // convert to/from the string representation: format is
52 // facename[;charset]
53
54 bool wxNativeEncodingInfo::FromString(const wxString& s)
55 {
56 wxStringTokenizer tokenizer(s, _T(";"));
57
58 facename = tokenizer.GetNextToken();
59 if ( !facename )
60 return FALSE;
61
62 wxString tmp = tokenizer.GetNextToken();
63 if ( !tmp )
64 {
65 // default charset (don't use DEFAULT_CHARSET though because of subtle
66 // Windows 9x/NT differences in handling it)
67 charset = 0;
68 }
69 else
70 {
71 if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
72 {
73 // should be a number!
74 return FALSE;
75 }
76 }
77
78 return TRUE;
79 }
80
81 wxString wxNativeEncodingInfo::ToString() const
82 {
83 wxString s(facename);
84 if ( charset != 0 )
85 {
86 s << _T(';') << charset;
87 }
88
89 return s;
90 }
91
92 // ----------------------------------------------------------------------------
93 // helper functions
94 // ----------------------------------------------------------------------------
95
96 bool wxGetNativeFontEncoding(wxFontEncoding encoding,
97 wxNativeEncodingInfo *info)
98 {
99 wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
100
101 if ( encoding == wxFONTENCODING_DEFAULT )
102 {
103 encoding = wxFont::GetDefaultEncoding();
104 }
105
106 switch ( encoding )
107 {
108 // although this function is supposed to return an exact match, do do
109 // some mappings here for the most common case of "standard" encoding
110 case wxFONTENCODING_SYSTEM:
111 case wxFONTENCODING_ISO8859_1:
112 case wxFONTENCODING_ISO8859_15:
113 case wxFONTENCODING_CP1252:
114 info->charset = 0;
115 break;
116
117 case wxFONTENCODING_CP1250:
118 info->charset = 0;
119 break;
120
121 case wxFONTENCODING_CP1251:
122 info->charset = 0;
123 break;
124
125 case wxFONTENCODING_CP1253:
126 info->charset = 0;
127 break;
128
129 case wxFONTENCODING_CP1254:
130 info->charset = 0;
131 break;
132
133 case wxFONTENCODING_CP1255:
134 info->charset = 0;
135 break;
136
137 case wxFONTENCODING_CP1256:
138 info->charset = 0;
139 break;
140
141 case wxFONTENCODING_CP1257:
142 info->charset = 0;
143 break;
144
145 case wxFONTENCODING_CP437:
146 info->charset = 0;
147 break;
148
149 default:
150 // no way to translate this encoding into a Windows charset
151 return FALSE;
152 }
153
154 return TRUE;
155 }
156
157 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
158 {
159 return TRUE;
160 }