]>
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" |
655822f3 | 29 | #include "wx/spinbutt.h" |
b8653fbf VZ |
30 | |
31 | #if wxUSE_CLIPBOARD | |
32 | #include "wx/dataobj.h" | |
33 | #include "wx/clipbrd.h" | |
34 | #endif | |
35 | ||
36 | #if wxUSE_TOOLTIPS | |
37 | #include "wx/tooltip.h" | |
38 | #endif | |
1c005ff7 | 39 | |
4b5f3fe6 | 40 | #if defined(__WXGTK__) || defined(__WXMOTIF__) |
73c700fd | 41 | #define USE_XPM |
4fabb575 JS |
42 | #endif |
43 | ||
44 | #ifdef USE_XPM | |
73c700fd VZ |
45 | #include "mondrian.xpm" |
46 | #include "icons/choice.xpm" | |
47 | #include "icons/combo.xpm" | |
48 | #include "icons/list.xpm" | |
49 | #include "icons/radio.xpm" | |
50 | #include "icons/text.xpm" | |
51 | #include "icons/gauge.xpm" | |
47908e25 RR |
52 | #endif |
53 | ||
1c005ff7 RR |
54 | //---------------------------------------------------------------------- |
55 | // class definitions | |
56 | //---------------------------------------------------------------------- | |
57 | ||
58 | class MyApp: public wxApp | |
655822f3 | 59 | { |
b8653fbf VZ |
60 | public: |
61 | bool OnInit(); | |
1c005ff7 RR |
62 | }; |
63 | ||
6085b116 VZ |
64 | // a text ctrl which allows to call different wxTextCtrl functions |
65 | // interactively by pressing function keys in it | |
66 | class MyTextCtrl : public wxTextCtrl | |
67 | { | |
68 | public: | |
69 | MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value, | |
70 | const wxPoint &pos, const wxSize &size, int style = 0) | |
71 | : wxTextCtrl(parent, id, value, pos, size, style) { } | |
72 | ||
5fb9fcfc | 73 | void OnKeyDown(wxKeyEvent& event); |
6085b116 VZ |
74 | |
75 | private: | |
76 | DECLARE_EVENT_TABLE() | |
77 | }; | |
78 | ||
1c005ff7 RR |
79 | class MyPanel: public wxPanel |
80 | { | |
b8653fbf | 81 | public: |
1c005ff7 | 82 | MyPanel(wxFrame *frame, int x, int y, int w, int h); |
2cb21a45 | 83 | virtual ~MyPanel(); |
16f6dfd8 | 84 | |
1c005ff7 RR |
85 | void OnSize( wxSizeEvent& event ); |
86 | void OnListBox( wxCommandEvent &event ); | |
5b077d48 | 87 | void OnListBoxDoubleClick( wxCommandEvent &event ); |
1c005ff7 | 88 | void OnListBoxButtons( wxCommandEvent &event ); |
47908e25 RR |
89 | void OnChoice( wxCommandEvent &event ); |
90 | void OnChoiceButtons( wxCommandEvent &event ); | |
91 | void OnCombo( wxCommandEvent &event ); | |
92 | void OnComboButtons( wxCommandEvent &event ); | |
93 | void OnRadio( wxCommandEvent &event ); | |
94 | void OnRadioButtons( wxCommandEvent &event ); | |
868a2826 | 95 | void OnSetFont( wxCommandEvent &event ); |
cb43b372 | 96 | void OnPageChanged( wxNotebookEvent &event ); |
7bce6aec | 97 | void OnSliderUpdate( wxCommandEvent &event ); |
2a47d3c1 | 98 | #ifndef __WIN16__ |
e380f72b | 99 | void OnSpinUpdate( wxSpinEvent &event ); |
2a47d3c1 | 100 | #endif |
b527aac5 RR |
101 | void OnPasteFromClipboard( wxCommandEvent &event ); |
102 | void OnCopyToClipboard( wxCommandEvent &event ); | |
d59051dd VZ |
103 | void OnMoveToEndOfText( wxCommandEvent &event ); |
104 | void OnMoveToEndOfEntry( wxCommandEvent &event ); | |
16f6dfd8 | 105 | |
e380f72b RR |
106 | wxListBox *m_listbox; |
107 | wxChoice *m_choice; | |
108 | wxComboBox *m_combo; | |
109 | wxRadioBox *m_radio; | |
110 | wxGauge *m_gauge; | |
111 | wxSlider *m_slider; | |
112 | wxButton *m_fontButton; | |
2a47d3c1 | 113 | #ifndef __WIN16__ |
e380f72b | 114 | wxSpinButton *m_spinbutton; |
2a47d3c1 | 115 | #endif |
e380f72b | 116 | wxTextCtrl *m_spintext; |
6085b116 VZ |
117 | MyTextCtrl *m_multitext; |
118 | MyTextCtrl *m_textentry; | |
ae0bdb01 | 119 | wxCheckBox *m_checkbox; |
16f6dfd8 | 120 | |
e380f72b | 121 | wxTextCtrl *m_text; |
655822f3 VZ |
122 | wxNotebook *m_notebook; |
123 | ||
b8653fbf VZ |
124 | private: |
125 | DECLARE_EVENT_TABLE() | |
1c005ff7 RR |
126 | }; |
127 | ||
128 | class MyFrame: public wxFrame | |
129 | { | |
b8653fbf | 130 | public: |
1c005ff7 | 131 | MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h); |
655822f3 | 132 | |
1c005ff7 RR |
133 | void OnQuit(wxCommandEvent& event); |
134 | void OnAbout(wxCommandEvent& event); | |
16f6dfd8 VZ |
135 | #if wxUSE_TOOLTIPS |
136 | void OnSetTooltipDelay(wxCommandEvent& event); | |
137 | void OnToggleTooltips(wxCommandEvent& event); | |
138 | #endif // wxUSE_TOOLTIPS | |
9f3362c4 | 139 | void OnIdle( wxIdleEvent& event ); |
5fb9fcfc | 140 | void OnSize( wxSizeEvent& event ); |
655822f3 | 141 | |
b8653fbf VZ |
142 | private: |
143 | DECLARE_EVENT_TABLE() | |
1c005ff7 RR |
144 | }; |
145 | ||
146 | //---------------------------------------------------------------------- | |
147 | // main() | |
148 | //---------------------------------------------------------------------- | |
149 | ||
d59051dd | 150 | IMPLEMENT_APP(MyApp) |
1c005ff7 RR |
151 | |
152 | //---------------------------------------------------------------------- | |
153 | // MyApp | |
154 | //---------------------------------------------------------------------- | |
155 | ||
16f6dfd8 VZ |
156 | enum |
157 | { | |
158 | MINIMAL_QUIT = 100, | |
159 | MINIMAL_TEXT, | |
160 | MINIMAL_ABOUT, | |
161 | ||
162 | // tooltip menu | |
163 | MINIMAL_SET_TOOLTIP_DELAY = 200, | |
164 | MINIMAL_ENABLE_TOOLTIPS | |
165 | }; | |
1c005ff7 | 166 | |
b8653fbf | 167 | bool MyApp::OnInit() |
1c005ff7 | 168 | { |
ec9f7884 VZ |
169 | // Create the main frame window |
170 | MyFrame *frame = new MyFrame((wxFrame *) NULL, | |
171 | "Controls wxWindows App", | |
172 | 50, 50, 530, 420); | |
655822f3 | 173 | |
ec9f7884 VZ |
174 | // Give it an icon |
175 | // The wxICON() macros loads an icon from a resource under Windows | |
176 | // and uses an #included XPM image under GTK+ and Motif | |
655822f3 | 177 | |
ec9f7884 | 178 | frame->SetIcon( wxICON(mondrian) ); |
1c005ff7 | 179 | |
ec9f7884 VZ |
180 | wxMenu *file_menu = new wxMenu; |
181 | file_menu->Append(MINIMAL_ABOUT, "&About"); | |
182 | file_menu->Append(MINIMAL_QUIT, "E&xit"); | |
16f6dfd8 | 183 | |
ec9f7884 VZ |
184 | wxMenuBar *menu_bar = new wxMenuBar; |
185 | menu_bar->Append(file_menu, "&File"); | |
16f6dfd8 VZ |
186 | |
187 | #if wxUSE_TOOLTIPS | |
ec9f7884 VZ |
188 | wxMenu *tooltip_menu = new wxMenu; |
189 | tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay"); | |
190 | tooltip_menu->AppendSeparator(); | |
191 | tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips", | |
192 | "enable/disable tooltips", TRUE); | |
193 | tooltip_menu->Check(MINIMAL_ENABLE_TOOLTIPS, TRUE); | |
194 | menu_bar->Append(tooltip_menu, "&Tooltips"); | |
16f6dfd8 VZ |
195 | #endif // wxUSE_TOOLTIPS |
196 | ||
ec9f7884 | 197 | frame->SetMenuBar(menu_bar); |
1c005ff7 | 198 | |
ec9f7884 | 199 | frame->Show(TRUE); |
9018abe3 | 200 | frame->SetCursor(wxCursor(wxCURSOR_HAND)); |
655822f3 | 201 | |
ec9f7884 | 202 | SetTopWindow(frame); |
1c005ff7 | 203 | |
ec9f7884 | 204 | return TRUE; |
1c005ff7 RR |
205 | } |
206 | ||
6085b116 VZ |
207 | //---------------------------------------------------------------------- |
208 | // MyTextCtrl | |
209 | //---------------------------------------------------------------------- | |
210 | ||
211 | BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl) | |
ec9f7884 | 212 | EVT_KEY_DOWN(MyTextCtrl::OnKeyDown) |
6085b116 VZ |
213 | END_EVENT_TABLE() |
214 | ||
5fb9fcfc | 215 | void MyTextCtrl::OnKeyDown(wxKeyEvent& event) |
6085b116 VZ |
216 | { |
217 | switch ( event.KeyCode() ) | |
218 | { | |
219 | case WXK_F1: | |
220 | // show current position and text length | |
221 | { | |
222 | long line, column, pos = GetInsertionPoint(); | |
223 | PositionToXY(pos, &column, &line); | |
224 | ||
225 | wxLogMessage("Current position: %ld\n" | |
ec9f7884 VZ |
226 | "Current line, column: (%ld, %ld)\n" |
227 | "Number of lines: %ld\n" | |
228 | "Current line length: %ld\n" | |
229 | "Total text length: %ld", | |
230 | pos, | |
231 | line, column, | |
232 | GetNumberOfLines(), | |
233 | GetLineLength(line), | |
234 | GetLastPosition()); | |
6085b116 VZ |
235 | } |
236 | break; | |
237 | ||
238 | case WXK_F2: | |
239 | // go to the end | |
240 | SetInsertionPointEnd(); | |
241 | break; | |
242 | ||
243 | case WXK_F3: | |
244 | // go to position 10 | |
245 | SetInsertionPoint(10); | |
246 | break; | |
247 | ||
248 | default: | |
249 | event.Skip(); | |
250 | } | |
251 | } | |
252 | ||
1c005ff7 RR |
253 | //---------------------------------------------------------------------- |
254 | // MyPanel | |
255 | //---------------------------------------------------------------------- | |
256 | ||
4fabb575 | 257 | const int ID_NOTEBOOK = 1000; |
1c005ff7 | 258 | |
4fabb575 JS |
259 | const int ID_LISTBOX = 130; |
260 | const int ID_LISTBOX_SEL_NUM = 131; | |
261 | const int ID_LISTBOX_SEL_STR = 132; | |
262 | const int ID_LISTBOX_CLEAR = 133; | |
263 | const int ID_LISTBOX_APPEND = 134; | |
264 | const int ID_LISTBOX_DELETE = 135; | |
265 | const int ID_LISTBOX_FONT = 136; | |
266 | const int ID_LISTBOX_ENABLE = 137; | |
1c005ff7 | 267 | |
4fabb575 JS |
268 | const int ID_CHOICE = 120; |
269 | const int ID_CHOICE_SEL_NUM = 121; | |
270 | const int ID_CHOICE_SEL_STR = 122; | |
271 | const int ID_CHOICE_CLEAR = 123; | |
272 | const int ID_CHOICE_APPEND = 124; | |
273 | const int ID_CHOICE_DELETE = 125; | |
274 | const int ID_CHOICE_FONT = 126; | |
275 | const int ID_CHOICE_ENABLE = 127; | |
53010e52 | 276 | |
4fabb575 JS |
277 | const int ID_COMBO = 140; |
278 | const int ID_COMBO_SEL_NUM = 141; | |
279 | const int ID_COMBO_SEL_STR = 142; | |
280 | const int ID_COMBO_CLEAR = 143; | |
281 | const int ID_COMBO_APPEND = 144; | |
282 | const int ID_COMBO_DELETE = 145; | |
283 | const int ID_COMBO_FONT = 146; | |
284 | const int ID_COMBO_ENABLE = 147; | |
53010e52 | 285 | |
4fabb575 | 286 | const int ID_TEXT = 150; |
b527aac5 RR |
287 | const int ID_PASTE_TEXT = 151; |
288 | const int ID_COPY_TEXT = 152; | |
d59051dd VZ |
289 | const int ID_MOVE_END_ENTRY = 153; |
290 | const int ID_MOVE_END_ZONE = 154; | |
219f895a | 291 | |
4fabb575 JS |
292 | const int ID_RADIOBOX = 160; |
293 | const int ID_RADIOBOX_SEL_NUM = 161; | |
294 | const int ID_RADIOBOX_SEL_STR = 162; | |
295 | const int ID_RADIOBOX_FONT = 163; | |
296 | const int ID_RADIOBOX_ENABLE = 164; | |
868a2826 | 297 | |
f5d29b39 RR |
298 | const int ID_RADIOBUTTON_1 = 166; |
299 | const int ID_RADIOBUTTON_2 = 167; | |
300 | ||
4fabb575 | 301 | const int ID_SET_FONT = 170; |
47908e25 | 302 | |
4fabb575 JS |
303 | const int ID_GAUGE = 180; |
304 | const int ID_SLIDER = 181; | |
58614078 | 305 | |
4fabb575 | 306 | const int ID_SPIN = 182; |
e380f72b | 307 | |
1c005ff7 | 308 | BEGIN_EVENT_TABLE(MyPanel, wxPanel) |
ec9f7884 VZ |
309 | EVT_SIZE ( MyPanel::OnSize) |
310 | EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyPanel::OnPageChanged) | |
311 | EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) | |
312 | EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick) | |
313 | EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyPanel::OnListBoxButtons) | |
314 | EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons) | |
315 | EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) | |
316 | EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) | |
317 | EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons) | |
318 | EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons) | |
319 | EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons) | |
320 | EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice) | |
321 | EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons) | |
322 | EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons) | |
323 | EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons) | |
324 | EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons) | |
325 | EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons) | |
326 | EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons) | |
327 | EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons) | |
328 | EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo) | |
329 | EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) | |
330 | EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) | |
331 | EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) | |
332 | EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons) | |
333 | EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons) | |
334 | EVT_BUTTON (ID_COMBO_FONT, MyPanel::OnComboButtons) | |
335 | EVT_CHECKBOX (ID_COMBO_ENABLE, MyPanel::OnComboButtons) | |
336 | EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio) | |
337 | EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons) | |
338 | EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons) | |
339 | EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons) | |
340 | EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons) | |
341 | EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont) | |
342 | EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate) | |
2a47d3c1 | 343 | #ifndef __WIN16__ |
ec9f7884 | 344 | EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate) |
2a47d3c1 | 345 | #endif |
ec9f7884 VZ |
346 | EVT_BUTTON (ID_PASTE_TEXT, MyPanel::OnPasteFromClipboard) |
347 | EVT_BUTTON (ID_COPY_TEXT, MyPanel::OnCopyToClipboard) | |
348 | EVT_BUTTON (ID_MOVE_END_ZONE, MyPanel::OnMoveToEndOfText) | |
349 | EVT_BUTTON (ID_MOVE_END_ENTRY, MyPanel::OnMoveToEndOfEntry) | |
1c005ff7 RR |
350 | END_EVENT_TABLE() |
351 | ||
5fb9fcfc | 352 | MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) |
ec9f7884 VZ |
353 | : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), |
354 | m_text(NULL), m_notebook(NULL) | |
1c005ff7 | 355 | { |
ec9f7884 | 356 | // SetBackgroundColour("cadet blue"); |
a81258be | 357 | |
ec9f7884 VZ |
358 | m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); |
359 | // m_text->SetBackgroundColour("wheat"); | |
655822f3 | 360 | |
ec9f7884 | 361 | m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) ); |
655822f3 | 362 | |
ec9f7884 VZ |
363 | wxString choices[] = |
364 | { | |
365 | "This", | |
366 | "is one of my", | |
367 | "really", | |
368 | "wonderful", | |
369 | "examples." | |
370 | }; | |
655822f3 | 371 | |
4fabb575 | 372 | #ifdef USE_XPM |
ec9f7884 VZ |
373 | // image ids |
374 | enum | |
375 | { | |
376 | Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max | |
377 | }; | |
378 | ||
379 | // fill the image list | |
380 | wxImageList *imagelist = new wxImageList(32, 32); | |
381 | ||
382 | imagelist-> Add( wxBitmap( list_xpm )); | |
383 | imagelist-> Add( wxBitmap( choice_xpm )); | |
384 | imagelist-> Add( wxBitmap( combo_xpm )); | |
385 | imagelist-> Add( wxBitmap( text_xpm )); | |
386 | imagelist-> Add( wxBitmap( radio_xpm )); | |
387 | imagelist-> Add( wxBitmap( gauge_xpm )); | |
388 | m_notebook->SetImageList(imagelist); | |
73c700fd | 389 | #elif defined(__WXMSW__) |
ec9f7884 VZ |
390 | // load images from resources |
391 | enum | |
392 | { | |
393 | Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max | |
394 | }; | |
395 | wxImageList *imagelist = new wxImageList(16, 16, FALSE, Image_Max); | |
396 | ||
397 | static const char *s_iconNames[Image_Max] = | |
398 | { | |
399 | "list", "choice", "combo", "text", "radio", "gauge" | |
400 | }; | |
401 | ||
402 | for ( size_t n = 0; n < Image_Max; n++ ) | |
403 | { | |
404 | wxBitmap bmp(s_iconNames[n]); | |
405 | if ( !bmp.Ok() || (imagelist->Add(bmp) == -1) ) | |
406 | { | |
407 | wxLogWarning("Couldn't load the image '%s' for the notebook page %d.", | |
408 | s_iconNames[n], n); | |
409 | } | |
410 | } | |
411 | ||
412 | m_notebook->SetImageList(imagelist); | |
4fabb575 JS |
413 | #else |
414 | ||
ec9f7884 | 415 | // No images for now |
4fabb575 JS |
416 | #define Image_List -1 |
417 | #define Image_Choice -1 | |
418 | #define Image_Combo -1 | |
419 | #define Image_Text -1 | |
420 | #define Image_Radio -1 | |
421 | #define Image_Gauge -1 | |
422 | #define Image_Max -1 | |
423 | ||
fc54776e | 424 | #endif |
2cb21a45 | 425 | |
ec9f7884 VZ |
426 | wxButton *button = (wxButton*) NULL; /* who did this ? */ |
427 | wxPanel *panel = (wxPanel*) NULL; | |
9838df2c | 428 | |
ec9f7884 VZ |
429 | panel = new wxPanel(m_notebook); |
430 | m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices ); | |
431 | m_listbox->SetCursor(*wxCROSS_CURSOR); | |
b8653fbf | 432 | #if wxUSE_TOOLTIPS |
ec9f7884 | 433 | m_listbox->SetToolTip( "This is a list box" ); |
16f6dfd8 | 434 | #endif // wxUSE_TOOLTIPS |
9f3362c4 | 435 | |
ec9f7884 VZ |
436 | (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
437 | (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
438 | (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); | |
439 | (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
440 | (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
441 | button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); | |
b8653fbf | 442 | #if wxUSE_TOOLTIPS |
ec9f7884 | 443 | button->SetToolTip( "Press here to set italic font" ); |
16f6dfd8 | 444 | #endif // wxUSE_TOOLTIPS |
b1170810 | 445 | |
ec9f7884 VZ |
446 | m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); |
447 | m_checkbox->SetValue(FALSE); | |
b8653fbf | 448 | #if wxUSE_TOOLTIPS |
ec9f7884 | 449 | m_checkbox->SetToolTip( "Click here to disable the listbox" ); |
16f6dfd8 | 450 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
451 | m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List); |
452 | ||
453 | panel = new wxPanel(m_notebook); | |
454 | m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices ); | |
455 | (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); | |
456 | (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
457 | (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); | |
458 | (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
459 | (void)new wxButton( panel, ID_CHOICE_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
460 | (void)new wxButton( panel, ID_CHOICE_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); | |
461 | (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); | |
462 | m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); | |
463 | ||
464 | panel = new wxPanel(m_notebook); | |
465 | m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices ); | |
466 | (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); | |
467 | (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); | |
468 | (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); | |
469 | (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); | |
470 | (void)new wxButton( panel, ID_COMBO_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); | |
471 | (void)new wxButton( panel, ID_COMBO_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); | |
472 | (void)new wxCheckBox( panel, ID_COMBO_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); | |
473 | m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo); | |
474 | ||
475 | panel = new wxPanel(m_notebook); | |
476 | m_textentry = new MyTextCtrl( panel, -1, "Some text.", wxPoint(10,10), wxSize(320,28), //0); | |
477 | wxTE_PROCESS_ENTER); | |
478 | (*m_textentry) << " Appended."; | |
479 | m_textentry->SetInsertionPoint(0); | |
480 | m_textentry->WriteText( "Prepended. " ); | |
481 | ||
482 | m_multitext = new MyTextCtrl( panel, ID_TEXT, "Some text.", wxPoint(10,50), wxSize(320,70), wxTE_MULTILINE ); | |
483 | (*m_multitext) << " Appended."; | |
484 | m_multitext->SetInsertionPoint(0); | |
485 | m_multitext->WriteText( "Prepended. " ); | |
486 | m_multitext->AppendText( "\nPress function keys to test different wxTextCtrl functions." ); | |
487 | ||
488 | (*m_multitext) << "\nDoes it have cross cursor?"; | |
489 | m_multitext->SetCursor(*wxCROSS_CURSOR); | |
490 | ||
491 | new MyTextCtrl( panel, -1, "This one is with wxTE_PROCESS_TAB style.", wxPoint(10,120), wxSize(320,70), wxTE_MULTILINE | wxTE_PROCESS_TAB); | |
16f6dfd8 | 492 | #if wxUSE_TOOLTIPS |
ec9f7884 VZ |
493 | m_multitext->AppendText( "\nThis ctrl has a tooltip. " ); |
494 | m_multitext->SetToolTip("Press F1 here."); | |
16f6dfd8 | 495 | #endif // wxUSE_TOOLTIPS |
9f3362c4 | 496 | |
ec9f7884 VZ |
497 | (void)new wxStaticBox( panel, -1, "&Move cursor to the end of:", wxPoint(345, 0), wxSize(160, 100) ); |
498 | (void)new wxButton( panel, ID_MOVE_END_ENTRY, "Text &entry", wxPoint(370, 20), wxSize(110, 30) ); | |
499 | (void)new wxButton( panel, ID_MOVE_END_ZONE, "Text &zone", wxPoint(370, 60), wxSize(110, 30) ); | |
500 | (void)new wxStaticBox( panel, -1, "wx&Clipboard", wxPoint(345,100), wxSize(160,100) ); | |
501 | (void)new wxButton( panel, ID_COPY_TEXT, "C&opy line 1", wxPoint(370,120), wxSize(110,30) ); | |
502 | (void)new wxButton( panel, ID_PASTE_TEXT, "&Paste text", wxPoint(370,160), wxSize(110,30) ); | |
503 | m_notebook->AddPage( panel, "wxTextCtrl" , FALSE, Image_Text ); | |
504 | ||
505 | wxString choices2[] = | |
506 | { | |
9018abe3 VZ |
507 | "First", "Second", "Third", |
508 | "Fourth", "Fifth", //"Sixth", | |
509 | //"Seventh", "Eighth", "Nineth", "Tenth" | |
ec9f7884 VZ |
510 | }; |
511 | ||
512 | panel = new wxPanel(m_notebook); | |
9018abe3 VZ |
513 | (void)new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS ); |
514 | m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS ); | |
ec9f7884 VZ |
515 | (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); |
516 | (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) ); | |
517 | m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(140,30) ); | |
518 | (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(340,80), wxSize(140,30) ); | |
519 | (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "Disable", wxPoint(340,130), wxSize(140,30) ); | |
520 | wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, "Radiobutton1", wxPoint(210,170), wxSize(110,30) ); | |
521 | rb->SetValue( FALSE ); | |
522 | (void)new wxRadioButton( panel, ID_RADIOBUTTON_2, "Radiobutton2", wxPoint(340,170), wxSize(110,30) ); | |
523 | m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio); | |
524 | ||
525 | panel = new wxPanel(m_notebook); | |
526 | (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) ); | |
527 | m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155, 30) ); | |
528 | m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) ); | |
529 | (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) ); | |
9838df2c | 530 | #ifdef __WXMOTIF__ |
ec9f7884 VZ |
531 | // No wrapping text in wxStaticText yet :-( |
532 | (void)new wxStaticText( panel, -1, | |
533 | "Drag the slider!", | |
534 | wxPoint(208,30), | |
535 | wxSize(210, -1) | |
536 | ); | |
9838df2c | 537 | #else |
ec9f7884 VZ |
538 | (void)new wxStaticText( panel, -1, |
539 | "In order see the gauge (aka progress bar)\n" | |
540 | "control do something you have to drag the\n" | |
541 | "handle of the slider to the right.\n" | |
542 | "\n" | |
543 | "This is also supposed to demonstrate how\n" | |
544 | "to use static controls.\n", | |
545 | wxPoint(208,25), | |
546 | wxSize(250, 110) | |
547 | ); | |
9838df2c | 548 | #endif |
ec9f7884 | 549 | m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) ); |
2a47d3c1 | 550 | #ifndef __WIN16__ |
ec9f7884 | 551 | m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) ); |
6380910c VZ |
552 | m_spinbutton->SetRange(-10,30); |
553 | m_spinbutton->SetValue(-5); | |
2a47d3c1 | 554 | #endif |
ec9f7884 | 555 | m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge); |
1c005ff7 RR |
556 | } |
557 | ||
b527aac5 RR |
558 | void MyPanel::OnPasteFromClipboard( wxCommandEvent &WXUNUSED(event) ) |
559 | { | |
ec9f7884 VZ |
560 | // We test for wxUSE_DRAG_AND_DROP also, because data objects |
561 | // may not be implemented for compilers that can't cope with the OLE | |
562 | // parts in wxUSE_DRAG_AND_DROP. | |
8e0080ee JS |
563 | |
564 | #if wxUSE_CLIPBOARD && wxUSE_DRAG_AND_DROP | |
ec9f7884 VZ |
565 | if (!wxTheClipboard->Open()) |
566 | { | |
567 | *m_text << "Error opening the clipboard.\n"; | |
568 | ||
569 | return; | |
570 | } | |
571 | else | |
572 | { | |
573 | *m_text << "Successfully opened the clipboard.\n"; | |
574 | } | |
575 | ||
576 | wxTextDataObject data; | |
577 | ||
578 | if (wxTheClipboard->IsSupported( data.GetFormat() )) | |
579 | { | |
580 | *m_text << "Clipboard supports requested format.\n"; | |
581 | ||
582 | if (wxTheClipboard->GetData( &data )) | |
583 | { | |
584 | *m_text << "Successfully retrieved data from the clipboard.\n"; | |
585 | *m_multitext << data.GetText() << "\n"; | |
586 | } | |
587 | else | |
588 | { | |
589 | *m_text << "Error getting data from the clipboard.\n"; | |
590 | } | |
591 | } | |
592 | else | |
593 | { | |
594 | *m_text << "Clipboard doesn't support requested format.\n"; | |
595 | } | |
596 | ||
597 | wxTheClipboard->Close(); | |
598 | ||
599 | *m_text << "Closed the clipboard.\n"; | |
341c92a8 | 600 | #else |
ec9f7884 | 601 | wxLogError("Your version of wxWindows is compiled without clipboard support."); |
b527aac5 RR |
602 | #endif |
603 | } | |
604 | ||
605 | void MyPanel::OnCopyToClipboard( wxCommandEvent &WXUNUSED(event) ) | |
606 | { | |
8e0080ee | 607 | #if wxUSE_CLIPBOARD && wxUSE_DRAG_AND_DROP |
ec9f7884 | 608 | wxString text( m_multitext->GetLineText(0) ); |
3069ac4e | 609 | |
ec9f7884 VZ |
610 | if (text.IsEmpty()) |
611 | { | |
612 | *m_text << "No text to copy.\n"; | |
b8653fbf | 613 | |
ec9f7884 VZ |
614 | return; |
615 | } | |
655822f3 | 616 | |
ec9f7884 VZ |
617 | if (!wxTheClipboard->Open()) |
618 | { | |
619 | *m_text << "Error opening the clipboard.\n"; | |
655822f3 | 620 | |
ec9f7884 VZ |
621 | return; |
622 | } | |
623 | else | |
624 | { | |
625 | *m_text << "Successfully opened the clipboard.\n"; | |
626 | } | |
3069ac4e | 627 | |
ec9f7884 | 628 | wxTextDataObject *data = new wxTextDataObject( text ); |
0d2a2b60 | 629 | |
ec9f7884 VZ |
630 | if (!wxTheClipboard->SetData( data )) |
631 | { | |
632 | *m_text << "Error while copying to the clipboard.\n"; | |
633 | } | |
634 | else | |
635 | { | |
636 | *m_text << "Successfully copied data to the clipboard.\n"; | |
637 | } | |
8b53e5a2 | 638 | |
ec9f7884 | 639 | wxTheClipboard->Close(); |
655822f3 | 640 | |
ec9f7884 | 641 | *m_text << "Closed the clipboard.\n"; |
b8653fbf | 642 | #else |
ec9f7884 | 643 | wxLogError("Your version of wxWindows is compiled without clipboard support."); |
3069ac4e | 644 | #endif |
b527aac5 RR |
645 | } |
646 | ||
d59051dd VZ |
647 | void MyPanel::OnMoveToEndOfText( wxCommandEvent &event ) |
648 | { | |
649 | m_multitext->SetInsertionPointEnd(); | |
650 | m_multitext->SetFocus(); | |
651 | } | |
652 | ||
653 | void MyPanel::OnMoveToEndOfEntry( wxCommandEvent &event ) | |
654 | { | |
655 | m_textentry->SetInsertionPointEnd(); | |
656 | m_textentry->SetFocus(); | |
657 | } | |
658 | ||
1c005ff7 RR |
659 | void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) |
660 | { | |
ec9f7884 VZ |
661 | int x = 0; |
662 | int y = 0; | |
663 | GetClientSize( &x, &y ); | |
655822f3 | 664 | |
ec9f7884 VZ |
665 | if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 ); |
666 | if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 ); | |
1c005ff7 RR |
667 | } |
668 | ||
cb43b372 RR |
669 | void MyPanel::OnPageChanged( wxNotebookEvent &event ) |
670 | { | |
ec9f7884 | 671 | *m_text << "Notebook selection is " << event.GetSelection() << "\n"; |
cb43b372 RR |
672 | } |
673 | ||
1c005ff7 RR |
674 | void MyPanel::OnListBox( wxCommandEvent &event ) |
675 | { | |
ec9f7884 VZ |
676 | m_text->AppendText( "ListBox selection string is: " ); |
677 | m_text->AppendText( event.GetString() ); | |
678 | m_text->AppendText( "\n" ); | |
1c005ff7 RR |
679 | } |
680 | ||
5b077d48 RR |
681 | void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event ) |
682 | { | |
ec9f7884 VZ |
683 | m_text->AppendText( "ListBox double click string is: " ); |
684 | m_text->AppendText( event.GetString() ); | |
685 | m_text->AppendText( "\n" ); | |
5b077d48 RR |
686 | } |
687 | ||
47908e25 RR |
688 | void MyPanel::OnListBoxButtons( wxCommandEvent &event ) |
689 | { | |
ec9f7884 | 690 | switch (event.GetId()) |
d3904ceb | 691 | { |
ec9f7884 VZ |
692 | case ID_LISTBOX_ENABLE: |
693 | { | |
694 | m_text->AppendText("Checkbox clicked.\n"); | |
695 | wxCheckBox *cb = (wxCheckBox*)event.GetEventObject(); | |
b8653fbf | 696 | #if wxUSE_TOOLTIPS |
ec9f7884 VZ |
697 | if (event.GetInt()) |
698 | cb->SetToolTip( "Click to enable listbox" ); | |
699 | else | |
700 | cb->SetToolTip( "Click to disable listbox" ); | |
16f6dfd8 | 701 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
702 | m_listbox->Enable( event.GetInt() == 0 ); |
703 | break; | |
704 | } | |
705 | case ID_LISTBOX_SEL_NUM: | |
706 | { | |
707 | m_listbox->SetSelection( 2 ); | |
708 | break; | |
709 | } | |
710 | case ID_LISTBOX_SEL_STR: | |
711 | { | |
712 | m_listbox->SetStringSelection( "This" ); | |
713 | break; | |
714 | } | |
715 | case ID_LISTBOX_CLEAR: | |
716 | { | |
717 | m_listbox->Clear(); | |
718 | break; | |
719 | } | |
720 | case ID_LISTBOX_APPEND: | |
721 | { | |
722 | m_listbox->Append( "Hi!" ); | |
723 | break; | |
724 | } | |
725 | case ID_LISTBOX_DELETE: | |
726 | { | |
727 | int idx = m_listbox->GetSelection(); | |
728 | m_listbox->Delete( idx ); | |
729 | break; | |
730 | } | |
731 | case ID_LISTBOX_FONT: | |
732 | { | |
733 | m_listbox->SetFont( *wxITALIC_FONT ); | |
734 | m_checkbox->SetFont( *wxITALIC_FONT ); | |
735 | break; | |
736 | } | |
868a2826 | 737 | } |
47908e25 RR |
738 | } |
739 | ||
740 | void MyPanel::OnChoice( wxCommandEvent &event ) | |
741 | { | |
ec9f7884 VZ |
742 | m_text->AppendText( "Choice selection string is: " ); |
743 | m_text->AppendText( event.GetString() ); | |
744 | m_text->AppendText( "\n" ); | |
47908e25 RR |
745 | } |
746 | ||
747 | void MyPanel::OnChoiceButtons( wxCommandEvent &event ) | |
748 | { | |
ec9f7884 | 749 | switch (event.GetId()) |
47908e25 | 750 | { |
ec9f7884 VZ |
751 | case ID_CHOICE_ENABLE: |
752 | { | |
753 | m_choice->Enable( event.GetInt() == 0 ); | |
754 | break; | |
755 | } | |
756 | case ID_CHOICE_SEL_NUM: | |
757 | { | |
758 | m_choice->SetSelection( 2 ); | |
759 | break; | |
760 | } | |
761 | case ID_CHOICE_SEL_STR: | |
762 | { | |
763 | m_choice->SetStringSelection( "This" ); | |
764 | break; | |
765 | } | |
766 | case ID_CHOICE_CLEAR: | |
767 | { | |
768 | m_choice->Clear(); | |
769 | break; | |
770 | } | |
771 | case ID_CHOICE_APPEND: | |
772 | { | |
773 | m_choice->Append( "Hi!" ); | |
774 | break; | |
775 | } | |
776 | case ID_CHOICE_DELETE: | |
777 | { | |
778 | int idx = m_choice->GetSelection(); | |
779 | m_choice->Delete( idx ); | |
780 | break; | |
781 | } | |
782 | case ID_CHOICE_FONT: | |
783 | { | |
784 | m_choice->SetFont( *wxITALIC_FONT ); | |
785 | break; | |
786 | } | |
868a2826 | 787 | } |
47908e25 RR |
788 | } |
789 | ||
790 | void MyPanel::OnCombo( wxCommandEvent &event ) | |
791 | { | |
ec9f7884 VZ |
792 | m_text->AppendText( "ComboBox selection string is: " ); |
793 | m_text->AppendText( event.GetString() ); | |
794 | m_text->AppendText( "\n" ); | |
47908e25 RR |
795 | } |
796 | ||
797 | void MyPanel::OnComboButtons( wxCommandEvent &event ) | |
1c005ff7 | 798 | { |
ec9f7884 | 799 | switch (event.GetId()) |
2f6407b9 | 800 | { |
ec9f7884 VZ |
801 | case ID_COMBO_ENABLE: |
802 | { | |
803 | m_combo->Enable( event.GetInt() == 0 ); | |
804 | break; | |
805 | } | |
806 | case ID_COMBO_SEL_NUM: | |
807 | { | |
808 | m_combo->SetSelection( 2 ); | |
809 | break; | |
810 | } | |
811 | case ID_COMBO_SEL_STR: | |
812 | { | |
813 | m_combo->SetStringSelection( "This" ); | |
814 | break; | |
815 | } | |
816 | case ID_COMBO_CLEAR: | |
817 | { | |
818 | m_combo->Clear(); | |
819 | break; | |
820 | } | |
821 | case ID_COMBO_APPEND: | |
822 | { | |
823 | m_combo->Append( "Hi!" ); | |
824 | break; | |
825 | } | |
826 | case ID_COMBO_DELETE: | |
827 | { | |
828 | int idx = m_combo->GetSelection(); | |
829 | m_combo->Delete( idx ); | |
830 | break; | |
831 | } | |
832 | case ID_COMBO_FONT: | |
833 | { | |
834 | m_combo->SetFont( *wxITALIC_FONT ); | |
835 | break; | |
836 | } | |
868a2826 | 837 | } |
47908e25 RR |
838 | } |
839 | ||
840 | void MyPanel::OnRadio( wxCommandEvent &event ) | |
841 | { | |
ec9f7884 VZ |
842 | m_text->AppendText( "RadioBox selection string is: " ); |
843 | m_text->AppendText( event.GetString() ); | |
844 | m_text->AppendText( "\n" ); | |
47908e25 RR |
845 | } |
846 | ||
847 | void MyPanel::OnRadioButtons( wxCommandEvent &event ) | |
848 | { | |
ec9f7884 | 849 | switch (event.GetId()) |
d3904ceb | 850 | { |
ec9f7884 VZ |
851 | case ID_RADIOBOX_ENABLE: |
852 | { | |
853 | m_radio->Enable( event.GetInt() == 0 ); | |
854 | break; | |
855 | } | |
856 | case ID_RADIOBOX_SEL_NUM: | |
857 | { | |
858 | m_radio->SetSelection( 2 ); | |
859 | break; | |
860 | } | |
861 | case ID_RADIOBOX_SEL_STR: | |
862 | { | |
863 | m_radio->SetStringSelection( "This" ); | |
864 | break; | |
865 | } | |
866 | case ID_RADIOBOX_FONT: | |
867 | { | |
868 | m_radio->SetFont( *wxITALIC_FONT ); | |
869 | break; | |
870 | } | |
868a2826 | 871 | } |
1c005ff7 RR |
872 | } |
873 | ||
868a2826 RR |
874 | void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) ) |
875 | { | |
ec9f7884 VZ |
876 | m_fontButton->SetFont( *wxITALIC_FONT ); |
877 | m_text->SetFont( *wxITALIC_FONT ); | |
868a2826 RR |
878 | } |
879 | ||
7bce6aec RR |
880 | void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) |
881 | { | |
ec9f7884 | 882 | m_gauge->SetValue( m_slider->GetValue() ); |
7bce6aec RR |
883 | } |
884 | ||
2a47d3c1 | 885 | #ifndef __WIN16__ |
e380f72b RR |
886 | void MyPanel::OnSpinUpdate( wxSpinEvent &event ) |
887 | { | |
ec9f7884 | 888 | wxString value; |
6380910c | 889 | value.Printf( "%d", event.GetPosition() ); |
ec9f7884 | 890 | m_spintext->SetValue( value ); |
6380910c VZ |
891 | |
892 | value.Printf("Spin control range: (%d, %d), current = %d\n", | |
893 | m_spinbutton->GetMin(), m_spinbutton->GetMax(), | |
894 | m_spinbutton->GetValue()); | |
895 | ||
896 | m_text->AppendText(value); | |
e380f72b | 897 | } |
2a47d3c1 | 898 | #endif |
e380f72b | 899 | |
2cb21a45 VZ |
900 | MyPanel::~MyPanel() |
901 | { | |
ec9f7884 | 902 | delete m_notebook->GetImageList(); |
2cb21a45 VZ |
903 | } |
904 | ||
1c005ff7 RR |
905 | //---------------------------------------------------------------------- |
906 | // MyFrame | |
907 | //---------------------------------------------------------------------- | |
908 | ||
909 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
ec9f7884 VZ |
910 | EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit) |
911 | EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout) | |
16f6dfd8 | 912 | #if wxUSE_TOOLTIPS |
ec9f7884 VZ |
913 | EVT_MENU(MINIMAL_SET_TOOLTIP_DELAY, MyFrame::OnSetTooltipDelay) |
914 | EVT_MENU(MINIMAL_ENABLE_TOOLTIPS, MyFrame::OnToggleTooltips) | |
16f6dfd8 | 915 | #endif // wxUSE_TOOLTIPS |
ec9f7884 VZ |
916 | EVT_SIZE(MyFrame::OnSize) |
917 | EVT_IDLE(MyFrame::OnIdle) | |
1c005ff7 RR |
918 | END_EVENT_TABLE() |
919 | ||
9f3362c4 | 920 | MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h) |
ec9f7884 | 921 | : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) |
1c005ff7 | 922 | { |
5fb9fcfc | 923 | CreateStatusBar(2); |
9f3362c4 VZ |
924 | |
925 | (void)new MyPanel( this, 10, 10, 300, 100 ); | |
1c005ff7 RR |
926 | } |
927 | ||
928 | void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) | |
929 | { | |
ec9f7884 | 930 | Close(TRUE); |
1c005ff7 RR |
931 | } |
932 | ||
933 | void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
934 | { | |
ec9f7884 VZ |
935 | wxBeginBusyCursor(); |
936 | ||
937 | wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK ); | |
938 | dialog.ShowModal(); | |
939 | ||
940 | wxEndBusyCursor(); | |
1c005ff7 | 941 | } |
9f3362c4 | 942 | |
16f6dfd8 VZ |
943 | #if wxUSE_TOOLTIPS |
944 | void MyFrame::OnSetTooltipDelay(wxCommandEvent& event) | |
945 | { | |
946 | static long s_delay = 5000; | |
947 | ||
948 | wxString delay; | |
949 | delay.Printf("%ld", s_delay); | |
950 | ||
951 | delay = wxGetTextFromUser("Enter delay (in milliseconds)", | |
ec9f7884 VZ |
952 | "Set tooltip delay", |
953 | delay, | |
954 | this); | |
16f6dfd8 VZ |
955 | if ( !delay ) |
956 | return; // cancelled | |
957 | ||
958 | sscanf(delay, "%ld", &s_delay); | |
959 | ||
960 | wxToolTip::SetDelay(s_delay); | |
961 | ||
962 | wxLogStatus(this, "Tooltip delay set to %ld milliseconds", s_delay); | |
963 | } | |
964 | ||
965 | void MyFrame::OnToggleTooltips(wxCommandEvent& event) | |
966 | { | |
967 | static bool s_enabled = TRUE; | |
968 | ||
969 | s_enabled = !s_enabled; | |
970 | ||
971 | wxToolTip::Enable(s_enabled); | |
972 | ||
973 | wxLogStatus(this, "Tooltips %sabled", s_enabled ? "en" : "dis"); | |
974 | } | |
975 | #endif // tooltips | |
976 | ||
5fb9fcfc VZ |
977 | void MyFrame::OnSize( wxSizeEvent& event ) |
978 | { | |
979 | wxString msg; | |
980 | msg.Printf("%dx%d", event.GetSize().x, event.GetSize().y); | |
981 | SetStatusText(msg, 1); | |
982 | ||
983 | event.Skip(); | |
984 | } | |
985 | ||
9f3362c4 VZ |
986 | void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) |
987 | { | |
988 | // track the window which has the focus in the status bar | |
989 | static wxWindow *s_windowFocus = (wxWindow *)NULL; | |
990 | wxWindow *focus = wxWindow::FindFocus(); | |
991 | if ( focus && (focus != s_windowFocus) ) | |
992 | { | |
993 | s_windowFocus = focus; | |
994 | ||
995 | wxString msg; | |
996 | msg.Printf("Focus: wxWindow = %p" | |
997 | #ifdef __WXMSW__ | |
ec9f7884 | 998 | ", HWND = %08x" |
9f3362c4 | 999 | #endif // wxMSW |
ec9f7884 | 1000 | , s_windowFocus |
9f3362c4 | 1001 | #ifdef __WXMSW__ |
ec9f7884 | 1002 | , s_windowFocus->GetHWND() |
9f3362c4 VZ |
1003 | #endif // wxMSW |
1004 | ); | |
1005 | ||
1006 | SetStatusText(msg); | |
1007 | } | |
341c92a8 | 1008 | } |