]>
Commit | Line | Data |
---|---|---|
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 | ||
68 | class MyApp: public wxApp | |
655822f3 | 69 | { |
b8653fbf VZ |
70 | public: |
71 | bool OnInit(); | |
1c005ff7 RR |
72 | }; |
73 | ||
74 | class MyPanel: public wxPanel | |
75 | { | |
b8653fbf | 76 | public: |
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 | 178 | private: |
29e7e51a VZ |
179 | wxLog *m_logTargetOld; |
180 | ||
b8653fbf | 181 | DECLARE_EVENT_TABLE() |
1c005ff7 RR |
182 | }; |
183 | ||
184 | class MyFrame: public wxFrame | |
185 | { | |
b8653fbf | 186 | public: |
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 | 214 | private: |
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...) |
239 | class MyButton : public wxButton | |
240 | { | |
241 | public: | |
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 | ||
258 | private: | |
259 | DECLARE_EVENT_TABLE() | |
260 | }; | |
261 | ||
262 | // a combo which intercepts chars (to test Windows behaviour) | |
263 | class MyComboBox : public wxComboBox | |
264 | { | |
265 | public: | |
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 | ||
277 | protected: | |
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 | ||
288 | private: | |
289 | DECLARE_EVENT_TABLE() | |
290 | }; | |
291 | ||
292 | // a radiobox which handles focus set/kill (for testing) | |
293 | class MyRadioBox : public wxRadioBox | |
294 | { | |
295 | public: | |
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 | |
311 | protected: | |
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 | ||
326 | private: | |
327 | DECLARE_EVENT_TABLE() | |
328 | }; | |
329 | ||
1a84e759 RR |
330 | // a choice which handles focus set/kill (for testing) |
331 | class MyChoice : public wxChoice | |
332 | { | |
333 | public: | |
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 | ||
345 | protected: | |
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 | ||
360 | private: | |
361 | DECLARE_EVENT_TABLE() | |
362 | }; | |
363 | ||
364 | ||
365 | ||
1c005ff7 | 366 | //---------------------------------------------------------------------- |
6c8a980f | 367 | // other |
1c005ff7 RR |
368 | //---------------------------------------------------------------------- |
369 | ||
8b81a824 | 370 | static void SetListboxClientData(const wxChar *name, wxListBox *control); |
2b5f62a0 VZ |
371 | |
372 | #if wxUSE_CHOICE | |
8b81a824 | 373 | static void SetChoiceClientData(const wxChar *name, wxChoice *control); |
2b5f62a0 | 374 | #endif // wxUSE_CHOICE |
6c8a980f | 375 | |
d59051dd | 376 | IMPLEMENT_APP(MyApp) |
1c005ff7 RR |
377 | |
378 | //---------------------------------------------------------------------- | |
379 | // MyApp | |
380 | //---------------------------------------------------------------------- | |
381 | ||
16f6dfd8 VZ |
382 | enum |
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 | 401 | bool 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 | 431 | const int ID_BOOK = 1000; |
1c005ff7 | 432 | |
4fabb575 JS |
433 | const int ID_LISTBOX = 130; |
434 | const int ID_LISTBOX_SEL_NUM = 131; | |
435 | const int ID_LISTBOX_SEL_STR = 132; | |
436 | const int ID_LISTBOX_CLEAR = 133; | |
437 | const int ID_LISTBOX_APPEND = 134; | |
438 | const int ID_LISTBOX_DELETE = 135; | |
439 | const int ID_LISTBOX_FONT = 136; | |
440 | const int ID_LISTBOX_ENABLE = 137; | |
6c8a980f | 441 | const int ID_LISTBOX_SORTED = 138; |
1c005ff7 | 442 | |
4fabb575 JS |
443 | const int ID_CHOICE = 120; |
444 | const int ID_CHOICE_SEL_NUM = 121; | |
445 | const int ID_CHOICE_SEL_STR = 122; | |
446 | const int ID_CHOICE_CLEAR = 123; | |
447 | const int ID_CHOICE_APPEND = 124; | |
448 | const int ID_CHOICE_DELETE = 125; | |
449 | const int ID_CHOICE_FONT = 126; | |
450 | const int ID_CHOICE_ENABLE = 127; | |
b56c2246 | 451 | const int ID_CHOICE_SORTED = 128; |
53010e52 | 452 | |
4fabb575 JS |
453 | const int ID_COMBO = 140; |
454 | const int ID_COMBO_SEL_NUM = 141; | |
455 | const int ID_COMBO_SEL_STR = 142; | |
456 | const int ID_COMBO_CLEAR = 143; | |
457 | const int ID_COMBO_APPEND = 144; | |
458 | const int ID_COMBO_DELETE = 145; | |
459 | const int ID_COMBO_FONT = 146; | |
460 | const int ID_COMBO_ENABLE = 147; | |
cc7e9e20 | 461 | const int ID_COMBO_SET_TEXT = 148; |
53010e52 | 462 | |
4fabb575 JS |
463 | const int ID_RADIOBOX = 160; |
464 | const int ID_RADIOBOX_SEL_NUM = 161; | |
465 | const int ID_RADIOBOX_SEL_STR = 162; | |
466 | const int ID_RADIOBOX_FONT = 163; | |
467 | const int ID_RADIOBOX_ENABLE = 164; | |
be8b4385 | 468 | const int ID_RADIOBOX2 = 165; |
f5d29b39 RR |
469 | const int ID_RADIOBUTTON_1 = 166; |
470 | const int ID_RADIOBUTTON_2 = 167; | |
471 | ||
4fabb575 | 472 | const int ID_SET_FONT = 170; |
47908e25 | 473 | |
516ab399 | 474 | #if wxUSE_GAUGE |
4fabb575 | 475 | const int ID_GAUGE = 180; |
516ab399 WS |
476 | #endif // wxUSE_GAUGE |
477 | ||
6bb44116 | 478 | #if wxUSE_SLIDER |
4fabb575 | 479 | const int ID_SLIDER = 181; |
6bb44116 | 480 | #endif // wxUSE_SLIDER |
58614078 | 481 | |
4fabb575 | 482 | const int ID_SPIN = 182; |
516ab399 | 483 | #if wxUSE_PROGRESSDLG |
9726da4f | 484 | const int ID_BTNPROGRESS = 183; |
516ab399 | 485 | #endif // wxUSE_PROGRESSDLG |
185fa6bf | 486 | const int ID_BUTTON_LABEL = 184; |
baccb514 | 487 | const int ID_SPINCTRL = 185; |
1dd815f3 | 488 | const int ID_BTNNEWTEXT = 186; |
e380f72b | 489 | |
3e2dd3db VZ |
490 | const int ID_BUTTON_TEST1 = 190; |
491 | const int ID_BUTTON_TEST2 = 191; | |
9121bed2 | 492 | const int ID_BITMAP_BTN = 192; |
bebc503c | 493 | const int ID_BITMAP_BTN_ENABLE = 193; |
3e2dd3db | 494 | |
87a1e308 VZ |
495 | const int ID_CHANGE_COLOUR = 200; |
496 | ||
2b5f62a0 VZ |
497 | const int ID_SIZER_CHECK1 = 201; |
498 | const int ID_SIZER_CHECK2 = 202; | |
499 | const int ID_SIZER_CHECK3 = 203; | |
500 | const int ID_SIZER_CHECK4 = 204; | |
501 | const int ID_SIZER_CHECK14 = 205; | |
502 | const int ID_SIZER_CHECKBIG = 206; | |
503 | ||
1a8b677e VZ |
504 | const int ID_HYPERLINK = 300; |
505 | ||
1c005ff7 | 506 | BEGIN_EVENT_TABLE(MyPanel, wxPanel) |
f226be17 | 507 | EVT_IDLE ( MyPanel::OnIdle) |
61c083e7 WS |
508 | EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging) |
509 | EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged) | |
ec9f7884 | 510 | EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) |
6c8a980f | 511 | EVT_LISTBOX (ID_LISTBOX_SORTED, MyPanel::OnListBox) |
ec9f7884 VZ |
512 | EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick) |
513 | EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons) | |
514 | EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons) | |
515 | EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) | |
516 | EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) | |
517 | EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons) | |
518 | EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons) | |
519 | EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons) | |
1ccd23f5 | 520 | #if wxUSE_CHOICE |
ec9f7884 | 521 | EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice) |
b56c2246 | 522 | EVT_CHOICE (ID_CHOICE_SORTED, MyPanel::OnChoice) |
ec9f7884 VZ |
523 | EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons) |
524 | EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons) | |
525 | EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons) | |
526 | EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons) | |
527 | EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons) | |
528 | EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons) | |
529 | EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons) | |
1ccd23f5 | 530 | #endif |
ec9f7884 | 531 | EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo) |
f6bcfd97 BP |
532 | EVT_TEXT (ID_COMBO, MyPanel::OnComboTextChanged) |
533 | EVT_TEXT_ENTER(ID_COMBO, MyPanel::OnComboTextEnter) | |
ec9f7884 VZ |
534 | EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) |
535 | EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) | |
536 | EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) | |
537 | EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons) | |
538 | EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons) | |
539 | EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons) | |
cc7e9e20 | 540 | EVT_BUTTON (ID_COMBO_SET_TEXT, MyPanel::OnComboButtons) |
ec9f7884 VZ |
541 | EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons) |
542 | EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio) | |
be8b4385 | 543 | EVT_RADIOBOX (ID_RADIOBOX2, MyPanel::OnRadio) |
ec9f7884 VZ |
544 | EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons) |
545 | EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons) | |
546 | EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons) | |
547 | EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons) | |
a48b9bfb VZ |
548 | EVT_RADIOBUTTON(ID_RADIOBUTTON_1, MyPanel::OnRadioButton1) |
549 | EVT_RADIOBUTTON(ID_RADIOBUTTON_2, MyPanel::OnRadioButton2) | |
ec9f7884 | 550 | EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont) |
6bb44116 | 551 | #if wxUSE_SLIDER |
ec9f7884 | 552 | EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate) |
6bb44116 | 553 | #endif // wxUSE_SLIDER |
0e528b99 | 554 | #if wxUSE_SPINBTN |
ec9f7884 | 555 | EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate) |
8c3c31d4 VZ |
556 | EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp) |
557 | EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown) | |
516ab399 | 558 | #if wxUSE_PROGRESSDLG |
9726da4f VZ |
559 | EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress) |
560 | EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress) | |
516ab399 | 561 | #endif // wxUSE_PROGRESSDLG |
0e528b99 | 562 | #endif // wxUSE_SPINBTN |
baccb514 | 563 | #if wxUSE_SPINCTRL |
57160afe | 564 | EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl) |
76106901 VZ |
565 | EVT_SPIN_UP (ID_SPINCTRL, MyPanel::OnSpinCtrlUp) |
566 | EVT_SPIN_DOWN (ID_SPINCTRL, MyPanel::OnSpinCtrlDown) | |
567 | EVT_TEXT (ID_SPINCTRL, MyPanel::OnSpinCtrlText) | |
baccb514 | 568 | #endif // wxUSE_SPINCTRL |
1dd815f3 | 569 | EVT_BUTTON (ID_BTNNEWTEXT, MyPanel::OnNewText) |
1db8dc4a | 570 | EVT_TOGGLEBUTTON(ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) |
87a1e308 | 571 | EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour) |
3e2dd3db VZ |
572 | EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton) |
573 | EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton) | |
9121bed2 | 574 | EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton) |
bebc503c | 575 | EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE, MyPanel::OnBmpButtonToggle) |
2b5f62a0 VZ |
576 | |
577 | EVT_CHECKBOX (ID_SIZER_CHECK1, MyPanel::OnSizerCheck) | |
578 | EVT_CHECKBOX (ID_SIZER_CHECK2, MyPanel::OnSizerCheck) | |
579 | EVT_CHECKBOX (ID_SIZER_CHECK3, MyPanel::OnSizerCheck) | |
580 | EVT_CHECKBOX (ID_SIZER_CHECK4, MyPanel::OnSizerCheck) | |
581 | EVT_CHECKBOX (ID_SIZER_CHECK14, MyPanel::OnSizerCheck) | |
582 | EVT_CHECKBOX (ID_SIZER_CHECKBIG, MyPanel::OnSizerCheck) | |
583 | ||
1c005ff7 RR |
584 | END_EVENT_TABLE() |
585 | ||
f6bcfd97 BP |
586 | BEGIN_EVENT_TABLE(MyButton, wxButton) |
587 | EVT_LEFT_DCLICK(MyButton::OnDClick) | |
588 | END_EVENT_TABLE() | |
589 | ||
590 | BEGIN_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) | |
596 | END_EVENT_TABLE() | |
597 | ||
598 | BEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox) | |
599 | EVT_SET_FOCUS(MyRadioBox::OnFocusGot) | |
600 | EVT_KILL_FOCUS(MyRadioBox::OnFocusLost) | |
601 | END_EVENT_TABLE() | |
602 | ||
1a84e759 RR |
603 | BEGIN_EVENT_TABLE(MyChoice, wxChoice) |
604 | EVT_SET_FOCUS(MyChoice::OnFocusGot) | |
605 | EVT_KILL_FOCUS(MyChoice::OnFocusLost) | |
606 | END_EVENT_TABLE() | |
607 | ||
f6bcfd97 BP |
608 | // ============================================================================ |
609 | // implementation | |
610 | // ============================================================================ | |
611 | ||
5fb9fcfc | 612 | MyPanel::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]); | |
a1b806b9 | 724 | if ( !bmp.IsOk() || (imagelist->Add(bmp) == -1) ) |
ec9f7884 | 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); |
0a12e013 | 858 | m_slider->SetTickFreq(40); |
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 | ||
d9317033 VZ |
952 | wxPanel *panel2 = new wxPanel(panel, -1, wxPoint(100, 0), wxSize(100, 200)); |
953 | (void)new wxBitmapButton(panel2, ID_BITMAP_BTN, bitmap, wxPoint(0, 20)); | |
954 | (void)new wxToggleButton(panel2, ID_BITMAP_BTN_ENABLE, | |
955 | wxT("Enable/disable &bitmap"), wxPoint(0, 140)); | |
f048e32f | 956 | |
aae0472b | 957 | #if defined(__WXMSW__) || defined(__WXMOTIF__) |
3e2dd3db | 958 | // test for masked bitmap display |
9a83f860 | 959 | bitmap = wxBitmap(wxT("test2.bmp"), wxBITMAP_TYPE_BMP); |
a1b806b9 | 960 | if (bitmap.IsOk()) |
9bb3479c JS |
961 | { |
962 | bitmap.SetMask(new wxMask(bitmap, *wxBLUE)); | |
669f7a11 | 963 | |
bebc503c | 964 | (void)new wxStaticBitmap(panel, wxID_ANY, bitmap, wxPoint(300, 120)); |
9bb3479c | 965 | } |
57160afe | 966 | #endif |
5ef2e633 | 967 | |
389d906b VS |
968 | wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)), |
969 | bmp2(wxArtProvider::GetBitmap(wxART_WARNING)), | |
970 | bmp3(wxArtProvider::GetBitmap(wxART_QUESTION)); | |
f048e32f VZ |
971 | wxBitmapButton *bmpBtn = new wxBitmapButton |
972 | ( | |
9230b621 | 973 | panel, wxID_ANY, |
f048e32f | 974 | bmp1, |
1db8dc4a | 975 | wxPoint(30, 70) |
f048e32f | 976 | ); |
76fcf0f2 | 977 | |
f048e32f VZ |
978 | bmpBtn->SetBitmapSelected(bmp2); |
979 | bmpBtn->SetBitmapFocus(bmp3); | |
980 | ||
1db8dc4a | 981 | (void)new wxToggleButton(panel, ID_BUTTON_LABEL, |
9a83f860 | 982 | wxT("&Toggle label"), wxPoint(250, 20)); |
bedaf53e | 983 | |
9a83f860 | 984 | m_label = new wxStaticText(panel, wxID_ANY, wxT("Label with some long text"), |
185fa6bf | 985 | wxPoint(250, 60), wxDefaultSize, |
f6bcfd97 | 986 | wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/); |
103aab26 | 987 | m_label->SetForegroundColour( *wxBLUE ); |
2ac1b69a | 988 | |
9a83f860 | 989 | m_book->AddPage(panel, wxT("wxBitmapXXX")); |
dcc71398 | 990 | |
9d9b7755 | 991 | // sizer |
61c083e7 | 992 | panel = new wxPanel(m_book); |
dcc71398 | 993 | |
2b5f62a0 VZ |
994 | wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); |
995 | ||
996 | wxStaticBoxSizer *csizer = | |
9a83f860 | 997 | new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, wxT("Show Buttons")), wxHORIZONTAL ); |
61c083e7 | 998 | |
2b5f62a0 | 999 | wxCheckBox *check1, *check2, *check3, *check4, *check14, *checkBig; |
9a83f860 | 1000 | check1 = new wxCheckBox (panel, ID_SIZER_CHECK1, wxT("1")); |
9230b621 | 1001 | check1->SetValue (true); |
2b5f62a0 | 1002 | csizer->Add (check1); |
9a83f860 | 1003 | check2 = new wxCheckBox (panel, ID_SIZER_CHECK2, wxT("2")); |
9230b621 | 1004 | check2->SetValue (true); |
2b5f62a0 | 1005 | csizer->Add (check2); |
9a83f860 | 1006 | check3 = new wxCheckBox (panel, ID_SIZER_CHECK3, wxT("3")); |
9230b621 | 1007 | check3->SetValue (true); |
2b5f62a0 | 1008 | csizer->Add (check3); |
9a83f860 | 1009 | check4 = new wxCheckBox (panel, ID_SIZER_CHECK4, wxT("4")); |
9230b621 | 1010 | check4->SetValue (true); |
2b5f62a0 | 1011 | csizer->Add (check4); |
9a83f860 | 1012 | check14 = new wxCheckBox (panel, ID_SIZER_CHECK14, wxT("1-4")); |
9230b621 | 1013 | check14->SetValue (true); |
2b5f62a0 | 1014 | csizer->Add (check14); |
9a83f860 | 1015 | checkBig = new wxCheckBox (panel, ID_SIZER_CHECKBIG, wxT("Big")); |
9230b621 | 1016 | checkBig->SetValue (true); |
2b5f62a0 | 1017 | csizer->Add (checkBig); |
61c083e7 | 1018 | |
2b5f62a0 VZ |
1019 | sizer->Add (csizer); |
1020 | ||
1021 | m_hsizer = new wxBoxSizer( wxHORIZONTAL ); | |
9d9b7755 | 1022 | |
2b5f62a0 | 1023 | m_buttonSizer = new wxBoxSizer (wxVERTICAL); |
61c083e7 | 1024 | |
9a83f860 | 1025 | m_sizerBtn1 = new wxButton(panel, wxID_ANY, wxT("Test Button &1 (tab order 1)") ); |
2b5f62a0 | 1026 | m_buttonSizer->Add( m_sizerBtn1, 0, wxALL, 10 ); |
9a83f860 | 1027 | m_sizerBtn2 = new wxButton(panel, wxID_ANY, wxT("Test Button &2 (tab order 3)") ); |
2b5f62a0 | 1028 | m_buttonSizer->Add( m_sizerBtn2, 0, wxALL, 10 ); |
9a83f860 | 1029 | m_sizerBtn3 = new wxButton(panel, wxID_ANY, wxT("Test Button &3 (tab order 2)") ); |
2b5f62a0 | 1030 | m_buttonSizer->Add( m_sizerBtn3, 0, wxALL, 10 ); |
9a83f860 | 1031 | m_sizerBtn4 = new wxButton(panel, wxID_ANY, wxT("Test Button &4 (tab order 4)") ); |
2b5f62a0 VZ |
1032 | m_buttonSizer->Add( m_sizerBtn4, 0, wxALL, 10 ); |
1033 | ||
3f93f659 VS |
1034 | m_sizerBtn3->MoveBeforeInTabOrder(m_sizerBtn2); |
1035 | ||
2b5f62a0 VZ |
1036 | m_hsizer->Add (m_buttonSizer); |
1037 | m_hsizer->Add( 20,20, 1 ); | |
9a83f860 | 1038 | m_bigBtn = new wxButton(panel, wxID_ANY, wxT("Multiline\nbutton") ); |
2b5f62a0 VZ |
1039 | m_hsizer->Add( m_bigBtn , 3, wxGROW|wxALL, 10 ); |
1040 | ||
1041 | sizer->Add (m_hsizer, 1, wxGROW); | |
9d9b7755 VZ |
1042 | |
1043 | panel->SetSizer( sizer ); | |
1044 | ||
9a83f860 | 1045 | m_book->AddPage(panel, wxT("wxSizer")); |
655822f3 | 1046 | |
9ae19599 VZ |
1047 | // set the sizer for the panel itself |
1048 | sizer = new wxBoxSizer(wxVERTICAL); | |
1049 | sizer->Add(m_book, wxSizerFlags().Border().Expand()); | |
1050 | sizer->Add(m_text, wxSizerFlags(1).Border().Expand()); | |
1051 | SetSizer(sizer); | |
be8b4385 VZ |
1052 | |
1053 | #if wxUSE_TOOLTIPS | |
1054 | SetAllToolTips(); | |
1055 | #endif // wxUSE_TOOLTIPS | |
1c005ff7 RR |
1056 | } |
1057 | ||
be8b4385 VZ |
1058 | #if wxUSE_TOOLTIPS |
1059 | ||
1060 | namespace | |
1061 | { | |
1062 | ||
1063 | void ResetToolTip(wxWindow *win, const char *tip) | |
1064 | { | |
1065 | wxCHECK_RET( win, "NULL window?" ); | |
1066 | ||
1067 | win->UnsetToolTip(); | |
1068 | win->SetToolTip(tip); | |
1069 | } | |
1070 | ||
1071 | } | |
1072 | ||
1073 | void MyPanel::SetAllToolTips() | |
1074 | { | |
1075 | ResetToolTip(FindWindow(ID_LISTBOX_FONT), "Press here to set italic font"); | |
1076 | ResetToolTip(m_checkbox, "Click here to disable the listbox"); | |
1077 | ResetToolTip(m_listbox, "This is a list box"); | |
1078 | ResetToolTip(m_combo, "This is a natural\ncombobox - can you believe me?"); | |
1079 | ResetToolTip(m_slider, "This is a sliding slider"); | |
1080 | ResetToolTip(FindWindow(ID_RADIOBOX2), "Ever seen a radiobox?"); | |
1081 | ||
1082 | //ResetToolTip(m_radio, "Tooltip for the entire radiobox"); | |
1083 | for ( unsigned int nb = 0; nb < m_radio->GetCount(); nb++ ) | |
1084 | { | |
1085 | m_radio->SetItemToolTip(nb, ""); | |
1086 | m_radio->SetItemToolTip(nb, "tooltip for\n" + m_radio->GetString(nb)); | |
1087 | } | |
1088 | ||
1089 | // remove the tooltip for one of the items | |
1090 | m_radio->SetItemToolTip(2, ""); | |
1091 | } | |
1092 | #endif // wxUSE_TOOLTIPS | |
1093 | ||
f226be17 VZ |
1094 | void MyPanel::OnIdle(wxIdleEvent& event) |
1095 | { | |
1096 | static const int INVALID_SELECTION = -2; | |
1097 | ||
1098 | static int s_selCombo = INVALID_SELECTION; | |
25e19bdf JS |
1099 | |
1100 | if (!m_combo || !m_choice) | |
1101 | { | |
1102 | event.Skip(); | |
1103 | return; | |
1104 | } | |
1105 | ||
f226be17 VZ |
1106 | int sel = m_combo->GetSelection(); |
1107 | if ( sel != s_selCombo ) | |
1108 | { | |
1109 | if ( s_selCombo != INVALID_SELECTION ) | |
1110 | { | |
9a83f860 | 1111 | wxLogMessage(wxT("EVT_IDLE: combobox selection changed from %d to %d"), |
f226be17 VZ |
1112 | s_selCombo, sel); |
1113 | } | |
1114 | ||
1115 | s_selCombo = sel; | |
1116 | } | |
1117 | ||
d6bbc10c VZ |
1118 | static int s_selChoice = INVALID_SELECTION; |
1119 | sel = m_choice->GetSelection(); | |
1120 | if ( sel != s_selChoice ) | |
1121 | { | |
1122 | if ( s_selChoice != INVALID_SELECTION ) | |
1123 | { | |
9a83f860 | 1124 | wxLogMessage(wxT("EVT_IDLE: choice selection changed from %d to %d"), |
d6bbc10c VZ |
1125 | s_selChoice, sel); |
1126 | } | |
1127 | ||
1128 | s_selChoice = sel; | |
1129 | } | |
1130 | ||
f226be17 VZ |
1131 | event.Skip(); |
1132 | } | |
1133 | ||
61c083e7 | 1134 | void MyPanel::OnPageChanging( wxBookCtrlEvent &event ) |
4d0f3cd6 | 1135 | { |
45e41c05 VZ |
1136 | int selOld = event.GetOldSelection(); |
1137 | if ( selOld == 2 ) | |
4d0f3cd6 | 1138 | { |
9a83f860 VZ |
1139 | if ( wxMessageBox(wxT("This demonstrates how a program may prevent the\n") |
1140 | wxT("page change from taking place - if you select\n") | |
1141 | wxT("[No] the current page will stay the third one\n"), | |
1142 | wxT("Control sample"), | |
f6bcfd97 | 1143 | wxICON_QUESTION | wxYES_NO, this) != wxYES ) |
8c3c31d4 VZ |
1144 | { |
1145 | event.Veto(); | |
45e41c05 | 1146 | |
8c3c31d4 VZ |
1147 | return; |
1148 | } | |
4d0f3cd6 | 1149 | } |
45e41c05 | 1150 | |
9a83f860 VZ |
1151 | *m_text << wxT("Book selection is being changed from ") << selOld |
1152 | << wxT(" to ") << event.GetSelection() | |
1153 | << wxT(" (current page from book is ") | |
1154 | << m_book->GetSelection() << wxT(")\n"); | |
4d0f3cd6 VZ |
1155 | } |
1156 | ||
61c083e7 | 1157 | void MyPanel::OnPageChanged( wxBookCtrlEvent &event ) |
cb43b372 | 1158 | { |
9a83f860 VZ |
1159 | *m_text << wxT("Book selection is now ") << event.GetSelection() |
1160 | << wxT(" (from book: ") << m_book->GetSelection() | |
1161 | << wxT(")\n"); | |
cb43b372 RR |
1162 | } |
1163 | ||
3e2dd3db VZ |
1164 | void MyPanel::OnTestButton(wxCommandEvent& event) |
1165 | { | |
9a83f860 VZ |
1166 | wxLogMessage(wxT("Button %c clicked."), |
1167 | event.GetId() == ID_BUTTON_TEST1 ? wxT('1') : wxT('2')); | |
3e2dd3db VZ |
1168 | } |
1169 | ||
87728739 | 1170 | void MyPanel::OnBmpButton(wxCommandEvent& WXUNUSED(event)) |
9121bed2 | 1171 | { |
9a83f860 | 1172 | wxLogMessage(wxT("Bitmap button clicked.")); |
9121bed2 VZ |
1173 | } |
1174 | ||
bebc503c VZ |
1175 | void MyPanel::OnBmpButtonToggle(wxCommandEvent& event) |
1176 | { | |
1177 | FindWindow(ID_BITMAP_BTN)->Enable(!event.IsChecked()); | |
1178 | } | |
1179 | ||
87a1e308 VZ |
1180 | void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event)) |
1181 | { | |
1182 | static wxColour s_colOld; | |
1183 | ||
29c749b8 | 1184 | SetThemeEnabled(false); |
87a1e308 | 1185 | // test panel colour changing and propagation to the subcontrols |
a1b806b9 | 1186 | if ( s_colOld.IsOk() ) |
87a1e308 VZ |
1187 | { |
1188 | SetBackgroundColour(s_colOld); | |
1189 | s_colOld = wxNullColour; | |
1190 | ||
29c749b8 VS |
1191 | m_lbSelectThis->SetForegroundColour(wxNullColour); |
1192 | m_lbSelectThis->SetBackgroundColour(wxNullColour); | |
87a1e308 VZ |
1193 | } |
1194 | else | |
1195 | { | |
a60b1f5d MB |
1196 | s_colOld = wxColour(wxT("red")); |
1197 | SetBackgroundColour(wxT("white")); | |
87a1e308 | 1198 | |
a60b1f5d MB |
1199 | m_lbSelectThis->SetForegroundColour(wxT("white")); |
1200 | m_lbSelectThis->SetBackgroundColour(wxT("red")); | |
87a1e308 VZ |
1201 | } |
1202 | ||
1203 | m_lbSelectThis->Refresh(); | |
1204 | Refresh(); | |
1205 | } | |
1206 | ||
1c005ff7 RR |
1207 | void MyPanel::OnListBox( wxCommandEvent &event ) |
1208 | { | |
6c8a980f VZ |
1209 | wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox |
1210 | : m_listboxSorted; | |
1211 | ||
0f252d11 RR |
1212 | bool deselect = false; |
1213 | if (listbox->HasFlag(wxLB_MULTIPLE) || listbox->HasFlag(wxLB_EXTENDED)) | |
1214 | { | |
1215 | deselect = !event.IsSelection(); | |
1216 | if (deselect) | |
9a83f860 | 1217 | m_text->AppendText( wxT("ListBox deselection event\n") ); |
0f252d11 RR |
1218 | } |
1219 | ||
9a83f860 | 1220 | m_text->AppendText( wxT("ListBox event selection string is: '") ); |
ec9f7884 | 1221 | m_text->AppendText( event.GetString() ); |
9a83f860 | 1222 | m_text->AppendText( wxT("'\n") ); |
45262a34 VZ |
1223 | |
1224 | // can't use GetStringSelection() with multiple selections, there could be | |
1225 | // more than one of them | |
0f252d11 | 1226 | if ( !listbox->HasFlag(wxLB_MULTIPLE) && !listbox->HasFlag(wxLB_EXTENDED) ) |
45262a34 | 1227 | { |
9a83f860 | 1228 | m_text->AppendText( wxT("ListBox control selection string is: '") ); |
45262a34 | 1229 | m_text->AppendText( listbox->GetStringSelection() ); |
9a83f860 | 1230 | m_text->AppendText( wxT("'\n") ); |
45262a34 | 1231 | } |
6c8a980f VZ |
1232 | |
1233 | wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject()); | |
9a83f860 | 1234 | m_text->AppendText( wxT("ListBox event client data string is: '") ); |
6e47faf1 | 1235 | if (obj) // BC++ doesn't like use of '? .. : .. ' in this context |
74a533f7 | 1236 | m_text->AppendText( obj->GetData() ); |
6e47faf1 | 1237 | else |
9a83f860 | 1238 | m_text->AppendText( wxString(wxT("none")) ); |
6e47faf1 | 1239 | |
9a83f860 VZ |
1240 | m_text->AppendText( wxT("'\n") ); |
1241 | m_text->AppendText( wxT("ListBox control client data string is: '") ); | |
45262a34 | 1242 | obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt()); |
6e47faf1 | 1243 | if (obj) |
74a533f7 | 1244 | m_text->AppendText( obj->GetData() ); |
6e47faf1 | 1245 | else |
9a83f860 VZ |
1246 | m_text->AppendText( wxString(wxT("none")) ); |
1247 | m_text->AppendText( wxT("'\n") ); | |
1c005ff7 RR |
1248 | } |
1249 | ||
5b077d48 RR |
1250 | void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event ) |
1251 | { | |
9a83f860 | 1252 | m_text->AppendText( wxT("ListBox double click string is: ") ); |
ec9f7884 | 1253 | m_text->AppendText( event.GetString() ); |
9a83f860 | 1254 | m_text->AppendText( wxT("\n") ); |
5b077d48 RR |
1255 | } |
1256 | ||
47908e25 RR |
1257 | void MyPanel::OnListBoxButtons( wxCommandEvent &event ) |
1258 | { | |
ec9f7884 | 1259 | switch (event.GetId()) |
d3904ceb | 1260 | { |
ec9f7884 VZ |
1261 | case ID_LISTBOX_ENABLE: |
1262 | { | |
9a83f860 | 1263 | m_text->AppendText(wxT("Checkbox clicked.\n")); |
b8653fbf | 1264 | #if wxUSE_TOOLTIPS |
0ae0226b | 1265 | wxCheckBox *cb = (wxCheckBox*)event.GetEventObject(); |
ec9f7884 | 1266 | if (event.GetInt()) |
9a83f860 | 1267 | cb->SetToolTip( wxT("Click to enable listbox") ); |
ec9f7884 | 1268 | else |
9a83f860 | 1269 | cb->SetToolTip( wxT("Click to disable listbox") ); |
16f6dfd8 | 1270 | #endif // wxUSE_TOOLTIPS |
ec9f7884 | 1271 | m_listbox->Enable( event.GetInt() == 0 ); |
57160afe VZ |
1272 | m_lbSelectThis->Enable( event.GetInt() == 0 ); |
1273 | m_lbSelectNum->Enable( event.GetInt() == 0 ); | |
6c8a980f | 1274 | m_listboxSorted->Enable( event.GetInt() == 0 ); |
ee6e1b1d | 1275 | FindWindow(ID_CHANGE_COLOUR)->Enable( event.GetInt() == 0 ); |
ec9f7884 VZ |
1276 | break; |
1277 | } | |
1278 | case ID_LISTBOX_SEL_NUM: | |
1279 | { | |
91f2c154 JS |
1280 | if (m_listbox->GetCount() > 2) |
1281 | m_listbox->SetSelection( 2 ); | |
1282 | if (m_listboxSorted->GetCount() > 2) | |
1283 | m_listboxSorted->SetSelection( 2 ); | |
8c3c31d4 | 1284 | m_lbSelectThis->WarpPointer( 40, 14 ); |
ec9f7884 VZ |
1285 | break; |
1286 | } | |
1287 | case ID_LISTBOX_SEL_STR: | |
1288 | { | |
9a83f860 VZ |
1289 | if (m_listbox->FindString(wxT("This")) != wxNOT_FOUND) |
1290 | m_listbox->SetStringSelection( wxT("This") ); | |
1291 | if (m_listboxSorted->FindString(wxT("This")) != wxNOT_FOUND) | |
1292 | m_listboxSorted->SetStringSelection( wxT("This") ); | |
8c3c31d4 | 1293 | m_lbSelectNum->WarpPointer( 40, 14 ); |
ec9f7884 VZ |
1294 | break; |
1295 | } | |
1296 | case ID_LISTBOX_CLEAR: | |
1297 | { | |
1298 | m_listbox->Clear(); | |
6c8a980f | 1299 | m_listboxSorted->Clear(); |
ec9f7884 VZ |
1300 | break; |
1301 | } | |
1302 | case ID_LISTBOX_APPEND: | |
1303 | { | |
9a83f860 VZ |
1304 | m_listbox->Append( wxT("Hi kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk!") ); |
1305 | m_listboxSorted->Append( wxT("Hi hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!") ); | |
ec9f7884 VZ |
1306 | break; |
1307 | } | |
1308 | case ID_LISTBOX_DELETE: | |
1309 | { | |
6c8a980f VZ |
1310 | int idx; |
1311 | idx = m_listbox->GetSelection(); | |
f6bcfd97 BP |
1312 | if ( idx != wxNOT_FOUND ) |
1313 | m_listbox->Delete( idx ); | |
6c8a980f | 1314 | idx = m_listboxSorted->GetSelection(); |
f6bcfd97 BP |
1315 | if ( idx != wxNOT_FOUND ) |
1316 | m_listboxSorted->Delete( idx ); | |
ec9f7884 VZ |
1317 | break; |
1318 | } | |
1319 | case ID_LISTBOX_FONT: | |
1320 | { | |
1321 | m_listbox->SetFont( *wxITALIC_FONT ); | |
6c8a980f | 1322 | m_listboxSorted->SetFont( *wxITALIC_FONT ); |
ec9f7884 VZ |
1323 | m_checkbox->SetFont( *wxITALIC_FONT ); |
1324 | break; | |
1325 | } | |
868a2826 | 1326 | } |
47908e25 RR |
1327 | } |
1328 | ||
1ccd23f5 | 1329 | #if wxUSE_CHOICE |
bc50a2ae | 1330 | |
da603a67 | 1331 | static wxString GetDataString(wxClientData *data) |
bc50a2ae | 1332 | { |
81d3348a | 1333 | return data ? static_cast<wxStringClientData *>(data)->GetData() |
da603a67 | 1334 | : wxString("none"); |
bc50a2ae VZ |
1335 | } |
1336 | ||
47908e25 RR |
1337 | void MyPanel::OnChoice( wxCommandEvent &event ) |
1338 | { | |
6c8a980f VZ |
1339 | wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice |
1340 | : m_choiceSorted; | |
1341 | ||
bc50a2ae | 1342 | const int sel = choice->GetSelection(); |
6c8a980f | 1343 | |
bc50a2ae VZ |
1344 | wxClientData *dataEvt = event.GetClientObject(), |
1345 | *dataCtrl = choice->GetClientObject(sel); | |
6e47faf1 | 1346 | |
9a83f860 VZ |
1347 | wxLogMessage(wxT("EVT_CHOICE: item %d/%d (event/control), ") |
1348 | wxT("string \"%s\"/\"%s\", ") | |
1349 | wxT("data \"%s\"/\"%s\""), | |
bc50a2ae VZ |
1350 | (int)event.GetInt(), |
1351 | sel, | |
da603a67 VZ |
1352 | event.GetString(), |
1353 | choice->GetStringSelection(), | |
bc50a2ae VZ |
1354 | GetDataString(dataEvt), |
1355 | GetDataString(dataCtrl)); | |
47908e25 RR |
1356 | } |
1357 | ||
1358 | void MyPanel::OnChoiceButtons( wxCommandEvent &event ) | |
1359 | { | |
ec9f7884 | 1360 | switch (event.GetId()) |
47908e25 | 1361 | { |
ec9f7884 VZ |
1362 | case ID_CHOICE_ENABLE: |
1363 | { | |
1364 | m_choice->Enable( event.GetInt() == 0 ); | |
b56c2246 | 1365 | m_choiceSorted->Enable( event.GetInt() == 0 ); |
ec9f7884 VZ |
1366 | break; |
1367 | } | |
1368 | case ID_CHOICE_SEL_NUM: | |
1369 | { | |
1370 | m_choice->SetSelection( 2 ); | |
b56c2246 | 1371 | m_choiceSorted->SetSelection( 2 ); |
ec9f7884 VZ |
1372 | break; |
1373 | } | |
1374 | case ID_CHOICE_SEL_STR: | |
1375 | { | |
9a83f860 VZ |
1376 | m_choice->SetStringSelection( wxT("This") ); |
1377 | m_choiceSorted->SetStringSelection( wxT("This") ); | |
ec9f7884 VZ |
1378 | break; |
1379 | } | |
1380 | case ID_CHOICE_CLEAR: | |
1381 | { | |
1382 | m_choice->Clear(); | |
b56c2246 | 1383 | m_choiceSorted->Clear(); |
ec9f7884 VZ |
1384 | break; |
1385 | } | |
1386 | case ID_CHOICE_APPEND: | |
1387 | { | |
9a83f860 VZ |
1388 | m_choice->Append( wxT("Hi!") ); |
1389 | m_choiceSorted->Append( wxT("Hi!") ); | |
ec9f7884 VZ |
1390 | break; |
1391 | } | |
1392 | case ID_CHOICE_DELETE: | |
1393 | { | |
1394 | int idx = m_choice->GetSelection(); | |
f6bcfd97 BP |
1395 | if ( idx != wxNOT_FOUND ) |
1396 | m_choice->Delete( idx ); | |
b56c2246 | 1397 | idx = m_choiceSorted->GetSelection(); |
f6bcfd97 BP |
1398 | if ( idx != wxNOT_FOUND ) |
1399 | m_choiceSorted->Delete( idx ); | |
ec9f7884 VZ |
1400 | break; |
1401 | } | |
1402 | case ID_CHOICE_FONT: | |
1403 | { | |
1404 | m_choice->SetFont( *wxITALIC_FONT ); | |
b56c2246 | 1405 | m_choiceSorted->SetFont( *wxITALIC_FONT ); |
ec9f7884 VZ |
1406 | break; |
1407 | } | |
868a2826 | 1408 | } |
47908e25 | 1409 | } |
1ccd23f5 | 1410 | #endif // wxUSE_CHOICE |
47908e25 RR |
1411 | |
1412 | void MyPanel::OnCombo( wxCommandEvent &event ) | |
1413 | { | |
00dff4d2 JS |
1414 | if (!m_combo) |
1415 | return; | |
43b2d5e7 | 1416 | |
9a83f860 | 1417 | wxLogMessage(wxT("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""), |
0d29fecd | 1418 | (int)event.GetInt(), |
f226be17 VZ |
1419 | m_combo->GetSelection(), |
1420 | event.GetString().c_str(), | |
1421 | m_combo->GetStringSelection().c_str()); | |
47908e25 RR |
1422 | } |
1423 | ||
27ff87da | 1424 | void MyPanel::OnComboTextChanged(wxCommandEvent& event) |
f6bcfd97 | 1425 | { |
7c2151fa | 1426 | if (m_combo) |
43b2d5e7 | 1427 | { |
7c2151fa SN |
1428 | wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."), |
1429 | event.GetString().c_str(), | |
1430 | m_combo->GetValue().c_str()); | |
43b2d5e7 | 1431 | } |
f6bcfd97 BP |
1432 | } |
1433 | ||
1434 | void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event)) | |
1435 | { | |
7c2151fa | 1436 | if (m_combo) |
43b2d5e7 | 1437 | { |
9a83f860 | 1438 | wxLogMessage(wxT("Enter pressed in the combobox: value is '%s'."), |
7c2151fa | 1439 | m_combo->GetValue().c_str()); |
43b2d5e7 | 1440 | } |
f6bcfd97 BP |
1441 | } |
1442 | ||
47908e25 | 1443 | void MyPanel::OnComboButtons( wxCommandEvent &event ) |
1c005ff7 | 1444 | { |
ec9f7884 | 1445 | switch (event.GetId()) |
2f6407b9 | 1446 | { |
ec9f7884 VZ |
1447 | case ID_COMBO_ENABLE: |
1448 | { | |
1449 | m_combo->Enable( event.GetInt() == 0 ); | |
1450 | break; | |
1451 | } | |
1452 | case ID_COMBO_SEL_NUM: | |
1453 | { | |
1454 | m_combo->SetSelection( 2 ); | |
1455 | break; | |
1456 | } | |
1457 | case ID_COMBO_SEL_STR: | |
1458 | { | |
9a83f860 | 1459 | m_combo->SetStringSelection( wxT("This") ); |
ec9f7884 VZ |
1460 | break; |
1461 | } | |
1462 | case ID_COMBO_CLEAR: | |
1463 | { | |
1464 | m_combo->Clear(); | |
1465 | break; | |
1466 | } | |
1467 | case ID_COMBO_APPEND: | |
1468 | { | |
9a83f860 | 1469 | m_combo->Append( wxT("Hi!") ); |
ec9f7884 VZ |
1470 | break; |
1471 | } | |
1472 | case ID_COMBO_DELETE: | |
1473 | { | |
1474 | int idx = m_combo->GetSelection(); | |
1475 | m_combo->Delete( idx ); | |
1476 | break; | |
1477 | } | |
1478 | case ID_COMBO_FONT: | |
1479 | { | |
1480 | m_combo->SetFont( *wxITALIC_FONT ); | |
1481 | break; | |
1482 | } | |
cc7e9e20 RR |
1483 | case ID_COMBO_SET_TEXT: |
1484 | { | |
1485 | m_combo->SetString( 2, wxT("Hi!") ); | |
1486 | break; | |
1487 | } | |
868a2826 | 1488 | } |
47908e25 RR |
1489 | } |
1490 | ||
1491 | void MyPanel::OnRadio( wxCommandEvent &event ) | |
1492 | { | |
9a83f860 | 1493 | m_text->AppendText( wxT("RadioBox selection string is: ") ); |
ec9f7884 | 1494 | m_text->AppendText( event.GetString() ); |
9a83f860 | 1495 | m_text->AppendText( wxT("\n") ); |
47908e25 RR |
1496 | } |
1497 | ||
a48b9bfb VZ |
1498 | void MyPanel::OnRadioButton1( wxCommandEvent & WXUNUSED(event) ) |
1499 | { | |
9a83f860 | 1500 | wxMessageBox(wxT("First wxRadioButton selected."), wxT("wxControl sample")); |
a48b9bfb VZ |
1501 | } |
1502 | ||
1503 | void MyPanel::OnRadioButton2( wxCommandEvent & WXUNUSED(event) ) | |
1504 | { | |
9a83f860 | 1505 | m_text->AppendText(wxT("Second wxRadioButton selected.\n")); |
a48b9bfb VZ |
1506 | } |
1507 | ||
47908e25 RR |
1508 | void MyPanel::OnRadioButtons( wxCommandEvent &event ) |
1509 | { | |
ec9f7884 | 1510 | switch (event.GetId()) |
d3904ceb | 1511 | { |
ec9f7884 | 1512 | case ID_RADIOBOX_ENABLE: |
7891b4d4 VZ |
1513 | m_radio->Enable( event.GetInt() == 0 ); |
1514 | break; | |
1515 | ||
ec9f7884 | 1516 | case ID_RADIOBOX_SEL_NUM: |
7891b4d4 VZ |
1517 | m_radio->SetSelection( 2 ); |
1518 | break; | |
1519 | ||
ec9f7884 | 1520 | case ID_RADIOBOX_SEL_STR: |
9a83f860 | 1521 | m_radio->SetStringSelection( wxT("This") ); |
7891b4d4 | 1522 | break; |
8b1d8f36 | 1523 | |
7891b4d4 VZ |
1524 | case ID_RADIOBOX_FONT: |
1525 | m_radio->SetFont( *wxITALIC_FONT ); | |
1526 | break; | |
868a2826 | 1527 | } |
1c005ff7 RR |
1528 | } |
1529 | ||
868a2826 RR |
1530 | void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) ) |
1531 | { | |
ec9f7884 VZ |
1532 | m_fontButton->SetFont( *wxITALIC_FONT ); |
1533 | m_text->SetFont( *wxITALIC_FONT ); | |
868a2826 RR |
1534 | } |
1535 | ||
1db8dc4a | 1536 | void MyPanel::OnUpdateLabel( wxCommandEvent &event ) |
185fa6bf | 1537 | { |
9a83f860 VZ |
1538 | m_label->SetLabel(event.GetInt() ? wxT("Very very very very very long text.") |
1539 | : wxT("Shorter text.")); | |
185fa6bf VZ |
1540 | } |
1541 | ||
6bb44116 WS |
1542 | #if wxUSE_SLIDER |
1543 | ||
7bce6aec RR |
1544 | void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) |
1545 | { | |
516ab399 | 1546 | #if wxUSE_GAUGE |
ec9f7884 | 1547 | m_gauge->SetValue( m_slider->GetValue() ); |
37ed3ae3 | 1548 | m_gaugeVert->SetValue( m_slider->GetValue() / 2 ); |
516ab399 | 1549 | #endif // wxUSE_GAUGE |
7bce6aec RR |
1550 | } |
1551 | ||
6bb44116 WS |
1552 | #endif // wxUSE_SLIDER |
1553 | ||
baccb514 VZ |
1554 | #if wxUSE_SPINCTRL |
1555 | ||
76106901 VZ |
1556 | void MyPanel::OnSpinCtrlText(wxCommandEvent& event) |
1557 | { | |
1558 | if ( m_spinctrl ) | |
1559 | { | |
1560 | wxString s; | |
9a83f860 | 1561 | s.Printf( wxT("Spin ctrl text changed: now %d (from event: %s)\n"), |
508d586e | 1562 | m_spinctrl->GetValue(), event.GetString().c_str() ); |
76106901 VZ |
1563 | m_text->AppendText(s); |
1564 | } | |
1565 | } | |
1566 | ||
457e6c54 | 1567 | void MyPanel::OnSpinCtrl(wxSpinEvent& event) |
baccb514 | 1568 | { |
76106901 VZ |
1569 | if ( m_spinctrl ) |
1570 | { | |
1571 | wxString s; | |
9a83f860 | 1572 | s.Printf( wxT("Spin ctrl changed: now %d (from event: %d)\n"), |
508d586e | 1573 | m_spinctrl->GetValue(), event.GetInt() ); |
76106901 VZ |
1574 | m_text->AppendText(s); |
1575 | } | |
1576 | } | |
1577 | ||
1578 | void MyPanel::OnSpinCtrlUp(wxSpinEvent& event) | |
1579 | { | |
1580 | if ( m_spinctrl ) | |
1581 | { | |
508d586e | 1582 | m_text->AppendText( wxString::Format( |
9a83f860 | 1583 | wxT("Spin up: %d (from event: %d)\n"), |
508d586e | 1584 | m_spinctrl->GetValue(), event.GetInt() ) ); |
76106901 VZ |
1585 | } |
1586 | } | |
1587 | ||
1588 | void MyPanel::OnSpinCtrlDown(wxSpinEvent& event) | |
1589 | { | |
1590 | if ( m_spinctrl ) | |
1591 | { | |
508d586e | 1592 | m_text->AppendText( wxString::Format( |
9a83f860 | 1593 | wxT("Spin down: %d (from event: %d)\n"), |
508d586e | 1594 | m_spinctrl->GetValue(), event.GetInt() ) ); |
76106901 | 1595 | } |
baccb514 VZ |
1596 | } |
1597 | ||
1598 | #endif // wxUSE_SPINCTRL | |
1599 | ||
0e528b99 | 1600 | #if wxUSE_SPINBTN |
8c3c31d4 VZ |
1601 | void MyPanel::OnSpinUp( wxSpinEvent &event ) |
1602 | { | |
1603 | wxString value; | |
9a83f860 | 1604 | value.Printf( wxT("Spin control up: current = %d\n"), |
8c3c31d4 VZ |
1605 | m_spinbutton->GetValue()); |
1606 | ||
e94ff4cb | 1607 | if ( event.GetPosition() > 17 ) |
8c3c31d4 | 1608 | { |
9a83f860 | 1609 | value += wxT("Preventing the spin button from going above 17.\n"); |
8c3c31d4 VZ |
1610 | |
1611 | event.Veto(); | |
1612 | } | |
1613 | ||
1614 | m_text->AppendText(value); | |
1615 | } | |
1616 | ||
1617 | void MyPanel::OnSpinDown( wxSpinEvent &event ) | |
1618 | { | |
1619 | wxString value; | |
9a83f860 | 1620 | value.Printf( wxT("Spin control down: current = %d\n"), |
8c3c31d4 VZ |
1621 | m_spinbutton->GetValue()); |
1622 | ||
e94ff4cb | 1623 | if ( event.GetPosition() < -17 ) |
8c3c31d4 | 1624 | { |
9a83f860 | 1625 | value += wxT("Preventing the spin button from going below -17.\n"); |
8c3c31d4 VZ |
1626 | |
1627 | event.Veto(); | |
1628 | } | |
1629 | ||
1630 | m_text->AppendText(value); | |
1631 | } | |
1632 | ||
e380f72b RR |
1633 | void MyPanel::OnSpinUpdate( wxSpinEvent &event ) |
1634 | { | |
ec9f7884 | 1635 | wxString value; |
9a83f860 | 1636 | value.Printf( wxT("%d"), event.GetPosition() ); |
ec9f7884 | 1637 | m_spintext->SetValue( value ); |
6380910c | 1638 | |
9a83f860 | 1639 | value.Printf( wxT("Spin control range: (%d, %d), current = %d\n"), |
6380910c VZ |
1640 | m_spinbutton->GetMin(), m_spinbutton->GetMax(), |
1641 | m_spinbutton->GetValue()); | |
1642 | ||
1643 | m_text->AppendText(value); | |
e380f72b | 1644 | } |
9726da4f | 1645 | |
fe1bc285 | 1646 | void MyPanel::OnNewText( wxCommandEvent& /* event */) |
1dd815f3 RR |
1647 | { |
1648 | m_nonWrappingText->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") ); | |
1649 | m_wrappingText->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") ); | |
1650 | m_wrappingText->GetParent()->Layout(); | |
1651 | } | |
1652 | ||
516ab399 WS |
1653 | #if wxUSE_PROGRESSDLG |
1654 | ||
9726da4f VZ |
1655 | void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event ) |
1656 | { | |
1657 | event.Enable( m_spinbutton->GetValue() > 0 ); | |
1658 | } | |
1659 | ||
1660 | void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) | |
1661 | { | |
1662 | int max = m_spinbutton->GetValue(); | |
61c083e7 | 1663 | |
601964ff VS |
1664 | if ( max <= 0 ) |
1665 | { | |
9a83f860 | 1666 | wxLogError(wxT("You must set positive range!")); |
601964ff VS |
1667 | return; |
1668 | } | |
61c083e7 | 1669 | |
9a83f860 VZ |
1670 | wxProgressDialog dialog(wxT("Progress dialog example"), |
1671 | wxT("An informative message"), | |
9726da4f VZ |
1672 | max, // range |
1673 | this, // parent | |
8c3c31d4 | 1674 | wxPD_CAN_ABORT | |
2c8e4738 | 1675 | wxPD_AUTO_HIDE | |
8c3c31d4 VZ |
1676 | wxPD_APP_MODAL | |
1677 | wxPD_ELAPSED_TIME | | |
1678 | wxPD_ESTIMATED_TIME | | |
1679 | wxPD_REMAINING_TIME); | |
2ac1b69a | 1680 | |
9726da4f | 1681 | |
9230b621 | 1682 | bool cont = true; |
abceee76 | 1683 | for ( int i = 0; i <= max && cont; i++ ) |
9726da4f VZ |
1684 | { |
1685 | wxSleep(1); | |
abceee76 | 1686 | if ( i == max ) |
be9abe3f | 1687 | { |
9a83f860 | 1688 | cont = dialog.Update(i, wxT("That's all, folks!")); |
be9abe3f VZ |
1689 | } |
1690 | else if ( i == max / 2 ) | |
9726da4f | 1691 | { |
9a83f860 | 1692 | cont = dialog.Update(i, wxT("Only a half left (very long message)!")); |
9726da4f VZ |
1693 | } |
1694 | else | |
1695 | { | |
1696 | cont = dialog.Update(i); | |
1697 | } | |
1698 | } | |
1699 | ||
1700 | if ( !cont ) | |
1701 | { | |
9a83f860 | 1702 | *m_text << wxT("Progress dialog aborted!\n"); |
9726da4f VZ |
1703 | } |
1704 | else | |
1705 | { | |
9a83f860 | 1706 | *m_text << wxT("Countdown from ") << max << wxT(" finished.\n"); |
9726da4f VZ |
1707 | } |
1708 | } | |
1709 | ||
516ab399 | 1710 | #endif // wxUSE_PROGRESSDLG |
0e528b99 | 1711 | #endif // wxUSE_SPINBTN |
e380f72b | 1712 | |
2b5f62a0 VZ |
1713 | void MyPanel::OnSizerCheck( wxCommandEvent &event) |
1714 | { | |
1715 | switch (event.GetId ()) { | |
1716 | case ID_SIZER_CHECK1: | |
1717 | m_buttonSizer->Show (m_sizerBtn1, event.IsChecked ()); | |
1718 | m_buttonSizer->Layout (); | |
1719 | break; | |
1720 | case ID_SIZER_CHECK2: | |
1721 | m_buttonSizer->Show (m_sizerBtn2, event.IsChecked ()); | |
1722 | m_buttonSizer->Layout (); | |
1723 | break; | |
1724 | case ID_SIZER_CHECK3: | |
1725 | m_buttonSizer->Show (m_sizerBtn3, event.IsChecked ()); | |
1726 | m_buttonSizer->Layout (); | |
1727 | break; | |
1728 | case ID_SIZER_CHECK4: | |
1729 | m_buttonSizer->Show (m_sizerBtn4, event.IsChecked ()); | |
1730 | m_buttonSizer->Layout (); | |
1731 | break; | |
1732 | case ID_SIZER_CHECK14: | |
1733 | m_hsizer->Show (m_buttonSizer, event.IsChecked ()); | |
1734 | m_hsizer->Layout (); | |
1735 | break; | |
1736 | case ID_SIZER_CHECKBIG: | |
1737 | m_hsizer->Show (m_bigBtn, event.IsChecked ()); | |
1738 | m_hsizer->Layout (); | |
1739 | break; | |
1740 | } | |
1741 | ||
1742 | } | |
1743 | ||
2cb21a45 VZ |
1744 | MyPanel::~MyPanel() |
1745 | { | |
9a83f860 | 1746 | //wxLog::RemoveTraceMask(wxT("focus")); |
29e7e51a VZ |
1747 | delete wxLog::SetActiveTarget(m_logTargetOld); |
1748 | ||
61c083e7 | 1749 | delete m_book->GetImageList(); |
2cb21a45 VZ |
1750 | } |
1751 | ||
1c005ff7 RR |
1752 | //---------------------------------------------------------------------- |
1753 | // MyFrame | |
1754 | //---------------------------------------------------------------------- | |
1755 | ||
1756 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
3e2dd3db VZ |
1757 | EVT_MENU(CONTROLS_QUIT, MyFrame::OnQuit) |
1758 | EVT_MENU(CONTROLS_ABOUT, MyFrame::OnAbout) | |
1759 | EVT_MENU(CONTROLS_CLEAR_LOG, MyFrame::OnClearLog) | |
16f6dfd8 | 1760 | #if wxUSE_TOOLTIPS |
3e2dd3db VZ |
1761 | EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay) |
1762 | EVT_MENU(CONTROLS_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips) | |
be8b4385 VZ |
1763 | #ifdef __WXMSW__ |
1764 | EVT_MENU(CONTROLS_SET_TOOLTIPS_MAX_WIDTH, MyFrame::OnSetMaxTooltipWidth) | |
1765 | #endif // __WXMSW__ | |
16f6dfd8 | 1766 | #endif // wxUSE_TOOLTIPS |
87a1e308 | 1767 | |
3e2dd3db | 1768 | EVT_MENU(CONTROLS_ENABLE_ALL, MyFrame::OnEnableAll) |
47a8a4d5 VZ |
1769 | EVT_MENU(CONTROLS_HIDE_ALL, MyFrame::OnHideAll) |
1770 | EVT_MENU(CONTROLS_HIDE_LIST, MyFrame::OnHideList) | |
1a8b677e | 1771 | EVT_MENU(CONTROLS_CONTEXT_HELP, MyFrame::OnContextHelp) |
87a1e308 | 1772 | |
35960bbf VZ |
1773 | EVT_ICONIZE(MyFrame::OnIconized) |
1774 | EVT_MAXIMIZE(MyFrame::OnMaximized) | |
87a1e308 | 1775 | EVT_SIZE(MyFrame::OnSize) |
97206645 VZ |
1776 | EVT_MOVE(MyFrame::OnMove) |
1777 | ||
87a1e308 | 1778 | EVT_IDLE(MyFrame::OnIdle) |
1c005ff7 RR |
1779 | END_EVENT_TABLE() |
1780 | ||
9f84eccd | 1781 | MyFrame::MyFrame(const wxChar *title, int x, int y) |
c4ef14c2 | 1782 | : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450)) |
1c005ff7 | 1783 | { |
9a83f860 | 1784 | SetHelpText( wxT("Controls sample demonstrating various widgets") ); |
1a8b677e | 1785 | |
7bfc22f6 VZ |
1786 | // Give it an icon |
1787 | // The wxICON() macros loads an icon from a resource under Windows | |
1788 | // and uses an #included XPM image under GTK+ and Motif | |
1789 | ||
3cb332c1 | 1790 | SetIcon( wxICON(sample) ); |
7bfc22f6 VZ |
1791 | |
1792 | wxMenu *file_menu = new wxMenu; | |
1793 | ||
9a83f860 | 1794 | file_menu->Append(CONTROLS_CLEAR_LOG, wxT("&Clear log\tCtrl-L")); |
7bfc22f6 | 1795 | file_menu->AppendSeparator(); |
9a83f860 | 1796 | file_menu->Append(CONTROLS_ABOUT, wxT("&About\tF1")); |
7bfc22f6 | 1797 | file_menu->AppendSeparator(); |
9a83f860 | 1798 | file_menu->Append(CONTROLS_QUIT, wxT("E&xit\tAlt-X"), wxT("Quit controls sample")); |
7bfc22f6 VZ |
1799 | |
1800 | wxMenuBar *menu_bar = new wxMenuBar; | |
9a83f860 | 1801 | menu_bar->Append(file_menu, wxT("&File")); |
7bfc22f6 VZ |
1802 | |
1803 | #if wxUSE_TOOLTIPS | |
1804 | wxMenu *tooltip_menu = new wxMenu; | |
9a83f860 | 1805 | tooltip_menu->Append(CONTROLS_SET_TOOLTIP_DELAY, wxT("Set &delay\tCtrl-D")); |
7bfc22f6 | 1806 | tooltip_menu->AppendSeparator(); |
9a83f860 VZ |
1807 | tooltip_menu->Append(CONTROLS_ENABLE_TOOLTIPS, wxT("&Toggle tooltips\tCtrl-T"), |
1808 | wxT("enable/disable tooltips"), true); | |
9230b621 | 1809 | tooltip_menu->Check(CONTROLS_ENABLE_TOOLTIPS, true); |
be8b4385 VZ |
1810 | #ifdef __WXMSW__ |
1811 | tooltip_menu->Append(CONTROLS_SET_TOOLTIPS_MAX_WIDTH, "Set maximal &width"); | |
1812 | #endif // __WXMSW__ | |
9a83f860 | 1813 | menu_bar->Append(tooltip_menu, wxT("&Tooltips")); |
7bfc22f6 VZ |
1814 | #endif // wxUSE_TOOLTIPS |
1815 | ||
1816 | wxMenu *panel_menu = new wxMenu; | |
9a83f860 VZ |
1817 | panel_menu->Append(CONTROLS_ENABLE_ALL, wxT("&Disable all\tCtrl-E"), |
1818 | wxT("Enable/disable all panel controls"), true); | |
1819 | panel_menu->Append(CONTROLS_HIDE_ALL, wxT("&Hide all\tCtrl-I"), | |
1820 | wxT("Show/hide thoe whole panel controls"), true); | |
1821 | panel_menu->Append(CONTROLS_HIDE_LIST, wxT("Hide &list ctrl\tCtrl-S"), | |
1822 | wxT("Enable/disable all panel controls"), true); | |
1823 | panel_menu->Append(CONTROLS_CONTEXT_HELP, wxT("&Context help...\tCtrl-H"), | |
1824 | wxT("Get context help for a control")); | |
1825 | menu_bar->Append(panel_menu, wxT("&Panel")); | |
7bfc22f6 VZ |
1826 | |
1827 | SetMenuBar(menu_bar); | |
1828 | ||
960a83cc | 1829 | #if wxUSE_STATUSBAR |
5fb9fcfc | 1830 | CreateStatusBar(2); |
960a83cc | 1831 | #endif // wxUSE_STATUSBAR |
9f3362c4 | 1832 | |
87a1e308 | 1833 | m_panel = new MyPanel( this, 10, 10, 300, 100 ); |
1c005ff7 RR |
1834 | } |
1835 | ||
1836 | void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) | |
1837 | { | |
9230b621 | 1838 | Close(true); |
1c005ff7 RR |
1839 | } |
1840 | ||
1841 | void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
1842 | { | |
abceee76 VZ |
1843 | wxBusyCursor bc; |
1844 | ||
9a83f860 | 1845 | wxMessageDialog dialog(this, wxT("This is a control sample"), wxT("About Controls"), wxOK ); |
ec9f7884 | 1846 | dialog.ShowModal(); |
1c005ff7 | 1847 | } |
9f3362c4 | 1848 | |
3e2dd3db VZ |
1849 | void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) |
1850 | { | |
1851 | m_panel->m_text->Clear(); | |
1852 | } | |
1853 | ||
16f6dfd8 | 1854 | #if wxUSE_TOOLTIPS |
87728739 | 1855 | void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event)) |
16f6dfd8 VZ |
1856 | { |
1857 | static long s_delay = 5000; | |
1858 | ||
1859 | wxString delay; | |
9a83f860 | 1860 | delay.Printf( wxT("%ld"), s_delay); |
16f6dfd8 | 1861 | |
9a83f860 VZ |
1862 | delay = wxGetTextFromUser(wxT("Enter delay (in milliseconds)"), |
1863 | wxT("Set tooltip delay"), | |
ec9f7884 VZ |
1864 | delay, |
1865 | this); | |
16f6dfd8 VZ |
1866 | if ( !delay ) |
1867 | return; // cancelled | |
1868 | ||
9a83f860 | 1869 | wxSscanf(delay, wxT("%ld"), &s_delay); |
16f6dfd8 VZ |
1870 | |
1871 | wxToolTip::SetDelay(s_delay); | |
1872 | ||
9a83f860 | 1873 | wxLogStatus(this, wxT("Tooltip delay set to %ld milliseconds"), s_delay); |
16f6dfd8 VZ |
1874 | } |
1875 | ||
87728739 | 1876 | void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event)) |
16f6dfd8 | 1877 | { |
9230b621 | 1878 | static bool s_enabled = true; |
16f6dfd8 VZ |
1879 | |
1880 | s_enabled = !s_enabled; | |
1881 | ||
1882 | wxToolTip::Enable(s_enabled); | |
1883 | ||
9a83f860 | 1884 | wxLogStatus(this, wxT("Tooltips %sabled"), s_enabled ? wxT("en") : wxT("dis") ); |
16f6dfd8 | 1885 | } |
be8b4385 VZ |
1886 | |
1887 | #ifdef __WXMSW__ | |
1888 | ||
1889 | void MyFrame::OnSetMaxTooltipWidth(wxCommandEvent& WXUNUSED(event)) | |
1890 | { | |
1891 | static int s_maxWidth = 0; | |
1892 | ||
1893 | wxNumberEntryDialog dlg | |
1894 | ( | |
1895 | this, | |
1896 | "Change maximal tooltip width", | |
1897 | "&Width in pixels:", | |
1898 | GetTitle(), | |
1899 | s_maxWidth, | |
1900 | -1, | |
1901 | 600 | |
1902 | ); | |
1903 | if ( dlg.ShowModal() == wxID_CANCEL ) | |
1904 | return; | |
1905 | ||
1906 | s_maxWidth = dlg.GetValue(); | |
1907 | wxToolTip::SetMaxWidth(s_maxWidth); | |
1908 | ||
1909 | // we need to set the tooltip again to test the new width | |
1910 | m_panel->SetAllToolTips(); | |
1911 | } | |
1912 | ||
1913 | #endif // __WXMSW__ | |
1914 | ||
1915 | #endif // wxUSE_TOOLTIPS | |
16f6dfd8 | 1916 | |
87a1e308 VZ |
1917 | void MyFrame::OnEnableAll(wxCommandEvent& WXUNUSED(event)) |
1918 | { | |
9230b621 | 1919 | static bool s_enable = true; |
87a1e308 VZ |
1920 | |
1921 | s_enable = !s_enable; | |
1922 | m_panel->Enable(s_enable); | |
47a8a4d5 VZ |
1923 | static bool s_enableCheckbox = true; |
1924 | if ( !s_enable ) | |
1925 | { | |
1926 | // this is a test for correct behaviour of either enabling or disabling | |
1927 | // a child when its parent is disabled: the checkbox should have the | |
1928 | // correct state when the parent is enabled back | |
1929 | m_panel->m_checkbox->Enable(s_enableCheckbox); | |
1930 | s_enableCheckbox = !s_enableCheckbox; | |
1931 | } | |
1932 | } | |
1933 | ||
1934 | void MyFrame::OnHideAll(wxCommandEvent& WXUNUSED(event)) | |
1935 | { | |
1936 | static bool s_show = true; | |
1937 | ||
1938 | s_show = !s_show; | |
1939 | m_panel->Show(s_show); | |
1940 | } | |
1941 | ||
1942 | void MyFrame::OnHideList(wxCommandEvent& WXUNUSED(event)) | |
1943 | { | |
1944 | static bool s_show = true; | |
1945 | ||
1946 | s_show = !s_show; | |
1947 | m_panel->m_listbox->Show(s_show); | |
87a1e308 VZ |
1948 | } |
1949 | ||
1a8b677e VZ |
1950 | void MyFrame::OnContextHelp(wxCommandEvent& WXUNUSED(event)) |
1951 | { | |
1952 | // starts a local event loop | |
1953 | wxContextHelp chelp(this); | |
1954 | } | |
1955 | ||
97206645 VZ |
1956 | void MyFrame::OnMove( wxMoveEvent& event ) |
1957 | { | |
960a83cc | 1958 | #if wxUSE_STATUSBAR |
97206645 | 1959 | UpdateStatusBar(event.GetPosition(), GetSize()); |
960a83cc | 1960 | #endif // wxUSE_STATUSBAR |
97206645 VZ |
1961 | |
1962 | event.Skip(); | |
1963 | } | |
1964 | ||
35960bbf VZ |
1965 | void MyFrame::OnIconized( wxIconizeEvent& event ) |
1966 | { | |
9a83f860 VZ |
1967 | wxLogMessage(wxT("Frame %s"), event.IsIconized() ? wxT("iconized") |
1968 | : wxT("restored")); | |
35960bbf VZ |
1969 | event.Skip(); |
1970 | } | |
1971 | ||
1972 | void MyFrame::OnMaximized( wxMaximizeEvent& WXUNUSED(event) ) | |
1973 | { | |
9a83f860 | 1974 | wxLogMessage(wxT("Frame maximized")); |
35960bbf VZ |
1975 | } |
1976 | ||
5fb9fcfc VZ |
1977 | void MyFrame::OnSize( wxSizeEvent& event ) |
1978 | { | |
960a83cc | 1979 | #if wxUSE_STATUSBAR |
97206645 | 1980 | UpdateStatusBar(GetPosition(), event.GetSize()); |
960a83cc | 1981 | #endif // wxUSE_STATUSBAR |
5fb9fcfc VZ |
1982 | |
1983 | event.Skip(); | |
1984 | } | |
1985 | ||
9f3362c4 VZ |
1986 | void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) |
1987 | { | |
1988 | // track the window which has the focus in the status bar | |
2dd8d2d7 | 1989 | static wxWindow *s_windowFocus = NULL; |
9f3362c4 | 1990 | wxWindow *focus = wxWindow::FindFocus(); |
2dd8d2d7 | 1991 | if ( focus != s_windowFocus ) |
9f3362c4 VZ |
1992 | { |
1993 | s_windowFocus = focus; | |
1994 | ||
1995 | wxString msg; | |
2dd8d2d7 VZ |
1996 | if ( focus ) |
1997 | { | |
1998 | msg.Printf( | |
d3eb13d2 | 1999 | "Focus: %s" |
9f3362c4 | 2000 | #ifdef __WXMSW__ |
d3eb13d2 | 2001 | ", HWND = %08x" |
f70d5829 | 2002 | #endif |
2dd8d2d7 | 2003 | , s_windowFocus->GetName().c_str() |
9f3362c4 | 2004 | #ifdef __WXMSW__ |
2dd8d2d7 | 2005 | , (unsigned int) s_windowFocus->GetHWND() |
f70d5829 | 2006 | #endif |
2dd8d2d7 VZ |
2007 | ); |
2008 | } | |
2009 | else | |
2010 | { | |
9a83f860 | 2011 | msg = wxT("No focus"); |
2dd8d2d7 | 2012 | } |
9f3362c4 | 2013 | |
960a83cc | 2014 | #if wxUSE_STATUSBAR |
9f3362c4 | 2015 | SetStatusText(msg); |
960a83cc | 2016 | #endif // wxUSE_STATUSBAR |
9f3362c4 | 2017 | } |
341c92a8 | 2018 | } |
6c8a980f | 2019 | |
f6bcfd97 BP |
2020 | void MyComboBox::OnChar(wxKeyEvent& event) |
2021 | { | |
9a83f860 | 2022 | wxLogMessage(wxT("MyComboBox::OnChar")); |
f6bcfd97 | 2023 | |
b1d4dd7a | 2024 | if ( event.GetKeyCode() == 'w' ) |
43b2d5e7 | 2025 | { |
9a83f860 | 2026 | wxLogMessage(wxT("MyComboBox: 'w' will be ignored.")); |
43b2d5e7 | 2027 | } |
f6bcfd97 | 2028 | else |
43b2d5e7 | 2029 | { |
f6bcfd97 | 2030 | event.Skip(); |
43b2d5e7 | 2031 | } |
f6bcfd97 BP |
2032 | } |
2033 | ||
2034 | void MyComboBox::OnKeyDown(wxKeyEvent& event) | |
2035 | { | |
9a83f860 | 2036 | wxLogMessage(wxT("MyComboBox::OnKeyDown")); |
f6bcfd97 | 2037 | |
b1d4dd7a | 2038 | if ( event.GetKeyCode() == 'w' ) |
43b2d5e7 | 2039 | { |
9a83f860 | 2040 | wxLogMessage(wxT("MyComboBox: 'w' will be ignored.")); |
43b2d5e7 | 2041 | } |
f6bcfd97 | 2042 | else |
43b2d5e7 | 2043 | { |
f6bcfd97 | 2044 | event.Skip(); |
43b2d5e7 | 2045 | } |
f6bcfd97 BP |
2046 | } |
2047 | ||
2048 | void MyComboBox::OnKeyUp(wxKeyEvent& event) | |
2049 | { | |
9a83f860 | 2050 | wxLogMessage(wxT("MyComboBox::OnKeyUp")); |
f6bcfd97 BP |
2051 | |
2052 | event.Skip(); | |
2053 | } | |
2054 | ||
8b81a824 VS |
2055 | static void SetListboxClientData(const wxChar *name, wxListBox *control) |
2056 | { | |
2057 | size_t count = control->GetCount(); | |
2058 | for ( size_t n = 0; n < count; n++ ) | |
2059 | { | |
2060 | wxString s; | |
2061 | s.Printf(wxT("%s client data for '%s'"), | |
2062 | name, control->GetString(n).c_str()); | |
2063 | ||
2064 | control->SetClientObject(n, new wxStringClientData(s)); | |
2065 | } | |
2066 | } | |
2067 | ||
2b5f62a0 VZ |
2068 | #if wxUSE_CHOICE |
2069 | ||
8b81a824 | 2070 | static void SetChoiceClientData(const wxChar *name, wxChoice *control) |
6c8a980f VZ |
2071 | { |
2072 | size_t count = control->GetCount(); | |
2073 | for ( size_t n = 0; n < count; n++ ) | |
2074 | { | |
2075 | wxString s; | |
4acb6ca6 | 2076 | s.Printf(wxT("%s client data for '%s'"), |
6c8a980f VZ |
2077 | name, control->GetString(n).c_str()); |
2078 | ||
2079 | control->SetClientObject(n, new wxStringClientData(s)); | |
2080 | } | |
2081 | } | |
2b5f62a0 VZ |
2082 | |
2083 | #endif // wxUSE_CHOICE |