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