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