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