]> git.saurik.com Git - wxWidgets.git/blob - samples/typetest/typetest.cpp
Correct placement of calling convention keyword: must follow the return type.
[wxWidgets.git] / samples / typetest / typetest.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: typetest.cpp
3 // Purpose: Types wxWidgets sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 #include "wx/variant.h"
24 #include "wx/mimetype.h"
25
26 #include "typetest.h"
27
28 #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__)
29 #include "mondrian.xpm"
30 #endif
31
32 #ifdef new
33 #undef new
34 #endif
35
36 #include "wx/ioswrap.h"
37
38 #if wxUSE_IOSTREAMH
39 #include <fstream.h>
40 #else
41 #include <fstream>
42 #endif
43
44 #include "wx/wfstream.h"
45 #include "wx/datstrm.h"
46 #include "wx/txtstrm.h"
47 #include "wx/mstream.h"
48
49 // Create a new application object
50 IMPLEMENT_APP (MyApp)
51
52 IMPLEMENT_DYNAMIC_CLASS (MyApp, wxApp)
53
54 BEGIN_EVENT_TABLE(MyApp, wxApp)
55 EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo)
56 EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo)
57 #if wxUSE_UNICODE
58 EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo)
59 #endif // wxUSE_UNICODE
60 EVT_MENU(TYPES_STREAM, MyApp::DoStreamDemo)
61 EVT_MENU(TYPES_STREAM2, MyApp::DoStreamDemo2)
62 EVT_MENU(TYPES_STREAM3, MyApp::DoStreamDemo3)
63 EVT_MENU(TYPES_STREAM4, MyApp::DoStreamDemo4)
64 EVT_MENU(TYPES_STREAM5, MyApp::DoStreamDemo5)
65 EVT_MENU(TYPES_STREAM6, MyApp::DoStreamDemo6)
66 EVT_MENU(TYPES_STREAM7, MyApp::DoStreamDemo7)
67 EVT_MENU(TYPES_MIME, MyApp::DoMIMEDemo)
68 END_EVENT_TABLE()
69
70 wxString file_name = wxT("test_wx.dat");
71 wxString file_name2 = wxString(wxT("test_wx2.dat"));
72
73 bool MyApp::OnInit()
74 {
75 if ( !wxApp::OnInit() )
76 return false;
77
78 // Create the main frame window
79 MyFrame *frame = new MyFrame((wxFrame *) NULL, wxT("wxWidgets Types Demo"),
80 wxPoint(50, 50), wxSize(450, 340));
81
82 // Give it an icon
83 frame->SetIcon(wxICON(mondrian));
84
85 // Make a menubar
86 wxMenu *file_menu = new wxMenu;
87
88 file_menu->Append(TYPES_ABOUT, wxT("&About"));
89 file_menu->AppendSeparator();
90 file_menu->Append(TYPES_QUIT, wxT("E&xit\tAlt-X"));
91
92 wxMenu *test_menu = new wxMenu;
93 test_menu->Append(TYPES_VARIANT, wxT("&Variant test"));
94 test_menu->Append(TYPES_BYTEORDER, wxT("&Byteorder test"));
95 #if wxUSE_UNICODE
96 test_menu->Append(TYPES_UNICODE, wxT("&Unicode test"));
97 #endif // wxUSE_UNICODE
98 test_menu->Append(TYPES_STREAM, wxT("&Stream test"));
99 test_menu->Append(TYPES_STREAM2, wxT("&Stream seek test"));
100 test_menu->Append(TYPES_STREAM3, wxT("&Stream error test"));
101 test_menu->Append(TYPES_STREAM4, wxT("&Stream buffer test"));
102 test_menu->Append(TYPES_STREAM5, wxT("&Stream peek test"));
103 test_menu->Append(TYPES_STREAM6, wxT("&Stream ungetch test"));
104 test_menu->Append(TYPES_STREAM7, wxT("&Stream ungetch test for a buffered stream"));
105 test_menu->AppendSeparator();
106 test_menu->Append(TYPES_MIME, wxT("&MIME database test"));
107
108 wxMenuBar *menu_bar = new wxMenuBar;
109 menu_bar->Append(file_menu, wxT("&File"));
110 menu_bar->Append(test_menu, wxT("&Tests"));
111 frame->SetMenuBar(menu_bar);
112
113 m_textCtrl = new wxTextCtrl(frame, wxID_ANY, wxEmptyString,
114 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
115
116 // Show the frame
117 frame->Show(true);
118
119 SetTopWindow(frame);
120
121 return true;
122 }
123
124 void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
125 {
126 wxTextCtrl& textCtrl = * GetTextCtrl();
127
128 textCtrl.Clear();
129 textCtrl << wxT("\nTest fstream vs. wxFileStream:\n\n");
130
131 textCtrl.WriteText( wxT("Writing to ofstream and wxFileOutputStream:\n") );
132
133 wxSTD ofstream std_file_output( "test_std.dat" );
134 wxFileOutputStream file_output( file_name );
135 wxBufferedOutputStream buf_output( file_output );
136 wxTextOutputStream text_output( buf_output );
137
138 wxString tmp;
139 signed int si = 0xFFFFFFFF;
140 tmp.Printf( wxT("Signed int: %d\n"), si );
141 textCtrl.WriteText( tmp );
142 text_output << si << wxT("\n");
143 std_file_output << si << "\n";
144
145 unsigned int ui = 0xFFFFFFFF;
146 tmp.Printf( wxT("Unsigned int: %u\n"), ui );
147 textCtrl.WriteText( tmp );
148 text_output << ui << wxT("\n");
149 std_file_output << ui << "\n";
150
151 double d = 2.01234567890123456789;
152 tmp.Printf( wxT("Double: %f\n"), d );
153 textCtrl.WriteText( tmp );
154 text_output << d << wxT("\n");
155 std_file_output << d << "\n";
156
157 float f = (float)0.00001;
158 tmp.Printf( wxT("Float: %f\n"), f );
159 textCtrl.WriteText( tmp );
160 text_output << f << wxT("\n");
161 std_file_output << f << "\n";
162
163 wxString str( wxT("Hello!") );
164 tmp.Printf( wxT("String: %s\n"), str.c_str() );
165 textCtrl.WriteText( tmp );
166 text_output << str << wxT("\n");
167 std_file_output << str.ToAscii() << "\n";
168
169 std_file_output.close();
170
171 textCtrl.WriteText( wxT("\nReading from ifstream:\n") );
172
173 wxSTD ifstream std_file_input( "test_std.dat" );
174
175 std_file_input >> si;
176 tmp.Printf( wxT("Signed int: %d\n"), si );
177 textCtrl.WriteText( tmp );
178
179 std_file_input >> ui;
180 tmp.Printf( wxT("Unsigned int: %u\n"), ui );
181 textCtrl.WriteText( tmp );
182
183 std_file_input >> d;
184 tmp.Printf( wxT("Double: %f\n"), d );
185 textCtrl.WriteText( tmp );
186
187 std_file_input >> f;
188 tmp.Printf( wxT("Float: %f\n"), f );
189 textCtrl.WriteText( tmp );
190
191 char std_buf[200];
192 std_file_input >> std_buf;
193 str = wxString::FromAscii(std_buf);
194 tmp.Printf( wxT("String: %s\n"), str.c_str() );
195 textCtrl.WriteText( tmp );
196
197 textCtrl.WriteText( wxT("\nReading from wxFileInputStream:\n") );
198
199 buf_output.Sync();
200
201 wxFileInputStream file_input( file_name );
202 wxBufferedInputStream buf_input( file_input );
203 wxTextInputStream text_input( file_input );
204
205 text_input >> si;
206 tmp.Printf( wxT("Signed int: %d\n"), si );
207 textCtrl.WriteText( tmp );
208
209 text_input >> ui;
210 tmp.Printf( wxT("Unsigned int: %u\n"), ui );
211 textCtrl.WriteText( tmp );
212
213 text_input >> d;
214 tmp.Printf( wxT("Double: %f\n"), d );
215 textCtrl.WriteText( tmp );
216
217 text_input >> f;
218 tmp.Printf( wxT("Float: %f\n"), f );
219 textCtrl.WriteText( tmp );
220
221 text_input >> str;
222 tmp.Printf( wxT("String: %s\n"), str.c_str() );
223 textCtrl.WriteText( tmp );
224
225
226
227 textCtrl << wxT("\nTest for wxDataStream:\n\n");
228
229 textCtrl.WriteText( wxT("Writing to wxDataOutputStream:\n") );
230
231 file_output.SeekO( 0 );
232 wxDataOutputStream data_output( buf_output );
233
234 wxInt16 i16 = (unsigned short)0xFFFF;
235 tmp.Printf( wxT("Signed int16: %d\n"), (int)i16 );
236 textCtrl.WriteText( tmp );
237 data_output.Write16( i16 );
238
239 wxUint16 ui16 = 0xFFFF;
240 tmp.Printf( wxT("Unsigned int16: %u\n"), (unsigned int) ui16 );
241 textCtrl.WriteText( tmp );
242 data_output.Write16( ui16 );
243
244 d = 2.01234567890123456789;
245 tmp.Printf( wxT("Double: %f\n"), d );
246 textCtrl.WriteText( tmp );
247 data_output.WriteDouble( d );
248
249 str = wxT("Hello!");
250 tmp.Printf( wxT("String: %s\n"), str.c_str() );
251 textCtrl.WriteText( tmp );
252 data_output.WriteString( str );
253
254 buf_output.Sync();
255
256 textCtrl.WriteText( wxT("\nReading from wxDataInputStream:\n") );
257
258 file_input.SeekI( 0 );
259 wxDataInputStream data_input( buf_input );
260
261 i16 = data_input.Read16();
262 tmp.Printf( wxT("Signed int16: %d\n"), (int)i16 );
263 textCtrl.WriteText( tmp );
264
265 ui16 = data_input.Read16();
266 tmp.Printf( wxT("Unsigned int16: %u\n"), (unsigned int) ui16 );
267 textCtrl.WriteText( tmp );
268
269 d = data_input.ReadDouble();
270 tmp.Printf( wxT("Double: %f\n"), d );
271 textCtrl.WriteText( tmp );
272
273 str = data_input.ReadString();
274 tmp.Printf( wxT("String: %s\n"), str.c_str() );
275 textCtrl.WriteText( tmp );
276 }
277
278 void MyApp::DoStreamDemo2(wxCommandEvent& WXUNUSED(event))
279 {
280 wxTextCtrl& textCtrl = * GetTextCtrl();
281
282 textCtrl.Clear();
283 textCtrl << wxT("\nTesting wxBufferedStream:\n\n");
284
285 char ch,ch2;
286
287 textCtrl.WriteText( wxT("Writing number 0 to 9 to buffered wxFileOutputStream:\n\n") );
288
289 wxFileOutputStream file_output( file_name );
290 wxBufferedOutputStream buf_output( file_output );
291 for (ch = 0; ch < 10; ch++)
292 buf_output.Write( &ch, 1 );
293 buf_output.Sync();
294
295 wxFileInputStream file_input( file_name );
296 for (ch2 = 0; ch2 < 10; ch2++)
297 {
298 file_input.Read( &ch, 1 );
299 textCtrl.WriteText( (wxChar)(ch + wxT('0')) );
300 }
301 textCtrl.WriteText( wxT("\n\n\n") );
302
303 textCtrl.WriteText( wxT("Writing number 0 to 9 to buffered wxFileOutputStream, then\n") );
304 textCtrl.WriteText( wxT("seeking back to #3 and writing 0:\n\n") );
305
306 wxFileOutputStream file_output2( file_name2 );
307 wxBufferedOutputStream buf_output2( file_output2 );
308 for (ch = 0; ch < 10; ch++)
309 buf_output2.Write( &ch, 1 );
310 buf_output2.SeekO( 3 );
311 ch = 0;
312 buf_output2.Write( &ch, 1 );
313 buf_output2.Sync();
314
315 wxFileInputStream file_input2( file_name2 );
316 for (ch2 = 0; ch2 < 10; ch2++)
317 {
318 file_input2.Read( &ch, 1 );
319 textCtrl.WriteText( (wxChar)(ch + wxT('0')) );
320 }
321 textCtrl.WriteText( wxT("\n\n\n") );
322
323 // now append 2000 bytes to file (bigger than buffer)
324 buf_output2.SeekO( 0, wxFromEnd );
325 ch = 1;
326 for (int i = 0; i < 2000; i++)
327 buf_output2.Write( &ch, 1 );
328 buf_output2.Sync();
329
330 textCtrl.WriteText( wxT("Reading number 0 to 9 from buffered wxFileInputStream, then\n") );
331 textCtrl.WriteText( wxT("seeking back to #3 and reading the 0:\n\n") );
332
333 wxFileInputStream file_input3( file_name2 );
334 wxBufferedInputStream buf_input3( file_input3 );
335 for (ch2 = 0; ch2 < 10; ch2++)
336 {
337 buf_input3.Read( &ch, 1 );
338 textCtrl.WriteText( (wxChar)(ch + wxT('0')) );
339 }
340 for (int j = 0; j < 2000; j++)
341 buf_input3.Read( &ch, 1 );
342 textCtrl.WriteText( wxT("\n") );
343 buf_input3.SeekI( 3 );
344 buf_input3.Read( &ch, 1 );
345 textCtrl.WriteText( (wxChar)(ch + wxT('0')) );
346 textCtrl.WriteText( wxT("\n\n\n") );
347
348 }
349
350 void MyApp::DoStreamDemo3(wxCommandEvent& WXUNUSED(event))
351 {
352 wxTextCtrl& textCtrl = * GetTextCtrl();
353
354 textCtrl.Clear();
355 textCtrl << wxT("\nTesting wxFileInputStream's and wxFFileInputStream's error handling:\n\n");
356
357 char ch,ch2;
358
359 textCtrl.WriteText( wxT("Writing number 0 to 9 to wxFileOutputStream:\n\n") );
360
361 wxFileOutputStream file_output( file_name );
362 for (ch = 0; ch < 10; ch++)
363 file_output.Write( &ch, 1 );
364
365 // Testing wxFileInputStream
366
367 textCtrl.WriteText( wxT("Reading 0 to 10 to wxFileInputStream:\n\n") );
368
369 wxFileInputStream file_input( file_name );
370 for (ch2 = 0; ch2 < 11; ch2++)
371 {
372 file_input.Read( &ch, 1 );
373 textCtrl.WriteText( wxT("Value read: ") );
374 textCtrl.WriteText( (wxChar)(ch + '0') );
375 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
376 switch (file_input.GetLastError())
377 {
378 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
379 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
380 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
381 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
382 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
383 }
384 }
385 textCtrl.WriteText( wxT("\n") );
386
387 textCtrl.WriteText( wxT("Seeking to 0; stream.GetLastError() returns: ") );
388 file_input.SeekI( 0 );
389 switch (file_input.GetLastError())
390 {
391 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
392 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
393 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
394 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
395 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
396 }
397 textCtrl.WriteText( wxT("\n") );
398
399 file_input.Read( &ch, 1 );
400 textCtrl.WriteText( wxT("Value read: ") );
401 textCtrl.WriteText( (wxChar)(ch + wxT('0')) );
402 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
403 switch (file_input.GetLastError())
404 {
405 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
406 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
407 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
408 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
409 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
410 }
411 textCtrl.WriteText( wxT("\n\n") );
412
413
414 // Testing wxFFileInputStream
415
416 textCtrl.WriteText( wxT("Reading 0 to 10 to wxFFileInputStream:\n\n") );
417
418 wxFFileInputStream ffile_input( file_name );
419 for (ch2 = 0; ch2 < 11; ch2++)
420 {
421 ffile_input.Read( &ch, 1 );
422 textCtrl.WriteText( wxT("Value read: ") );
423 textCtrl.WriteText( (wxChar)(ch + '0') );
424 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
425 switch (ffile_input.GetLastError())
426 {
427 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
428 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
429 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
430 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
431 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
432 }
433 }
434 textCtrl.WriteText( wxT("\n") );
435
436 textCtrl.WriteText( wxT("Seeking to 0; stream.GetLastError() returns: ") );
437 ffile_input.SeekI( 0 );
438 switch (ffile_input.GetLastError())
439 {
440 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
441 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
442 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
443 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
444 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
445 }
446 textCtrl.WriteText( wxT("\n") );
447
448 ffile_input.Read( &ch, 1 );
449 textCtrl.WriteText( wxT("Value read: ") );
450 textCtrl.WriteText( (wxChar)(ch + '0') );
451 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
452 switch (ffile_input.GetLastError())
453 {
454 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
455 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
456 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
457 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
458 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
459 }
460 textCtrl.WriteText( wxT("\n\n") );
461
462 // Testing wxFFileInputStream
463
464 textCtrl.WriteText( wxT("Reading 0 to 10 to buffered wxFFileInputStream:\n\n") );
465
466 wxFFileInputStream ffile_input2( file_name );
467 wxBufferedInputStream buf_input( ffile_input2 );
468 for (ch2 = 0; ch2 < 11; ch2++)
469 {
470 buf_input.Read( &ch, 1 );
471 textCtrl.WriteText( wxT("Value read: ") );
472 textCtrl.WriteText( (wxChar)(ch + '0') );
473 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
474 switch (buf_input.GetLastError())
475 {
476 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
477 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
478 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
479 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
480 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
481 }
482 }
483 textCtrl.WriteText( wxT("\n") );
484
485 textCtrl.WriteText( wxT("Seeking to 0; stream.GetLastError() returns: ") );
486 buf_input.SeekI( 0 );
487 switch (buf_input.GetLastError())
488 {
489 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
490 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
491 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
492 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
493 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
494 }
495 textCtrl.WriteText( wxT("\n") );
496
497 buf_input.Read( &ch, 1 );
498 textCtrl.WriteText( wxT("Value read: ") );
499 textCtrl.WriteText( (wxChar)(ch + '0') );
500 textCtrl.WriteText( wxT("; stream.GetLastError() returns: ") );
501 switch (buf_input.GetLastError())
502 {
503 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
504 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
505 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
506 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
507 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
508 }
509 }
510
511 void MyApp::DoStreamDemo4(wxCommandEvent& WXUNUSED(event))
512 {
513 wxTextCtrl& textCtrl = * GetTextCtrl();
514
515 wxString msg;
516
517 textCtrl.Clear();
518 textCtrl << wxT("\nTesting wxStreamBuffer:\n\n");
519
520 // bigger than buffer
521 textCtrl.WriteText( wxT("Writing 2000x 1 to wxFileOutputStream.\n\n") );
522
523 wxFileOutputStream file_output( file_name );
524 for (int i = 0; i < 2000; i++)
525 {
526 char ch = 1;
527 file_output.Write( &ch, 1 );
528 }
529
530 textCtrl.WriteText( wxT("Opening with a buffered wxFileInputStream:\n\n") );
531
532 wxFileInputStream file_input( file_name );
533 wxBufferedInputStream buf_input( file_input );
534
535 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
536 switch (buf_input.GetLastError())
537 {
538 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
539 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
540 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
541 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
542 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
543 }
544 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
545 textCtrl.WriteText( msg );
546 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
547 textCtrl.WriteText( msg );
548 textCtrl.WriteText( wxT("\n\n") );
549
550
551 textCtrl.WriteText( wxT("Seeking to position 300:\n\n") );
552
553 buf_input.SeekI( 300 );
554
555 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
556 switch (buf_input.GetLastError())
557 {
558 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
559 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
560 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
561 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
562 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
563 }
564 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
565 textCtrl.WriteText( msg );
566 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
567 textCtrl.WriteText( msg );
568 textCtrl.WriteText( wxT("\n\n") );
569
570
571 char buf[2000];
572
573 textCtrl.WriteText( wxT("Reading 500 bytes:\n\n") );
574
575 buf_input.Read( buf, 500 );
576
577 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
578 switch (buf_input.GetLastError())
579 {
580 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
581 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
582 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
583 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
584 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
585 }
586 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
587 textCtrl.WriteText( msg );
588 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
589 textCtrl.WriteText( msg );
590 textCtrl.WriteText( wxT("\n\n") );
591
592 textCtrl.WriteText( wxT("Reading another 500 bytes:\n\n") );
593
594 buf_input.Read( buf, 500 );
595
596 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
597 switch (buf_input.GetLastError())
598 {
599 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
600 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
601 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
602 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
603 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
604 }
605 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
606 textCtrl.WriteText( msg );
607 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
608 textCtrl.WriteText( msg );
609 textCtrl.WriteText( wxT("\n\n") );
610
611 textCtrl.WriteText( wxT("Reading another 500 bytes:\n\n") );
612
613 buf_input.Read( buf, 500 );
614
615 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
616 switch (buf_input.GetLastError())
617 {
618 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
619 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
620 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
621 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
622 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
623 }
624 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
625 textCtrl.WriteText( msg );
626 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
627 textCtrl.WriteText( msg );
628 textCtrl.WriteText( wxT("\n\n") );
629
630 textCtrl.WriteText( wxT("Reading another 500 bytes:\n\n") );
631
632 buf_input.Read( buf, 500 );
633
634 textCtrl.WriteText( wxT("wxBufferedInputStream.GetLastError() returns: ") );
635 switch (buf_input.GetLastError())
636 {
637 case wxSTREAM_NO_ERROR: textCtrl.WriteText( wxT("wxSTREAM_NO_ERROR\n") ); break;
638 case wxSTREAM_EOF: textCtrl.WriteText( wxT("wxSTREAM_EOF\n") ); break;
639 case wxSTREAM_READ_ERROR: textCtrl.WriteText( wxT("wxSTREAM_READ_ERROR\n") ); break;
640 case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( wxT("wxSTREAM_WRITE_ERROR\n") ); break;
641 default: textCtrl.WriteText( wxT("Huh?\n") ); break;
642 }
643 msg.Printf( wxT("wxBufferedInputStream.LastRead() returns: %d\n"), (int)buf_input.LastRead() );
644 textCtrl.WriteText( msg );
645 msg.Printf( wxT("wxBufferedInputStream.TellI() returns: %d\n"), (int)buf_input.TellI() );
646 textCtrl.WriteText( msg );
647 textCtrl.WriteText( wxT("\n\n") );
648 }
649
650 void MyApp::DoStreamDemo5(wxCommandEvent& WXUNUSED(event))
651 {
652 wxTextCtrl& textCtrl = * GetTextCtrl();
653
654 textCtrl.Clear();
655 textCtrl << wxT("\nTesting wxFileInputStream's Peek():\n\n");
656
657 char ch;
658 wxString str;
659
660 textCtrl.WriteText( wxT("Writing number 0 to 9 to wxFileOutputStream:\n\n") );
661
662 wxFileOutputStream file_output( file_name );
663 for (ch = 0; ch < 10; ch++)
664 file_output.Write( &ch, 1 );
665
666 file_output.Sync();
667
668 wxFileInputStream file_input( file_name );
669
670 ch = file_input.Peek();
671 str.Printf( wxT("First char peeked: %d\n"), (int) ch );
672 textCtrl.WriteText( str );
673
674 ch = file_input.GetC();
675 str.Printf( wxT("First char read: %d\n"), (int) ch );
676 textCtrl.WriteText( str );
677
678 ch = file_input.Peek();
679 str.Printf( wxT("Second char peeked: %d\n"), (int) ch );
680 textCtrl.WriteText( str );
681
682 ch = file_input.GetC();
683 str.Printf( wxT("Second char read: %d\n"), (int) ch );
684 textCtrl.WriteText( str );
685
686 ch = file_input.Peek();
687 str.Printf( wxT("Third char peeked: %d\n"), (int) ch );
688 textCtrl.WriteText( str );
689
690 ch = file_input.GetC();
691 str.Printf( wxT("Third char read: %d\n"), (int) ch );
692 textCtrl.WriteText( str );
693
694
695 textCtrl << wxT("\n\n\nTesting wxMemoryInputStream's Peek():\n\n");
696
697 char buf[] = { 0,1,2,3,4,5,6,7,8,9,10 };
698 wxMemoryInputStream input( buf, 10 );
699
700 ch = input.Peek();
701 str.Printf( wxT("First char peeked: %d\n"), (int) ch );
702 textCtrl.WriteText( str );
703
704 ch = input.GetC();
705 str.Printf( wxT("First char read: %d\n"), (int) ch );
706 textCtrl.WriteText( str );
707
708 ch = input.Peek();
709 str.Printf( wxT("Second char peeked: %d\n"), (int) ch );
710 textCtrl.WriteText( str );
711
712 ch = input.GetC();
713 str.Printf( wxT("Second char read: %d\n"), (int) ch );
714 textCtrl.WriteText( str );
715
716 ch = input.Peek();
717 str.Printf( wxT("Third char peeked: %d\n"), (int) ch );
718 textCtrl.WriteText( str );
719
720 ch = input.GetC();
721 str.Printf( wxT("Third char read: %d\n"), (int) ch );
722 textCtrl.WriteText( str );
723 }
724
725 void MyApp::DoStreamDemo6(wxCommandEvent& WXUNUSED(event))
726 {
727 wxTextCtrl& textCtrl = * GetTextCtrl();
728
729 textCtrl.Clear();
730 textCtrl.WriteText( wxT("\nTesting Ungetch():\n\n") );
731
732 char ch = 0;
733 wxString str;
734
735 textCtrl.WriteText( wxT("Writing number 0 to 9 to wxFileOutputStream...\n\n") );
736
737 wxFileOutputStream file_output( file_name );
738 for (ch = 0; ch < 10; ch++)
739 file_output.Write( &ch, 1 );
740
741 file_output.Sync();
742
743 textCtrl.WriteText( wxT("Reading char from wxFileInputStream:\n\n") );
744
745 wxFileInputStream file_input( file_name );
746
747 ch = file_input.GetC();
748 size_t pos = (size_t)file_input.TellI();
749 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
750 textCtrl.WriteText( str );
751
752 textCtrl.WriteText( wxT("Reading another char from wxFileInputStream:\n\n") );
753
754 ch = file_input.GetC();
755 pos = (size_t)file_input.TellI();
756 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
757 textCtrl.WriteText( str );
758
759 textCtrl.WriteText( wxT("Reading yet another char from wxFileInputStream:\n\n") );
760
761 ch = file_input.GetC();
762 pos = (size_t)file_input.TellI();
763 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
764 textCtrl.WriteText( str );
765
766 textCtrl.WriteText( wxT("Now calling Ungetch( 5 ) from wxFileInputStream...\n\n") );
767
768 file_input.Ungetch( 5 );
769 pos = (size_t)file_input.TellI();
770 str.Printf( wxT("Now at position %d\n\n"), (int) pos );
771 textCtrl.WriteText( str );
772
773 textCtrl.WriteText( wxT("Reading char from wxFileInputStream:\n\n") );
774
775 ch = file_input.GetC();
776 pos = (size_t)file_input.TellI();
777 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
778 textCtrl.WriteText( str );
779
780 textCtrl.WriteText( wxT("Reading another char from wxFileInputStream:\n\n") );
781
782 ch = file_input.GetC();
783 pos = (size_t)file_input.TellI();
784 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
785 textCtrl.WriteText( str );
786
787 textCtrl.WriteText( wxT("Now calling Ungetch( 5 ) from wxFileInputStream again...\n\n") );
788
789 file_input.Ungetch( 5 );
790 pos = (size_t)file_input.TellI();
791 str.Printf( wxT("Now at position %d\n\n"), (int) pos );
792 textCtrl.WriteText( str );
793
794 textCtrl.WriteText( wxT("Seeking to pos 3 in wxFileInputStream. This invalidates the writeback buffer.\n\n") );
795
796 file_input.SeekI( 3 );
797
798 ch = file_input.GetC();
799 pos = (size_t)file_input.TellI();
800 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
801 textCtrl.WriteText( str );
802 }
803
804 void MyApp::DoStreamDemo7(wxCommandEvent& WXUNUSED(event))
805 {
806 wxTextCtrl& textCtrl = * GetTextCtrl();
807
808 textCtrl.Clear();
809 textCtrl.WriteText( wxT("\nTesting Ungetch() in buffered input stream:\n\n") );
810
811 char ch = 0;
812 wxString str;
813
814 textCtrl.WriteText( wxT("Writing number 0 to 9 to wxFileOutputStream...\n\n") );
815
816 wxFileOutputStream file_output( file_name );
817 for (ch = 0; ch < 10; ch++)
818 file_output.Write( &ch, 1 );
819
820 file_output.Sync();
821
822 textCtrl.WriteText( wxT("Reading char from wxBufferedInputStream via wxFileInputStream:\n\n") );
823
824 wxFileInputStream file_input( file_name );
825 wxBufferedInputStream buf_input( file_input );
826
827 ch = buf_input.GetC();
828 size_t pos = (size_t)buf_input.TellI();
829 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
830 textCtrl.WriteText( str );
831
832 textCtrl.WriteText( wxT("Reading another char from wxBufferedInputStream:\n\n") );
833
834 ch = buf_input.GetC();
835 pos = (size_t)buf_input.TellI();
836 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
837 textCtrl.WriteText( str );
838
839 textCtrl.WriteText( wxT("Reading yet another char from wxBufferedInputStream:\n\n") );
840
841 ch = buf_input.GetC();
842 pos = (size_t)buf_input.TellI();
843 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
844 textCtrl.WriteText( str );
845
846 textCtrl.WriteText( wxT("Now calling Ungetch( 5 ) from wxBufferedInputStream...\n\n") );
847
848 buf_input.Ungetch( 5 );
849 pos = (size_t)buf_input.TellI();
850 str.Printf( wxT("Now at position %d\n\n"), (int) pos );
851 textCtrl.WriteText( str );
852
853 textCtrl.WriteText( wxT("Reading char from wxBufferedInputStream:\n\n") );
854
855 ch = buf_input.GetC();
856 pos = (size_t)buf_input.TellI();
857 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
858 textCtrl.WriteText( str );
859
860 textCtrl.WriteText( wxT("Reading another char from wxBufferedInputStream:\n\n") );
861
862 ch = buf_input.GetC();
863 pos = (size_t)buf_input.TellI();
864 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
865 textCtrl.WriteText( str );
866
867 textCtrl.WriteText( wxT("Now calling Ungetch( 5 ) from wxBufferedInputStream again...\n\n") );
868
869 buf_input.Ungetch( 5 );
870 pos = (size_t)buf_input.TellI();
871 str.Printf( wxT("Now at position %d\n\n"), (int) pos );
872 textCtrl.WriteText( str );
873
874 textCtrl.WriteText( wxT("Seeking to pos 3 in wxBufferedInputStream. This invalidates the writeback buffer.\n\n") );
875
876 buf_input.SeekI( 3 );
877
878 ch = buf_input.GetC();
879 pos = (size_t)buf_input.TellI();
880 str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
881 textCtrl.WriteText( str );
882 }
883
884 #if wxUSE_UNICODE
885 void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event))
886 {
887 wxTextCtrl& textCtrl = * GetTextCtrl();
888
889 textCtrl.Clear();
890 textCtrl << wxT("\nTest wchar_t to char (Unicode to ANSI/Multibyte) converions:");
891
892 wxString str;
893 str = wxT("Robert R\366bling\n");
894
895 printf( "\n\nConversion with wxConvLocal:\n" );
896 wxConvCurrent = &wxConvLocal;
897 printf( (const char*) str.mbc_str() );
898 printf( "\n\nConversion with wxConvLibc:\n" );
899 wxConvCurrent = &wxConvLibc;
900 printf( (const char*) str.mbc_str() );
901
902 }
903 #endif
904
905 void MyApp::DoMIMEDemo(wxCommandEvent& WXUNUSED(event))
906 {
907 static wxString s_defaultExt = wxT("xyz");
908
909 wxString ext = wxGetTextFromUser(wxT("Enter a file extension: "),
910 wxT("MIME database test"),
911 s_defaultExt);
912 if ( !!ext )
913 {
914 s_defaultExt = ext;
915
916 // init MIME database if not done yet
917 if ( !m_mimeDatabase )
918 {
919 m_mimeDatabase = new wxMimeTypesManager;
920
921 static const wxFileTypeInfo fallbacks[] =
922 {
923 wxFileTypeInfo(wxT("application/xyz"),
924 wxT("XyZ %s"),
925 wxT("XyZ -p %s"),
926 wxT("The one and only XYZ format file"),
927 wxT("xyz"), wxT("123"), wxNullPtr),
928 wxFileTypeInfo(wxT("text/html"),
929 wxT("lynx %s"),
930 wxT("lynx -dump %s | lpr"),
931 wxT("HTML document (from fallback)"),
932 wxT("htm"), wxT("html"), wxNullPtr),
933
934 // must terminate the table with this!
935 wxFileTypeInfo()
936 };
937
938 m_mimeDatabase->AddFallbacks(fallbacks);
939 }
940
941 wxTextCtrl& textCtrl = * GetTextCtrl();
942
943 wxFileType *filetype = m_mimeDatabase->GetFileTypeFromExtension(ext);
944 if ( !filetype )
945 {
946 textCtrl << wxT("Unknown extension '") << ext << wxT("'\n");
947 }
948 else
949 {
950 wxString type, desc, open;
951 filetype->GetMimeType(&type);
952 filetype->GetDescription(&desc);
953
954 wxString filename = wxT("filename");
955 filename << wxT(".") << ext;
956 wxFileType::MessageParameters params(filename, type);
957 filetype->GetOpenCommand(&open, params);
958
959 textCtrl << wxT("MIME information about extension '") << ext << wxT('\n')
960 << wxT("\tMIME type: ") << ( !type ? wxString("unknown") : type ) << wxT('\n')
961 << wxT("\tDescription: ") << ( !desc ? wxString(wxEmptyString) : desc )
962 << wxT('\n')
963 << wxT("\tCommand to open: ") << ( !open ? wxString("no") : open )
964 << wxT('\n');
965
966 delete filetype;
967 }
968 }
969 //else: cancelled by user
970 }
971
972 void MyApp::DoByteOrderDemo(wxCommandEvent& WXUNUSED(event))
973 {
974 wxTextCtrl& textCtrl = * GetTextCtrl();
975
976 textCtrl.Clear();
977 textCtrl << wxT("\nTest byte order macros:\n\n");
978
979 #if wxBYTE_ORDER == wxLITTLE_ENDIAN
980 textCtrl << wxT("This is a little endian system.\n\n");
981 #else
982 textCtrl << wxT("This is a big endian system.\n\n");
983 #endif
984
985 wxString text;
986
987 wxInt32 var = 0xF1F2F3F4;
988 text = wxEmptyString;
989 text.Printf( wxT("Value of wxInt32 is now: %#x.\n\n"), var );
990 textCtrl.WriteText( text );
991
992 text = wxEmptyString;
993 text.Printf( wxT("Value of swapped wxInt32 is: %#x.\n\n"), wxINT32_SWAP_ALWAYS( var ) );
994 textCtrl.WriteText( text );
995
996 text = wxEmptyString;
997 text.Printf( wxT("Value of wxInt32 swapped on little endian is: %#x.\n\n"), wxINT32_SWAP_ON_LE( var ) );
998 textCtrl.WriteText( text );
999
1000 text = wxEmptyString;
1001 text.Printf( wxT("Value of wxInt32 swapped on big endian is: %#x.\n\n"), wxINT32_SWAP_ON_BE( var ) );
1002 textCtrl.WriteText( text );
1003 }
1004
1005 void MyApp::DoVariantDemo(wxCommandEvent& WXUNUSED(event) )
1006 {
1007 wxTextCtrl& textCtrl = * GetTextCtrl();
1008
1009 wxVariant var1 = wxT("String value");
1010 textCtrl << wxT("var1 = ") << var1.MakeString() << wxT("\n");
1011
1012 // Conversion
1013 wxString str = var1.MakeString();
1014
1015 var1 = 123.456;
1016 textCtrl << wxT("var1 = ") << var1.GetReal() << wxT("\n");
1017
1018 // Implicit conversion
1019 double v = var1;
1020
1021 var1 = 9876L;
1022 textCtrl << wxT("var1 = ") << var1.GetLong() << wxT("\n");
1023
1024 // Implicit conversion
1025 long l = var1;
1026
1027 // suppress compile warnings about unused variables
1028 wxUnusedVar(l);
1029 wxUnusedVar(v);
1030
1031 wxArrayString stringArray;
1032 stringArray.Add(wxT("one")); stringArray.Add(wxT("two")); stringArray.Add(wxT("three"));
1033 var1 = stringArray;
1034 textCtrl << wxT("var1 = ") << var1.MakeString() << wxT("\n");
1035
1036 var1.ClearList();
1037 var1.Append(wxVariant(1.2345));
1038 var1.Append(wxVariant(wxT("hello")));
1039 var1.Append(wxVariant(54321L));
1040
1041 textCtrl << wxT("var1 = ") << var1.MakeString() << wxT("\n");
1042
1043 size_t n = var1.GetCount();
1044 size_t i;
1045 for (i = (size_t) 0; i < n; i++)
1046 {
1047 textCtrl << wxT("var1[") << (int) i << wxT("] (type ") << var1[i].GetType() << wxT(") = ") << var1[i].MakeString() << wxT("\n");
1048 }
1049
1050 var1 = wxVariant(new wxFont(wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT)));
1051 textCtrl << wxT("var1 = (wxfont)\"");
1052 wxFont* font = wxGetVariantCast(var1,wxFont);
1053 if (font)
1054 {
1055 textCtrl << font->GetNativeFontInfoDesc() << wxT("\"\n");
1056 }
1057 else
1058 {
1059 textCtrl << wxT("(null)\"\n");
1060 }
1061 }
1062
1063 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
1064 EVT_MENU(TYPES_QUIT, MyFrame::OnQuit)
1065 EVT_MENU(TYPES_ABOUT, MyFrame::OnAbout)
1066 END_EVENT_TABLE()
1067
1068 // My frame constructor
1069 MyFrame::MyFrame(wxFrame *parent, const wxString& title,
1070 const wxPoint& pos, const wxSize& size)
1071 : wxFrame(parent, wxID_ANY, title, pos, size)
1072 {}
1073
1074 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
1075 {
1076 Close(true);
1077 }
1078
1079 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
1080 {
1081 wxMessageDialog dialog(this, wxT("Tests various wxWidgets types"),
1082 wxT("About Types"), wxYES_NO|wxCANCEL);
1083
1084 dialog.ShowModal();
1085 }
1086
1087