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