]> git.saurik.com Git - wxWidgets.git/blob - samples/controls/controls.cpp
fa791e095fe73cee7f16215978e05b656a673dbc
[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->SetBackgroundColour("wheat");
328 tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
329 tc->SetBackgroundColour("wheat");
330 m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
331
332 wxString choices2[] =
333 {
334 "Wonderful",
335 "examples.",
336 };
337
338 panel = new wxPanel(m_notebook);
339 panel->SetBackgroundColour("cadet blue");
340 panel->SetForegroundColour("blue");
341 m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL );
342 m_radio->SetBackgroundColour("wheat");
343 m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL );
344 m_radio->SetBackgroundColour("wheat");
345 (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
346 (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
347 (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(180,130), wxSize(140,30) );
348 (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "Disable", wxPoint(340,130), wxSize(140,30) );
349 m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(160,30) );
350 m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio);
351
352 panel = new wxPanel(m_notebook);
353 panel->SetBackgroundColour("cadet blue");
354 panel->SetForegroundColour("blue");
355 (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) );
356 m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155,-1) );
357 m_gauge->SetBackgroundColour("wheat");
358 m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
359 m_slider->SetBackgroundColour("wheat");
360 (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) );
361 (void)new wxStaticText( panel, -1,
362 "In order see the gauge (aka progress bar)\n"
363 "control do something you have to drag the\n"
364 "handle of the slider to the right.\n"
365 "\n"
366 "This is also supposed to demonstrate how\n"
367 "to use static controls.\n",
368 wxPoint(208,25) );
369 m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
370 }
371
372 void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
373 {
374 int x = 0;
375 int y = 0;
376 GetClientSize( &x, &y );
377
378 if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 );
379 if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
380 }
381
382 void MyPanel::OnPageChanged( wxNotebookEvent &event )
383 {
384 *m_text << "Notebook selection is " << event.GetSelection() << "\n";
385 }
386
387 void MyPanel::OnListBox( wxCommandEvent &event )
388 {
389 m_text->WriteText( "ListBox selection string is: " );
390 m_text->WriteText( event.GetString() );
391 m_text->WriteText( "\n" );
392 }
393
394 void MyPanel::OnListBoxButtons( wxCommandEvent &event )
395 {
396 switch (event.GetId())
397 {
398 case ID_LISTBOX_ENABLE:
399 {
400 m_listbox->Enable( !((bool)event.GetInt()) );
401 break;
402 }
403 case ID_LISTBOX_SEL_NUM:
404 {
405 m_listbox->SetSelection( 2 );
406 break;
407 }
408 case ID_LISTBOX_SEL_STR:
409 {
410 m_listbox->SetStringSelection( "This" );
411 break;
412 }
413 case ID_LISTBOX_CLEAR:
414 {
415 m_listbox->Clear();
416 break;
417 }
418 case ID_LISTBOX_APPEND:
419 {
420 m_listbox->Append( "Hi!" );
421 break;
422 }
423 case ID_LISTBOX_DELETE:
424 {
425 int idx = m_listbox->GetSelection();
426 m_listbox->Delete( idx );
427 break;
428 }
429 case ID_LISTBOX_FONT:
430 {
431 m_listbox->SetFont( *wxITALIC_FONT );
432 break;
433 }
434 }
435 }
436
437 void MyPanel::OnChoice( wxCommandEvent &event )
438 {
439 m_text->WriteText( "Choice selection string is: " );
440 m_text->WriteText( event.GetString() );
441 m_text->WriteText( "\n" );
442 }
443
444 void MyPanel::OnChoiceButtons( wxCommandEvent &event )
445 {
446 switch (event.GetId())
447 {
448 case ID_CHOICE_ENABLE:
449 {
450 m_choice->Enable( !((bool)event.GetInt()) );
451 break;
452 }
453 case ID_CHOICE_SEL_NUM:
454 {
455 m_choice->SetSelection( 2 );
456 break;
457 }
458 case ID_CHOICE_SEL_STR:
459 {
460 m_choice->SetStringSelection( "This" );
461 break;
462 }
463 case ID_CHOICE_CLEAR:
464 {
465 m_choice->Clear();
466 break;
467 }
468 case ID_CHOICE_APPEND:
469 {
470 m_choice->Append( "Hi!" );
471 break;
472 }
473 case ID_CHOICE_DELETE:
474 {
475 int idx = m_choice->GetSelection();
476 m_choice->Delete( idx );
477 break;
478 }
479 case ID_CHOICE_FONT:
480 {
481 m_choice->SetFont( *wxITALIC_FONT );
482 break;
483 }
484 }
485 }
486
487 void MyPanel::OnCombo( wxCommandEvent &event )
488 {
489 m_text->WriteText( "ComboBox selection string is: " );
490 m_text->WriteText( event.GetString() );
491 m_text->WriteText( "\n" );
492 }
493
494 void MyPanel::OnComboButtons( wxCommandEvent &event )
495 {
496 switch (event.GetId())
497 {
498 case ID_COMBO_ENABLE:
499 {
500 m_combo->Enable( !((bool)event.GetInt()) );
501 break;
502 }
503 case ID_COMBO_SEL_NUM:
504 {
505 m_combo->SetSelection( 2 );
506 break;
507 }
508 case ID_COMBO_SEL_STR:
509 {
510 m_combo->SetStringSelection( "This" );
511 break;
512 }
513 case ID_COMBO_CLEAR:
514 {
515 m_combo->Clear();
516 break;
517 }
518 case ID_COMBO_APPEND:
519 {
520 m_combo->Append( "Hi!" );
521 break;
522 }
523 case ID_COMBO_DELETE:
524 {
525 int idx = m_combo->GetSelection();
526 m_combo->Delete( idx );
527 break;
528 }
529 case ID_COMBO_FONT:
530 {
531 m_combo->SetFont( *wxITALIC_FONT );
532 break;
533 }
534 }
535 }
536
537 void MyPanel::OnRadio( wxCommandEvent &event )
538 {
539 m_text->WriteText( "RadioBox selection string is: " );
540 m_text->WriteText( event.GetString() );
541 m_text->WriteText( "\n" );
542 }
543
544 void MyPanel::OnRadioButtons( wxCommandEvent &event )
545 {
546 switch (event.GetId())
547 {
548 case ID_RADIOBOX_ENABLE:
549 {
550 m_radio->Enable( !((bool)event.GetInt()) );
551 break;
552 }
553 case ID_RADIOBOX_SEL_NUM:
554 {
555 m_radio->SetSelection( 2 );
556 break;
557 }
558 case ID_RADIOBOX_SEL_STR:
559 {
560 m_radio->SetStringSelection( "This" );
561 break;
562 }
563 case ID_RADIOBOX_FONT:
564 {
565 m_radio->SetFont( *wxITALIC_FONT );
566 break;
567 }
568 }
569 }
570
571 void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) )
572 {
573 m_fontButton->SetFont( *wxITALIC_FONT );
574 m_text->SetFont( *wxITALIC_FONT );
575 }
576
577 void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
578 {
579 m_gauge->SetValue( m_slider->GetValue() );
580 }
581
582 MyPanel::~MyPanel()
583 {
584 delete m_notebook->GetImageList();
585 }
586
587 //----------------------------------------------------------------------
588 // MyFrame
589 //----------------------------------------------------------------------
590
591 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
592 EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
593 EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
594 END_EVENT_TABLE()
595
596 MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
597 wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
598 {
599 (void)new MyPanel( this, 10, 10, 300, 100 );
600 }
601
602 void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
603 {
604 Close(TRUE);
605 }
606
607 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
608 {
609 wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK );
610 dialog.ShowModal();
611 }