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