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