]>
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 | ||
4fabb575 | 26 | #include "wx/spinbutt.h" |
53b28675 | 27 | #include "wx/notebook.h" |
2cb21a45 | 28 | #include "wx/imaglist.h" |
b8653fbf VZ |
29 | |
30 | #if wxUSE_TOOLTIPS | |
31 | #include "wx/tooltip.h" | |
32 | #endif | |
1c005ff7 | 33 | |
4b5f3fe6 | 34 | #if defined(__WXGTK__) || defined(__WXMOTIF__) |
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 | ||
9726da4f VZ |
48 | #ifdef __WIN16__ |
49 | // Win16 doesn't have them | |
50 | #undef wxUSE_SPINBUTTON | |
51 | #define wxUSE_SPINBUTTON 0 | |
52 | #endif // __WIN16__ | |
53 | ||
54 | #include "wx/progdlg.h" | |
55 | ||
1c005ff7 RR |
56 | //---------------------------------------------------------------------- |
57 | // class definitions | |
58 | //---------------------------------------------------------------------- | |
59 | ||
60 | class MyApp: public wxApp | |
655822f3 | 61 | { |
b8653fbf VZ |
62 | public: |
63 | bool OnInit(); | |
1c005ff7 RR |
64 | }; |
65 | ||
66 | class MyPanel: public wxPanel | |
67 | { | |
b8653fbf | 68 | public: |
1c005ff7 | 69 | MyPanel(wxFrame *frame, int x, int y, int w, int h); |
2cb21a45 | 70 | virtual ~MyPanel(); |
16f6dfd8 | 71 | |
1c005ff7 RR |
72 | void OnSize( wxSizeEvent& event ); |
73 | void OnListBox( wxCommandEvent &event ); | |
5b077d48 | 74 | void OnListBoxDoubleClick( wxCommandEvent &event ); |
1c005ff7 | 75 | void OnListBoxButtons( wxCommandEvent &event ); |
47908e25 RR |
76 | void OnChoice( wxCommandEvent &event ); |
77 | void OnChoiceButtons( wxCommandEvent &event ); | |
78 | void OnCombo( wxCommandEvent &event ); | |
79 | void OnComboButtons( wxCommandEvent &event ); | |
80 | void OnRadio( wxCommandEvent &event ); | |
81 | void OnRadioButtons( wxCommandEvent &event ); | |
868a2826 | 82 | void OnSetFont( wxCommandEvent &event ); |
cb43b372 | 83 | void OnPageChanged( wxNotebookEvent &event ); |
4d0f3cd6 | 84 | void OnPageChanging( wxNotebookEvent &event ); |
7bce6aec | 85 | void OnSliderUpdate( wxCommandEvent &event ); |
9726da4f | 86 | #ifndef wxUSE_SPINBUTTON |
e380f72b | 87 | void OnSpinUpdate( wxSpinEvent &event ); |
9726da4f VZ |
88 | void OnUpdateShowProgress( wxUpdateUIEvent& event ); |
89 | void OnShowProgress( wxCommandEvent &event ); | |
90 | #endif // wxUSE_SPINBUTTON | |
16f6dfd8 | 91 | |
e380f72b RR |
92 | wxListBox *m_listbox; |
93 | wxChoice *m_choice; | |
94 | wxComboBox *m_combo; | |
95 | wxRadioBox *m_radio; | |
96 | wxGauge *m_gauge; | |
97 | wxSlider *m_slider; | |
98 | wxButton *m_fontButton; | |
85eb36c2 RR |
99 | wxButton *m_lbSelectNum; |
100 | wxButton *m_lbSelectThis; | |
9726da4f | 101 | #ifndef wxUSE_SPINBUTTON |
e380f72b | 102 | wxSpinButton *m_spinbutton; |
9726da4f | 103 | wxButton *m_btnProgress; |
2a47d3c1 | 104 | #endif |
e380f72b | 105 | wxTextCtrl *m_spintext; |
ae0bdb01 | 106 | wxCheckBox *m_checkbox; |
16f6dfd8 | 107 | |
e380f72b | 108 | wxTextCtrl *m_text; |
655822f3 VZ |
109 | wxNotebook *m_notebook; |
110 | ||
b8653fbf VZ |
111 | private: |
112 | DECLARE_EVENT_TABLE() | |
1c005ff7 RR |
113 | }; |
114 | ||
115 | class MyFrame: public wxFrame | |
116 | { | |
b8653fbf | 117 | public: |
1c005ff7 | 118 | MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h); |
655822f3 | 119 | |
1c005ff7 RR |
120 | void OnQuit(wxCommandEvent& event); |
121 | void OnAbout(wxCommandEvent& event); | |
16f6dfd8 VZ |
122 | #if wxUSE_TOOLTIPS |
123 | void OnSetTooltipDelay(wxCommandEvent& event); | |
124 | void OnToggleTooltips(wxCommandEvent& event); | |
125 | #endif // wxUSE_TOOLTIPS | |
9f3362c4 | 126 | void OnIdle( wxIdleEvent& event ); |
5fb9fcfc | 127 | void OnSize( wxSizeEvent& event ); |
655822f3 | 128 | |
b8653fbf VZ |
129 | private: |
130 | DECLARE_EVENT_TABLE() | |
1c005ff7 RR |
131 | }; |
132 | ||
133 | //---------------------------------------------------------------------- | |
134 | // main() | |
135 | //---------------------------------------------------------------------- | |
136 | ||
d59051dd | 137 | IMPLEMENT_APP(MyApp) |
1c005ff7 RR |
138 | |
139 | //---------------------------------------------------------------------- | |
140 | // MyApp | |
141 | //---------------------------------------------------------------------- | |
142 | ||
16f6dfd8 VZ |
143 | enum |
144 | { | |
145 | MINIMAL_QUIT = 100, | |
146 | MINIMAL_TEXT, | |
147 | MINIMAL_ABOUT, | |
148 | ||
149 | // tooltip menu | |
150 | MINIMAL_SET_TOOLTIP_DELAY = 200, | |
151 | MINIMAL_ENABLE_TOOLTIPS | |
152 | }; | |
1c005ff7 | 153 | |
b8653fbf | 154 | bool MyApp::OnInit() |
1c005ff7 | 155 | { |
ec9f7884 VZ |
156 | // Create the main frame window |
157 | MyFrame *frame = new MyFrame((wxFrame *) NULL, | |
158 | "Controls wxWindows App", | |
159 | 50, 50, 530, 420); | |
655822f3 | 160 | |
ec9f7884 VZ |
161 | // Give it an icon |
162 | // The wxICON() macros loads an icon from a resource under Windows | |
163 | // and uses an #included XPM image under GTK+ and Motif | |
655822f3 | 164 | |
ec9f7884 | 165 | frame->SetIcon( wxICON(mondrian) ); |
1c005ff7 | 166 | |
934e1eda | 167 | wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF ); |
6bc8a1c8 RR |
168 | file_menu->Append(MINIMAL_ABOUT, "&About\tF1"); |
169 | file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample"); | |
16f6dfd8 | 170 | |
33caefb3 | 171 | wxMenuBar *menu_bar = new wxMenuBar; |
ec9f7884 | 172 | menu_bar->Append(file_menu, "&File"); |
16f6dfd8 VZ |
173 | |
174 | #if wxUSE_TOOLTIPS | |
ec9f7884 | 175 | wxMenu *tooltip_menu = new wxMenu; |
6bc8a1c8 | 176 | tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay\tCtrl-D"); |
ec9f7884 | 177 | tooltip_menu->AppendSeparator(); |
6bc8a1c8 | 178 | tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips\tCrtl-T", |
ec9f7884 VZ |
179 | "enable/disable tooltips", TRUE); |
180 | tooltip_menu->Check(MINIMAL_ENABLE_TOOLTIPS, TRUE); | |
181 | menu_bar->Append(tooltip_menu, "&Tooltips"); | |
16f6dfd8 VZ |
182 | #endif // wxUSE_TOOLTIPS |
183 | ||
ec9f7884 | 184 | frame->SetMenuBar(menu_bar); |
1c005ff7 | 185 | |
ec9f7884 | 186 | frame->Show(TRUE); |
9018abe3 | 187 | frame->SetCursor(wxCursor(wxCURSOR_HAND)); |
655822f3 | 188 | |
ec9f7884 | 189 | SetTopWindow(frame); |
1c005ff7 | 190 | |
ec9f7884 | 191 | return TRUE; |
1c005ff7 RR |
192 | } |
193 | ||
194 | //---------------------------------------------------------------------- | |
195 | // MyPanel | |
196 | //---------------------------------------------------------------------- | |
197 | ||
4fabb575 | 198 | const int ID_NOTEBOOK = 1000; |
1c005ff7 | 199 | |
4fabb575 JS |
200 | const int ID_LISTBOX = 130; |
201 | const int ID_LISTBOX_SEL_NUM = 131; | |
202 | const int ID_LISTBOX_SEL_STR = 132; | |
203 | const int ID_LISTBOX_CLEAR = 133; | |
204 | const int ID_LISTBOX_APPEND = 134; | |
205 | const int ID_LISTBOX_DELETE = 135; | |
206 | const int ID_LISTBOX_FONT = 136; | |
207 | const int ID_LISTBOX_ENABLE = 137; | |
1c005ff7 | 208 | |
4fabb575 JS |
209 | const int ID_CHOICE = 120; |
210 | const int ID_CHOICE_SEL_NUM = 121; | |
211 | const int ID_CHOICE_SEL_STR = 122; | |
212 | const int ID_CHOICE_CLEAR = 123; | |
213 | const int ID_CHOICE_APPEND = 124; | |
214 | const int ID_CHOICE_DELETE = 125; | |
215 | const int ID_CHOICE_FONT = 126; | |
216 | const int ID_CHOICE_ENABLE = 127; | |
53010e52 | 217 | |
4fabb575 JS |
218 | const int ID_COMBO = 140; |
219 | const int ID_COMBO_SEL_NUM = 141; | |
220 | const int ID_COMBO_SEL_STR = 142; | |
221 | const int ID_COMBO_CLEAR = 143; | |
222 | const int ID_COMBO_APPEND = 144; | |
223 | const int ID_COMBO_DELETE = 145; | |
224 | const int ID_COMBO_FONT = 146; | |
225 | const int ID_COMBO_ENABLE = 147; | |
53010e52 | 226 | |
4fabb575 JS |
227 | const int ID_RADIOBOX = 160; |
228 | const int ID_RADIOBOX_SEL_NUM = 161; | |
229 | const int ID_RADIOBOX_SEL_STR = 162; | |
230 | const int ID_RADIOBOX_FONT = 163; | |
231 | const int ID_RADIOBOX_ENABLE = 164; | |
868a2826 | 232 | |
f5d29b39 RR |
233 | const int ID_RADIOBUTTON_1 = 166; |
234 | const int ID_RADIOBUTTON_2 = 167; | |
235 | ||
4fabb575 | 236 | const int ID_SET_FONT = 170; |
47908e25 | 237 | |
4fabb575 JS |
238 | const int ID_GAUGE = 180; |
239 | const int ID_SLIDER = 181; | |
58614078 | 240 | |
4fabb575 | 241 | const int ID_SPIN = 182; |
9726da4f | 242 | const int ID_BTNPROGRESS = 183; |
e380f72b | 243 | |
1c005ff7 | 244 | BEGIN_EVENT_TABLE(MyPanel, wxPanel) |
ec9f7884 | 245 | EVT_SIZE ( MyPanel::OnSize) |
4d0f3cd6 | 246 | EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging) |
ec9f7884 VZ |
247 | EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyPanel::OnPageChanged) |
248 | EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) | |
249 | EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick) | |
250 | EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons) | |
251 | EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons) | |
252 | EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) | |
253 | EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) | |
254 | EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons) | |
255 | EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons) | |
256 | EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons) | |
257 | EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice) | |
258 | EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons) | |
259 | EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons) | |
260 | EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons) | |
261 | EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons) | |
262 | EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons) | |
263 | EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons) | |
264 | EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons) | |
265 | EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo) | |
266 | EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) | |
267 | EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) | |
268 | EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) | |
269 | EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons) | |
270 | EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons) | |
271 | EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons) | |
272 | EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons) | |
273 | EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio) | |
274 | EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons) | |
275 | EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons) | |
276 | EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons) | |
277 | EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons) | |
278 | EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont) | |
279 | EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate) | |
9726da4f | 280 | #ifndef wxUSE_SPINBUTTON |
ec9f7884 | 281 | EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate) |
9726da4f VZ |
282 | EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress) |
283 | EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress) | |
2a47d3c1 | 284 | #endif |
1c005ff7 RR |
285 | END_EVENT_TABLE() |
286 | ||
5fb9fcfc | 287 | MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) |
0a772322 VZ |
288 | : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), |
289 | m_text(NULL), m_notebook(NULL) | |
1c005ff7 | 290 | { |
ec9f7884 | 291 | // SetBackgroundColour("cadet blue"); |
a81258be | 292 | |
ec9f7884 VZ |
293 | m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); |
294 | // m_text->SetBackgroundColour("wheat"); | |
655822f3 | 295 | |
4d0f3cd6 | 296 | delete wxLog::SetActiveTarget(new wxLogStderr); |
0a772322 | 297 | |
ec9f7884 | 298 | m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) ); |
655822f3 | 299 | |
ec9f7884 VZ |
300 | wxString choices[] = |
301 | { | |
302 | "This", | |
303 | "is one of my", | |
304 | "really", | |
305 | "wonderful", | |
306 | "examples." | |
307 | }; | |
655822f3 | 308 | |
4fabb575 | 309 | #ifdef USE_XPM |
ec9f7884 VZ |
310 | // image ids |
311 | enum | |
312 | { | |
313 | Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max | |
314 | }; | |
315 | ||
316 | // fill the image list | |
317 | wxImageList *imagelist = new wxImageList(32, 32); | |
318 | ||
319 | imagelist-> Add( wxBitmap( list_xpm )); | |
320 | imagelist-> Add( wxBitmap( choice_xpm )); | |
321 | imagelist-> Add( wxBitmap( combo_xpm )); | |
322 | imagelist-> Add( wxBitmap( text_xpm )); | |
323 | imagelist-> Add( wxBitmap( radio_xpm )); | |
324 | imagelist-> Add( wxBitmap( gauge_xpm )); | |
325 | m_notebook->SetImageList(imagelist); | |
73c700fd | 326 | #elif defined(__WXMSW__) |
ec9f7884 VZ |
327 | // load images from resources |
328 | enum | |
329 | { | |
330 | Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max | |
331 | }; | |
332 | wxImageList *imagelist = new wxImageList(16, 16, FALSE, Image_Max); | |
333 | ||
334 | static const char *s_iconNames[Image_Max] = | |
335 | { | |
336 | "list", "choice", "combo", "text", "radio", "gauge" | |
337 | }; | |
338 | ||
339 | for ( size_t n = 0; n < Image_Max; n++ ) | |
340 | { | |
341 | wxBitmap bmp(s_iconNames[n]); | |
342 | if ( !bmp.Ok() || (imagelist->Add(bmp) == -1) ) | |
343 | { | |
344 | wxLogWarning("Couldn't load the image '%s' for the notebook page %d.", | |
345 | s_iconNames[n], n); | |
346 | } | |
347 | } | |
348 | ||
349 | m_notebook->SetImageList(imagelist); | |
4fabb575 JS |
350 | #else |
351 | ||
ec9f7884 | 352 | // No images for now |
4fabb575 JS |
353 | #define Image_List -1 |
354 | #define Image_Choice -1 | |
355 | #define Image_Combo -1 | |
356 | #define Image_Text -1 | |
357 | #define Image_Radio -1 | |
358 | #define Image_Gauge -1 | |
359 | #define Image_Max -1 | |
360 | ||
fc54776e | 361 | #endif |
2cb21a45 | 362 | |
ec9f7884 VZ |
363 | wxButton *button = (wxButton*) NULL; /* who did this ? */ |
364 | wxPanel *panel = (wxPanel*) NULL; | |
9838df2c | 365 | |
ec9f7884 | 366 | panel = new wxPanel(m_notebook); |
034be888 | 367 | m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices, wxLB_ALWAYS_SB ); |
ec9f7884 | 368 | m_listbox->SetCursor(*wxCROSS_CURSOR); |
b8653fbf | 369 | #if wxUSE_TOOLTIPS |
ec9f7884 | 370 | m_listbox->SetToolTip( "This is a list box" ); |
16f6dfd8 | 371 | #endif // wxUSE_TOOLTIPS |
9f3362c4 | 372 | |
85eb36c2 RR |
373 | m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
374 | m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
ec9f7884 VZ |
375 | (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); |
376 | (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
377 | (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
034be888 | 378 | button = new wxButton( panel, ID_LISTBOX_FONT, "Set &Italic font", wxPoint(340,130), wxSize(140,30) ); |
b8653fbf | 379 | #if wxUSE_TOOLTIPS |
ec9f7884 | 380 | button->SetToolTip( "Press here to set italic font" ); |
16f6dfd8 | 381 | #endif // wxUSE_TOOLTIPS |
b1170810 | 382 | |
0a772322 | 383 | m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130), wxSize(-1, -1), wxALIGN_RIGHT ); |
ec9f7884 | 384 | m_checkbox->SetValue(FALSE); |
b8653fbf | 385 | #if wxUSE_TOOLTIPS |
ec9f7884 | 386 | m_checkbox->SetToolTip( "Click here to disable the listbox" ); |
16f6dfd8 | 387 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
388 | m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List); |
389 | ||
390 | panel = new wxPanel(m_notebook); | |
391 | m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices ); | |
2b07d713 | 392 | m_choice->SetBackgroundColour( "red" ); |
ec9f7884 VZ |
393 | (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
394 | (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
395 | (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); | |
396 | (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
397 | (void)new wxButton( panel, ID_CHOICE_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
398 | (void)new wxButton( panel, ID_CHOICE_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); | |
399 | (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); | |
1fad4c3e | 400 | |
ec9f7884 VZ |
401 | m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); |
402 | ||
403 | panel = new wxPanel(m_notebook); | |
a260fe6a | 404 | m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices, wxCB_READONLY ); |
ec9f7884 VZ |
405 | (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
406 | (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
407 | (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); | |
408 | (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
409 | (void)new wxButton( panel, ID_COMBO_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
410 | (void)new wxButton( panel, ID_COMBO_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); | |
411 | (void)new wxCheckBox( panel, ID_COMBO_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); | |
412 | m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo); | |
413 | ||
ec9f7884 VZ |
414 | wxString choices2[] = |
415 | { | |
17867d61 | 416 | "First", "Second", |
0a772322 | 417 | /* "Third", |
17867d61 RR |
418 | "Fourth", "Fifth", "Sixth", |
419 | "Seventh", "Eighth", "Nineth", "Tenth" */ | |
ec9f7884 VZ |
420 | }; |
421 | ||
422 | panel = new wxPanel(m_notebook); | |
9018abe3 VZ |
423 | (void)new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS ); |
424 | m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS ); | |
ec9f7884 VZ |
425 | (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
426 | (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) ); | |
427 | m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(140,30) ); | |
428 | (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(340,80), wxSize(140,30) ); | |
429 | (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "Disable", wxPoint(340,130), wxSize(140,30) ); | |
0544bc0a | 430 | wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, "Radiobutton1", wxPoint(210,170), wxSize(110,30), wxRB_GROUP ); |
ec9f7884 VZ |
431 | rb->SetValue( FALSE ); |
432 | (void)new wxRadioButton( panel, ID_RADIOBUTTON_2, "Radiobutton2", wxPoint(340,170), wxSize(110,30) ); | |
433 | m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio); | |
434 | ||
435 | panel = new wxPanel(m_notebook); | |
436 | (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) ); | |
437 | m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155, 30) ); | |
858b5bdd | 438 | m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1), wxSL_LABELS ); |
ec9f7884 | 439 | (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) ); |
9838df2c | 440 | #ifdef __WXMOTIF__ |
ec9f7884 VZ |
441 | // No wrapping text in wxStaticText yet :-( |
442 | (void)new wxStaticText( panel, -1, | |
443 | "Drag the slider!", | |
444 | wxPoint(208,30), | |
445 | wxSize(210, -1) | |
446 | ); | |
9838df2c | 447 | #else |
ec9f7884 VZ |
448 | (void)new wxStaticText( panel, -1, |
449 | "In order see the gauge (aka progress bar)\n" | |
450 | "control do something you have to drag the\n" | |
451 | "handle of the slider to the right.\n" | |
452 | "\n" | |
453 | "This is also supposed to demonstrate how\n" | |
454 | "to use static controls.\n", | |
455 | wxPoint(208,25), | |
456 | wxSize(250, 110) | |
457 | ); | |
9838df2c | 458 | #endif |
ec9f7884 | 459 | m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) ); |
9726da4f | 460 | #ifndef wxUSE_SPINBUTTON |
ec9f7884 | 461 | m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) ); |
6380910c VZ |
462 | m_spinbutton->SetRange(-10,30); |
463 | m_spinbutton->SetValue(-5); | |
9726da4f VZ |
464 | |
465 | m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog", | |
466 | wxPoint(208, 159) ); | |
2a47d3c1 | 467 | #endif |
ec9f7884 | 468 | m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge); |
45e41c05 VZ |
469 | |
470 | panel = new wxPanel(m_notebook); | |
471 | wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); | |
472 | wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10)); | |
473 | ||
474 | bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10)); | |
475 | bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION)); | |
476 | ||
477 | wxBitmap bitmap( 100, 100 ); | |
478 | wxMemoryDC dc; | |
479 | dc.SelectObject( bitmap ); | |
480 | dc.SetPen(*wxGREEN_PEN); | |
481 | dc.DrawEllipse(5, 5, 90, 90); | |
482 | dc.DrawText("Bitmap", 20, 20); | |
483 | dc.SelectObject( wxNullBitmap ); | |
484 | ||
485 | wxBitmapButton *bmpBtn = new wxBitmapButton | |
486 | ( | |
487 | panel, | |
488 | -1, | |
489 | bitmap, | |
490 | wxPoint(100, 20) | |
491 | ); | |
492 | bmpBtn = NULL; // suppress warning | |
493 | ||
2ac1b69a RD |
494 | new wxButton(panel, -1, "Another button", wxPoint(250, 20)); |
495 | ||
45e41c05 | 496 | m_notebook->AddPage(panel, "wxBitmapXXX"); |
1c005ff7 RR |
497 | } |
498 | ||
499 | void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) | |
500 | { | |
ec9f7884 VZ |
501 | int x = 0; |
502 | int y = 0; | |
503 | GetClientSize( &x, &y ); | |
655822f3 | 504 | |
ec9f7884 VZ |
505 | if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 ); |
506 | if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 ); | |
1c005ff7 RR |
507 | } |
508 | ||
4d0f3cd6 VZ |
509 | void MyPanel::OnPageChanging( wxNotebookEvent &event ) |
510 | { | |
45e41c05 VZ |
511 | int selOld = event.GetOldSelection(); |
512 | if ( selOld == 2 ) | |
4d0f3cd6 VZ |
513 | { |
514 | wxMessageBox("This demonstrates how a program may prevent the " | |
953704c1 RR |
515 | "page change from taking place - \n the current page will " |
516 | "stay the third one", "Control sample", | |
4d0f3cd6 VZ |
517 | wxICON_INFORMATION | wxOK); |
518 | ||
519 | event.Veto(); | |
45e41c05 VZ |
520 | |
521 | return; | |
4d0f3cd6 | 522 | } |
45e41c05 VZ |
523 | |
524 | *m_text << "Notebook selection is being changed from " << selOld << "\n"; | |
4d0f3cd6 VZ |
525 | } |
526 | ||
cb43b372 RR |
527 | void MyPanel::OnPageChanged( wxNotebookEvent &event ) |
528 | { | |
ec9f7884 | 529 | *m_text << "Notebook selection is " << event.GetSelection() << "\n"; |
cb43b372 RR |
530 | } |
531 | ||
1c005ff7 RR |
532 | void MyPanel::OnListBox( wxCommandEvent &event ) |
533 | { | |
19da4326 | 534 | m_text->AppendText( "ListBox event selection string is: " ); |
ec9f7884 VZ |
535 | m_text->AppendText( event.GetString() ); |
536 | m_text->AppendText( "\n" ); | |
19da4326 RR |
537 | m_text->AppendText( "ListBox control selection string is: " ); |
538 | m_text->AppendText( m_listbox->GetStringSelection() ); | |
539 | m_text->AppendText( "\n" ); | |
1c005ff7 RR |
540 | } |
541 | ||
5b077d48 RR |
542 | void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event ) |
543 | { | |
ec9f7884 VZ |
544 | m_text->AppendText( "ListBox double click string is: " ); |
545 | m_text->AppendText( event.GetString() ); | |
546 | m_text->AppendText( "\n" ); | |
5b077d48 RR |
547 | } |
548 | ||
47908e25 RR |
549 | void MyPanel::OnListBoxButtons( wxCommandEvent &event ) |
550 | { | |
ec9f7884 | 551 | switch (event.GetId()) |
d3904ceb | 552 | { |
ec9f7884 VZ |
553 | case ID_LISTBOX_ENABLE: |
554 | { | |
555 | m_text->AppendText("Checkbox clicked.\n"); | |
556 | wxCheckBox *cb = (wxCheckBox*)event.GetEventObject(); | |
b8653fbf | 557 | #if wxUSE_TOOLTIPS |
ec9f7884 VZ |
558 | if (event.GetInt()) |
559 | cb->SetToolTip( "Click to enable listbox" ); | |
560 | else | |
561 | cb->SetToolTip( "Click to disable listbox" ); | |
16f6dfd8 | 562 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
563 | m_listbox->Enable( event.GetInt() == 0 ); |
564 | break; | |
565 | } | |
566 | case ID_LISTBOX_SEL_NUM: | |
567 | { | |
568 | m_listbox->SetSelection( 2 ); | |
85eb36c2 | 569 | m_lbSelectThis->WarpPointer( 40, 14 ); |
ec9f7884 VZ |
570 | break; |
571 | } | |
572 | case ID_LISTBOX_SEL_STR: | |
573 | { | |
574 | m_listbox->SetStringSelection( "This" ); | |
85eb36c2 | 575 | m_lbSelectNum->WarpPointer( 40, 14 ); |
ec9f7884 VZ |
576 | break; |
577 | } | |
578 | case ID_LISTBOX_CLEAR: | |
579 | { | |
580 | m_listbox->Clear(); | |
581 | break; | |
582 | } | |
583 | case ID_LISTBOX_APPEND: | |
584 | { | |
585 | m_listbox->Append( "Hi!" ); | |
586 | break; | |
587 | } | |
588 | case ID_LISTBOX_DELETE: | |
589 | { | |
590 | int idx = m_listbox->GetSelection(); | |
591 | m_listbox->Delete( idx ); | |
592 | break; | |
593 | } | |
594 | case ID_LISTBOX_FONT: | |
595 | { | |
596 | m_listbox->SetFont( *wxITALIC_FONT ); | |
597 | m_checkbox->SetFont( *wxITALIC_FONT ); | |
598 | break; | |
599 | } | |
868a2826 | 600 | } |
47908e25 RR |
601 | } |
602 | ||
603 | void MyPanel::OnChoice( wxCommandEvent &event ) | |
604 | { | |
19da4326 | 605 | m_text->AppendText( "Choice event selection string is: " ); |
ec9f7884 VZ |
606 | m_text->AppendText( event.GetString() ); |
607 | m_text->AppendText( "\n" ); | |
19da4326 RR |
608 | m_text->AppendText( "Choice control selection string is: " ); |
609 | m_text->AppendText( m_choice->GetStringSelection() ); | |
610 | m_text->AppendText( "\n" ); | |
47908e25 RR |
611 | } |
612 | ||
613 | void MyPanel::OnChoiceButtons( wxCommandEvent &event ) | |
614 | { | |
ec9f7884 | 615 | switch (event.GetId()) |
47908e25 | 616 | { |
ec9f7884 VZ |
617 | case ID_CHOICE_ENABLE: |
618 | { | |
619 | m_choice->Enable( event.GetInt() == 0 ); | |
620 | break; | |
621 | } | |
622 | case ID_CHOICE_SEL_NUM: | |
623 | { | |
624 | m_choice->SetSelection( 2 ); | |
625 | break; | |
626 | } | |
627 | case ID_CHOICE_SEL_STR: | |
628 | { | |
629 | m_choice->SetStringSelection( "This" ); | |
630 | break; | |
631 | } | |
632 | case ID_CHOICE_CLEAR: | |
633 | { | |
634 | m_choice->Clear(); | |
635 | break; | |
636 | } | |
637 | case ID_CHOICE_APPEND: | |
638 | { | |
639 | m_choice->Append( "Hi!" ); | |
640 | break; | |
641 | } | |
642 | case ID_CHOICE_DELETE: | |
643 | { | |
644 | int idx = m_choice->GetSelection(); | |
645 | m_choice->Delete( idx ); | |
646 | break; | |
647 | } | |
648 | case ID_CHOICE_FONT: | |
649 | { | |
650 | m_choice->SetFont( *wxITALIC_FONT ); | |
651 | break; | |
652 | } | |
868a2826 | 653 | } |
47908e25 RR |
654 | } |
655 | ||
656 | void MyPanel::OnCombo( wxCommandEvent &event ) | |
657 | { | |
19da4326 | 658 | m_text->AppendText( "ComboBox event selection string is: " ); |
ec9f7884 VZ |
659 | m_text->AppendText( event.GetString() ); |
660 | m_text->AppendText( "\n" ); | |
19da4326 RR |
661 | m_text->AppendText( "ComboBox control selection string is: " ); |
662 | m_text->AppendText( m_combo->GetStringSelection() ); | |
663 | m_text->AppendText( "\n" ); | |
47908e25 RR |
664 | } |
665 | ||
666 | void MyPanel::OnComboButtons( wxCommandEvent &event ) | |
1c005ff7 | 667 | { |
ec9f7884 | 668 | switch (event.GetId()) |
2f6407b9 | 669 | { |
ec9f7884 VZ |
670 | case ID_COMBO_ENABLE: |
671 | { | |
672 | m_combo->Enable( event.GetInt() == 0 ); | |
673 | break; | |
674 | } | |
675 | case ID_COMBO_SEL_NUM: | |
676 | { | |
677 | m_combo->SetSelection( 2 ); | |
678 | break; | |
679 | } | |
680 | case ID_COMBO_SEL_STR: | |
681 | { | |
682 | m_combo->SetStringSelection( "This" ); | |
683 | break; | |
684 | } | |
685 | case ID_COMBO_CLEAR: | |
686 | { | |
687 | m_combo->Clear(); | |
688 | break; | |
689 | } | |
690 | case ID_COMBO_APPEND: | |
691 | { | |
692 | m_combo->Append( "Hi!" ); | |
693 | break; | |
694 | } | |
695 | case ID_COMBO_DELETE: | |
696 | { | |
697 | int idx = m_combo->GetSelection(); | |
698 | m_combo->Delete( idx ); | |
699 | break; | |
700 | } | |
701 | case ID_COMBO_FONT: | |
702 | { | |
703 | m_combo->SetFont( *wxITALIC_FONT ); | |
704 | break; | |
705 | } | |
868a2826 | 706 | } |
47908e25 RR |
707 | } |
708 | ||
709 | void MyPanel::OnRadio( wxCommandEvent &event ) | |
710 | { | |
ec9f7884 VZ |
711 | m_text->AppendText( "RadioBox selection string is: " ); |
712 | m_text->AppendText( event.GetString() ); | |
713 | m_text->AppendText( "\n" ); | |
47908e25 RR |
714 | } |
715 | ||
716 | void MyPanel::OnRadioButtons( wxCommandEvent &event ) | |
717 | { | |
ec9f7884 | 718 | switch (event.GetId()) |
d3904ceb | 719 | { |
ec9f7884 VZ |
720 | case ID_RADIOBOX_ENABLE: |
721 | { | |
722 | m_radio->Enable( event.GetInt() == 0 ); | |
723 | break; | |
724 | } | |
725 | case ID_RADIOBOX_SEL_NUM: | |
726 | { | |
727 | m_radio->SetSelection( 2 ); | |
728 | break; | |
729 | } | |
730 | case ID_RADIOBOX_SEL_STR: | |
731 | { | |
732 | m_radio->SetStringSelection( "This" ); | |
733 | break; | |
734 | } | |
735 | case ID_RADIOBOX_FONT: | |
736 | { | |
737 | m_radio->SetFont( *wxITALIC_FONT ); | |
738 | break; | |
739 | } | |
868a2826 | 740 | } |
1c005ff7 RR |
741 | } |
742 | ||
868a2826 RR |
743 | void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) ) |
744 | { | |
ec9f7884 VZ |
745 | m_fontButton->SetFont( *wxITALIC_FONT ); |
746 | m_text->SetFont( *wxITALIC_FONT ); | |
868a2826 RR |
747 | } |
748 | ||
7bce6aec RR |
749 | void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) |
750 | { | |
ec9f7884 | 751 | m_gauge->SetValue( m_slider->GetValue() ); |
7bce6aec RR |
752 | } |
753 | ||
9726da4f | 754 | #ifndef wxUSE_SPINBUTTON |
e380f72b RR |
755 | void MyPanel::OnSpinUpdate( wxSpinEvent &event ) |
756 | { | |
ec9f7884 | 757 | wxString value; |
f70d5829 | 758 | value.Printf( _T("%d"), event.GetPosition() ); |
ec9f7884 | 759 | m_spintext->SetValue( value ); |
6380910c | 760 | |
f70d5829 | 761 | value.Printf( _T("Spin control range: (%d, %d), current = %d\n"), |
6380910c VZ |
762 | m_spinbutton->GetMin(), m_spinbutton->GetMax(), |
763 | m_spinbutton->GetValue()); | |
764 | ||
765 | m_text->AppendText(value); | |
e380f72b | 766 | } |
9726da4f VZ |
767 | |
768 | void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event ) | |
769 | { | |
770 | event.Enable( m_spinbutton->GetValue() > 0 ); | |
771 | } | |
772 | ||
773 | void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) | |
774 | { | |
775 | int max = m_spinbutton->GetValue(); | |
776 | wxProgressDialog dialog("Progress dialog example", | |
777 | "An informative message", | |
778 | max, // range | |
779 | this, // parent | |
40885923 | 780 | wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME); |
2ac1b69a | 781 | |
9726da4f VZ |
782 | |
783 | bool cont = TRUE; | |
784 | for ( int i = 0; i < max && cont; i++ ) | |
785 | { | |
786 | wxSleep(1); | |
be9abe3f VZ |
787 | if ( i == max - 1 ) |
788 | { | |
789 | cont = dialog.Update(i, "That's all, folks!"); | |
790 | } | |
791 | else if ( i == max / 2 ) | |
9726da4f VZ |
792 | { |
793 | cont = dialog.Update(i, "Only a half left!"); | |
794 | } | |
795 | else | |
796 | { | |
797 | cont = dialog.Update(i); | |
798 | } | |
799 | } | |
800 | ||
801 | if ( !cont ) | |
802 | { | |
803 | *m_text << "Progress dialog aborted!\n"; | |
804 | } | |
805 | else | |
806 | { | |
807 | *m_text << "Countdown from " << max << " finished.\n"; | |
808 | } | |
809 | } | |
810 | ||
811 | #endif // wxUSE_SPINBUTTON | |
e380f72b | 812 | |
2cb21a45 VZ |
813 | MyPanel::~MyPanel() |
814 | { | |
ec9f7884 | 815 | delete m_notebook->GetImageList(); |
2cb21a45 VZ |
816 | } |
817 | ||
1c005ff7 RR |
818 | //---------------------------------------------------------------------- |
819 | // MyFrame | |
820 | //---------------------------------------------------------------------- | |
821 | ||
822 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
ec9f7884 VZ |
823 | EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit) |
824 | EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout) | |
16f6dfd8 | 825 | #if wxUSE_TOOLTIPS |
ec9f7884 VZ |
826 | EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay) |
827 | EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips) | |
16f6dfd8 | 828 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
829 | EVT_SIZE(MyFrame::OnSize) |
830 | EVT_IDLE(MyFrame::OnIdle) | |
1c005ff7 RR |
831 | END_EVENT_TABLE() |
832 | ||
9f3362c4 | 833 | MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h) |
ec9f7884 | 834 | : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) |
1c005ff7 | 835 | { |
5fb9fcfc | 836 | CreateStatusBar(2); |
9f3362c4 VZ |
837 | |
838 | (void)new MyPanel( this, 10, 10, 300, 100 ); | |
1c005ff7 RR |
839 | } |
840 | ||
841 | void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) | |
842 | { | |
ec9f7884 | 843 | Close(TRUE); |
1c005ff7 RR |
844 | } |
845 | ||
846 | void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
847 | { | |
ec9f7884 VZ |
848 | wxBeginBusyCursor(); |
849 | ||
850 | wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK ); | |
851 | dialog.ShowModal(); | |
852 | ||
853 | wxEndBusyCursor(); | |
1c005ff7 | 854 | } |
9f3362c4 | 855 | |
16f6dfd8 VZ |
856 | #if wxUSE_TOOLTIPS |
857 | void MyFrame::OnSetTooltipDelay(wxCommandEvent& event) | |
858 | { | |
859 | static long s_delay = 5000; | |
860 | ||
861 | wxString delay; | |
f70d5829 | 862 | delay.Printf( _T("%ld"), s_delay); |
16f6dfd8 VZ |
863 | |
864 | delay = wxGetTextFromUser("Enter delay (in milliseconds)", | |
ec9f7884 VZ |
865 | "Set tooltip delay", |
866 | delay, | |
867 | this); | |
16f6dfd8 VZ |
868 | if ( !delay ) |
869 | return; // cancelled | |
870 | ||
f70d5829 | 871 | wxSscanf(delay, _T("%ld"), &s_delay); |
16f6dfd8 VZ |
872 | |
873 | wxToolTip::SetDelay(s_delay); | |
874 | ||
f70d5829 | 875 | wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay); |
16f6dfd8 VZ |
876 | } |
877 | ||
878 | void MyFrame::OnToggleTooltips(wxCommandEvent& event) | |
879 | { | |
880 | static bool s_enabled = TRUE; | |
881 | ||
882 | s_enabled = !s_enabled; | |
883 | ||
884 | wxToolTip::Enable(s_enabled); | |
885 | ||
f70d5829 | 886 | wxLogStatus(this, _T("Tooltips %sabled"), s_enabled ? _T("en") : _T("dis") ); |
16f6dfd8 VZ |
887 | } |
888 | #endif // tooltips | |
889 | ||
5fb9fcfc VZ |
890 | void MyFrame::OnSize( wxSizeEvent& event ) |
891 | { | |
892 | wxString msg; | |
f70d5829 | 893 | msg.Printf( _("%dx%d"), event.GetSize().x, event.GetSize().y); |
5fb9fcfc VZ |
894 | SetStatusText(msg, 1); |
895 | ||
896 | event.Skip(); | |
897 | } | |
898 | ||
9f3362c4 VZ |
899 | void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) |
900 | { | |
901 | // track the window which has the focus in the status bar | |
902 | static wxWindow *s_windowFocus = (wxWindow *)NULL; | |
903 | wxWindow *focus = wxWindow::FindFocus(); | |
904 | if ( focus && (focus != s_windowFocus) ) | |
905 | { | |
906 | s_windowFocus = focus; | |
907 | ||
908 | wxString msg; | |
f70d5829 | 909 | msg.Printf( |
9f3362c4 | 910 | #ifdef __WXMSW__ |
f70d5829 RR |
911 | _T("Focus: wxWindow = %p, HWND = %08x"), |
912 | #else | |
913 | _T("Focus: wxWindow = %p"), | |
914 | #endif | |
915 | s_windowFocus | |
9f3362c4 | 916 | #ifdef __WXMSW__ |
ec9f7884 | 917 | , s_windowFocus->GetHWND() |
f70d5829 | 918 | #endif |
9f3362c4 VZ |
919 | ); |
920 | ||
921 | SetStatusText(msg); | |
922 | } | |
341c92a8 | 923 | } |