]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: typetest.cpp | |
3 | // Purpose: Types wxWindows sample | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "typetest.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx/wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | #endif | |
26 | ||
27 | #include "wx/time.h" | |
28 | #include "wx/date.h" | |
29 | #include "wx/variant.h" | |
30 | #include "wx/mimetype.h" | |
31 | ||
32 | #include "typetest.h" | |
33 | ||
34 | #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) | |
35 | #include "mondrian.xpm" | |
36 | #endif | |
37 | ||
38 | #ifdef new | |
39 | #undef new | |
40 | #endif | |
41 | ||
42 | #include "wx/ioswrap.h" | |
43 | ||
44 | #if wxUSE_IOSTREAMH | |
45 | #include <fstream.h> | |
46 | #else | |
47 | #include <fstream> | |
48 | #endif | |
49 | ||
50 | #include "wx/wfstream.h" | |
51 | #include "wx/datstrm.h" | |
52 | #include "wx/txtstrm.h" | |
53 | #include "wx/mstream.h" | |
54 | ||
55 | // Create a new application object | |
56 | IMPLEMENT_APP (MyApp) | |
57 | ||
58 | IMPLEMENT_DYNAMIC_CLASS (MyApp, wxApp) | |
59 | ||
60 | BEGIN_EVENT_TABLE(MyApp, wxApp) | |
61 | #if wxUSE_TIMEDATE | |
62 | EVT_MENU(TYPES_DATE, MyApp::DoDateDemo) | |
63 | EVT_MENU(TYPES_TIME, MyApp::DoTimeDemo) | |
64 | #endif // wxUSE_TIMEDATE | |
65 | EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo) | |
66 | EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo) | |
67 | #if wxUSE_UNICODE | |
68 | EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo) | |
69 | #endif // wxUSE_UNICODE | |
70 | EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo) | |
71 | EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2) | |
72 | EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3) | |
73 | EVT_MENU(TYPES_STREAM4, MyApp::DoStreamDemo4) | |
74 | EVT_MENU(TYPES_STREAM5, MyApp::DoStreamDemo5) | |
75 | EVT_MENU(TYPES_STREAM6, MyApp::DoStreamDemo6) | |
76 | EVT_MENU(TYPES_STREAM7, MyApp::DoStreamDemo7) | |
77 | EVT_MENU(TYPES_MIME, MyApp::DoMIMEDemo) | |
78 | END_EVENT_TABLE() | |
79 | ||
80 | bool MyApp::OnInit() | |
81 | { | |
82 | // Create the main frame window | |
83 | MyFrame *frame = new MyFrame((wxFrame *) NULL, "wxWindows Types Demo", | |
84 | wxPoint(50, 50), wxSize(450, 340)); | |
85 | ||
86 | // Give it an icon | |
87 | frame->SetIcon(wxICON(mondrian)); | |
88 | ||
89 | // Make a menubar | |
90 | wxMenu *file_menu = new wxMenu; | |
91 | ||
92 | file_menu->Append(TYPES_ABOUT, "&About"); | |
93 | file_menu->AppendSeparator(); | |
94 | file_menu->Append(TYPES_QUIT, "E&xit\tAlt-X"); | |
95 | ||
96 | wxMenu *test_menu = new wxMenu; | |
97 | #if wxUSE_TIMEDATE | |
98 | test_menu->Append(TYPES_DATE, "&Date test"); | |
99 | #endif // wxUSE_TIMEDATE | |
100 | test_menu->Append(TYPES_TIME, "&Time test"); | |
101 | test_menu->Append(TYPES_VARIANT, "&Variant test"); | |
102 | test_menu->Append(TYPES_BYTEORDER, "&Byteorder test"); | |
103 | #if wxUSE_UNICODE | |
104 | test_menu->Append(TYPES_UNICODE, "&Unicode test"); | |
105 | #endif // wxUSE_UNICODE | |
106 | test_menu->Append(TYPES_STREAM, "&Stream test"); | |
107 | test_menu->Append(TYPES_STREAM2, "&Stream seek test"); | |
108 | test_menu->Append(TYPES_STREAM3, "&Stream error test"); | |
109 | test_menu->Append(TYPES_STREAM4, "&Stream buffer test"); | |
110 | test_menu->Append(TYPES_STREAM5, "&Stream peek test"); | |
111 | test_menu->Append(TYPES_STREAM6, "&Stream ungetch test"); | |
112 | test_menu->Append(TYPES_STREAM7, "&Stream ungetch test for a buffered stream"); | |
113 | test_menu->AppendSeparator(); | |
114 | test_menu->Append(TYPES_MIME, "&MIME database test"); | |
115 | ||
116 | wxMenuBar *menu_bar = new wxMenuBar; | |
117 | menu_bar->Append(file_menu, "&File"); | |
118 | menu_bar->Append(test_menu, "&Tests"); | |
119 | frame->SetMenuBar(menu_bar); | |
120 | ||
121 | m_textCtrl = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxDefaultSize, wxTE_MULTILINE); | |
122 | ||
123 | // Show the frame | |
124 | frame->Show(TRUE); | |
125 | ||
126 | SetTopWindow(frame); | |
127 | ||
128 | return TRUE; | |
129 | } | |
130 | ||
131 | void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event)) | |
132 | { | |
133 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
134 | ||
135 | textCtrl.Clear(); | |
136 | textCtrl << _T("\nTest fstream vs. wxFileStream:\n\n"); | |
137 | ||
138 | textCtrl.WriteText( "Writing to ofstream and wxFileOutputStream:\n" ); | |
139 | ||
140 | wxSTD ofstream std_file_output( "test_std.dat" ); | |
141 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
142 | wxBufferedOutputStream buf_output( file_output ); | |
143 | wxTextOutputStream text_output( buf_output ); | |
144 | ||
145 | wxString tmp; | |
146 | signed int si = 0xFFFFFFFF; | |
147 | tmp.Printf( _T("Signed int: %d\n"), si ); | |
148 | textCtrl.WriteText( tmp ); | |
149 | text_output << si << "\n"; | |
150 | std_file_output << si << "\n"; | |
151 | ||
152 | unsigned int ui = 0xFFFFFFFF; | |
153 | tmp.Printf( _T("Unsigned int: %u\n"), ui ); | |
154 | textCtrl.WriteText( tmp ); | |
155 | text_output << ui << "\n"; | |
156 | std_file_output << ui << "\n"; | |
157 | ||
158 | double d = 2.01234567890123456789; | |
159 | tmp.Printf( _T("Double: %f\n"), d ); | |
160 | textCtrl.WriteText( tmp ); | |
161 | text_output << d << "\n"; | |
162 | std_file_output << d << "\n"; | |
163 | ||
164 | float f = (float)0.00001; | |
165 | tmp.Printf( _T("Float: %f\n"), f ); | |
166 | textCtrl.WriteText( tmp ); | |
167 | text_output << f << "\n"; | |
168 | std_file_output << f << "\n"; | |
169 | ||
170 | wxString str( _T("Hello!") ); | |
171 | tmp.Printf( _T("String: %s\n"), str.c_str() ); | |
172 | textCtrl.WriteText( tmp ); | |
173 | text_output << str << "\n"; | |
174 | std_file_output << str.c_str() << "\n"; | |
175 | ||
176 | textCtrl.WriteText( "\nReading from ifstream:\n" ); | |
177 | ||
178 | wxSTD ifstream std_file_input( "test_std.dat" ); | |
179 | ||
180 | std_file_input >> si; | |
181 | tmp.Printf( _T("Signed int: %d\n"), si ); | |
182 | textCtrl.WriteText( tmp ); | |
183 | ||
184 | std_file_input >> ui; | |
185 | tmp.Printf( _T("Unsigned int: %u\n"), ui ); | |
186 | textCtrl.WriteText( tmp ); | |
187 | ||
188 | std_file_input >> d; | |
189 | tmp.Printf( _T("Double: %f\n"), d ); | |
190 | textCtrl.WriteText( tmp ); | |
191 | ||
192 | std_file_input >> f; | |
193 | tmp.Printf( _T("Float: %f\n"), f ); | |
194 | textCtrl.WriteText( tmp ); | |
195 | ||
196 | // Why doesn't this work? | |
197 | #if 0 | |
198 | char std_buf[200]; | |
199 | std_file_input >> std_buf; | |
200 | tmp.Printf( _T("String: %s\n"), std_buf ); | |
201 | textCtrl.WriteText( tmp ); | |
202 | #endif | |
203 | ||
204 | textCtrl.WriteText( "\nReading from wxFileInputStream:\n" ); | |
205 | ||
206 | buf_output.Sync(); | |
207 | ||
208 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
209 | wxBufferedInputStream buf_input( file_input ); | |
210 | wxTextInputStream text_input( file_input ); | |
211 | ||
212 | text_input >> si; | |
213 | tmp.Printf( _T("Signed int: %d\n"), si ); | |
214 | textCtrl.WriteText( tmp ); | |
215 | ||
216 | text_input >> ui; | |
217 | tmp.Printf( _T("Unsigned int: %u\n"), ui ); | |
218 | textCtrl.WriteText( tmp ); | |
219 | ||
220 | text_input >> d; | |
221 | tmp.Printf( _T("Double: %f\n"), d ); | |
222 | textCtrl.WriteText( tmp ); | |
223 | ||
224 | text_input >> f; | |
225 | tmp.Printf( _T("Float: %f\n"), f ); | |
226 | textCtrl.WriteText( tmp ); | |
227 | ||
228 | text_input >> str; | |
229 | tmp.Printf( _T("String: %s\n"), str.c_str() ); | |
230 | textCtrl.WriteText( tmp ); | |
231 | ||
232 | ||
233 | ||
234 | textCtrl << "\nTest for wxDataStream:\n\n"; | |
235 | ||
236 | textCtrl.WriteText( "Writing to wxDataOutputStream:\n" ); | |
237 | ||
238 | file_output.SeekO( 0 ); | |
239 | wxDataOutputStream data_output( buf_output ); | |
240 | ||
241 | wxInt16 i16 = (unsigned short)0xFFFF; | |
242 | tmp.Printf( _T("Signed int16: %d\n"), (int)i16 ); | |
243 | textCtrl.WriteText( tmp ); | |
244 | data_output.Write16( i16 ); | |
245 | ||
246 | wxUint16 ui16 = 0xFFFF; | |
247 | tmp.Printf( _T("Unsigned int16: %u\n"), (unsigned int) ui16 ); | |
248 | textCtrl.WriteText( tmp ); | |
249 | data_output.Write16( ui16 ); | |
250 | ||
251 | d = 2.01234567890123456789; | |
252 | tmp.Printf( _T("Double: %f\n"), d ); | |
253 | textCtrl.WriteText( tmp ); | |
254 | data_output.WriteDouble( d ); | |
255 | ||
256 | str = "Hello!"; | |
257 | tmp.Printf( _T("String: %s\n"), str.c_str() ); | |
258 | textCtrl.WriteText( tmp ); | |
259 | data_output.WriteString( str ); | |
260 | ||
261 | buf_output.Sync(); | |
262 | ||
263 | textCtrl.WriteText( "\nReading from wxDataInputStream:\n" ); | |
264 | ||
265 | file_input.SeekI( 0 ); | |
266 | wxDataInputStream data_input( buf_input ); | |
267 | ||
268 | i16 = data_input.Read16(); | |
269 | tmp.Printf( _T("Signed int16: %d\n"), (int)i16 ); | |
270 | textCtrl.WriteText( tmp ); | |
271 | ||
272 | ui16 = data_input.Read16(); | |
273 | tmp.Printf( _T("Unsigned int16: %u\n"), (unsigned int) ui16 ); | |
274 | textCtrl.WriteText( tmp ); | |
275 | ||
276 | d = data_input.ReadDouble(); | |
277 | tmp.Printf( _T("Double: %f\n"), d ); | |
278 | textCtrl.WriteText( tmp ); | |
279 | ||
280 | str = data_input.ReadString(); | |
281 | tmp.Printf( _T("String: %s\n"), str.c_str() ); | |
282 | textCtrl.WriteText( tmp ); | |
283 | } | |
284 | ||
285 | void MyApp::DoStreamDemo2(wxCommandEvent& WXUNUSED(event)) | |
286 | { | |
287 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
288 | ||
289 | textCtrl.Clear(); | |
290 | textCtrl << _T("\nTesting wxBufferedStream:\n\n"); | |
291 | ||
292 | char ch,ch2; | |
293 | ||
294 | textCtrl.WriteText( "Writing number 0 to 9 to buffered wxFileOutputStream:\n\n" ); | |
295 | ||
296 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
297 | wxBufferedOutputStream buf_output( file_output ); | |
298 | for (ch = 0; ch < 10; ch++) | |
299 | buf_output.Write( &ch, 1 ); | |
300 | buf_output.Sync(); | |
301 | ||
302 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
303 | for (ch2 = 0; ch2 < 10; ch2++) | |
304 | { | |
305 | file_input.Read( &ch, 1 ); | |
306 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
307 | } | |
308 | textCtrl.WriteText( "\n\n\n" ); | |
309 | ||
310 | textCtrl.WriteText( "Writing number 0 to 9 to buffered wxFileOutputStream, then\n" ); | |
311 | textCtrl.WriteText( "seeking back to #3 and writing 0:\n\n" ); | |
312 | ||
313 | wxFileOutputStream file_output2( wxString("test_wx2.dat") ); | |
314 | wxBufferedOutputStream buf_output2( file_output2 ); | |
315 | for (ch = 0; ch < 10; ch++) | |
316 | buf_output2.Write( &ch, 1 ); | |
317 | buf_output2.SeekO( 3 ); | |
318 | ch = 0; | |
319 | buf_output2.Write( &ch, 1 ); | |
320 | buf_output2.Sync(); | |
321 | ||
322 | wxFileInputStream file_input2( wxString("test_wx2.dat") ); | |
323 | for (ch2 = 0; ch2 < 10; ch2++) | |
324 | { | |
325 | file_input2.Read( &ch, 1 ); | |
326 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
327 | } | |
328 | textCtrl.WriteText( "\n\n\n" ); | |
329 | ||
330 | // now append 2000 bytes to file (bigger than buffer) | |
331 | buf_output2.SeekO( 0, wxFromEnd ); | |
332 | ch = 1; | |
333 | for (int i = 0; i < 2000; i++) | |
334 | buf_output2.Write( &ch, 1 ); | |
335 | buf_output2.Sync(); | |
336 | ||
337 | textCtrl.WriteText( "Reading number 0 to 9 from buffered wxFileInputStream, then\n" ); | |
338 | textCtrl.WriteText( "seeking back to #3 and reading the 0:\n\n" ); | |
339 | ||
340 | wxFileInputStream file_input3( wxString("test_wx2.dat") ); | |
341 | wxBufferedInputStream buf_input3( file_input3 ); | |
342 | for (ch2 = 0; ch2 < 10; ch2++) | |
343 | { | |
344 | buf_input3.Read( &ch, 1 ); | |
345 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
346 | } | |
347 | for (int j = 0; j < 2000; j++) | |
348 | buf_input3.Read( &ch, 1 ); | |
349 | textCtrl.WriteText( "\n" ); | |
350 | buf_input3.SeekI( 3 ); | |
351 | buf_input3.Read( &ch, 1 ); | |
352 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
353 | textCtrl.WriteText( "\n\n\n" ); | |
354 | ||
355 | } | |
356 | ||
357 | void MyApp::DoStreamDemo3(wxCommandEvent& WXUNUSED(event)) | |
358 | { | |
359 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
360 | ||
361 | textCtrl.Clear(); | |
362 | textCtrl << "\nTesting wxFileInputStream's and wxFFileInputStream's error handling:\n\n"; | |
363 | ||
364 | char ch,ch2; | |
365 | ||
366 | textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream:\n\n" ); | |
367 | ||
368 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
369 | for (ch = 0; ch < 10; ch++) | |
370 | file_output.Write( &ch, 1 ); | |
371 | ||
372 | // Testing wxFileInputStream | |
373 | ||
374 | textCtrl.WriteText( "Reading 0 to 10 to wxFileInputStream:\n\n" ); | |
375 | ||
376 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
377 | for (ch2 = 0; ch2 < 11; ch2++) | |
378 | { | |
379 | file_input.Read( &ch, 1 ); | |
380 | textCtrl.WriteText( "Value read: " ); | |
381 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
382 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
383 | switch (file_input.LastError()) | |
384 | { | |
385 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
386 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
387 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
388 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
389 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
390 | } | |
391 | } | |
392 | textCtrl.WriteText( "\n" ); | |
393 | ||
394 | textCtrl.WriteText( "Seeking to 0; stream.LastError() returns: " ); | |
395 | file_input.SeekI( 0 ); | |
396 | switch (file_input.LastError()) | |
397 | { | |
398 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
399 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
400 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
401 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
402 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
403 | } | |
404 | textCtrl.WriteText( "\n" ); | |
405 | ||
406 | file_input.Read( &ch, 1 ); | |
407 | textCtrl.WriteText( "Value read: " ); | |
408 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
409 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
410 | switch (file_input.LastError()) | |
411 | { | |
412 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
413 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
414 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
415 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
416 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
417 | } | |
418 | textCtrl.WriteText( "\n\n" ); | |
419 | ||
420 | ||
421 | // Testing wxFFileInputStream | |
422 | ||
423 | textCtrl.WriteText( "Reading 0 to 10 to wxFFileInputStream:\n\n" ); | |
424 | ||
425 | wxFFileInputStream ffile_input( wxString("test_wx.dat") ); | |
426 | for (ch2 = 0; ch2 < 11; ch2++) | |
427 | { | |
428 | ffile_input.Read( &ch, 1 ); | |
429 | textCtrl.WriteText( "Value read: " ); | |
430 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
431 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
432 | switch (ffile_input.LastError()) | |
433 | { | |
434 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
435 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
436 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
437 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
438 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
439 | } | |
440 | } | |
441 | textCtrl.WriteText( "\n" ); | |
442 | ||
443 | textCtrl.WriteText( "Seeking to 0; stream.LastError() returns: " ); | |
444 | ffile_input.SeekI( 0 ); | |
445 | switch (ffile_input.LastError()) | |
446 | { | |
447 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
448 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
449 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
450 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
451 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
452 | } | |
453 | textCtrl.WriteText( "\n" ); | |
454 | ||
455 | ffile_input.Read( &ch, 1 ); | |
456 | textCtrl.WriteText( "Value read: " ); | |
457 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
458 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
459 | switch (ffile_input.LastError()) | |
460 | { | |
461 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
462 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
463 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
464 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
465 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
466 | } | |
467 | textCtrl.WriteText( "\n\n" ); | |
468 | ||
469 | // Testing wxFFileInputStream | |
470 | ||
471 | textCtrl.WriteText( "Reading 0 to 10 to buffered wxFFileInputStream:\n\n" ); | |
472 | ||
473 | wxFFileInputStream ffile_input2( wxString("test_wx.dat") ); | |
474 | wxBufferedInputStream buf_input( ffile_input2 ); | |
475 | for (ch2 = 0; ch2 < 11; ch2++) | |
476 | { | |
477 | buf_input.Read( &ch, 1 ); | |
478 | textCtrl.WriteText( "Value read: " ); | |
479 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
480 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
481 | switch (buf_input.LastError()) | |
482 | { | |
483 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
484 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
485 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
486 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
487 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
488 | } | |
489 | } | |
490 | textCtrl.WriteText( "\n" ); | |
491 | ||
492 | textCtrl.WriteText( "Seeking to 0; stream.LastError() returns: " ); | |
493 | buf_input.SeekI( 0 ); | |
494 | switch (buf_input.LastError()) | |
495 | { | |
496 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
497 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
498 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
499 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
500 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
501 | } | |
502 | textCtrl.WriteText( "\n" ); | |
503 | ||
504 | buf_input.Read( &ch, 1 ); | |
505 | textCtrl.WriteText( "Value read: " ); | |
506 | textCtrl.WriteText( (wxChar)(ch + '0') ); | |
507 | textCtrl.WriteText( "; stream.LastError() returns: " ); | |
508 | switch (buf_input.LastError()) | |
509 | { | |
510 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
511 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
512 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
513 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
514 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
515 | } | |
516 | } | |
517 | ||
518 | void MyApp::DoStreamDemo4(wxCommandEvent& WXUNUSED(event)) | |
519 | { | |
520 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
521 | ||
522 | wxString msg; | |
523 | ||
524 | textCtrl.Clear(); | |
525 | textCtrl << "\nTesting wxStreamBuffer:\n\n"; | |
526 | ||
527 | // bigger than buffer | |
528 | textCtrl.WriteText( "Writing 2000x 1 to wxFileOutputStream.\n\n" ); | |
529 | ||
530 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
531 | for (int i = 0; i < 2000; i++) | |
532 | { | |
533 | char ch = 1; | |
534 | file_output.Write( &ch, 1 ); | |
535 | } | |
536 | ||
537 | textCtrl.WriteText( "Opening with a buffered wxFileInputStream:\n\n" ); | |
538 | ||
539 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
540 | wxBufferedInputStream buf_input( file_input ); | |
541 | ||
542 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
543 | switch (buf_input.LastError()) | |
544 | { | |
545 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
546 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
547 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
548 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
549 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
550 | } | |
551 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
552 | textCtrl.WriteText( msg ); | |
553 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
554 | textCtrl.WriteText( msg ); | |
555 | textCtrl.WriteText( "\n\n" ); | |
556 | ||
557 | ||
558 | textCtrl.WriteText( "Seeking to position 300:\n\n" ); | |
559 | ||
560 | buf_input.SeekI( 300 ); | |
561 | ||
562 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
563 | switch (buf_input.LastError()) | |
564 | { | |
565 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
566 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
567 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
568 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
569 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
570 | } | |
571 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
572 | textCtrl.WriteText( msg ); | |
573 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
574 | textCtrl.WriteText( msg ); | |
575 | textCtrl.WriteText( "\n\n" ); | |
576 | ||
577 | ||
578 | char buf[2000]; | |
579 | ||
580 | textCtrl.WriteText( "Reading 500 bytes:\n\n" ); | |
581 | ||
582 | buf_input.Read( buf, 500 ); | |
583 | ||
584 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
585 | switch (buf_input.LastError()) | |
586 | { | |
587 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
588 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
589 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
590 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
591 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
592 | } | |
593 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
594 | textCtrl.WriteText( msg ); | |
595 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
596 | textCtrl.WriteText( msg ); | |
597 | textCtrl.WriteText( "\n\n" ); | |
598 | ||
599 | textCtrl.WriteText( "Reading another 500 bytes:\n\n" ); | |
600 | ||
601 | buf_input.Read( buf, 500 ); | |
602 | ||
603 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
604 | switch (buf_input.LastError()) | |
605 | { | |
606 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
607 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
608 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
609 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
610 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
611 | } | |
612 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
613 | textCtrl.WriteText( msg ); | |
614 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
615 | textCtrl.WriteText( msg ); | |
616 | textCtrl.WriteText( "\n\n" ); | |
617 | ||
618 | textCtrl.WriteText( "Reading another 500 bytes:\n\n" ); | |
619 | ||
620 | buf_input.Read( buf, 500 ); | |
621 | ||
622 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
623 | switch (buf_input.LastError()) | |
624 | { | |
625 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
626 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
627 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
628 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
629 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
630 | } | |
631 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
632 | textCtrl.WriteText( msg ); | |
633 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
634 | textCtrl.WriteText( msg ); | |
635 | textCtrl.WriteText( "\n\n" ); | |
636 | ||
637 | textCtrl.WriteText( "Reading another 500 bytes:\n\n" ); | |
638 | ||
639 | buf_input.Read( buf, 500 ); | |
640 | ||
641 | textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " ); | |
642 | switch (buf_input.LastError()) | |
643 | { | |
644 | case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break; | |
645 | case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break; | |
646 | case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break; | |
647 | case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break; | |
648 | default: textCtrl.WriteText( "Huh?\n" ); break; | |
649 | } | |
650 | msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() ); | |
651 | textCtrl.WriteText( msg ); | |
652 | msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() ); | |
653 | textCtrl.WriteText( msg ); | |
654 | textCtrl.WriteText( "\n\n" ); | |
655 | } | |
656 | ||
657 | void MyApp::DoStreamDemo5(wxCommandEvent& WXUNUSED(event)) | |
658 | { | |
659 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
660 | ||
661 | textCtrl.Clear(); | |
662 | textCtrl << "\nTesting wxFileInputStream's Peek():\n\n"; | |
663 | ||
664 | char ch; | |
665 | wxString str; | |
666 | ||
667 | textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream:\n\n" ); | |
668 | ||
669 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
670 | for (ch = 0; ch < 10; ch++) | |
671 | file_output.Write( &ch, 1 ); | |
672 | ||
673 | file_output.Sync(); | |
674 | ||
675 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
676 | ||
677 | ch = file_input.Peek(); | |
678 | str.Printf( wxT("First char peeked: %d\n"), (int) ch ); | |
679 | textCtrl.WriteText( str ); | |
680 | ||
681 | ch = file_input.GetC(); | |
682 | str.Printf( wxT("First char read: %d\n"), (int) ch ); | |
683 | textCtrl.WriteText( str ); | |
684 | ||
685 | ch = file_input.Peek(); | |
686 | str.Printf( wxT("Second char peeked: %d\n"), (int) ch ); | |
687 | textCtrl.WriteText( str ); | |
688 | ||
689 | ch = file_input.GetC(); | |
690 | str.Printf( wxT("Second char read: %d\n"), (int) ch ); | |
691 | textCtrl.WriteText( str ); | |
692 | ||
693 | ch = file_input.Peek(); | |
694 | str.Printf( wxT("Third char peeked: %d\n"), (int) ch ); | |
695 | textCtrl.WriteText( str ); | |
696 | ||
697 | ch = file_input.GetC(); | |
698 | str.Printf( wxT("Third char read: %d\n"), (int) ch ); | |
699 | textCtrl.WriteText( str ); | |
700 | ||
701 | ||
702 | textCtrl << "\n\n\nTesting wxMemoryInputStream's Peek():\n\n"; | |
703 | ||
704 | char buf[] = { 0,1,2,3,4,5,6,7,8,9,10 }; | |
705 | wxMemoryInputStream input( buf, 10 ); | |
706 | ||
707 | ch = input.Peek(); | |
708 | str.Printf( wxT("First char peeked: %d\n"), (int) ch ); | |
709 | textCtrl.WriteText( str ); | |
710 | ||
711 | ch = input.GetC(); | |
712 | str.Printf( wxT("First char read: %d\n"), (int) ch ); | |
713 | textCtrl.WriteText( str ); | |
714 | ||
715 | ch = input.Peek(); | |
716 | str.Printf( wxT("Second char peeked: %d\n"), (int) ch ); | |
717 | textCtrl.WriteText( str ); | |
718 | ||
719 | ch = input.GetC(); | |
720 | str.Printf( wxT("Second char read: %d\n"), (int) ch ); | |
721 | textCtrl.WriteText( str ); | |
722 | ||
723 | ch = input.Peek(); | |
724 | str.Printf( wxT("Third char peeked: %d\n"), (int) ch ); | |
725 | textCtrl.WriteText( str ); | |
726 | ||
727 | ch = input.GetC(); | |
728 | str.Printf( wxT("Third char read: %d\n"), (int) ch ); | |
729 | textCtrl.WriteText( str ); | |
730 | } | |
731 | ||
732 | void MyApp::DoStreamDemo6(wxCommandEvent& WXUNUSED(event)) | |
733 | { | |
734 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
735 | ||
736 | textCtrl.Clear(); | |
737 | textCtrl.WriteText( "\nTesting Ungetch():\n\n" ); | |
738 | ||
739 | char ch = 0; | |
740 | size_t pos = 0; | |
741 | wxString str; | |
742 | ||
743 | textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream...\n\n" ); | |
744 | ||
745 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
746 | for (ch = 0; ch < 10; ch++) | |
747 | file_output.Write( &ch, 1 ); | |
748 | ||
749 | file_output.Sync(); | |
750 | ||
751 | textCtrl.WriteText( "Reading char from wxFileInputStream:\n\n" ); | |
752 | ||
753 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
754 | ||
755 | ch = file_input.GetC(); | |
756 | pos = file_input.TellI(); | |
757 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
758 | textCtrl.WriteText( str ); | |
759 | ||
760 | textCtrl.WriteText( "Reading another char from wxFileInputStream:\n\n" ); | |
761 | ||
762 | ch = file_input.GetC(); | |
763 | pos = file_input.TellI(); | |
764 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
765 | textCtrl.WriteText( str ); | |
766 | ||
767 | textCtrl.WriteText( "Reading yet another char from wxFileInputStream:\n\n" ); | |
768 | ||
769 | ch = file_input.GetC(); | |
770 | pos = file_input.TellI(); | |
771 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
772 | textCtrl.WriteText( str ); | |
773 | ||
774 | textCtrl.WriteText( "Now calling Ungetch( 5 ) from wxFileInputStream...\n\n" ); | |
775 | ||
776 | file_input.Ungetch( 5 ); | |
777 | pos = file_input.TellI(); | |
778 | str.Printf( wxT("Now at position %d\n\n"), (int) pos ); | |
779 | textCtrl.WriteText( str ); | |
780 | ||
781 | textCtrl.WriteText( "Reading char from wxFileInputStream:\n\n" ); | |
782 | ||
783 | ch = file_input.GetC(); | |
784 | pos = file_input.TellI(); | |
785 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
786 | textCtrl.WriteText( str ); | |
787 | ||
788 | textCtrl.WriteText( "Reading another char from wxFileInputStream:\n\n" ); | |
789 | ||
790 | ch = file_input.GetC(); | |
791 | pos = file_input.TellI(); | |
792 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
793 | textCtrl.WriteText( str ); | |
794 | ||
795 | textCtrl.WriteText( "Now calling Ungetch( 5 ) from wxFileInputStream again...\n\n" ); | |
796 | ||
797 | file_input.Ungetch( 5 ); | |
798 | pos = file_input.TellI(); | |
799 | str.Printf( wxT("Now at position %d\n\n"), (int) pos ); | |
800 | textCtrl.WriteText( str ); | |
801 | ||
802 | textCtrl.WriteText( "Seeking to pos 3 in wxFileInputStream. This invalidates the writeback buffer.\n\n" ); | |
803 | ||
804 | file_input.SeekI( 3 ); | |
805 | ||
806 | ch = file_input.GetC(); | |
807 | pos = file_input.TellI(); | |
808 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
809 | textCtrl.WriteText( str ); | |
810 | } | |
811 | ||
812 | void MyApp::DoStreamDemo7(wxCommandEvent& WXUNUSED(event)) | |
813 | { | |
814 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
815 | ||
816 | textCtrl.Clear(); | |
817 | textCtrl.WriteText( "\nTesting Ungetch() in buffered input stream:\n\n" ); | |
818 | ||
819 | char ch = 0; | |
820 | size_t pos = 0; | |
821 | wxString str; | |
822 | ||
823 | textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream...\n\n" ); | |
824 | ||
825 | wxFileOutputStream file_output( wxString("test_wx.dat") ); | |
826 | for (ch = 0; ch < 10; ch++) | |
827 | file_output.Write( &ch, 1 ); | |
828 | ||
829 | file_output.Sync(); | |
830 | ||
831 | textCtrl.WriteText( "Reading char from wxBufferedInputStream via wxFileInputStream:\n\n" ); | |
832 | ||
833 | wxFileInputStream file_input( wxString("test_wx.dat") ); | |
834 | wxBufferedInputStream buf_input( file_input ); | |
835 | ||
836 | ch = buf_input.GetC(); | |
837 | pos = buf_input.TellI(); | |
838 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
839 | textCtrl.WriteText( str ); | |
840 | ||
841 | textCtrl.WriteText( "Reading another char from wxBufferedInputStream:\n\n" ); | |
842 | ||
843 | ch = buf_input.GetC(); | |
844 | pos = buf_input.TellI(); | |
845 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
846 | textCtrl.WriteText( str ); | |
847 | ||
848 | textCtrl.WriteText( "Reading yet another char from wxBufferedInputStream:\n\n" ); | |
849 | ||
850 | ch = buf_input.GetC(); | |
851 | pos = buf_input.TellI(); | |
852 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
853 | textCtrl.WriteText( str ); | |
854 | ||
855 | textCtrl.WriteText( "Now calling Ungetch( 5 ) from wxBufferedInputStream...\n\n" ); | |
856 | ||
857 | buf_input.Ungetch( 5 ); | |
858 | pos = buf_input.TellI(); | |
859 | str.Printf( wxT("Now at position %d\n\n"), (int) pos ); | |
860 | textCtrl.WriteText( str ); | |
861 | ||
862 | textCtrl.WriteText( "Reading char from wxBufferedInputStream:\n\n" ); | |
863 | ||
864 | ch = buf_input.GetC(); | |
865 | pos = buf_input.TellI(); | |
866 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
867 | textCtrl.WriteText( str ); | |
868 | ||
869 | textCtrl.WriteText( "Reading another char from wxBufferedInputStream:\n\n" ); | |
870 | ||
871 | ch = buf_input.GetC(); | |
872 | pos = buf_input.TellI(); | |
873 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
874 | textCtrl.WriteText( str ); | |
875 | ||
876 | textCtrl.WriteText( "Now calling Ungetch( 5 ) from wxBufferedInputStream again...\n\n" ); | |
877 | ||
878 | buf_input.Ungetch( 5 ); | |
879 | pos = buf_input.TellI(); | |
880 | str.Printf( wxT("Now at position %d\n\n"), (int) pos ); | |
881 | textCtrl.WriteText( str ); | |
882 | ||
883 | textCtrl.WriteText( "Seeking to pos 3 in wxBufferedInputStream. This invalidates the writeback buffer.\n\n" ); | |
884 | ||
885 | buf_input.SeekI( 3 ); | |
886 | ||
887 | ch = buf_input.GetC(); | |
888 | pos = buf_input.TellI(); | |
889 | str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos ); | |
890 | textCtrl.WriteText( str ); | |
891 | } | |
892 | ||
893 | #if wxUSE_UNICODE | |
894 | void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event)) | |
895 | { | |
896 | wxTextCtrl& textCtrl = * GetTextCtrl(); | |
897 | ||
898 | textCtrl.Clear(); | |
899 | textCtrl << "\nTest wchar_t to char (Unicode to ANSI/Multibyte) converions:"; | |
900 | ||
901 | wxString str; | |
902 |