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