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