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