]>
git.saurik.com Git - wxWidgets.git/blob - samples/controls/controls.cpp
0fba093a1ff10286e54740b40142e5dfe772f626
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Controls wxWindows sample
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling, Julian Smart
8 // Licence: wxWindows license
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "controls.h"
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
26 #include "wx/spinbutt.h"
27 #include "wx/notebook.h"
28 #include "wx/imaglist.h"
29 #include "wx/clipbrd.h"
31 // XPM doesn't seem to work under Windows at present. Or, wxNotebook images
33 // Uncomment this line and comment out the next to try it.
34 // #if defined(__WXGTK__) || defined(__WXMOTIF__) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
35 #if defined(__WXGTK__) || defined(__WXMOTIF__)
40 #include "mondrian.xpm"
41 #include "icons/choice.xpm"
42 #include "icons/combo.xpm"
43 #include "icons/list.xpm"
44 #include "icons/radio.xpm"
45 #include "icons/text.xpm"
46 #include "icons/gauge.xpm"
49 //----------------------------------------------------------------------
51 //----------------------------------------------------------------------
53 class MyApp
: public wxApp
59 class MyPanel
: public wxPanel
63 MyPanel(wxFrame
*frame
, int x
, int y
, int w
, int h
);
66 void OnSize( wxSizeEvent
& event
);
67 void OnListBox( wxCommandEvent
&event
);
68 void OnListBoxButtons( wxCommandEvent
&event
);
69 void OnChoice( wxCommandEvent
&event
);
70 void OnChoiceButtons( wxCommandEvent
&event
);
71 void OnCombo( wxCommandEvent
&event
);
72 void OnComboButtons( wxCommandEvent
&event
);
73 void OnRadio( wxCommandEvent
&event
);
74 void OnRadioButtons( wxCommandEvent
&event
);
75 void OnSetFont( wxCommandEvent
&event
);
76 void OnPageChanged( wxNotebookEvent
&event
);
77 void OnSliderUpdate( wxCommandEvent
&event
);
78 void OnSpinUpdate( wxSpinEvent
&event
);
79 void OnPasteFromClipboard( wxCommandEvent
&event
);
80 void OnCopyToClipboard( wxCommandEvent
&event
);
81 void OnCutToClipboard( wxCommandEvent
&event
);
89 wxButton
*m_fontButton
;
90 wxSpinButton
*m_spinbutton
;
91 wxTextCtrl
*m_spintext
;
92 wxTextCtrl
*m_multitext
;
93 wxCheckBox
*m_checkbox
;
96 wxNotebook
*m_notebook
;
101 class MyFrame
: public wxFrame
105 MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
);
109 void OnQuit(wxCommandEvent
& event
);
110 void OnAbout(wxCommandEvent
& event
);
111 bool OnClose(void) { return TRUE
; }
113 DECLARE_EVENT_TABLE()
116 //----------------------------------------------------------------------
118 //----------------------------------------------------------------------
120 IMPLEMENT_APP (MyApp
)
122 //----------------------------------------------------------------------
124 //----------------------------------------------------------------------
126 const int MINIMAL_QUIT
= 100;
127 const int MINIMAL_TEXT
= 101;
128 const int MINIMAL_ABOUT
= 102;
130 bool MyApp::OnInit(void)
132 // Create the main frame window
133 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, (char *) "Controls wxWindows App", 50, 50, 530, 420 );
136 // The wxICON() macros loads an icon from a resource under Windows
137 // and uses an #included XPM image under GTK+ and Motif
139 frame
->SetIcon( wxICON(mondrian
) );
141 wxMenu
*file_menu
= new wxMenu
;
143 file_menu
->Append(MINIMAL_ABOUT
, "&About");
144 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
145 wxMenuBar
*menu_bar
= new wxMenuBar
;
146 menu_bar
->Append(file_menu
, "&File");
147 frame
->SetMenuBar(menu_bar
);
156 //----------------------------------------------------------------------
158 //----------------------------------------------------------------------
160 const int ID_NOTEBOOK
= 1000;
162 const int ID_LISTBOX
= 130;
163 const int ID_LISTBOX_SEL_NUM
= 131;
164 const int ID_LISTBOX_SEL_STR
= 132;
165 const int ID_LISTBOX_CLEAR
= 133;
166 const int ID_LISTBOX_APPEND
= 134;
167 const int ID_LISTBOX_DELETE
= 135;
168 const int ID_LISTBOX_FONT
= 136;
169 const int ID_LISTBOX_ENABLE
= 137;
171 const int ID_CHOICE
= 120;
172 const int ID_CHOICE_SEL_NUM
= 121;
173 const int ID_CHOICE_SEL_STR
= 122;
174 const int ID_CHOICE_CLEAR
= 123;
175 const int ID_CHOICE_APPEND
= 124;
176 const int ID_CHOICE_DELETE
= 125;
177 const int ID_CHOICE_FONT
= 126;
178 const int ID_CHOICE_ENABLE
= 127;
180 const int ID_COMBO
= 140;
181 const int ID_COMBO_SEL_NUM
= 141;
182 const int ID_COMBO_SEL_STR
= 142;
183 const int ID_COMBO_CLEAR
= 143;
184 const int ID_COMBO_APPEND
= 144;
185 const int ID_COMBO_DELETE
= 145;
186 const int ID_COMBO_FONT
= 146;
187 const int ID_COMBO_ENABLE
= 147;
189 const int ID_TEXT
= 150;
190 const int ID_PASTE_TEXT
= 151;
191 const int ID_COPY_TEXT
= 152;
192 const int ID_CUT_TEXT
= 153;
194 const int ID_RADIOBOX
= 160;
195 const int ID_RADIOBOX_SEL_NUM
= 161;
196 const int ID_RADIOBOX_SEL_STR
= 162;
197 const int ID_RADIOBOX_FONT
= 163;
198 const int ID_RADIOBOX_ENABLE
= 164;
200 const int ID_RADIOBUTTON_1
= 166;
201 const int ID_RADIOBUTTON_2
= 167;
203 const int ID_SET_FONT
= 170;
205 const int ID_GAUGE
= 180;
206 const int ID_SLIDER
= 181;
208 const int ID_SPIN
= 182;
211 BEGIN_EVENT_TABLE(MyPanel
, wxPanel
)
212 EVT_SIZE ( MyPanel::OnSize
)
213 EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK
, MyPanel::OnPageChanged
)
214 EVT_LISTBOX (ID_LISTBOX
, MyPanel::OnListBox
)
215 EVT_BUTTON (ID_LISTBOX_SEL_NUM
, MyPanel::OnListBoxButtons
)
216 EVT_BUTTON (ID_LISTBOX_SEL_STR
, MyPanel::OnListBoxButtons
)
217 EVT_BUTTON (ID_LISTBOX_CLEAR
, MyPanel::OnListBoxButtons
)
218 EVT_BUTTON (ID_LISTBOX_APPEND
, MyPanel::OnListBoxButtons
)
219 EVT_BUTTON (ID_LISTBOX_DELETE
, MyPanel::OnListBoxButtons
)
220 EVT_BUTTON (ID_LISTBOX_FONT
, MyPanel::OnListBoxButtons
)
221 EVT_CHECKBOX (ID_LISTBOX_ENABLE
, MyPanel::OnListBoxButtons
)
222 EVT_CHOICE (ID_CHOICE
, MyPanel::OnChoice
)
223 EVT_BUTTON (ID_CHOICE_SEL_NUM
, MyPanel::OnChoiceButtons
)
224 EVT_BUTTON (ID_CHOICE_SEL_STR
, MyPanel::OnChoiceButtons
)
225 EVT_BUTTON (ID_CHOICE_CLEAR
, MyPanel::OnChoiceButtons
)
226 EVT_BUTTON (ID_CHOICE_APPEND
, MyPanel::OnChoiceButtons
)
227 EVT_BUTTON (ID_CHOICE_DELETE
, MyPanel::OnChoiceButtons
)
228 EVT_BUTTON (ID_CHOICE_FONT
, MyPanel::OnChoiceButtons
)
229 EVT_CHECKBOX (ID_CHOICE_ENABLE
, MyPanel::OnChoiceButtons
)
230 EVT_CHOICE (ID_COMBO
, MyPanel::OnCombo
)
231 EVT_BUTTON (ID_COMBO_SEL_NUM
, MyPanel::OnComboButtons
)
232 EVT_BUTTON (ID_COMBO_SEL_STR
, MyPanel::OnComboButtons
)
233 EVT_BUTTON (ID_COMBO_CLEAR
, MyPanel::OnComboButtons
)
234 EVT_BUTTON (ID_COMBO_APPEND
, MyPanel::OnComboButtons
)
235 EVT_BUTTON (ID_COMBO_DELETE
, MyPanel::OnComboButtons
)
236 EVT_BUTTON (ID_COMBO_FONT
, MyPanel::OnComboButtons
)
237 EVT_CHECKBOX (ID_COMBO_ENABLE
, MyPanel::OnComboButtons
)
238 EVT_RADIOBOX (ID_RADIOBOX
, MyPanel::OnRadio
)
239 EVT_BUTTON (ID_RADIOBOX_SEL_NUM
, MyPanel::OnRadioButtons
)
240 EVT_BUTTON (ID_RADIOBOX_SEL_STR
, MyPanel::OnRadioButtons
)
241 EVT_BUTTON (ID_RADIOBOX_FONT
, MyPanel::OnRadioButtons
)
242 EVT_CHECKBOX (ID_RADIOBOX_ENABLE
, MyPanel::OnRadioButtons
)
243 EVT_BUTTON (ID_SET_FONT
, MyPanel::OnSetFont
)
244 EVT_SLIDER (ID_SLIDER
, MyPanel::OnSliderUpdate
)
245 EVT_SPIN (ID_SPIN
, MyPanel::OnSpinUpdate
)
246 EVT_BUTTON (ID_PASTE_TEXT
, MyPanel::OnPasteFromClipboard
)
247 EVT_BUTTON (ID_COPY_TEXT
, MyPanel::OnCopyToClipboard
)
248 EVT_BUTTON (ID_CUT_TEXT
, MyPanel::OnCutToClipboard
)
251 MyPanel::MyPanel( wxFrame
*frame
, int x
, int y
, int w
, int h
) :
252 wxPanel( frame
, -1, wxPoint(x
, y
), wxSize(w
, h
) )
254 // SetBackgroundColour("cadet blue");
256 m_text
= new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE
);
257 // m_text->SetBackgroundColour("wheat");
259 m_notebook
= new wxNotebook( this, ID_NOTEBOOK
, wxPoint(0,0), wxSize(200,150) );
271 // image ids and names
274 Image_List
, Image_Choice
, Image_Combo
, Image_Text
, Image_Radio
, Image_Gauge
, Image_Max
277 // fill the image list
278 wxImageList
*imagelist
= new wxImageList(32, 32);
280 imagelist
-> Add( wxBitmap( list_xpm
));
281 imagelist
-> Add( wxBitmap( choice_xpm
));
282 imagelist
-> Add( wxBitmap( combo_xpm
));
283 imagelist
-> Add( wxBitmap( text_xpm
));
284 imagelist
-> Add( wxBitmap( radio_xpm
));
285 imagelist
-> Add( wxBitmap( gauge_xpm
));
286 m_notebook
->SetImageList(imagelist
);
290 #define Image_List -1
291 #define Image_Choice -1
292 #define Image_Combo -1
293 #define Image_Text -1
294 #define Image_Radio -1
295 #define Image_Gauge -1
300 wxButton
*button
= (wxButton
*)NULL
;
302 // m_notebook->SetBackgroundColour("cadet blue");
304 wxPanel
*panel
= (wxPanel
*) NULL
;
305 panel
= new wxPanel(m_notebook
);
306 // panel->SetBackgroundColour("cadet blue");
307 // panel->SetForegroundColour("blue");
308 m_listbox
= new wxListBox( panel
, ID_LISTBOX
, wxPoint(10,10), wxSize(120,70), 5, choices
);
309 // m_listbox->SetBackgroundColour("wheat");
310 (void)new wxButton( panel
, ID_LISTBOX_SEL_NUM
, "Select #2", wxPoint(180,30), wxSize(140,30) );
311 (void)new wxButton( panel
, ID_LISTBOX_SEL_STR
, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
312 (void)new wxButton( panel
, ID_LISTBOX_CLEAR
, "Clear", wxPoint(180,80), wxSize(140,30) );
313 (void)new wxButton( panel
, ID_LISTBOX_APPEND
, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
314 (void)new wxButton( panel
, ID_LISTBOX_DELETE
, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
315 button
= new wxButton( panel
, ID_LISTBOX_FONT
, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
316 // button->SetForegroundColour( "red" );
317 m_checkbox
= new wxCheckBox( panel
, ID_LISTBOX_ENABLE
, "Disable", wxPoint(20,130), wxSize(140,30) );
318 m_notebook
->AddPage(panel
, "wxList", FALSE
, Image_List
);
320 panel
= new wxPanel(m_notebook
);
321 // panel->SetBackgroundColour("cadet blue");
322 // panel->SetForegroundColour("blue");
323 m_choice
= new wxChoice( panel
, ID_CHOICE
, wxPoint(10,10), wxSize(120,-1), 5, choices
);
324 // m_choice->SetBackgroundColour("wheat");
325 (void)new wxButton( panel
, ID_CHOICE_SEL_NUM
, "Select #2", wxPoint(180,30), wxSize(140,30) );
326 (void)new wxButton( panel
, ID_CHOICE_SEL_STR
, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
327 (void)new wxButton( panel
, ID_CHOICE_CLEAR
, "Clear", wxPoint(180,80), wxSize(140,30) );
328 (void)new wxButton( panel
, ID_CHOICE_APPEND
, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
329 (void)new wxButton( panel
, ID_CHOICE_DELETE
, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
330 (void)new wxButton( panel
, ID_CHOICE_FONT
, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
331 (void)new wxCheckBox( panel
, ID_CHOICE_ENABLE
, "Disable", wxPoint(20,130), wxSize(140,30) );
332 m_notebook
->AddPage(panel
, "wxChoice", FALSE
, Image_Choice
);
334 panel
= new wxPanel(m_notebook
);
335 // panel->SetBackgroundColour("cadet blue");
336 // panel->SetForegroundColour("blue");
337 m_combo
= new wxComboBox( panel
, ID_COMBO
, "This", wxPoint(10,10), wxSize(120,-1), 5, choices
);
338 // m_combo->SetBackgroundColour("wheat");
339 (void)new wxButton( panel
, ID_COMBO_SEL_NUM
, "Select #2", wxPoint(180,30), wxSize(140,30) );
340 (void)new wxButton( panel
, ID_COMBO_SEL_STR
, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
341 (void)new wxButton( panel
, ID_COMBO_CLEAR
, "Clear", wxPoint(180,80), wxSize(140,30) );
342 (void)new wxButton( panel
, ID_COMBO_APPEND
, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
343 (void)new wxButton( panel
, ID_COMBO_DELETE
, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
344 (void)new wxButton( panel
, ID_COMBO_FONT
, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
345 (void)new wxCheckBox( panel
, ID_COMBO_ENABLE
, "Disable", wxPoint(20,130), wxSize(140,30) );
346 m_notebook
->AddPage(panel
, "wxComboBox", FALSE
, Image_Combo
);
348 panel
= new wxPanel(m_notebook
);
349 // panel->SetBackgroundColour("cadet blue");
350 // panel->SetForegroundColour("blue");
351 wxTextCtrl
*tc
= new wxTextCtrl( panel
, ID_TEXT
, "Write text here.", wxPoint(10,10), wxSize(320,28));
352 (*tc
) << " More text.";
353 // tc->SetBackgroundColour("wheat");
354 m_multitext
= new wxTextCtrl( panel
, ID_TEXT
, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE
);
355 (*m_multitext
) << " More text.";
356 // m_multitext->SetBackgroundColour("wheat");
357 (void)new wxStaticBox( panel
, -1, "wxClipboard", wxPoint(345,50), wxSize(160,145) );
358 (void)new wxButton( panel
, ID_COPY_TEXT
, "Copy line 1", wxPoint(370,70), wxSize(110,30) );
359 (void)new wxButton( panel
, ID_PASTE_TEXT
, "Paste text", wxPoint(370,110), wxSize(110,30) );
360 (void)new wxButton( panel
, ID_CUT_TEXT
, "Cut line 1", wxPoint(370,150), wxSize(110,30) );
361 m_notebook
->AddPage(panel
, "wxTextCtrl" , FALSE
, Image_Text
);
363 wxString choices2
[] =
369 panel
= new wxPanel(m_notebook
);
370 // panel->SetBackgroundColour("cadet blue");
371 // panel->SetForegroundColour("blue");
372 m_radio
= new wxRadioBox( panel
, ID_RADIOBOX
, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2
, 1, wxRA_VERTICAL
);
373 // m_radio->SetBackgroundColour("wheat");
374 m_radio
= new wxRadioBox( panel
, ID_RADIOBOX
, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices
, 1, wxRA_HORIZONTAL
);
375 // m_radio->SetBackgroundColour("wheat");
376 (void)new wxButton( panel
, ID_RADIOBOX_SEL_NUM
, "Select #2", wxPoint(180,30), wxSize(140,30) );
377 (void)new wxButton( panel
, ID_RADIOBOX_SEL_STR
, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
378 m_fontButton
= new wxButton( panel
, ID_SET_FONT
, "Set more Italic font", wxPoint(340,30), wxSize(140,30) );
379 m_fontButton
->SetForegroundColour("blue");
380 (void)new wxButton( panel
, ID_RADIOBOX_FONT
, "Set Italic font", wxPoint(340,80), wxSize(140,30) );
381 (void)new wxCheckBox( panel
, ID_RADIOBOX_ENABLE
, "Disable", wxPoint(340,130), wxSize(140,30) );
382 wxRadioButton
*rb
= new wxRadioButton( panel
, ID_RADIOBUTTON_1
, "Radiobutton1", wxPoint(210,170), wxSize(110,30) );
383 rb
->SetValue( FALSE
);
384 (void)new wxRadioButton( panel
, ID_RADIOBUTTON_2
, "Radiobutton2", wxPoint(340,170), wxSize(110,30) );
385 m_notebook
->AddPage(panel
, "wxRadioBox", FALSE
, Image_Radio
);
387 panel
= new wxPanel(m_notebook
);
388 // panel->SetBackgroundColour("cadet blue");
389 // panel->SetForegroundColour("blue");
390 (void)new wxStaticBox( panel
, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) );
391 m_gauge
= new wxGauge( panel
, -1, 200, wxPoint(18,50), wxSize(155,-1) );
392 // m_gauge->SetBackgroundColour("wheat");
393 m_slider
= new wxSlider( panel
, ID_SLIDER
, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
394 // m_slider->SetBackgroundColour("wheat");
395 (void)new wxStaticBox( panel
, -1, "Explanation", wxPoint(200,10), wxSize(290,130) );
396 (void)new wxStaticText( panel
, -1,
397 "In order see the gauge (aka progress bar)\n"
398 "control do something you have to drag the\n"
399 "handle of the slider to the right.\n"
401 "This is also supposed to demonstrate how\n"
402 "to use static controls.\n",
404 m_spintext
= new wxTextCtrl( panel
, -1, "0", wxPoint(20,160), wxSize(80,-1) );
405 // m_spintext->SetBackgroundColour("wheat");
406 m_spinbutton
= new wxSpinButton( panel
, ID_SPIN
, wxPoint(103,159), wxSize(-1,-1) );
407 // m_spinbutton->SetBackgroundColour("wheat");
408 m_spinbutton
->SetRange(0,100);
410 m_notebook
->AddPage(panel
, "wxGauge", FALSE
, Image_Gauge
);
413 void MyPanel::OnPasteFromClipboard( wxCommandEvent
&WXUNUSED(event
) )
417 if (!wxTheClipboard
->IsSupportedFormat( wxDF_TEXT
))
419 *m_text
<< "The clipboard doesn't contain any data in the requested format." << "\n";
424 if (!wxTheClipboard
->Open())
426 *m_text
<< "Error opening the clipboard." << "\n";
432 *m_text
<< "Successfully opened the clipboard." << "\n";
435 wxTextDataObject
*data
= new wxTextDataObject();
437 if (wxTheClipboard
->GetData( data
))
439 *m_text
<< "Successfully retrieved data from the clipboard." << "\n";
440 *m_multitext
<< data
->GetText() << "\n";
444 *m_text
<< "Error getting data from the clipboard." << "\n";
447 wxTheClipboard
->Close();
449 *m_text
<< "Closed the clipboard." << "\n";
456 void MyPanel::OnCopyToClipboard( wxCommandEvent
&WXUNUSED(event
) )
460 wxString
text( m_multitext
->GetLineText(0) );
462 if (text
.IsEmpty()) return;
464 wxTextDataObject
*data
= new wxTextDataObject( text
);
466 if (!wxTheClipboard
->Open())
468 *m_text
<< "Error opening the clipboard." << "\n";
474 *m_text
<< "Successfully opened the clipboard." << "\n";
477 if (!wxTheClipboard
->SetData( data
))
479 *m_text
<< "Error while copying to the clipboard." << "\n";
483 *m_text
<< "Successfully copied data to the clipboard." << "\n";
486 wxTheClipboard
->Close();
488 *m_text
<< "Closed the clipboard." << "\n";
493 void MyPanel::OnCutToClipboard( wxCommandEvent
&WXUNUSED(event
) )
497 void MyPanel::OnSize( wxSizeEvent
& WXUNUSED(event
) )
501 GetClientSize( &x
, &y
);
503 if (m_notebook
) m_notebook
->SetSize( 2, 2, x
-4, y
*2/3-4 );
504 if (m_text
) m_text
->SetSize( 2, y
*2/3+2, x
-4, y
/3-4 );
507 void MyPanel::OnPageChanged( wxNotebookEvent
&event
)
509 *m_text
<< "Notebook selection is " << event
.GetSelection() << "\n";
512 void MyPanel::OnListBox( wxCommandEvent
&event
)
514 m_text
->WriteText( "ListBox selection string is: " );
515 m_text
->WriteText( event
.GetString() );
516 m_text
->WriteText( "\n" );
519 void MyPanel::OnListBoxButtons( wxCommandEvent
&event
)
521 switch (event
.GetId())
523 case ID_LISTBOX_ENABLE
:
525 m_listbox
->Enable( !((bool)event
.GetInt()) );
528 case ID_LISTBOX_SEL_NUM
:
530 m_listbox
->SetSelection( 2 );
533 case ID_LISTBOX_SEL_STR
:
535 m_listbox
->SetStringSelection( "This" );
538 case ID_LISTBOX_CLEAR
:
543 case ID_LISTBOX_APPEND
:
545 m_listbox
->Append( "Hi!" );
548 case ID_LISTBOX_DELETE
:
550 int idx
= m_listbox
->GetSelection();
551 m_listbox
->Delete( idx
);
554 case ID_LISTBOX_FONT
:
556 m_listbox
->SetFont( *wxITALIC_FONT
);
557 m_checkbox
->SetFont( *wxITALIC_FONT
);
563 void MyPanel::OnChoice( wxCommandEvent
&event
)
565 m_text
->WriteText( "Choice selection string is: " );
566 m_text
->WriteText( event
.GetString() );
567 m_text
->WriteText( "\n" );
570 void MyPanel::OnChoiceButtons( wxCommandEvent
&event
)
572 switch (event
.GetId())
574 case ID_CHOICE_ENABLE
:
576 m_choice
->Enable( !((bool)event
.GetInt()) );
579 case ID_CHOICE_SEL_NUM
:
581 m_choice
->SetSelection( 2 );
584 case ID_CHOICE_SEL_STR
:
586 m_choice
->SetStringSelection( "This" );
589 case ID_CHOICE_CLEAR
:
594 case ID_CHOICE_APPEND
:
596 m_choice
->Append( "Hi!" );
599 case ID_CHOICE_DELETE
:
601 int idx
= m_choice
->GetSelection();
602 m_choice
->Delete( idx
);
607 m_choice
->SetFont( *wxITALIC_FONT
);
613 void MyPanel::OnCombo( wxCommandEvent
&event
)
615 m_text
->WriteText( "ComboBox selection string is: " );
616 m_text
->WriteText( event
.GetString() );
617 m_text
->WriteText( "\n" );
620 void MyPanel::OnComboButtons( wxCommandEvent
&event
)
622 switch (event
.GetId())
624 case ID_COMBO_ENABLE
:
626 m_combo
->Enable( !((bool)event
.GetInt()) );
629 case ID_COMBO_SEL_NUM
:
631 m_combo
->SetSelection( 2 );
634 case ID_COMBO_SEL_STR
:
636 m_combo
->SetStringSelection( "This" );
644 case ID_COMBO_APPEND
:
646 m_combo
->Append( "Hi!" );
649 case ID_COMBO_DELETE
:
651 int idx
= m_combo
->GetSelection();
652 m_combo
->Delete( idx
);
657 m_combo
->SetFont( *wxITALIC_FONT
);
663 void MyPanel::OnRadio( wxCommandEvent
&event
)
665 m_text
->WriteText( "RadioBox selection string is: " );
666 m_text
->WriteText( event
.GetString() );
667 m_text
->WriteText( "\n" );
670 void MyPanel::OnRadioButtons( wxCommandEvent
&event
)
672 switch (event
.GetId())
674 case ID_RADIOBOX_ENABLE
:
676 m_radio
->Enable( !((bool)event
.GetInt()) );
679 case ID_RADIOBOX_SEL_NUM
:
681 m_radio
->SetSelection( 2 );
684 case ID_RADIOBOX_SEL_STR
:
686 m_radio
->SetStringSelection( "This" );
689 case ID_RADIOBOX_FONT
:
691 m_radio
->SetFont( *wxITALIC_FONT
);
697 void MyPanel::OnSetFont( wxCommandEvent
&WXUNUSED(event
) )
699 m_fontButton
->SetFont( *wxITALIC_FONT
);
700 m_text
->SetFont( *wxITALIC_FONT
);
703 void MyPanel::OnSliderUpdate( wxCommandEvent
&WXUNUSED(event
) )
705 m_gauge
->SetValue( m_slider
->GetValue() );
708 void MyPanel::OnSpinUpdate( wxSpinEvent
&event
)
711 value
.sprintf( "%d", (int)event
.GetPosition() );
712 m_spintext
->SetValue( value
);
717 delete m_notebook
->GetImageList();
720 //----------------------------------------------------------------------
722 //----------------------------------------------------------------------
724 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
725 EVT_MENU(MINIMAL_QUIT
, MyFrame::OnQuit
)
726 EVT_MENU(MINIMAL_ABOUT
, MyFrame::OnAbout
)
729 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
730 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
732 (void)new MyPanel( this, 10, 10, 300, 100 );
735 void MyFrame::OnQuit (wxCommandEvent
& WXUNUSED(event
) )
740 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
742 wxMessageDialog
dialog(this, "This is a control sample", "About Controls", wxOK
);