]> git.saurik.com Git - wxWidgets.git/blob - samples/controls/controls.cpp
Big color update with the newest information
[wxWidgets.git] / samples / controls / controls.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: controls.cpp
3 // Purpose: Controls wxWindows sample
4 // Author: Robert Roebling
5 // Modified by:
6 // RCS-ID: $Id$
7 // Copyright: (c) Robert Roebling, Julian Smart
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "controls.h"
13 #endif
14
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 #ifndef WX_PRECOMP
23 #include "wx/wx.h"
24 #endif
25
26 #include "wx/notebook.h"
27 #include "wx/imaglist.h"
28
29 #if defined(__WXGTK__) || defined(__WXMOTIF__)
30 #include "mondrian.xpm"
31 #include "icons/choice.xpm"
32 #include "icons/combo.xpm"
33 #include "icons/list.xpm"
34 #include "icons/radio.xpm"
35 #include "icons/text.xpm"
36 #include "icons/gauge.xpm"
37 #endif
38
39 //----------------------------------------------------------------------
40 // class definitions
41 //----------------------------------------------------------------------
42
43 class MyApp: public wxApp
44 {
45 public:
46 bool OnInit(void);
47 };
48
49 class MyPanel: public wxPanel
50 {
51 public:
52
53 MyPanel(wxFrame *frame, int x, int y, int w, int h);
54 virtual ~MyPanel();
55
56 void OnSize( wxSizeEvent& event );
57 void OnListBox( wxCommandEvent &event );
58 void OnListBoxButtons( wxCommandEvent &event );
59 void OnChoice( wxCommandEvent &event );
60 void OnChoiceButtons( wxCommandEvent &event );
61 void OnCombo( wxCommandEvent &event );
62 void OnComboButtons( wxCommandEvent &event );
63 void OnRadio( wxCommandEvent &event );
64 void OnRadioButtons( wxCommandEvent &event );
65 void OnSetFont( wxCommandEvent &event );
66 void OnPageChanged( wxNotebookEvent &event );
67
68 wxListBox *m_listbox;
69 wxChoice *m_choice;
70 wxComboBox *m_combo;
71 wxRadioBox *m_radio;
72 wxGauge *m_gauge;
73 wxSlider *m_slider;
74 wxButton *m_fontButton;
75
76 wxTextCtrl *m_text;
77 wxNotebook *m_notebook;
78
79 DECLARE_EVENT_TABLE()
80 };
81
82 class MyFrame: public wxFrame
83 {
84 public:
85
86 MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
87
88 public:
89
90 void OnQuit(wxCommandEvent& event);
91 void OnAbout(wxCommandEvent& event);
92 bool OnClose(void) { return TRUE; }
93
94 DECLARE_EVENT_TABLE()
95 };
96
97 //----------------------------------------------------------------------
98 // main()
99 //----------------------------------------------------------------------
100
101 IMPLEMENT_APP (MyApp)
102
103 //----------------------------------------------------------------------
104 // MyApp
105 //----------------------------------------------------------------------
106
107 const int MINIMAL_QUIT = 100;
108 const int MINIMAL_TEXT = 101;
109 const int MINIMAL_ABOUT = 102;
110
111 bool MyApp::OnInit(void)
112 {
113 // Create the main frame window
114 MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Controls wxWindows App", 50, 50, 530, 420 );
115
116 // Give it an icon
117 #ifdef __WXMSW__
118 frame->SetIcon(wxIcon("mondrian"));
119 #else
120 frame->SetIcon(wxIcon( mondrian_xpm ));
121 #endif
122
123 wxMenu *file_menu = new wxMenu;
124
125 file_menu->Append(MINIMAL_ABOUT, "&About");
126 file_menu->Append(MINIMAL_QUIT, "E&xit");
127 wxMenuBar *menu_bar = new wxMenuBar;
128 menu_bar->Append(file_menu, "&File");
129 frame->SetMenuBar(menu_bar);
130
131 frame->Show(TRUE);
132
133 SetTopWindow(frame);
134
135 return TRUE;
136 }
137
138 //----------------------------------------------------------------------
139 // MyPanel
140 //----------------------------------------------------------------------
141
142 const ID_NOTEBOOK = 1000;
143
144 const ID_LISTBOX = 130;
145 const ID_LISTBOX_SEL_NUM = 131;
146 const ID_LISTBOX_SEL_STR = 132;
147 const ID_LISTBOX_CLEAR = 133;
148 const ID_LISTBOX_APPEND = 134;
149 const ID_LISTBOX_DELETE = 135;
150 const ID_LISTBOX_FONT = 136;
151 const ID_LISTBOX_ENABLE = 137;
152
153 const ID_CHOICE = 120;
154 const ID_CHOICE_SEL_NUM = 121;
155 const ID_CHOICE_SEL_STR = 122;
156 const ID_CHOICE_CLEAR = 123;
157 const ID_CHOICE_APPEND = 124;
158 const ID_CHOICE_DELETE = 125;
159 const ID_CHOICE_FONT = 126;
160 const ID_CHOICE_ENABLE = 127;
161
162 const ID_COMBO = 140;
163 const ID_COMBO_SEL_NUM = 141;
164 const ID_COMBO_SEL_STR = 142;
165 const ID_COMBO_CLEAR = 143;
166 const ID_COMBO_APPEND = 144;
167 const ID_COMBO_DELETE = 145;
168 const ID_COMBO_FONT = 146;
169 const ID_COMBO_ENABLE = 147;
170
171 const ID_TEXT = 150;
172
173 const ID_RADIOBOX = 160;
174 const ID_RADIOBOX_SEL_NUM = 161;
175 const ID_RADIOBOX_SEL_STR = 162;
176 const ID_RADIOBOX_FONT = 163;
177 const ID_RADIOBOX_ENABLE = 164;
178
179 const ID_SET_FONT = 170;
180
181 const ID_GAUGE = 180;
182 const ID_SLIDER = 181;
183
184
185 BEGIN_EVENT_TABLE(MyPanel, wxPanel)
186 EVT_SIZE ( MyPanel::OnSize)
187 EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyPanel::OnPageChanged)
188 EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
189 EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons)
190 EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons)
191 EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
192 EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons)
193 EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons)
194 EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons)
195 EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons)
196 EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice)
197 EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons)
198 EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons)
199 EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons)
200 EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons)
201 EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
202 EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons)
203 EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons)
204 EVT_CHOICE (ID_COMBO, MyPanel::OnCombo)
205 EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
206 EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
207 EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
208 EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons)
209 EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons)
210 EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons)
211 EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons)
212 EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio)
213 EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons)
214 EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons)
215 EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons)
216 EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
217 EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
218 END_EVENT_TABLE()
219
220 MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
221 wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
222 {
223 // SetBackgroundColour("cadet blue");
224
225 m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
226 m_text->SetBackgroundColour("wheat");
227
228 m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
229
230 wxString choices[] =
231 {
232 "This",
233 "is one of my",
234 "really",
235 "wonderful",
236 "examples.",
237 };
238
239 // image ids and names
240 enum
241 {
242 Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max
243 };
244
245 // fill the image list
246 #ifdef __WXMSW__
247 const char *aIconNames[] =
248 {
249 "list.xpm", "choice.xpm", "combo.xpm", "text.xpm", "radio.xpm", "gauge.txt"
250 };
251
252 wxASSERT( WXSIZEOF(aIconNames) == Image_Max ); // keep in sync
253
254 wxString strIconDir = "icons/";
255
256 wxImageList *imagelist = new wxImageList(32, 32);
257 for ( size_t n = 0; n < Image_Max; n++ )
258 {
259 imagelist->Add(wxBitmap(strIconDir + aIconNames[n]));
260 }
261 #else
262 wxImageList *imagelist = new wxImageList(32, 32);
263
264 imagelist-> Add( wxBitmap( list_xpm ));
265 imagelist-> Add( wxBitmap( choice_xpm ));
266 imagelist-> Add( wxBitmap( combo_xpm ));
267 imagelist-> Add( wxBitmap( text_xpm ));
268 imagelist-> Add( wxBitmap( radio_xpm ));
269 imagelist-> Add( wxBitmap( gauge_xpm ));
270 #endif
271
272 wxButton *button = (wxButton*)NULL;
273
274 m_notebook->SetImageList(imagelist);
275 m_notebook->SetBackgroundColour("cadet blue");
276
277 wxPanel *panel = (wxPanel*) NULL;
278 panel = new wxPanel(m_notebook);
279 panel->SetBackgroundColour("cadet blue");
280 panel->SetForegroundColour("blue");
281 m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices );
282 m_listbox->SetBackgroundColour("wheat");
283 (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
284 (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
285 (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
286 (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
287 (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
288 button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
289 button->SetForegroundColour( "red" );
290 (void)new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
291 m_notebook->AddPage(panel, "wxList", FALSE, Image_List);
292
293 panel = new wxPanel(m_notebook);
294 // panel->SetBackgroundColour("cadet blue");
295 // panel->SetForegroundColour("blue");
296 m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
297 m_choice->SetBackgroundColour("wheat");
298 (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
299 (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
300 (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
301 (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
302 (void)new wxButton( panel, ID_CHOICE_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
303 (void)new wxButton( panel, ID_CHOICE_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
304 (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
305 m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
306
307 panel = new wxPanel(m_notebook);
308 // panel->SetBackgroundColour("cadet blue");
309 // panel->SetForegroundColour("blue");
310 m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices );
311 // m_combo->SetBackgroundColour("wheat");
312 (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
313 (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
314 (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
315 (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
316 (void)new wxButton( panel, ID_COMBO_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
317 (void)new wxButton( panel, ID_COMBO_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
318 (void)new wxCheckBox( panel, ID_COMBO_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
319 m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo);
320
321 panel = new wxPanel(m_notebook);
322 // panel->SetBackgroundColour("cadet blue");
323 // panel->SetForegroundColour("blue");
324 wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
325 // tc->SetBackgroundColour("wheat");
326 tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
327 // tc->SetBackgroundColour("wheat");
328 m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
329
330 wxString choices2[] =
331 {
332 "Wonderful",
333 "examples.",
334 };
335
336 panel = new wxPanel(m_notebook);
337 // panel->SetBackgroundColour("cadet blue");
338 // panel->SetForegroundColour("blue");
339 m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL );
340 // m_radio->SetBackgroundColour("wheat");
341 m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL );
342 // m_radio->SetBackgroundColour("wheat");
343 (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
344 (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
345 (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(180,130), wxSize(140,30) );
346 (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "Disable", wxPoint(340,130), wxSize(140,30) );
347 m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(160,30) );
348 m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio);
349
350 panel = new wxPanel(m_notebook);
351 // panel->SetBackgroundColour("cadet blue");
352 // panel->SetForegroundColour("blue");
353 (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) );
354 m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155,-1) );
355 // m_gauge->SetBackgroundColour("wheat");
356 m_slider = new wxSlider( panel, -1, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
357 // m_slider->SetBackgroundColour("wheat");
358 m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
359 }
360
361 void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
362 {
363 int x = 0;
364 int y = 0;
365 GetClientSize( &x, &y );
366
367 if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 );
368 if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
369 }
370
371 void MyPanel::OnPageChanged( wxNotebookEvent &event )
372 {
373 *m_text << "Notebook selection is " << event.GetSelection() << "\n";
374 }
375
376 void MyPanel::OnListBox( wxCommandEvent &event )
377 {
378 m_text->WriteText( "ListBox selection string is: " );
379 m_text->WriteText( event.GetString() );
380 m_text->WriteText( "\n" );
381 }
382
383 void MyPanel::OnListBoxButtons( wxCommandEvent &event )
384 {
385 switch (event.GetId())
386 {
387 case ID_LISTBOX_ENABLE:
388 {
389 m_listbox->Enable( !((bool)event.GetInt()) );
390 break;
391 }
392 case ID_LISTBOX_SEL_NUM:
393 {
394 m_listbox->SetSelection( 2 );
395 break;
396 }
397 case ID_LISTBOX_SEL_STR:
398 {
399 m_listbox->SetStringSelection( "This" );
400 break;
401 }
402 case ID_LISTBOX_CLEAR:
403 {
404 m_listbox->Clear();
405 break;
406 }
407 case ID_LISTBOX_APPEND:
408 {
409 m_listbox->Append( "Hi!" );
410 break;
411 }
412 case ID_LISTBOX_DELETE:
413 {
414 int idx = m_listbox->GetSelection();
415 m_listbox->Delete( idx );
416 break;
417 }
418 case ID_LISTBOX_FONT:
419 {
420 m_listbox->SetFont( *wxITALIC_FONT );
421 break;
422 }
423 }
424 }
425
426 void MyPanel::OnChoice( wxCommandEvent &event )
427 {
428 m_text->WriteText( "Choice selection string is: " );
429 m_text->WriteText( event.GetString() );
430 m_text->WriteText( "\n" );
431 }
432
433 void MyPanel::OnChoiceButtons( wxCommandEvent &event )
434 {
435 switch (event.GetId())
436 {
437 case ID_CHOICE_ENABLE:
438 {
439 m_choice->Enable( !((bool)event.GetInt()) );
440 break;
441 }
442 case ID_CHOICE_SEL_NUM:
443 {
444 m_choice->SetSelection( 2 );
445 break;
446 }
447 case ID_CHOICE_SEL_STR:
448 {
449 m_choice->SetStringSelection( "This" );
450 break;
451 }
452 case ID_CHOICE_CLEAR:
453 {
454 m_choice->Clear();
455 break;
456 }
457 case ID_CHOICE_APPEND:
458 {
459 m_choice->Append( "Hi!" );
460 break;
461 }
462 case ID_CHOICE_DELETE:
463 {
464 int idx = m_choice->GetSelection();
465 m_choice->Delete( idx );
466 break;
467 }
468 case ID_CHOICE_FONT:
469 {
470 m_choice->SetFont( *wxITALIC_FONT );
471 break;
472 }
473 }
474 }
475
476 void MyPanel::OnCombo( wxCommandEvent &event )
477 {
478 m_text->WriteText( "ComboBox selection string is: " );
479 m_text->WriteText( event.GetString() );
480 m_text->WriteText( "\n" );
481 }
482
483 void MyPanel::OnComboButtons( wxCommandEvent &event )
484 {
485 switch (event.GetId())
486 {
487 case ID_COMBO_ENABLE:
488 {
489 m_combo->Enable( !((bool)event.GetInt()) );
490 break;
491 }
492 case ID_COMBO_SEL_NUM:
493 {
494 m_combo->SetSelection( 2 );
495 break;
496 }
497 case ID_COMBO_SEL_STR:
498 {
499 m_combo->SetStringSelection( "This" );
500 break;
501 }
502 case ID_COMBO_CLEAR:
503 {
504 m_combo->Clear();
505 break;
506 }
507 case ID_COMBO_APPEND:
508 {
509 m_combo->Append( "Hi!" );
510 break;
511 }
512 case ID_COMBO_DELETE:
513 {
514 int idx = m_combo->GetSelection();
515 m_combo->Delete( idx );
516 break;
517 }
518 case ID_COMBO_FONT:
519 {
520 m_combo->SetFont( *wxITALIC_FONT );
521 break;
522 }
523 }
524 }
525
526 void MyPanel::OnRadio( wxCommandEvent &event )
527 {
528 m_text->WriteText( "RadioBox selection string is: " );
529 m_text->WriteText( event.GetString() );
530 m_text->WriteText( "\n" );
531 }
532
533 void MyPanel::OnRadioButtons( wxCommandEvent &event )
534 {
535 switch (event.GetId())
536 {
537 case ID_RADIOBOX_ENABLE:
538 {
539 m_radio->Enable( !((bool)event.GetInt()) );
540 break;
541 }
542 case ID_RADIOBOX_SEL_NUM:
543 {
544 m_radio->SetSelection( 2 );
545 break;
546 }
547 case ID_RADIOBOX_SEL_STR:
548 {
549 m_radio->SetStringSelection( "This" );
550 break;
551 }
552 case ID_RADIOBOX_FONT:
553 {
554 m_radio->SetFont( *wxITALIC_FONT );
555 break;
556 }
557 }
558 }
559
560 void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) )
561 {
562 m_fontButton->SetFont( *wxITALIC_FONT );
563 m_text->SetFont( *wxITALIC_FONT );
564 }
565
566 MyPanel::~MyPanel()
567 {
568 delete m_notebook->GetImageList();
569 }
570
571 //----------------------------------------------------------------------
572 // MyFrame
573 //----------------------------------------------------------------------
574
575 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
576 EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
577 EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
578 END_EVENT_TABLE()
579
580 MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
581 wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
582 {
583 (void)new MyPanel( this, 10, 10, 300, 100 );
584 }
585
586 void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
587 {
588 Close(TRUE);
589 }
590
591 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
592 {
593 wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK );
594 dialog.ShowModal();
595 }