]> git.saurik.com Git - wxWidgets.git/blame - samples/controls/controls.cpp
no real changes, just added a default value for the command used by exec with redirec...
[wxWidgets.git] / samples / controls / controls.cpp
CommitLineData
1c005ff7 1/////////////////////////////////////////////////////////////////////////////
dfad0599 2// Name: controls.cpp
be5a51fb 3// Purpose: Controls wxWidgets sample
1c005ff7
RR
4// Author: Robert Roebling
5// Modified by:
6// RCS-ID: $Id$
c67d8618 7// Copyright: (c) Robert Roebling, Julian Smart
655822f3 8// Licence: wxWindows license
1c005ff7
RR
9/////////////////////////////////////////////////////////////////////////////
10
1c005ff7
RR
11// For compilers that support precompilation, includes "wx/wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
9f3362c4 15 #pragma hdrstop
1c005ff7
RR
16#endif
17
18#ifndef WX_PRECOMP
9f3362c4 19 #include "wx/wx.h"
1c005ff7
RR
20#endif
21
4fabb575 22#include "wx/spinbutt.h"
1db8dc4a 23#include "wx/tglbtn.h"
61c083e7 24#include "wx/bookctrl.h"
2cb21a45 25#include "wx/imaglist.h"
389d906b 26#include "wx/artprov.h"
1a8b677e 27#include "wx/cshelp.h"
b8653fbf
VZ
28
29#if wxUSE_TOOLTIPS
30 #include "wx/tooltip.h"
31#endif
1c005ff7 32
a5e635be 33#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
73c700fd 34 #define USE_XPM
4fabb575
JS
35#endif
36
37#ifdef USE_XPM
73c700fd
VZ
38 #include "mondrian.xpm"
39 #include "icons/choice.xpm"
40 #include "icons/combo.xpm"
41 #include "icons/list.xpm"
42 #include "icons/radio.xpm"
43 #include "icons/text.xpm"
44 #include "icons/gauge.xpm"
47908e25
RR
45#endif
46
3a5bcc4d 47#ifndef wxUSE_SPINBTN
ad556aa9 48 #define wxUSE_SPINBTN 1
3a5bcc4d 49#endif
9726da4f
VZ
50
51#include "wx/progdlg.h"
52
b782f2e0
VZ
53#if wxUSE_SPINCTRL
54 #include "wx/spinctrl.h"
55#endif // wxUSE_SPINCTRL
56
bebc503c
VZ
57#if !wxUSE_TOGGLEBTN
58 #define wxToggleButton wxCheckBox
59 #define EVT_TOGGLEBUTTON EVT_CHECKBOX
60#endif
61
1c005ff7
RR
62//----------------------------------------------------------------------
63// class definitions
64//----------------------------------------------------------------------
65
66class MyApp: public wxApp
655822f3 67{
b8653fbf
VZ
68public:
69 bool OnInit();
1c005ff7
RR
70};
71
72class MyPanel: public wxPanel
73{
b8653fbf 74public:
1c005ff7 75 MyPanel(wxFrame *frame, int x, int y, int w, int h);
2cb21a45 76 virtual ~MyPanel();
16f6dfd8 77
f226be17 78 void OnIdle( wxIdleEvent &event );
1c005ff7 79 void OnListBox( wxCommandEvent &event );
5b077d48 80 void OnListBoxDoubleClick( wxCommandEvent &event );
1c005ff7 81 void OnListBoxButtons( wxCommandEvent &event );
1ccd23f5 82#if wxUSE_CHOICE
47908e25
RR
83 void OnChoice( wxCommandEvent &event );
84 void OnChoiceButtons( wxCommandEvent &event );
1ccd23f5 85#endif
47908e25 86 void OnCombo( wxCommandEvent &event );
f6bcfd97
BP
87 void OnComboTextChanged( wxCommandEvent &event );
88 void OnComboTextEnter( wxCommandEvent &event );
47908e25
RR
89 void OnComboButtons( wxCommandEvent &event );
90 void OnRadio( wxCommandEvent &event );
91 void OnRadioButtons( wxCommandEvent &event );
a48b9bfb
VZ
92 void OnRadioButton1( wxCommandEvent &event );
93 void OnRadioButton2( wxCommandEvent &event );
868a2826 94 void OnSetFont( wxCommandEvent &event );
61c083e7
WS
95 void OnPageChanged( wxBookCtrlEvent &event );
96 void OnPageChanging( wxBookCtrlEvent &event );
7bce6aec 97 void OnSliderUpdate( wxCommandEvent &event );
185fa6bf 98 void OnUpdateLabel( wxCommandEvent &event );
0e528b99 99#if wxUSE_SPINBTN
8c3c31d4
VZ
100 void OnSpinUp( wxSpinEvent &event );
101 void OnSpinDown( wxSpinEvent &event );
e380f72b 102 void OnSpinUpdate( wxSpinEvent &event );
516ab399 103#if wxUSE_PROGRESSDLG
9726da4f
VZ
104 void OnUpdateShowProgress( wxUpdateUIEvent& event );
105 void OnShowProgress( wxCommandEvent &event );
516ab399 106#endif // wxUSE_PROGRESSDLG
0e528b99 107#endif // wxUSE_SPINBTN
1dd815f3 108 void OnNewText( wxCommandEvent &event );
baccb514 109#if wxUSE_SPINCTRL
457e6c54 110 void OnSpinCtrl(wxSpinEvent& event);
76106901
VZ
111 void OnSpinCtrlUp(wxSpinEvent& event);
112 void OnSpinCtrlDown(wxSpinEvent& event);
113 void OnSpinCtrlText(wxCommandEvent& event);
baccb514
VZ
114#endif // wxUSE_SPINCTRL
115
87a1e308
VZ
116 void OnEnableAll(wxCommandEvent& event);
117 void OnChangeColour(wxCommandEvent& event);
3e2dd3db 118 void OnTestButton(wxCommandEvent& event);
9121bed2 119 void OnBmpButton(wxCommandEvent& event);
bebc503c 120 void OnBmpButtonToggle(wxCommandEvent& event);
87a1e308 121
2b5f62a0
VZ
122 void OnSizerCheck (wxCommandEvent &event);
123
6c8a980f
VZ
124 wxListBox *m_listbox,
125 *m_listboxSorted;
1ccd23f5 126#if wxUSE_CHOICE
b56c2246
VZ
127 wxChoice *m_choice,
128 *m_choiceSorted;
2b5f62a0
VZ
129#endif // wxUSE_CHOICE
130
e380f72b
RR
131 wxComboBox *m_combo;
132 wxRadioBox *m_radio;
516ab399 133#if wxUSE_GAUGE
37ed3ae3
VZ
134 wxGauge *m_gauge,
135 *m_gaugeVert;
516ab399 136#endif // wxUSE_GAUGE
6bb44116 137#if wxUSE_SLIDER
e380f72b 138 wxSlider *m_slider;
6bb44116 139#endif // wxUSE_SLIDER
e380f72b 140 wxButton *m_fontButton;
85eb36c2
RR
141 wxButton *m_lbSelectNum;
142 wxButton *m_lbSelectThis;
0e528b99 143#if wxUSE_SPINBTN
e380f72b 144 wxSpinButton *m_spinbutton;
516ab399 145#if wxUSE_PROGRESSDLG
9726da4f 146 wxButton *m_btnProgress;
516ab399 147#endif // wxUSE_PROGRESSDLG
0e528b99 148#endif // wxUSE_SPINBTN
1dd815f3
RR
149 wxStaticText *m_wrappingText;
150 wxStaticText *m_nonWrappingText;
b782f2e0
VZ
151
152#if wxUSE_SPINCTRL
153 wxSpinCtrl *m_spinctrl;
154#endif // wxUSE_SPINCTRL
155
e380f72b 156 wxTextCtrl *m_spintext;
ae0bdb01 157 wxCheckBox *m_checkbox;
16f6dfd8 158
e380f72b 159 wxTextCtrl *m_text;
61c083e7 160 wxBookCtrl *m_book;
655822f3 161
185fa6bf
VZ
162 wxStaticText *m_label;
163
2b5f62a0
VZ
164 wxBoxSizer *m_buttonSizer;
165 wxButton *m_sizerBtn1;
166 wxButton *m_sizerBtn2;
167 wxButton *m_sizerBtn3;
168 wxButton *m_sizerBtn4;
169 wxBoxSizer *m_hsizer;
170 wxButton *m_bigBtn;
171
b8653fbf 172private:
29e7e51a
VZ
173 wxLog *m_logTargetOld;
174
b8653fbf 175 DECLARE_EVENT_TABLE()
1c005ff7
RR
176};
177
178class MyFrame: public wxFrame
179{
b8653fbf 180public:
9f84eccd 181 MyFrame(const wxChar *title, int x, int y);
655822f3 182
1c005ff7
RR
183 void OnQuit(wxCommandEvent& event);
184 void OnAbout(wxCommandEvent& event);
3e2dd3db 185 void OnClearLog(wxCommandEvent& event);
87a1e308 186
16f6dfd8
VZ
187#if wxUSE_TOOLTIPS
188 void OnSetTooltipDelay(wxCommandEvent& event);
189 void OnToggleTooltips(wxCommandEvent& event);
190#endif // wxUSE_TOOLTIPS
87a1e308
VZ
191
192 void OnEnableAll(wxCommandEvent& event);
47a8a4d5
VZ
193 void OnHideAll(wxCommandEvent& event);
194 void OnHideList(wxCommandEvent& event);
1a8b677e 195 void OnContextHelp(wxCommandEvent& event);
87a1e308 196
9f3362c4 197 void OnIdle( wxIdleEvent& event );
35960bbf
VZ
198 void OnIconized( wxIconizeEvent& event );
199 void OnMaximized( wxMaximizeEvent& event );
5fb9fcfc 200 void OnSize( wxSizeEvent& event );
97206645 201 void OnMove( wxMoveEvent& event );
655822f3 202
f048e32f
VZ
203 MyPanel *GetPanel() const { return m_panel; }
204
b8653fbf 205private:
960a83cc 206#if wxUSE_STATUSBAR
97206645
VZ
207 void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
208 {
7bfc22f6
VZ
209 if ( m_frameStatusBar )
210 {
211 wxString msg;
0545d965
VZ
212 wxSize sizeAll = GetSize(),
213 sizeCl = GetClientSize();
214 msg.Printf(_("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)"),
7bfc22f6
VZ
215 pos.x, pos.y,
216 size.x, size.y,
0545d965 217 sizeAll.x, sizeAll.y,
7bfc22f6
VZ
218 sizeCl.x, sizeCl.y);
219 SetStatusText(msg, 1);
220 }
97206645 221 }
960a83cc 222#endif // wxUSE_STATUSBAR
97206645 223
f048e32f 224 MyPanel *m_panel;
87a1e308 225
b8653fbf 226 DECLARE_EVENT_TABLE()
1c005ff7
RR
227};
228
f6bcfd97
BP
229// a button which intercepts double clicks (for testing...)
230class MyButton : public wxButton
231{
232public:
233 MyButton(wxWindow *parent,
234 wxWindowID id,
235 const wxString& label = wxEmptyString,
236 const wxPoint& pos = wxDefaultPosition,
237 const wxSize& size = wxDefaultSize)
238 : wxButton(parent, id, label, pos, size)
239 {
240 }
241
242 void OnDClick(wxMouseEvent& event)
243 {
244 wxLogMessage(_T("MyButton::OnDClick"));
245
246 event.Skip();
247 }
248
249private:
250 DECLARE_EVENT_TABLE()
251};
252
253// a combo which intercepts chars (to test Windows behaviour)
254class MyComboBox : public wxComboBox
255{
256public:
257 MyComboBox(wxWindow *parent, wxWindowID id,
258 const wxString& value = wxEmptyString,
259 const wxPoint& pos = wxDefaultPosition,
260 const wxSize& size = wxDefaultSize,
261 int n = 0, const wxString choices[] = NULL,
262 long style = 0,
263 const wxValidator& validator = wxDefaultValidator,
264 const wxString& name = wxComboBoxNameStr)
265 : wxComboBox(parent, id, value, pos, size, n, choices, style,
266 validator, name) { }
267
268protected:
269 void OnChar(wxKeyEvent& event);
270 void OnKeyDown(wxKeyEvent& event);
271 void OnKeyUp(wxKeyEvent& event);
272 void OnFocusGot(wxFocusEvent& event)
273 {
274 wxLogMessage(_T("MyComboBox::OnFocusGot"));
275
276 event.Skip();
277 }
278
279private:
280 DECLARE_EVENT_TABLE()
281};
282
283// a radiobox which handles focus set/kill (for testing)
284class MyRadioBox : public wxRadioBox
285{
286public:
287 MyRadioBox(wxWindow *parent,
288 wxWindowID id,
289 const wxString& title = wxEmptyString,
290 const wxPoint& pos = wxDefaultPosition,
291 const wxSize& size = wxDefaultSize,
292 int n = 0, const wxString choices[] = NULL,
293 int majorDim = 1,
294 long style = wxRA_HORIZONTAL,
295 const wxValidator& validator = wxDefaultValidator,
0bb62421 296 const wxString& name = wxRadioBoxNameStr)
f6bcfd97 297 : wxRadioBox(parent, id, title, pos, size, n, choices, majorDim,
7891b4d4
VZ
298 style, validator, name)
299 {
300 }
f6bcfd97
BP
301
302protected:
303 void OnFocusGot(wxFocusEvent& event)
304 {
305 wxLogMessage(_T("MyRadioBox::OnFocusGot"));
306
307 event.Skip();
308 }
309
310 void OnFocusLost(wxFocusEvent& event)
311 {
312 wxLogMessage(_T("MyRadioBox::OnFocusLost"));
313
314 event.Skip();
315 }
316
317private:
318 DECLARE_EVENT_TABLE()
319};
320
1a84e759
RR
321// a choice which handles focus set/kill (for testing)
322class MyChoice : public wxChoice
323{
324public:
325 MyChoice(wxWindow *parent,
326 wxWindowID id,
327 const wxPoint& pos = wxDefaultPosition,
328 const wxSize& size = wxDefaultSize,
329 int n = 0, const wxString choices[] = NULL,
330 long style = 0,
331 const wxValidator& validator = wxDefaultValidator,
332 const wxString& name = wxChoiceNameStr )
0d29fecd 333 : wxChoice(parent, id, pos, size, n, choices,
1a84e759
RR
334 style, validator, name) { }
335
336protected:
337 void OnFocusGot(wxFocusEvent& event)
338 {
339 wxLogMessage(_T("MyChoice::OnFocusGot"));
340
341 event.Skip();
342 }
343
344 void OnFocusLost(wxFocusEvent& event)
345 {
346 wxLogMessage(_T("MyChoice::OnFocusLost"));
347
348 event.Skip();
349 }
350
351private:
352 DECLARE_EVENT_TABLE()
353};
354
355
356
1c005ff7 357//----------------------------------------------------------------------
6c8a980f 358// other
1c005ff7
RR
359//----------------------------------------------------------------------
360
8b81a824 361static void SetListboxClientData(const wxChar *name, wxListBox *control);
2b5f62a0
VZ
362
363#if wxUSE_CHOICE
8b81a824 364static void SetChoiceClientData(const wxChar *name, wxChoice *control);
2b5f62a0 365#endif // wxUSE_CHOICE
6c8a980f 366
d59051dd 367IMPLEMENT_APP(MyApp)
1c005ff7
RR
368
369//----------------------------------------------------------------------
370// MyApp
371//----------------------------------------------------------------------
372
16f6dfd8
VZ
373enum
374{
91b07357
JS
375 CONTROLS_QUIT = wxID_EXIT,
376 CONTROLS_ABOUT = wxID_ABOUT,
377 CONTROLS_TEXT = 100,
3e2dd3db 378 CONTROLS_CLEAR_LOG,
16f6dfd8
VZ
379
380 // tooltip menu
3e2dd3db
VZ
381 CONTROLS_SET_TOOLTIP_DELAY = 200,
382 CONTROLS_ENABLE_TOOLTIPS,
87a1e308
VZ
383
384 // panel menu
1a8b677e 385 CONTROLS_ENABLE_ALL,
47a8a4d5
VZ
386 CONTROLS_HIDE_ALL,
387 CONTROLS_HIDE_LIST,
1a8b677e 388 CONTROLS_CONTEXT_HELP
16f6dfd8 389};
1c005ff7 390
b8653fbf 391bool MyApp::OnInit()
1c005ff7 392{
41b66be9
VS
393 // use standard command line handling:
394 if ( !wxApp::OnInit() )
9230b621 395 return false;
41b66be9 396
e66ad5c6
VZ
397 // parse the cmd line
398 int x = 50,
399 y = 50;
3ca6a5f0 400 if ( argc == 3 )
e66ad5c6 401 {
a60b1f5d
MB
402 wxSscanf(wxString(argv[1]), wxT("%d"), &x);
403 wxSscanf(wxString(argv[2]), wxT("%d"), &y);
e66ad5c6
VZ
404 }
405
1a8b677e
VZ
406#if wxUSE_HELP
407 wxHelpProvider::Set( new wxSimpleHelpProvider );
408#endif // wxUSE_HELP
409
ec9f7884 410 // Create the main frame window
be5a51fb 411 MyFrame *frame = new MyFrame(_T("Controls wxWidgets App"), x, y);
9230b621 412 frame->Show(true);
655822f3 413
9230b621 414 return true;
1c005ff7
RR
415}
416
417//----------------------------------------------------------------------
418// MyPanel
419//----------------------------------------------------------------------
420
61c083e7 421const int ID_BOOK = 1000;
1c005ff7 422
4fabb575
JS
423const int ID_LISTBOX = 130;
424const int ID_LISTBOX_SEL_NUM = 131;
425const int ID_LISTBOX_SEL_STR = 132;
426const int ID_LISTBOX_CLEAR = 133;
427const int ID_LISTBOX_APPEND = 134;
428const int ID_LISTBOX_DELETE = 135;
429const int ID_LISTBOX_FONT = 136;
430const int ID_LISTBOX_ENABLE = 137;
6c8a980f 431const int ID_LISTBOX_SORTED = 138;
1c005ff7 432
4fabb575
JS
433const int ID_CHOICE = 120;
434const int ID_CHOICE_SEL_NUM = 121;
435const int ID_CHOICE_SEL_STR = 122;
436const int ID_CHOICE_CLEAR = 123;
437const int ID_CHOICE_APPEND = 124;
438const int ID_CHOICE_DELETE = 125;
439const int ID_CHOICE_FONT = 126;
440const int ID_CHOICE_ENABLE = 127;
b56c2246 441const int ID_CHOICE_SORTED = 128;
53010e52 442
4fabb575
JS
443const int ID_COMBO = 140;
444const int ID_COMBO_SEL_NUM = 141;
445const int ID_COMBO_SEL_STR = 142;
446const int ID_COMBO_CLEAR = 143;
447const int ID_COMBO_APPEND = 144;
448const int ID_COMBO_DELETE = 145;
449const int ID_COMBO_FONT = 146;
450const int ID_COMBO_ENABLE = 147;
cc7e9e20 451const int ID_COMBO_SET_TEXT = 148;
53010e52 452
4fabb575
JS
453const int ID_RADIOBOX = 160;
454const int ID_RADIOBOX_SEL_NUM = 161;
455const int ID_RADIOBOX_SEL_STR = 162;
456const int ID_RADIOBOX_FONT = 163;
457const int ID_RADIOBOX_ENABLE = 164;
868a2826 458
f5d29b39
RR
459const int ID_RADIOBUTTON_1 = 166;
460const int ID_RADIOBUTTON_2 = 167;
461
4fabb575 462const int ID_SET_FONT = 170;
47908e25 463
516ab399 464#if wxUSE_GAUGE
4fabb575 465const int ID_GAUGE = 180;
516ab399
WS
466#endif // wxUSE_GAUGE
467
6bb44116 468#if wxUSE_SLIDER
4fabb575 469const int ID_SLIDER = 181;
6bb44116 470#endif // wxUSE_SLIDER
58614078 471
4fabb575 472const int ID_SPIN = 182;
516ab399 473#if wxUSE_PROGRESSDLG
9726da4f 474const int ID_BTNPROGRESS = 183;
516ab399 475#endif // wxUSE_PROGRESSDLG
185fa6bf 476const int ID_BUTTON_LABEL = 184;
baccb514 477const int ID_SPINCTRL = 185;
1dd815f3 478const int ID_BTNNEWTEXT = 186;
e380f72b 479
3e2dd3db
VZ
480const int ID_BUTTON_TEST1 = 190;
481const int ID_BUTTON_TEST2 = 191;
9121bed2 482const int ID_BITMAP_BTN = 192;
bebc503c 483const int ID_BITMAP_BTN_ENABLE = 193;
3e2dd3db 484
87a1e308
VZ
485const int ID_CHANGE_COLOUR = 200;
486
2b5f62a0
VZ
487const int ID_SIZER_CHECK1 = 201;
488const int ID_SIZER_CHECK2 = 202;
489const int ID_SIZER_CHECK3 = 203;
490const int ID_SIZER_CHECK4 = 204;
491const int ID_SIZER_CHECK14 = 205;
492const int ID_SIZER_CHECKBIG = 206;
493
1a8b677e
VZ
494const int ID_HYPERLINK = 300;
495
1c005ff7 496BEGIN_EVENT_TABLE(MyPanel, wxPanel)
f226be17 497EVT_IDLE ( MyPanel::OnIdle)
61c083e7
WS
498EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging)
499EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged)
ec9f7884 500EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
6c8a980f 501EVT_LISTBOX (ID_LISTBOX_SORTED, MyPanel::OnListBox)
ec9f7884
VZ
502EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick)
503EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons)
504EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons)
505EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
506EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons)
507EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons)
508EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons)
509EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons)
1ccd23f5 510#if wxUSE_CHOICE
ec9f7884 511EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice)
b56c2246 512EVT_CHOICE (ID_CHOICE_SORTED, MyPanel::OnChoice)
ec9f7884
VZ
513EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons)
514EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons)
515EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons)
516EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons)
517EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
518EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons)
519EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons)
1ccd23f5 520#endif
ec9f7884 521EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo)
f6bcfd97
BP
522EVT_TEXT (ID_COMBO, MyPanel::OnComboTextChanged)
523EVT_TEXT_ENTER(ID_COMBO, MyPanel::OnComboTextEnter)
ec9f7884
VZ
524EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
525EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
526EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
527EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons)
528EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons)
529EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons)
cc7e9e20 530EVT_BUTTON (ID_COMBO_SET_TEXT, MyPanel::OnComboButtons)
ec9f7884
VZ
531EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons)
532EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio)
533EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons)
534EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons)
535EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons)
536EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
a48b9bfb
VZ
537EVT_RADIOBUTTON(ID_RADIOBUTTON_1, MyPanel::OnRadioButton1)
538EVT_RADIOBUTTON(ID_RADIOBUTTON_2, MyPanel::OnRadioButton2)
ec9f7884 539EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
6bb44116 540#if wxUSE_SLIDER
ec9f7884 541EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
6bb44116 542#endif // wxUSE_SLIDER
0e528b99 543#if wxUSE_SPINBTN
ec9f7884 544EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
8c3c31d4
VZ
545EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp)
546EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown)
516ab399 547#if wxUSE_PROGRESSDLG
9726da4f
VZ
548EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
549EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
516ab399 550#endif // wxUSE_PROGRESSDLG
0e528b99 551#endif // wxUSE_SPINBTN
baccb514 552#if wxUSE_SPINCTRL
57160afe 553EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl)
76106901
VZ
554EVT_SPIN_UP (ID_SPINCTRL, MyPanel::OnSpinCtrlUp)
555EVT_SPIN_DOWN (ID_SPINCTRL, MyPanel::OnSpinCtrlDown)
556EVT_TEXT (ID_SPINCTRL, MyPanel::OnSpinCtrlText)
baccb514 557#endif // wxUSE_SPINCTRL
1dd815f3 558EVT_BUTTON (ID_BTNNEWTEXT, MyPanel::OnNewText)
1db8dc4a 559EVT_TOGGLEBUTTON(ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
87a1e308 560EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
3e2dd3db
VZ
561EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton)
562EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton)
9121bed2 563EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton)
bebc503c 564EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE, MyPanel::OnBmpButtonToggle)
2b5f62a0
VZ
565
566EVT_CHECKBOX (ID_SIZER_CHECK1, MyPanel::OnSizerCheck)
567EVT_CHECKBOX (ID_SIZER_CHECK2, MyPanel::OnSizerCheck)
568EVT_CHECKBOX (ID_SIZER_CHECK3, MyPanel::OnSizerCheck)
569EVT_CHECKBOX (ID_SIZER_CHECK4, MyPanel::OnSizerCheck)
570EVT_CHECKBOX (ID_SIZER_CHECK14, MyPanel::OnSizerCheck)
571EVT_CHECKBOX (ID_SIZER_CHECKBIG, MyPanel::OnSizerCheck)
572
1c005ff7
RR
573END_EVENT_TABLE()
574
f6bcfd97
BP
575BEGIN_EVENT_TABLE(MyButton, wxButton)
576 EVT_LEFT_DCLICK(MyButton::OnDClick)
577END_EVENT_TABLE()
578
579BEGIN_EVENT_TABLE(MyComboBox, wxComboBox)
580 EVT_CHAR(MyComboBox::OnChar)
581 EVT_KEY_DOWN(MyComboBox::OnKeyDown)
582 EVT_KEY_UP(MyComboBox::OnKeyUp)
583
584 EVT_SET_FOCUS(MyComboBox::OnFocusGot)
585END_EVENT_TABLE()
586
587BEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox)
588 EVT_SET_FOCUS(MyRadioBox::OnFocusGot)
589 EVT_KILL_FOCUS(MyRadioBox::OnFocusLost)
590END_EVENT_TABLE()
591
1a84e759
RR
592BEGIN_EVENT_TABLE(MyChoice, wxChoice)
593 EVT_SET_FOCUS(MyChoice::OnFocusGot)
594 EVT_KILL_FOCUS(MyChoice::OnFocusLost)
595END_EVENT_TABLE()
596
f6bcfd97
BP
597// ============================================================================
598// implementation
599// ============================================================================
600
5fb9fcfc 601MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
9230b621 602 : wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) )
1c005ff7 603{
946fb2b9
JS
604 m_listbox = NULL;
605 m_listboxSorted = NULL;
606#if wxUSE_CHOICE
607 m_choice = NULL;
608 m_choiceSorted = NULL;
6bb44116 609#endif // wxUSE_CHOICE
946fb2b9
JS
610 m_combo = NULL;
611 m_radio = NULL;
516ab399 612#if wxUSE_GAUGE
946fb2b9
JS
613 m_gauge = NULL;
614 m_gaugeVert = NULL;
516ab399 615#endif // wxUSE_GAUGE
6bb44116 616#if wxUSE_SLIDER
946fb2b9 617 m_slider = NULL;
6bb44116 618#endif // wxUSE_SLIDER
946fb2b9
JS
619 m_fontButton = NULL;
620 m_lbSelectNum = NULL;
621 m_lbSelectThis = NULL;
622#if wxUSE_SPINBTN
623 m_spinbutton = NULL;
516ab399 624#if wxUSE_PROGRESSDLG
946fb2b9 625 m_btnProgress = NULL;
516ab399 626#endif // wxUSE_PROGRESSDLG
946fb2b9
JS
627#endif // wxUSE_SPINBTN
628#if wxUSE_SPINCTRL
629 m_spinctrl = NULL;
630#endif // wxUSE_SPINCTRL
631 m_spintext = NULL;
632 m_checkbox = NULL;
633 m_text = NULL;
61c083e7 634 m_book = NULL;
946fb2b9
JS
635 m_label = NULL;
636
9230b621 637 m_text = new wxTextCtrl(this, wxID_ANY, _T("This is the log window.\n"),
3e2dd3db 638 wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
655822f3 639
29e7e51a 640 m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
0a772322 641
61c083e7 642 m_book = new wxBookCtrl(this, ID_BOOK);
655822f3 643
ec9f7884
VZ
644 wxString choices[] =
645 {
9f84eccd
MB
646 _T("This"),
647 _T("is one of my"),
648 _T("really"),
649 _T("wonderful"),
650 _T("examples.")
ec9f7884 651 };
655822f3 652
4fabb575 653#ifdef USE_XPM
ec9f7884
VZ
654 // image ids
655 enum
656 {
516ab399
WS
657 Image_List,
658 Image_Choice,
659 Image_Combo,
660 Image_Text,
661 Image_Radio,
662#if wxUSE_GAUGE
663 Image_Gauge,
664#endif // wxUSE_GAUGE
665 Image_Max
ec9f7884
VZ
666 };
667
668 // fill the image list
a374426f 669 wxBitmap bmp(list_xpm);
ec9f7884 670
a374426f
VZ
671 wxImageList *imagelist = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
672
673 imagelist-> Add( bmp );
ec9f7884
VZ
674 imagelist-> Add( wxBitmap( choice_xpm ));
675 imagelist-> Add( wxBitmap( combo_xpm ));
676 imagelist-> Add( wxBitmap( text_xpm ));
677 imagelist-> Add( wxBitmap( radio_xpm ));
516ab399 678#if wxUSE_GAUGE
ec9f7884 679 imagelist-> Add( wxBitmap( gauge_xpm ));
516ab399 680#endif // wxUSE_GAUGE
61c083e7 681 m_book->SetImageList(imagelist);
73c700fd 682#elif defined(__WXMSW__)
ec9f7884
VZ
683 // load images from resources
684 enum
685 {
516ab399
WS
686 Image_List,
687 Image_Choice,
688 Image_Combo,
689 Image_Text,
690 Image_Radio,
691#if wxUSE_GAUGE
692 Image_Gauge,
693#endif // wxUSE_GAUGE
694 Image_Max
ec9f7884 695 };
9230b621 696 wxImageList *imagelist = new wxImageList(16, 16, false, Image_Max);
ec9f7884 697
9f84eccd 698 static const wxChar *s_iconNames[Image_Max] =
ec9f7884 699 {
516ab399
WS
700 _T("list")
701 , _T("choice")
702 , _T("combo")
703 , _T("text")
704 , _T("radio")
705#if wxUSE_GAUGE
706 , _T("gauge")
707#endif // wxUSE_GAUGE
ec9f7884
VZ
708 };
709
710 for ( size_t n = 0; n < Image_Max; n++ )
711 {
712 wxBitmap bmp(s_iconNames[n]);
713 if ( !bmp.Ok() || (imagelist->Add(bmp) == -1) )
714 {
61c083e7 715 wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
ec9f7884
VZ
716 s_iconNames[n], n);
717 }
718 }
719
61c083e7 720 m_book->SetImageList(imagelist);
4fabb575
JS
721#else
722
ec9f7884 723 // No images for now
4fabb575
JS
724#define Image_List -1
725#define Image_Choice -1
726#define Image_Combo -1
727#define Image_Text -1
728#define Image_Radio -1
516ab399 729#if wxUSE_GAUGE
4fabb575 730#define Image_Gauge -1
516ab399 731#endif // wxUSE_GAUGE
4fabb575
JS
732#define Image_Max -1
733
fc54776e 734#endif
2cb21a45 735
61c083e7 736 wxPanel *panel = new wxPanel(m_book);
6c8a980f
VZ
737 m_listbox = new wxListBox( panel, ID_LISTBOX,
738 wxPoint(10,10), wxSize(120,70),
376c0148 739 5, choices, wxLB_MULTIPLE |wxLB_ALWAYS_SB );
6c8a980f
VZ
740 m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
741 wxPoint(10,90), wxSize(120,70),
354aa1e3 742 5, choices, wxLB_SORT );
6c8a980f 743
8b81a824
VS
744 SetListboxClientData(wxT("listbox"), m_listbox);
745 SetListboxClientData(wxT("listbox"), m_listboxSorted);
9838df2c 746
ec9f7884 747 m_listbox->SetCursor(*wxCROSS_CURSOR);
b8653fbf 748#if wxUSE_TOOLTIPS
9f84eccd 749 m_listbox->SetToolTip( _T("This is a list box") );
16f6dfd8 750#endif // wxUSE_TOOLTIPS
9f3362c4 751
9f84eccd
MB
752 m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
753 m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
754 (void)new wxButton( panel, ID_LISTBOX_CLEAR, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
755 (void)new MyButton( panel, ID_LISTBOX_APPEND, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
756 (void)new wxButton( panel, ID_LISTBOX_DELETE, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
757 wxButton *button = new MyButton( panel, ID_LISTBOX_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
57160afe
VZ
758
759 button->SetDefault();
57160afe 760
b8653fbf 761#if wxUSE_TOOLTIPS
9f84eccd 762 button->SetToolTip( _T("Press here to set italic font") );
16f6dfd8 763#endif // wxUSE_TOOLTIPS
b1170810 764
9f84eccd 765 m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, _T("&Disable"), wxPoint(20,170) );
9230b621 766 m_checkbox->SetValue(false);
35960bbf 767 button->MoveAfterInTabOrder(m_checkbox);
b8653fbf 768#if wxUSE_TOOLTIPS
9f84eccd 769 m_checkbox->SetToolTip( _T("Click here to disable the listbox") );
16f6dfd8 770#endif // wxUSE_TOOLTIPS
9f84eccd 771 (void)new wxCheckBox( panel, ID_CHANGE_COLOUR, _T("&Toggle colour"),
87a1e308 772 wxPoint(110,170) );
9121bed2 773 panel->SetCursor(wxCursor(wxCURSOR_HAND));
61c083e7 774 m_book->AddPage(panel, _T("wxListBox"), true, Image_List);
ec9f7884 775
1ccd23f5 776#if wxUSE_CHOICE
61c083e7 777 panel = new wxPanel(m_book);
1a84e759
RR
778 m_choice = new MyChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,wxDefaultCoord), 5, choices );
779 m_choiceSorted = new MyChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,wxDefaultCoord),
b56c2246 780 5, choices, wxCB_SORT );
6c8a980f 781
8b81a824
VS
782 SetChoiceClientData(wxT("choice"), m_choice);
783 SetChoiceClientData(wxT("choice"), m_choiceSorted);
6c8a980f 784
ddc8c2e3 785 m_choice->SetSelection(2);
9f84eccd
MB
786 (void)new wxButton( panel, ID_CHOICE_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
787 (void)new wxButton( panel, ID_CHOICE_SEL_STR, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
788 (void)new wxButton( panel, ID_CHOICE_CLEAR, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
789 (void)new wxButton( panel, ID_CHOICE_APPEND, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
790 (void)new wxButton( panel, ID_CHOICE_DELETE, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
791 (void)new wxButton( panel, ID_CHOICE_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
792 (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, _T("&Disable"), wxPoint(20,130), wxSize(140,30) );
793
61c083e7 794 m_book->AddPage(panel, _T("wxChoice"), false, Image_Choice);
1ccd23f5 795#endif // wxUSE_CHOICE
ec9f7884 796
61c083e7 797 panel = new wxPanel(m_book);
9230b621 798 (void)new wxStaticBox( panel, wxID_ANY, _T("&Box around combobox"),
f048e32f 799 wxPoint(5, 5), wxSize(150, 100));
9f84eccd 800 m_combo = new MyComboBox( panel, ID_COMBO, _T("This"),
422d0ff0 801 wxPoint(20,25), wxSize(120, wxDefaultCoord),
f6bcfd97 802 5, choices,
8e13c1ec 803 wxTE_PROCESS_ENTER);
f6bcfd97 804
9f84eccd
MB
805 (void)new wxButton( panel, ID_COMBO_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
806 (void)new wxButton( panel, ID_COMBO_SEL_STR, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
807 (void)new wxButton( panel, ID_COMBO_CLEAR, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
808 (void)new wxButton( panel, ID_COMBO_APPEND, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
809 (void)new wxButton( panel, ID_COMBO_DELETE, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
810 (void)new wxButton( panel, ID_COMBO_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
cc7e9e20 811 (void)new wxButton( panel, ID_COMBO_SET_TEXT, _T("Set 'Hi!' at #2"), wxPoint(340,180), wxSize(140,30) );
9f84eccd 812 (void)new wxCheckBox( panel, ID_COMBO_ENABLE, _T("&Disable"), wxPoint(20,130), wxSize(140,30) );
61c083e7 813 m_book->AddPage(panel, _T("wxComboBox"), false, Image_Combo);
ec9f7884 814
ec9f7884
VZ
815 wxString choices2[] =
816 {
9f84eccd 817 _T("First"), _T("Second"),
0a772322 818 /* "Third",
17867d61
RR
819 "Fourth", "Fifth", "Sixth",
820 "Seventh", "Eighth", "Nineth", "Tenth" */
ec9f7884
VZ
821 };
822
61c083e7 823 panel = new wxPanel(m_book);
ddaa6e89
VZ
824#if wxUSE_TOOLTIPS
825 wxRadioBox *radio2 =
826#endif // wxUSE_TOOLTIPS
827 new MyRadioBox( panel, ID_RADIOBOX, _T("&That"), wxPoint(10,160), wxDefaultSize, WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
9230b621 828 m_radio = new wxRadioBox( panel, ID_RADIOBOX, _T("T&his"), wxPoint(10,10), wxDefaultSize, WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS );
f048e32f
VZ
829
830#if wxUSE_TOOLTIPS
9f84eccd 831 m_combo->SetToolTip(_T("This is a natural\ncombobox - can you believe me?"));
c670c855
VZ
832 radio2->SetToolTip(_T("Ever seen a radiobox?"));
833
834 //m_radio->SetToolTip(_T("Tooltip for the entire radiobox"));
835 for ( unsigned int nb = 0; nb < WXSIZEOF(choices); nb++ )
836 {
837 m_radio->SetItemToolTip(nb, _T("tooltip for\n") + choices[nb]);
838 }
839
840 // remove the tooltip for one of the items
841 m_radio->SetItemToolTip(2, _T(""));
f048e32f
VZ
842#endif // wxUSE_TOOLTIPS
843
1a8b677e
VZ
844#if wxUSE_HELP
845 for( unsigned int item = 0; item < WXSIZEOF(choices); ++item )
846 m_radio->SetItemHelpText( item, wxString::Format( _T("Help text for \"%s\""), choices[item].c_str() ) );
847
848 // erase help text for the second item
849 m_radio->SetItemHelpText( 1, _T("") );
850 // set default help text for control
851 m_radio->SetHelpText( _T("Default helptext for wxRadioBox") );
852#endif // wxUSE_HELP
853
9f84eccd
MB
854 (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
855 (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, _T("&Select 'This'"), wxPoint(180,80), wxSize(140,30) );
856 m_fontButton = new wxButton( panel, ID_SET_FONT, _T("Set &more Italic font"), wxPoint(340,30), wxSize(140,30) );
857 (void)new wxButton( panel, ID_RADIOBOX_FONT, _T("Set &Italic font"), wxPoint(340,80), wxSize(140,30) );
858 (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, _T("&Disable"), wxPoint(340,130), wxDefaultSize );
bc50a2ae 859
9f84eccd 860 wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, _T("Radiobutton1"), wxPoint(210,170), wxDefaultSize, wxRB_GROUP );
9230b621 861 rb->SetValue( false );
9f84eccd 862 (void)new wxRadioButton( panel, ID_RADIOBUTTON_2, _T("&Radiobutton2"), wxPoint(340,170), wxDefaultSize );
61c083e7 863 m_book->AddPage(panel, _T("wxRadioBox"), false, Image_Radio);
ec9f7884 864
1dd815f3 865
6bb44116 866#if wxUSE_SLIDER && wxUSE_GAUGE
61c083e7 867 panel = new wxPanel(m_book);
0d29fecd 868
1dd815f3
RR
869 wxBoxSizer *main_sizer = new wxBoxSizer( wxHORIZONTAL );
870 panel->SetSizer( main_sizer );
0d29fecd 871
1dd815f3
RR
872 wxStaticBoxSizer *gauge_sizer = new wxStaticBoxSizer( wxHORIZONTAL, panel, _T("&wxGauge and wxSlider") );
873 main_sizer->Add( gauge_sizer, 0, wxALL, 5 );
874 wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
875 gauge_sizer->Add( sz );
876 m_gauge = new wxGauge( panel, wxID_ANY, 200, wxDefaultPosition, wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER );
1dd815f3 877 sz->Add( m_gauge, 0, wxALL, 10 );
bebc503c 878 m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200,
1dd815f3 879 wxDefaultPosition, wxSize(155,wxDefaultCoord),
bebc503c 880 wxSL_AUTOTICKS | wxSL_LABELS);
7ba4fbeb 881 m_slider->SetTickFreq(40, 0);
413d43d3 882#if wxUSE_TOOLTIPS
8b1d8f36 883 m_slider->SetToolTip(_T("This is a sliding slider"));
413d43d3 884#endif // wxUSE_TOOLTIPS
1dd815f3 885 sz->Add( m_slider, 0, wxALL, 10 );
0d29fecd 886
1dd815f3
RR
887 m_gaugeVert = new wxGauge( panel, wxID_ANY, 100,
888 wxDefaultPosition, wxSize(wxDefaultCoord, 90),
889 wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER );
890 gauge_sizer->Add( m_gaugeVert, 0, wxALL, 10 );
891
8b1d8f36 892
1dd815f3
RR
893
894 wxStaticBox *sb = new wxStaticBox( panel, wxID_ANY, _T("&Explanation"),
895 wxDefaultPosition, wxDefaultSize ); //, wxALIGN_CENTER );
896 wxStaticBoxSizer *wrapping_sizer = new wxStaticBoxSizer( sb, wxVERTICAL );
897 main_sizer->Add( wrapping_sizer, 0, wxALL, 5 );
4d23a4bf 898
9838df2c 899#ifdef __WXMOTIF__
ec9f7884 900 // No wrapping text in wxStaticText yet :-(
1dd815f3 901 m_wrappingText = new wxStaticText( panel, wxID_ANY,
9f84eccd 902 _T("Drag the slider!"),
37ed3ae3 903 wxPoint(250,30),
422d0ff0 904 wxSize(240, wxDefaultCoord)
ec9f7884 905 );
9838df2c 906#else
1dd815f3
RR
907 m_wrappingText = new wxStaticText( panel, wxID_ANY,
908 _T("In order see the gauge (aka progress bar) ")
909 _T("control do something you have to drag the ")
910 _T("handle of the slider to the right.")
911 _T("\n\n")
912 _T("This is also supposed to demonstrate how ")
913 _T("to use static controls with line wrapping."),
914 wxDefaultPosition,
a71d815b 915 wxSize(240, wxDefaultCoord)
ec9f7884 916 );
9838df2c 917#endif
1dd815f3
RR
918 wrapping_sizer->Add( m_wrappingText );
919
920 wxStaticBoxSizer *non_wrapping_sizer = new wxStaticBoxSizer( wxVERTICAL, panel, wxT("Non-wrapping") );
921 main_sizer->Add( non_wrapping_sizer, 0, wxALL, 5 );
922
923 m_nonWrappingText = new wxStaticText( panel, wxID_ANY,
924 _T("This static text has two lines.\nThey do not wrap."),
925 wxDefaultPosition,
926 wxDefaultSize
927 );
928 non_wrapping_sizer->Add( m_nonWrappingText );
929
930 (void)new wxButton( panel, ID_BTNNEWTEXT, wxT("New text"), wxPoint(450, 160) );
931
8c3c31d4
VZ
932 int initialSpinValue = -5;
933 wxString s;
934 s << initialSpinValue;
422d0ff0 935 m_spintext = new wxTextCtrl( panel, wxID_ANY, s, wxPoint(20,160), wxSize(80,wxDefaultCoord) );
0e528b99 936#if wxUSE_SPINBTN
1dd815f3 937 m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,160) );
e94ff4cb 938 m_spinbutton->SetRange(-40,30);
8c3c31d4 939 m_spinbutton->SetValue(initialSpinValue);
9726da4f 940
516ab399 941#if wxUSE_PROGRESSDLG
9f84eccd 942 m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, _T("&Show progress dialog"),
738f9e5a 943 wxPoint(300, 160) );
516ab399 944#endif // wxUSE_PROGRESSDLG
0e528b99 945#endif // wxUSE_SPINBTN
b782f2e0
VZ
946
947#if wxUSE_SPINCTRL
a71d815b 948 m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, wxEmptyString, wxPoint(200, 160), wxSize(80, wxDefaultCoord) );
69199aad 949 m_spinctrl->SetRange(-10,30);
b782f2e0
VZ
950 m_spinctrl->SetValue(15);
951#endif // wxUSE_SPINCTRL
952
61c083e7 953 m_book->AddPage(panel, _T("wxGauge"), false, Image_Gauge);
6bb44116 954#endif // wxUSE_SLIDER && wxUSE_GAUGE
45e41c05 955
1dd815f3 956
61c083e7 957 panel = new wxPanel(m_book);
b782f2e0 958
3a5bcc4d 959#if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
389d906b 960 wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION);
9230b621 961 (void) new wxStaticBitmap( panel, wxID_ANY, icon, wxPoint(10, 10) );
45e41c05 962
bebe1443 963 // VZ: don't leak memory
9230b621 964 // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
bebe1443 965 // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
b782f2e0
VZ
966#endif // !Motif
967
45e41c05
VZ
968 wxBitmap bitmap( 100, 100 );
969 wxMemoryDC dc;
970 dc.SelectObject( bitmap );
90d05e9b
JG
971 dc.SetBackground(*wxGREEN);
972 dc.SetPen(*wxRED_PEN);
f048e32f 973 dc.Clear();
45e41c05 974 dc.DrawEllipse(5, 5, 90, 90);
9f84eccd 975 dc.DrawText(_T("Bitmap"), 30, 40);
45e41c05
VZ
976 dc.SelectObject( wxNullBitmap );
977
9121bed2 978 (void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20));
bebc503c
VZ
979 (void)new wxToggleButton(panel, ID_BITMAP_BTN_ENABLE,
980 _T("Enable/disable &bitmap"), wxPoint(100, 140));
f048e32f 981
aae0472b 982#if defined(__WXMSW__) || defined(__WXMOTIF__)
3e2dd3db 983 // test for masked bitmap display
9f84eccd 984 bitmap = wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP);
9bb3479c
JS
985 if (bitmap.Ok())
986 {
987 bitmap.SetMask(new wxMask(bitmap, *wxBLUE));
669f7a11 988
bebc503c 989 (void)new wxStaticBitmap(panel, wxID_ANY, bitmap, wxPoint(300, 120));
9bb3479c 990 }
57160afe 991#endif
5ef2e633 992
389d906b
VS
993 wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)),
994 bmp2(wxArtProvider::GetBitmap(wxART_WARNING)),
995 bmp3(wxArtProvider::GetBitmap(wxART_QUESTION));
f048e32f
VZ
996 wxBitmapButton *bmpBtn = new wxBitmapButton
997 (
9230b621 998 panel, wxID_ANY,
f048e32f 999 bmp1,
1db8dc4a 1000 wxPoint(30, 70)
f048e32f 1001 );
76fcf0f2 1002
f048e32f
VZ
1003 bmpBtn->SetBitmapSelected(bmp2);
1004 bmpBtn->SetBitmapFocus(bmp3);
1005
1db8dc4a 1006 (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
9f84eccd 1007 _T("&Toggle label"), wxPoint(250, 20));
bedaf53e 1008
9230b621 1009 m_label = new wxStaticText(panel, wxID_ANY, _T("Label with some long text"),
185fa6bf 1010 wxPoint(250, 60), wxDefaultSize,
f6bcfd97 1011 wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
103aab26 1012 m_label->SetForegroundColour( *wxBLUE );
2ac1b69a 1013
61c083e7 1014 m_book->AddPage(panel, _T("wxBitmapXXX"));
dcc71398 1015
9d9b7755 1016 // sizer
61c083e7 1017 panel = new wxPanel(m_book);
dcc71398 1018
2b5f62a0
VZ
1019 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
1020
1021 wxStaticBoxSizer *csizer =
5014bb3a 1022 new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T("Show Buttons")), wxHORIZONTAL );
61c083e7 1023
2b5f62a0 1024 wxCheckBox *check1, *check2, *check3, *check4, *check14, *checkBig;
9f84eccd 1025 check1 = new wxCheckBox (panel, ID_SIZER_CHECK1, _T("1"));
9230b621 1026 check1->SetValue (true);
2b5f62a0 1027 csizer->Add (check1);
9f84eccd 1028 check2 = new wxCheckBox (panel, ID_SIZER_CHECK2, _T("2"));
9230b621 1029 check2->SetValue (true);
2b5f62a0 1030 csizer->Add (check2);
9f84eccd 1031 check3 = new wxCheckBox (panel, ID_SIZER_CHECK3, _T("3"));
9230b621 1032 check3->SetValue (true);
2b5f62a0 1033 csizer->Add (check3);
9f84eccd 1034 check4 = new wxCheckBox (panel, ID_SIZER_CHECK4, _T("4"));
9230b621 1035 check4->SetValue (true);
2b5f62a0 1036 csizer->Add (check4);
9f84eccd 1037 check14 = new wxCheckBox (panel, ID_SIZER_CHECK14, _T("1-4"));
9230b621 1038 check14->SetValue (true);
2b5f62a0 1039 csizer->Add (check14);
9f84eccd 1040 checkBig = new wxCheckBox (panel, ID_SIZER_CHECKBIG, _T("Big"));
9230b621 1041 checkBig->SetValue (true);
2b5f62a0 1042 csizer->Add (checkBig);
61c083e7 1043
2b5f62a0
VZ
1044 sizer->Add (csizer);
1045
1046 m_hsizer = new wxBoxSizer( wxHORIZONTAL );
9d9b7755 1047
2b5f62a0 1048 m_buttonSizer = new wxBoxSizer (wxVERTICAL);
61c083e7 1049
3f93f659 1050 m_sizerBtn1 = new wxButton(panel, wxID_ANY, _T("Test Button &1 (tab order 1)") );
2b5f62a0 1051 m_buttonSizer->Add( m_sizerBtn1, 0, wxALL, 10 );
3f93f659 1052 m_sizerBtn2 = new wxButton(panel, wxID_ANY, _T("Test Button &2 (tab order 3)") );
2b5f62a0 1053 m_buttonSizer->Add( m_sizerBtn2, 0, wxALL, 10 );
3f93f659 1054 m_sizerBtn3 = new wxButton(panel, wxID_ANY, _T("Test Button &3 (tab order 2)") );
2b5f62a0 1055 m_buttonSizer->Add( m_sizerBtn3, 0, wxALL, 10 );
3f93f659 1056 m_sizerBtn4 = new wxButton(panel, wxID_ANY, _T("Test Button &4 (tab order 4)") );
2b5f62a0
VZ
1057 m_buttonSizer->Add( m_sizerBtn4, 0, wxALL, 10 );
1058
3f93f659
VS
1059 m_sizerBtn3->MoveBeforeInTabOrder(m_sizerBtn2);
1060
2b5f62a0
VZ
1061 m_hsizer->Add (m_buttonSizer);
1062 m_hsizer->Add( 20,20, 1 );
9230b621 1063 m_bigBtn = new wxButton(panel, wxID_ANY, _T("Multiline\nbutton") );
2b5f62a0
VZ
1064 m_hsizer->Add( m_bigBtn , 3, wxGROW|wxALL, 10 );
1065
1066 sizer->Add (m_hsizer, 1, wxGROW);
9d9b7755
VZ
1067
1068 panel->SetSizer( sizer );
1069
61c083e7 1070 m_book->AddPage(panel, _T("wxSizer"));
655822f3 1071
9ae19599
VZ
1072 // set the sizer for the panel itself
1073 sizer = new wxBoxSizer(wxVERTICAL);
1074 sizer->Add(m_book, wxSizerFlags().Border().Expand());
1075 sizer->Add(m_text, wxSizerFlags(1).Border().Expand());
1076 SetSizer(sizer);
1c005ff7
RR
1077}
1078
f226be17
VZ
1079void MyPanel::OnIdle(wxIdleEvent& event)
1080{
1081 static const int INVALID_SELECTION = -2;
1082
1083 static int s_selCombo = INVALID_SELECTION;
25e19bdf
JS
1084
1085 if (!m_combo || !m_choice)
1086 {
1087 event.Skip();
1088 return;
1089 }
1090
f226be17
VZ
1091 int sel = m_combo->GetSelection();
1092 if ( sel != s_selCombo )
1093 {
1094 if ( s_selCombo != INVALID_SELECTION )
1095 {
1096 wxLogMessage(_T("EVT_IDLE: combobox selection changed from %d to %d"),
1097 s_selCombo, sel);
1098 }
1099
1100 s_selCombo = sel;
1101 }
1102
d6bbc10c
VZ
1103 static int s_selChoice = INVALID_SELECTION;
1104 sel = m_choice->GetSelection();
1105 if ( sel != s_selChoice )
1106 {
1107 if ( s_selChoice != INVALID_SELECTION )
1108 {
1109 wxLogMessage(_T("EVT_IDLE: choice selection changed from %d to %d"),
1110 s_selChoice, sel);
1111 }
1112
1113 s_selChoice = sel;
1114 }
1115
f226be17
VZ
1116 event.Skip();
1117}
1118
61c083e7 1119void MyPanel::OnPageChanging( wxBookCtrlEvent &event )
4d0f3cd6 1120{
45e41c05
VZ
1121 int selOld = event.GetOldSelection();
1122 if ( selOld == 2 )
4d0f3cd6 1123 {
9f84eccd
MB
1124 if ( wxMessageBox(_T("This demonstrates how a program may prevent the\n")
1125 _T("page change from taking place - if you select\n")
1126 _T("[No] the current page will stay the third one\n"),
1127 _T("Control sample"),
f6bcfd97 1128 wxICON_QUESTION | wxYES_NO, this) != wxYES )
8c3c31d4
VZ
1129 {
1130 event.Veto();
45e41c05 1131
8c3c31d4
VZ
1132 return;
1133 }
4d0f3cd6 1134 }
45e41c05 1135
61c083e7 1136 *m_text << _T("Book selection is being changed from ") << selOld
9f84eccd 1137 << _T(" to ") << event.GetSelection()
61c083e7
WS
1138 << _T(" (current page from book is ")
1139 << m_book->GetSelection() << _T(")\n");
4d0f3cd6
VZ
1140}
1141
61c083e7 1142void MyPanel::OnPageChanged( wxBookCtrlEvent &event )
cb43b372 1143{
61c083e7
WS
1144 *m_text << _T("Book selection is now ") << event.GetSelection()
1145 << _T(" (from book: ") << m_book->GetSelection()
9f84eccd 1146 << _T(")\n");
cb43b372
RR
1147}
1148
3e2dd3db
VZ
1149void MyPanel::OnTestButton(wxCommandEvent& event)
1150{
1151 wxLogMessage(_T("Button %c clicked."),
1152 event.GetId() == ID_BUTTON_TEST1 ? _T('1') : _T('2'));
1153}
1154
87728739 1155void MyPanel::OnBmpButton(wxCommandEvent& WXUNUSED(event))
9121bed2
VZ
1156{
1157 wxLogMessage(_T("Bitmap button clicked."));
1158}
1159
bebc503c
VZ
1160void MyPanel::OnBmpButtonToggle(wxCommandEvent& event)
1161{
1162 FindWindow(ID_BITMAP_BTN)->Enable(!event.IsChecked());
1163}
1164
87a1e308
VZ
1165void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
1166{
1167 static wxColour s_colOld;
1168
29c749b8 1169 SetThemeEnabled(false);
87a1e308
VZ
1170 // test panel colour changing and propagation to the subcontrols
1171 if ( s_colOld.Ok() )
1172 {
1173 SetBackgroundColour(s_colOld);
1174 s_colOld = wxNullColour;
1175
29c749b8
VS
1176 m_lbSelectThis->SetForegroundColour(wxNullColour);
1177 m_lbSelectThis->SetBackgroundColour(wxNullColour);
87a1e308
VZ
1178 }
1179 else
1180 {
a60b1f5d
MB
1181 s_colOld = wxColour(wxT("red"));
1182 SetBackgroundColour(wxT("white"));
87a1e308 1183
a60b1f5d
MB
1184 m_lbSelectThis->SetForegroundColour(wxT("white"));
1185 m_lbSelectThis->SetBackgroundColour(wxT("red"));
87a1e308
VZ
1186 }
1187
1188 m_lbSelectThis->Refresh();
1189 Refresh();
1190}
1191
1c005ff7
RR
1192void MyPanel::OnListBox( wxCommandEvent &event )
1193{
846e1424
RR
1194 if (event.GetInt() == -1)
1195 {
9f84eccd 1196 m_text->AppendText( _T("ListBox has no selections anymore\n") );
846e1424
RR
1197 return;
1198 }
1199
6c8a980f
VZ
1200 wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
1201 : m_listboxSorted;
1202
9f84eccd 1203 m_text->AppendText( _T("ListBox event selection string is: '") );
ec9f7884 1204 m_text->AppendText( event.GetString() );
9f84eccd 1205 m_text->AppendText( _T("'\n") );
45262a34
VZ
1206
1207 // can't use GetStringSelection() with multiple selections, there could be
1208 // more than one of them
1209 if ( !listbox->HasFlag(wxLB_MULTIPLE) )
1210 {
1211 m_text->AppendText( _T("ListBox control selection string is: '") );
1212 m_text->AppendText( listbox->GetStringSelection() );
1213 m_text->AppendText( _T("'\n") );
1214 }
6c8a980f
VZ
1215
1216 wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
9f84eccd 1217 m_text->AppendText( _T("ListBox event client data string is: '") );
6e47faf1 1218 if (obj) // BC++ doesn't like use of '? .. : .. ' in this context
74a533f7 1219 m_text->AppendText( obj->GetData() );
6e47faf1 1220 else
9f84eccd 1221 m_text->AppendText( wxString(_T("none")) );
6e47faf1 1222
9f84eccd
MB
1223 m_text->AppendText( _T("'\n") );
1224 m_text->AppendText( _T("ListBox control client data string is: '") );
45262a34 1225 obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt());
6e47faf1 1226 if (obj)
74a533f7 1227 m_text->AppendText( obj->GetData() );
6e47faf1 1228 else
9f84eccd
MB
1229 m_text->AppendText( wxString(_T("none")) );
1230 m_text->AppendText( _T("'\n") );
1c005ff7
RR
1231}
1232
5b077d48
RR
1233void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
1234{
9f84eccd 1235 m_text->AppendText( _T("ListBox double click string is: ") );
ec9f7884 1236 m_text->AppendText( event.GetString() );
9f84eccd 1237 m_text->AppendText( _T("\n") );
5b077d48
RR
1238}
1239
47908e25
RR
1240void MyPanel::OnListBoxButtons( wxCommandEvent &event )
1241{
ec9f7884 1242 switch (event.GetId())
d3904ceb 1243 {
ec9f7884
VZ
1244 case ID_LISTBOX_ENABLE:
1245 {
9f84eccd 1246 m_text->AppendText(_T("Checkbox clicked.\n"));
b8653fbf 1247#if wxUSE_TOOLTIPS
0ae0226b 1248 wxCheckBox *cb = (wxCheckBox*)event.GetEventObject();
ec9f7884 1249 if (event.GetInt())
9f84eccd 1250 cb->SetToolTip( _T("Click to enable listbox") );
ec9f7884 1251 else
9f84eccd 1252 cb->SetToolTip( _T("Click to disable listbox") );
16f6dfd8 1253#endif // wxUSE_TOOLTIPS
ec9f7884 1254 m_listbox->Enable( event.GetInt() == 0 );
57160afe
VZ
1255 m_lbSelectThis->Enable( event.GetInt() == 0 );
1256 m_lbSelectNum->Enable( event.GetInt() == 0 );
6c8a980f 1257 m_listboxSorted->Enable( event.GetInt() == 0 );
ee6e1b1d 1258 FindWindow(ID_CHANGE_COLOUR)->Enable( event.GetInt() == 0 );
ec9f7884
VZ
1259 break;
1260 }
1261 case ID_LISTBOX_SEL_NUM:
1262 {
91f2c154
JS
1263 if (m_listbox->GetCount() > 2)
1264 m_listbox->SetSelection( 2 );
1265 if (m_listboxSorted->GetCount() > 2)
1266 m_listboxSorted->SetSelection( 2 );
8c3c31d4 1267 m_lbSelectThis->WarpPointer( 40, 14 );
ec9f7884
VZ
1268 break;
1269 }
1270 case ID_LISTBOX_SEL_STR:
1271 {
5014bb3a 1272 if (m_listbox->FindString(_T("This")) != wxNOT_FOUND)
91f2c154 1273 m_listbox->SetStringSelection( _T("This") );
5014bb3a 1274 if (m_listboxSorted->FindString(_T("This")) != wxNOT_FOUND)
91f2c154 1275 m_listboxSorted->SetStringSelection( _T("This") );
8c3c31d4 1276 m_lbSelectNum->WarpPointer( 40, 14 );
ec9f7884
VZ
1277 break;
1278 }
1279 case ID_LISTBOX_CLEAR:
1280 {
1281 m_listbox->Clear();
6c8a980f 1282 m_listboxSorted->Clear();
ec9f7884
VZ
1283 break;
1284 }
1285 case ID_LISTBOX_APPEND:
1286 {
9f84eccd
MB
1287 m_listbox->Append( _T("Hi!") );
1288 m_listboxSorted->Append( _T("Hi!") );
ec9f7884
VZ
1289 break;
1290 }
1291 case ID_LISTBOX_DELETE:
1292 {
6c8a980f
VZ
1293 int idx;
1294 idx = m_listbox->GetSelection();
f6bcfd97
BP
1295 if ( idx != wxNOT_FOUND )
1296 m_listbox->Delete( idx );
6c8a980f 1297 idx = m_listboxSorted->GetSelection();
f6bcfd97
BP
1298 if ( idx != wxNOT_FOUND )
1299 m_listboxSorted->Delete( idx );
ec9f7884
VZ
1300 break;
1301 }
1302 case ID_LISTBOX_FONT:
1303 {
1304 m_listbox->SetFont( *wxITALIC_FONT );
6c8a980f 1305 m_listboxSorted->SetFont( *wxITALIC_FONT );
ec9f7884
VZ
1306 m_checkbox->SetFont( *wxITALIC_FONT );
1307 break;
1308 }
868a2826 1309 }
47908e25
RR
1310}
1311
1ccd23f5 1312#if wxUSE_CHOICE
bc50a2ae 1313
da603a67 1314static wxString GetDataString(wxClientData *data)
bc50a2ae 1315{
da603a67
VZ
1316 return data ? wx_static_cast(wxStringClientData *, data)->GetData()
1317 : wxString("none");
bc50a2ae
VZ
1318}
1319
47908e25
RR
1320void MyPanel::OnChoice( wxCommandEvent &event )
1321{
6c8a980f
VZ
1322 wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice
1323 : m_choiceSorted;
1324
bc50a2ae 1325 const int sel = choice->GetSelection();
6c8a980f 1326
bc50a2ae
VZ
1327 wxClientData *dataEvt = event.GetClientObject(),
1328 *dataCtrl = choice->GetClientObject(sel);
6e47faf1 1329
bc50a2ae
VZ
1330 wxLogMessage(_T("EVT_CHOICE: item %d/%d (event/control), ")
1331 _T("string \"%s\"/\"%s\", ")
1332 _T("data \"%s\"/\"%s\""),
1333 (int)event.GetInt(),
1334 sel,
da603a67
VZ
1335 event.GetString(),
1336 choice->GetStringSelection(),
bc50a2ae
VZ
1337 GetDataString(dataEvt),
1338 GetDataString(dataCtrl));
47908e25
RR
1339}
1340
1341void MyPanel::OnChoiceButtons( wxCommandEvent &event )
1342{
ec9f7884 1343 switch (event.GetId())
47908e25 1344 {
ec9f7884
VZ
1345 case ID_CHOICE_ENABLE:
1346 {
1347 m_choice->Enable( event.GetInt() == 0 );
b56c2246 1348 m_choiceSorted->Enable( event.GetInt() == 0 );
ec9f7884
VZ
1349 break;
1350 }
1351 case ID_CHOICE_SEL_NUM:
1352 {
1353 m_choice->SetSelection( 2 );
b56c2246 1354 m_choiceSorted->SetSelection( 2 );
ec9f7884
VZ
1355 break;
1356 }
1357 case ID_CHOICE_SEL_STR:
1358 {
9f84eccd
MB
1359 m_choice->SetStringSelection( _T("This") );
1360 m_choiceSorted->SetStringSelection( _T("This") );
ec9f7884
VZ
1361 break;
1362 }
1363 case ID_CHOICE_CLEAR:
1364 {
1365 m_choice->Clear();
b56c2246 1366 m_choiceSorted->Clear();
ec9f7884
VZ
1367 break;
1368 }
1369 case ID_CHOICE_APPEND:
1370 {
9f84eccd
MB
1371 m_choice->Append( _T("Hi!") );
1372 m_choiceSorted->Append( _T("Hi!") );
ec9f7884
VZ
1373 break;
1374 }
1375 case ID_CHOICE_DELETE:
1376 {
1377 int idx = m_choice->GetSelection();
f6bcfd97
BP
1378 if ( idx != wxNOT_FOUND )
1379 m_choice->Delete( idx );
b56c2246 1380 idx = m_choiceSorted->GetSelection();
f6bcfd97
BP
1381 if ( idx != wxNOT_FOUND )
1382 m_choiceSorted->Delete( idx );
ec9f7884
VZ
1383 break;
1384 }
1385 case ID_CHOICE_FONT:
1386 {
1387 m_choice->SetFont( *wxITALIC_FONT );
b56c2246 1388 m_choiceSorted->SetFont( *wxITALIC_FONT );
ec9f7884
VZ
1389 break;
1390 }
868a2826 1391 }
47908e25 1392}
1ccd23f5 1393#endif // wxUSE_CHOICE
47908e25
RR
1394
1395void MyPanel::OnCombo( wxCommandEvent &event )
1396{
00dff4d2
JS
1397 if (!m_combo)
1398 return;
1399
f226be17 1400 wxLogMessage(_T("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
0d29fecd 1401 (int)event.GetInt(),
f226be17
VZ
1402 m_combo->GetSelection(),
1403 event.GetString().c_str(),
1404 m_combo->GetStringSelection().c_str());
47908e25
RR
1405}
1406
27ff87da 1407void MyPanel::OnComboTextChanged(wxCommandEvent& event)
f6bcfd97 1408{
7c2151fa
SN
1409 if (m_combo)
1410 wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
1411 event.GetString().c_str(),
1412 m_combo->GetValue().c_str());
f6bcfd97
BP
1413}
1414
1415void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))
1416{
7c2151fa
SN
1417 if (m_combo)
1418 wxLogMessage(_T("Enter pressed in the combobox: value is '%s'."),
1419 m_combo->GetValue().c_str());
f6bcfd97
BP
1420}
1421
47908e25 1422void MyPanel::OnComboButtons( wxCommandEvent &event )
1c005ff7 1423{
ec9f7884 1424 switch (event.GetId())
2f6407b9 1425 {
ec9f7884
VZ
1426 case ID_COMBO_ENABLE:
1427 {
1428 m_combo->Enable( event.GetInt() == 0 );
1429 break;
1430 }
1431 case ID_COMBO_SEL_NUM:
1432 {
1433 m_combo->SetSelection( 2 );
1434 break;
1435 }
1436 case ID_COMBO_SEL_STR:
1437 {
9f84eccd 1438 m_combo->SetStringSelection( _T("This") );
ec9f7884
VZ
1439 break;
1440 }
1441 case ID_COMBO_CLEAR:
1442 {
1443 m_combo->Clear();
1444 break;
1445 }
1446 case ID_COMBO_APPEND:
1447 {
9f84eccd 1448 m_combo->Append( _T("Hi!") );
ec9f7884
VZ
1449 break;
1450 }
1451 case ID_COMBO_DELETE:
1452 {
1453 int idx = m_combo->GetSelection();
1454 m_combo->Delete( idx );
1455 break;
1456 }
1457 case ID_COMBO_FONT:
1458 {
1459 m_combo->SetFont( *wxITALIC_FONT );
1460 break;
1461 }
cc7e9e20
RR
1462 case ID_COMBO_SET_TEXT:
1463 {
1464 m_combo->SetString( 2, wxT("Hi!") );
1465 break;
1466 }
868a2826 1467 }
47908e25
RR
1468}
1469
1470void MyPanel::OnRadio( wxCommandEvent &event )
1471{
9f84eccd 1472 m_text->AppendText( _T("RadioBox selection string is: ") );
ec9f7884 1473 m_text->AppendText( event.GetString() );
9f84eccd 1474 m_text->AppendText( _T("\n") );
47908e25
RR
1475}
1476
a48b9bfb
VZ
1477void MyPanel::OnRadioButton1( wxCommandEvent & WXUNUSED(event) )
1478{
1479 wxMessageBox(_T("First wxRadioButton selected."), _T("wxControl sample"));
1480}
1481
1482void MyPanel::OnRadioButton2( wxCommandEvent & WXUNUSED(event) )
1483{
1484 m_text->AppendText(_T("Second wxRadioButton selected.\n"));
1485}
1486
47908e25
RR
1487void MyPanel::OnRadioButtons( wxCommandEvent &event )
1488{
ec9f7884 1489 switch (event.GetId())
d3904ceb 1490 {
ec9f7884 1491 case ID_RADIOBOX_ENABLE:
7891b4d4
VZ
1492 m_radio->Enable( event.GetInt() == 0 );
1493 break;
1494
ec9f7884 1495 case ID_RADIOBOX_SEL_NUM:
7891b4d4
VZ
1496 m_radio->SetSelection( 2 );
1497 break;
1498
ec9f7884 1499 case ID_RADIOBOX_SEL_STR:
7891b4d4
VZ
1500 m_radio->SetStringSelection( _T("This") );
1501 break;
8b1d8f36 1502
7891b4d4
VZ
1503 case ID_RADIOBOX_FONT:
1504 m_radio->SetFont( *wxITALIC_FONT );
1505 break;
868a2826 1506 }
1c005ff7
RR
1507}
1508
868a2826
RR
1509void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) )
1510{
ec9f7884
VZ
1511 m_fontButton->SetFont( *wxITALIC_FONT );
1512 m_text->SetFont( *wxITALIC_FONT );
868a2826
RR
1513}
1514
1db8dc4a 1515void MyPanel::OnUpdateLabel( wxCommandEvent &event )
185fa6bf 1516{
9f84eccd
MB
1517 m_label->SetLabel(event.GetInt() ? _T("Very very very very very long text.")
1518 : _T("Shorter text."));
185fa6bf
VZ
1519}
1520
6bb44116
WS
1521#if wxUSE_SLIDER
1522
7bce6aec
RR
1523void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
1524{
516ab399 1525#if wxUSE_GAUGE
ec9f7884 1526 m_gauge->SetValue( m_slider->GetValue() );
37ed3ae3 1527 m_gaugeVert->SetValue( m_slider->GetValue() / 2 );
516ab399 1528#endif // wxUSE_GAUGE
7bce6aec
RR
1529}
1530
6bb44116
WS
1531#endif // wxUSE_SLIDER
1532
baccb514
VZ
1533#if wxUSE_SPINCTRL
1534
76106901
VZ
1535void MyPanel::OnSpinCtrlText(wxCommandEvent& event)
1536{
1537 if ( m_spinctrl )
1538 {
1539 wxString s;
508d586e
MB
1540 s.Printf( _T("Spin ctrl text changed: now %d (from event: %s)\n"),
1541 m_spinctrl->GetValue(), event.GetString().c_str() );
76106901
VZ
1542 m_text->AppendText(s);
1543 }
1544}
1545
457e6c54 1546void MyPanel::OnSpinCtrl(wxSpinEvent& event)
baccb514 1547{
76106901
VZ
1548 if ( m_spinctrl )
1549 {
1550 wxString s;
33cf9a19 1551 s.Printf( _T("Spin ctrl changed: now %d (from event: %d)\n"),
508d586e 1552 m_spinctrl->GetValue(), event.GetInt() );
76106901
VZ
1553 m_text->AppendText(s);
1554 }
1555}
1556
1557void MyPanel::OnSpinCtrlUp(wxSpinEvent& event)
1558{
1559 if ( m_spinctrl )
1560 {
508d586e 1561 m_text->AppendText( wxString::Format(
33cf9a19 1562 _T("Spin up: %d (from event: %d)\n"),
508d586e 1563 m_spinctrl->GetValue(), event.GetInt() ) );
76106901
VZ
1564 }
1565}
1566
1567void MyPanel::OnSpinCtrlDown(wxSpinEvent& event)
1568{
1569 if ( m_spinctrl )
1570 {
508d586e 1571 m_text->AppendText( wxString::Format(
33cf9a19 1572 _T("Spin down: %d (from event: %d)\n"),
508d586e 1573 m_spinctrl->GetValue(), event.GetInt() ) );
76106901 1574 }
baccb514
VZ
1575}
1576
1577#endif // wxUSE_SPINCTRL
1578
0e528b99 1579#if wxUSE_SPINBTN
8c3c31d4
VZ
1580void MyPanel::OnSpinUp( wxSpinEvent &event )
1581{
1582 wxString value;
1583 value.Printf( _T("Spin control up: current = %d\n"),
1584 m_spinbutton->GetValue());
1585
e94ff4cb 1586 if ( event.GetPosition() > 17 )
8c3c31d4
VZ
1587 {
1588 value += _T("Preventing the spin button from going above 17.\n");
1589
1590 event.Veto();
1591 }
1592
1593 m_text->AppendText(value);
1594}
1595
1596void MyPanel::OnSpinDown( wxSpinEvent &event )
1597{
1598 wxString value;
1599 value.Printf( _T("Spin control down: current = %d\n"),
1600 m_spinbutton->GetValue());
1601
e94ff4cb 1602 if ( event.GetPosition() < -17 )
8c3c31d4
VZ
1603 {
1604 value += _T("Preventing the spin button from going below -17.\n");
1605
1606 event.Veto();
1607 }
1608
1609 m_text->AppendText(value);
1610}
1611
e380f72b
RR
1612void MyPanel::OnSpinUpdate( wxSpinEvent &event )
1613{
ec9f7884 1614 wxString value;
f70d5829 1615 value.Printf( _T("%d"), event.GetPosition() );
ec9f7884 1616 m_spintext->SetValue( value );
6380910c 1617
f70d5829 1618 value.Printf( _T("Spin control range: (%d, %d), current = %d\n"),
6380910c
VZ
1619 m_spinbutton->GetMin(), m_spinbutton->GetMax(),
1620 m_spinbutton->GetValue());
1621
1622 m_text->AppendText(value);
e380f72b 1623}
9726da4f 1624
fe1bc285 1625void MyPanel::OnNewText( wxCommandEvent& /* event */)
1dd815f3
RR
1626{
1627 m_nonWrappingText->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") );
1628 m_wrappingText->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );
1629 m_wrappingText->GetParent()->Layout();
1630}
1631
516ab399
WS
1632#if wxUSE_PROGRESSDLG
1633
9726da4f
VZ
1634void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event )
1635{
1636 event.Enable( m_spinbutton->GetValue() > 0 );
1637}
1638
1639void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
1640{
1641 int max = m_spinbutton->GetValue();
61c083e7 1642
601964ff
VS
1643 if ( max <= 0 )
1644 {
1645 wxLogError(_T("You must set positive range!"));
1646 return;
1647 }
61c083e7 1648
9f84eccd
MB
1649 wxProgressDialog dialog(_T("Progress dialog example"),
1650 _T("An informative message"),
9726da4f
VZ
1651 max, // range
1652 this, // parent
8c3c31d4 1653 wxPD_CAN_ABORT |
2c8e4738 1654 wxPD_AUTO_HIDE |
8c3c31d4
VZ
1655 wxPD_APP_MODAL |
1656 wxPD_ELAPSED_TIME |
1657 wxPD_ESTIMATED_TIME |
1658 wxPD_REMAINING_TIME);
2ac1b69a 1659
9726da4f 1660
9230b621 1661 bool cont = true;
abceee76 1662 for ( int i = 0; i <= max && cont; i++ )
9726da4f
VZ
1663 {
1664 wxSleep(1);
abceee76 1665 if ( i == max )
be9abe3f 1666 {
9f84eccd 1667 cont = dialog.Update(i, _T("That's all, folks!"));
be9abe3f
VZ
1668 }
1669 else if ( i == max / 2 )
9726da4f 1670 {
9f84eccd 1671 cont = dialog.Update(i, _T("Only a half left (very long message)!"));
9726da4f
VZ
1672 }
1673 else
1674 {
1675 cont = dialog.Update(i);
1676 }
1677 }
1678
1679 if ( !cont )
1680 {
9f84eccd 1681 *m_text << _T("Progress dialog aborted!\n");
9726da4f
VZ
1682 }
1683 else
1684 {
9f84eccd 1685 *m_text << _T("Countdown from ") << max << _T(" finished.\n");
9726da4f
VZ
1686 }
1687}
1688
516ab399 1689#endif // wxUSE_PROGRESSDLG
0e528b99 1690#endif // wxUSE_SPINBTN
e380f72b 1691
2b5f62a0
VZ
1692void MyPanel::OnSizerCheck( wxCommandEvent &event)
1693{
1694 switch (event.GetId ()) {
1695 case ID_SIZER_CHECK1:
1696 m_buttonSizer->Show (m_sizerBtn1, event.IsChecked ());
1697 m_buttonSizer->Layout ();
1698 break;
1699 case ID_SIZER_CHECK2:
1700 m_buttonSizer->Show (m_sizerBtn2, event.IsChecked ());
1701 m_buttonSizer->Layout ();
1702 break;
1703 case ID_SIZER_CHECK3:
1704 m_buttonSizer->Show (m_sizerBtn3, event.IsChecked ());
1705 m_buttonSizer->Layout ();
1706 break;
1707 case ID_SIZER_CHECK4:
1708 m_buttonSizer->Show (m_sizerBtn4, event.IsChecked ());
1709 m_buttonSizer->Layout ();
1710 break;
1711 case ID_SIZER_CHECK14:
1712 m_hsizer->Show (m_buttonSizer, event.IsChecked ());
1713 m_hsizer->Layout ();
1714 break;
1715 case ID_SIZER_CHECKBIG:
1716 m_hsizer->Show (m_bigBtn, event.IsChecked ());
1717 m_hsizer->Layout ();
1718 break;
1719 }
1720
1721}
1722
2cb21a45
VZ
1723MyPanel::~MyPanel()
1724{
29e7e51a
VZ
1725 //wxLog::RemoveTraceMask(_T("focus"));
1726 delete wxLog::SetActiveTarget(m_logTargetOld);
1727
61c083e7 1728 delete m_book->GetImageList();
2cb21a45
VZ
1729}
1730
1c005ff7
RR
1731//----------------------------------------------------------------------
1732// MyFrame
1733//----------------------------------------------------------------------
1734
1735BEGIN_EVENT_TABLE(MyFrame, wxFrame)
3e2dd3db
VZ
1736 EVT_MENU(CONTROLS_QUIT, MyFrame::OnQuit)
1737 EVT_MENU(CONTROLS_ABOUT, MyFrame::OnAbout)
1738 EVT_MENU(CONTROLS_CLEAR_LOG, MyFrame::OnClearLog)
16f6dfd8 1739#if wxUSE_TOOLTIPS
3e2dd3db
VZ
1740 EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay)
1741 EVT_MENU(CONTROLS_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips)
16f6dfd8 1742#endif // wxUSE_TOOLTIPS
87a1e308 1743
3e2dd3db 1744 EVT_MENU(CONTROLS_ENABLE_ALL, MyFrame::OnEnableAll)
47a8a4d5
VZ
1745 EVT_MENU(CONTROLS_HIDE_ALL, MyFrame::OnHideAll)
1746 EVT_MENU(CONTROLS_HIDE_LIST, MyFrame::OnHideList)
1a8b677e 1747 EVT_MENU(CONTROLS_CONTEXT_HELP, MyFrame::OnContextHelp)
87a1e308 1748
35960bbf
VZ
1749 EVT_ICONIZE(MyFrame::OnIconized)
1750 EVT_MAXIMIZE(MyFrame::OnMaximized)
87a1e308 1751 EVT_SIZE(MyFrame::OnSize)
97206645
VZ
1752 EVT_MOVE(MyFrame::OnMove)
1753
87a1e308 1754 EVT_IDLE(MyFrame::OnIdle)
1c005ff7
RR
1755END_EVENT_TABLE()
1756
9f84eccd 1757MyFrame::MyFrame(const wxChar *title, int x, int y)
c4ef14c2 1758 : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450))
1c005ff7 1759{
1a8b677e
VZ
1760 SetHelpText( _T("Controls sample demonstrating various widgets") );
1761
7bfc22f6
VZ
1762 // Give it an icon
1763 // The wxICON() macros loads an icon from a resource under Windows
1764 // and uses an #included XPM image under GTK+ and Motif
1765
cbf3565d 1766#ifdef USE_XPM
7bfc22f6 1767 SetIcon( wxICON(mondrian) );
cbf3565d 1768#endif
7bfc22f6
VZ
1769
1770 wxMenu *file_menu = new wxMenu;
1771
9f84eccd 1772 file_menu->Append(CONTROLS_CLEAR_LOG, _T("&Clear log\tCtrl-L"));
7bfc22f6 1773 file_menu->AppendSeparator();
9f84eccd 1774 file_menu->Append(CONTROLS_ABOUT, _T("&About\tF1"));
7bfc22f6 1775 file_menu->AppendSeparator();
9f84eccd 1776 file_menu->Append(CONTROLS_QUIT, _T("E&xit\tAlt-X"), _T("Quit controls sample"));
7bfc22f6
VZ
1777
1778 wxMenuBar *menu_bar = new wxMenuBar;
9f84eccd 1779 menu_bar->Append(file_menu, _T("&File"));
7bfc22f6
VZ
1780
1781#if wxUSE_TOOLTIPS
1782 wxMenu *tooltip_menu = new wxMenu;
9f84eccd 1783 tooltip_menu->Append(CONTROLS_SET_TOOLTIP_DELAY, _T("Set &delay\tCtrl-D"));
7bfc22f6 1784 tooltip_menu->AppendSeparator();
9f84eccd 1785 tooltip_menu->Append(CONTROLS_ENABLE_TOOLTIPS, _T("&Toggle tooltips\tCtrl-T"),
9230b621
VS
1786 _T("enable/disable tooltips"), true);
1787 tooltip_menu->Check(CONTROLS_ENABLE_TOOLTIPS, true);
9f84eccd 1788 menu_bar->Append(tooltip_menu, _T("&Tooltips"));
7bfc22f6
VZ
1789#endif // wxUSE_TOOLTIPS
1790
1791 wxMenu *panel_menu = new wxMenu;
9f84eccd 1792 panel_menu->Append(CONTROLS_ENABLE_ALL, _T("&Disable all\tCtrl-E"),
9230b621 1793 _T("Enable/disable all panel controls"), true);
47a8a4d5
VZ
1794 panel_menu->Append(CONTROLS_HIDE_ALL, _T("&Hide all\tCtrl-I"),
1795 _T("Show/hide thoe whole panel controls"), true);
1796 panel_menu->Append(CONTROLS_HIDE_LIST, _T("Hide &list ctrl\tCtrl-S"),
1797 _T("Enable/disable all panel controls"), true);
1a8b677e
VZ
1798 panel_menu->Append(CONTROLS_CONTEXT_HELP, _T("&Context help...\tCtrl-H"),
1799 _T("Get context help for a control"));
9f84eccd 1800 menu_bar->Append(panel_menu, _T("&Panel"));
7bfc22f6
VZ
1801
1802 SetMenuBar(menu_bar);
1803
960a83cc 1804#if wxUSE_STATUSBAR
5fb9fcfc 1805 CreateStatusBar(2);
960a83cc 1806#endif // wxUSE_STATUSBAR
9f3362c4 1807
87a1e308 1808 m_panel = new MyPanel( this, 10, 10, 300, 100 );
1c005ff7
RR
1809}
1810
1811void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )
1812{
9230b621 1813 Close(true);
1c005ff7
RR
1814}
1815
1816void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
1817{
abceee76
VZ
1818 wxBusyCursor bc;
1819
9f84eccd 1820 wxMessageDialog dialog(this, _T("This is a control sample"), _T("About Controls"), wxOK );
ec9f7884 1821 dialog.ShowModal();
1c005ff7 1822}
9f3362c4 1823
3e2dd3db
VZ
1824void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
1825{
1826 m_panel->m_text->Clear();
1827}
1828
16f6dfd8 1829#if wxUSE_TOOLTIPS
87728739 1830void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event))
16f6dfd8
VZ
1831{
1832 static long s_delay = 5000;
1833
1834 wxString delay;
f70d5829 1835 delay.Printf( _T("%ld"), s_delay);
16f6dfd8 1836
9f84eccd
MB
1837 delay = wxGetTextFromUser(_T("Enter delay (in milliseconds)"),
1838 _T("Set tooltip delay"),
ec9f7884
VZ
1839 delay,
1840 this);
16f6dfd8
VZ
1841 if ( !delay )
1842 return; // cancelled
1843
f70d5829 1844 wxSscanf(delay, _T("%ld"), &s_delay);
16f6dfd8
VZ
1845
1846 wxToolTip::SetDelay(s_delay);
1847
f70d5829 1848 wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay);
16f6dfd8
VZ
1849}
1850
87728739 1851void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event))
16f6dfd8 1852{
9230b621 1853 static bool s_enabled = true;
16f6dfd8
VZ
1854
1855 s_enabled = !s_enabled;
1856
1857 wxToolTip::Enable(s_enabled);
1858
f70d5829 1859 wxLogStatus(this, _T("Tooltips %sabled"), s_enabled ? _T("en") : _T("dis") );
16f6dfd8
VZ
1860}
1861#endif // tooltips
1862
87a1e308
VZ
1863void MyFrame::OnEnableAll(wxCommandEvent& WXUNUSED(event))
1864{
9230b621 1865 static bool s_enable = true;
87a1e308
VZ
1866
1867 s_enable = !s_enable;
1868 m_panel->Enable(s_enable);
47a8a4d5
VZ
1869 static bool s_enableCheckbox = true;
1870 if ( !s_enable )
1871 {
1872 // this is a test for correct behaviour of either enabling or disabling
1873 // a child when its parent is disabled: the checkbox should have the
1874 // correct state when the parent is enabled back
1875 m_panel->m_checkbox->Enable(s_enableCheckbox);
1876 s_enableCheckbox = !s_enableCheckbox;
1877 }
1878}
1879
1880void MyFrame::OnHideAll(wxCommandEvent& WXUNUSED(event))
1881{
1882 static bool s_show = true;
1883
1884 s_show = !s_show;
1885 m_panel->Show(s_show);
1886}
1887
1888void MyFrame::OnHideList(wxCommandEvent& WXUNUSED(event))
1889{
1890 static bool s_show = true;
1891
1892 s_show = !s_show;
1893 m_panel->m_listbox->Show(s_show);
87a1e308
VZ
1894}
1895
1a8b677e
VZ
1896void MyFrame::OnContextHelp(wxCommandEvent& WXUNUSED(event))
1897{
1898 // starts a local event loop
1899 wxContextHelp chelp(this);
1900}
1901
97206645
VZ
1902void MyFrame::OnMove( wxMoveEvent& event )
1903{
960a83cc 1904#if wxUSE_STATUSBAR
97206645 1905 UpdateStatusBar(event.GetPosition(), GetSize());
960a83cc 1906#endif // wxUSE_STATUSBAR
97206645
VZ
1907
1908 event.Skip();
1909}
1910
35960bbf
VZ
1911void MyFrame::OnIconized( wxIconizeEvent& event )
1912{
1913 wxLogMessage(_T("Frame %s"), event.Iconized() ? _T("iconized")
1914 : _T("restored"));
1915 event.Skip();
1916}
1917
1918void MyFrame::OnMaximized( wxMaximizeEvent& WXUNUSED(event) )
1919{
1920 wxLogMessage(_T("Frame maximized"));
1921}
1922
5fb9fcfc
VZ
1923void MyFrame::OnSize( wxSizeEvent& event )
1924{
960a83cc 1925#if wxUSE_STATUSBAR
97206645 1926 UpdateStatusBar(GetPosition(), event.GetSize());
960a83cc 1927#endif // wxUSE_STATUSBAR
5fb9fcfc
VZ
1928
1929 event.Skip();
1930}
1931
9f3362c4
VZ
1932void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
1933{
1934 // track the window which has the focus in the status bar
2dd8d2d7 1935 static wxWindow *s_windowFocus = NULL;
9f3362c4 1936 wxWindow *focus = wxWindow::FindFocus();
2dd8d2d7 1937 if ( focus != s_windowFocus )
9f3362c4
VZ
1938 {
1939 s_windowFocus = focus;
1940
1941 wxString msg;
2dd8d2d7
VZ
1942 if ( focus )
1943 {
1944 msg.Printf(
1945 _T("Focus: %s")
9f3362c4 1946#ifdef __WXMSW__
5cb83740 1947 , _T(", HWND = %08x")
f70d5829 1948#endif
2dd8d2d7 1949 , s_windowFocus->GetName().c_str()
9f3362c4 1950#ifdef __WXMSW__
2dd8d2d7 1951 , (unsigned int) s_windowFocus->GetHWND()
f70d5829 1952#endif
2dd8d2d7
VZ
1953 );
1954 }
1955 else
1956 {
1957 msg = _T("No focus");
1958 }
9f3362c4 1959
960a83cc 1960#if wxUSE_STATUSBAR
9f3362c4 1961 SetStatusText(msg);
960a83cc 1962#endif // wxUSE_STATUSBAR
9f3362c4 1963 }
341c92a8 1964}
6c8a980f 1965
f6bcfd97
BP
1966void MyComboBox::OnChar(wxKeyEvent& event)
1967{
1968 wxLogMessage(_T("MyComboBox::OnChar"));
1969
b1d4dd7a 1970 if ( event.GetKeyCode() == 'w' )
f6bcfd97
BP
1971 wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
1972 else
1973 event.Skip();
1974}
1975
1976void MyComboBox::OnKeyDown(wxKeyEvent& event)
1977{
1978 wxLogMessage(_T("MyComboBox::OnKeyDown"));
1979
b1d4dd7a 1980 if ( event.GetKeyCode() == 'w' )
f6bcfd97
BP
1981 wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
1982 else
1983 event.Skip();
1984}
1985
1986void MyComboBox::OnKeyUp(wxKeyEvent& event)
1987{
1988 wxLogMessage(_T("MyComboBox::OnKeyUp"));
1989
1990 event.Skip();
1991}
1992
8b81a824
VS
1993static void SetListboxClientData(const wxChar *name, wxListBox *control)
1994{
1995 size_t count = control->GetCount();
1996 for ( size_t n = 0; n < count; n++ )
1997 {
1998 wxString s;
1999 s.Printf(wxT("%s client data for '%s'"),
2000 name, control->GetString(n).c_str());
2001
2002 control->SetClientObject(n, new wxStringClientData(s));
2003 }
2004}
2005
2b5f62a0
VZ
2006#if wxUSE_CHOICE
2007
8b81a824 2008static void SetChoiceClientData(const wxChar *name, wxChoice *control)
6c8a980f
VZ
2009{
2010 size_t count = control->GetCount();
2011 for ( size_t n = 0; n < count; n++ )
2012 {
2013 wxString s;
4acb6ca6 2014 s.Printf(wxT("%s client data for '%s'"),
6c8a980f
VZ
2015 name, control->GetString(n).c_str());
2016
2017 control->SetClientObject(n, new wxStringClientData(s));
2018 }
2019}
2b5f62a0
VZ
2020
2021#endif // wxUSE_CHOICE