1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Controls wxWidgets sample
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling, Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
22 #include "wx/spinbutt.h"
23 #include "wx/tglbtn.h"
24 #include "wx/bookctrl.h"
25 #include "wx/imaglist.h"
26 #include "wx/artprov.h"
27 #include "wx/cshelp.h"
28 #include "wx/gbsizer.h"
31 #include "wx/tooltip.h"
33 #include "wx/numdlg.h"
35 #endif // wxUSE_TOOLTIPS
38 #include "icons/choice.xpm"
39 #include "icons/combo.xpm"
40 #include "icons/list.xpm"
41 #include "icons/radio.xpm"
42 #include "icons/text.xpm"
43 #include "icons/gauge.xpm"
47 #define wxUSE_SPINBTN 1
50 #include "wx/progdlg.h"
53 #include "wx/spinctrl.h"
54 #endif // wxUSE_SPINCTRL
57 #define wxToggleButton wxCheckBox
58 #define EVT_TOGGLEBUTTON EVT_CHECKBOX
61 #ifndef wxHAS_IMAGES_IN_RESOURCES
62 #include "../sample.xpm"
65 //----------------------------------------------------------------------
67 //----------------------------------------------------------------------
69 class MyApp
: public wxApp
75 class MyPanel
: public wxPanel
78 MyPanel(wxFrame
*frame
, int x
, int y
, int w
, int h
);
82 void SetAllToolTips();
83 #endif // wxUSE_TOOLTIPS
85 void OnIdle( wxIdleEvent
&event
);
86 void OnListBox( wxCommandEvent
&event
);
87 void OnListBoxDoubleClick( wxCommandEvent
&event
);
88 void OnListBoxButtons( wxCommandEvent
&event
);
90 void OnChoice( wxCommandEvent
&event
);
91 void OnChoiceButtons( wxCommandEvent
&event
);
93 void OnCombo( wxCommandEvent
&event
);
94 void OnComboTextChanged( wxCommandEvent
&event
);
95 void OnComboTextEnter( wxCommandEvent
&event
);
96 void OnComboButtons( wxCommandEvent
&event
);
97 void OnRadio( wxCommandEvent
&event
);
98 void OnRadioButtons( wxCommandEvent
&event
);
99 void OnRadioButton1( wxCommandEvent
&event
);
100 void OnRadioButton2( wxCommandEvent
&event
);
101 void OnSetFont( wxCommandEvent
&event
);
102 void OnPageChanged( wxBookCtrlEvent
&event
);
103 void OnPageChanging( wxBookCtrlEvent
&event
);
104 void OnSliderUpdate( wxCommandEvent
&event
);
105 void OnUpdateLabel( wxCommandEvent
&event
);
107 void OnSpinUp( wxSpinEvent
&event
);
108 void OnSpinDown( wxSpinEvent
&event
);
109 void OnSpinUpdate( wxSpinEvent
&event
);
110 #if wxUSE_PROGRESSDLG
111 void OnUpdateShowProgress( wxUpdateUIEvent
& event
);
112 void OnShowProgress( wxCommandEvent
&event
);
113 #endif // wxUSE_PROGRESSDLG
114 #endif // wxUSE_SPINBTN
115 void OnNewText( wxCommandEvent
&event
);
117 void OnSpinCtrl(wxSpinEvent
& event
);
118 void OnSpinCtrlUp(wxSpinEvent
& event
);
119 void OnSpinCtrlDown(wxSpinEvent
& event
);
120 void OnSpinCtrlText(wxCommandEvent
& event
);
121 #endif // wxUSE_SPINCTRL
123 void OnEnableAll(wxCommandEvent
& event
);
124 void OnChangeColour(wxCommandEvent
& event
);
125 void OnTestButton(wxCommandEvent
& event
);
126 void OnBmpButton(wxCommandEvent
& event
);
127 void OnBmpButtonToggle(wxCommandEvent
& event
);
129 void OnSizerCheck (wxCommandEvent
&event
);
131 wxListBox
*m_listbox
,
136 #endif // wxUSE_CHOICE
143 #endif // wxUSE_GAUGE
146 #endif // wxUSE_SLIDER
147 wxButton
*m_fontButton
;
148 wxButton
*m_lbSelectNum
;
149 wxButton
*m_lbSelectThis
;
151 wxSpinButton
*m_spinbutton
;
152 #if wxUSE_PROGRESSDLG
153 wxButton
*m_btnProgress
;
154 #endif // wxUSE_PROGRESSDLG
155 #endif // wxUSE_SPINBTN
156 wxStaticText
*m_wrappingText
;
157 wxStaticText
*m_nonWrappingText
;
160 wxSpinCtrl
*m_spinctrl
;
161 #endif // wxUSE_SPINCTRL
163 wxTextCtrl
*m_spintext
;
164 wxCheckBox
*m_checkbox
;
169 wxStaticText
*m_label
;
171 wxBoxSizer
*m_buttonSizer
;
172 wxButton
*m_sizerBtn1
;
173 wxButton
*m_sizerBtn2
;
174 wxButton
*m_sizerBtn3
;
175 wxButton
*m_sizerBtn4
;
176 wxBoxSizer
*m_hsizer
;
180 wxLog
*m_logTargetOld
;
182 DECLARE_EVENT_TABLE()
185 class MyFrame
: public wxFrame
188 MyFrame(const wxChar
*title
, int x
, int y
);
190 void OnQuit(wxCommandEvent
& event
);
191 void OnAbout(wxCommandEvent
& event
);
192 void OnClearLog(wxCommandEvent
& event
);
195 void OnSetTooltipDelay(wxCommandEvent
& event
);
196 void OnToggleTooltips(wxCommandEvent
& event
);
198 void OnSetMaxTooltipWidth(wxCommandEvent
& event
);
200 #endif // wxUSE_TOOLTIPS
202 void OnEnableAll(wxCommandEvent
& event
);
203 void OnHideAll(wxCommandEvent
& event
);
204 void OnHideList(wxCommandEvent
& event
);
205 void OnContextHelp(wxCommandEvent
& event
);
207 void OnIdle( wxIdleEvent
& event
);
208 void OnIconized( wxIconizeEvent
& event
);
209 void OnMaximized( wxMaximizeEvent
& event
);
210 void OnSize( wxSizeEvent
& event
);
211 void OnMove( wxMoveEvent
& event
);
213 MyPanel
*GetPanel() const { return m_panel
; }
217 void UpdateStatusBar(const wxPoint
& pos
, const wxSize
& size
)
219 if ( m_frameStatusBar
)
222 wxSize sizeAll
= GetSize(),
223 sizeCl
= GetClientSize();
224 msg
.Printf(_("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)"),
227 sizeAll
.x
, sizeAll
.y
,
229 SetStatusText(msg
, 1);
232 #endif // wxUSE_STATUSBAR
236 DECLARE_EVENT_TABLE()
239 // a button which intercepts double clicks (for testing...)
240 class MyButton
: public wxButton
243 MyButton(wxWindow
*parent
,
245 const wxString
& label
= wxEmptyString
,
246 const wxPoint
& pos
= wxDefaultPosition
,
247 const wxSize
& size
= wxDefaultSize
)
248 : wxButton(parent
, id
, label
, pos
, size
)
252 void OnDClick(wxMouseEvent
& event
)
254 wxLogMessage(wxT("MyButton::OnDClick"));
260 DECLARE_EVENT_TABLE()
263 // a combo which intercepts chars (to test Windows behaviour)
264 class MyComboBox
: public wxComboBox
267 MyComboBox(wxWindow
*parent
, wxWindowID id
,
268 const wxString
& value
= wxEmptyString
,
269 const wxPoint
& pos
= wxDefaultPosition
,
270 const wxSize
& size
= wxDefaultSize
,
271 int n
= 0, const wxString choices
[] = NULL
,
273 const wxValidator
& validator
= wxDefaultValidator
,
274 const wxString
& name
= wxComboBoxNameStr
)
275 : wxComboBox(parent
, id
, value
, pos
, size
, n
, choices
, style
,
279 void OnChar(wxKeyEvent
& event
);
280 void OnKeyDown(wxKeyEvent
& event
);
281 void OnKeyUp(wxKeyEvent
& event
);
282 void OnFocusGot(wxFocusEvent
& event
)
284 wxLogMessage(wxT("MyComboBox::OnFocusGot"));
290 DECLARE_EVENT_TABLE()
293 // a radiobox which handles focus set/kill (for testing)
294 class MyRadioBox
: public wxRadioBox
297 MyRadioBox(wxWindow
*parent
,
299 const wxString
& title
= wxEmptyString
,
300 const wxPoint
& pos
= wxDefaultPosition
,
301 const wxSize
& size
= wxDefaultSize
,
302 int n
= 0, const wxString choices
[] = NULL
,
304 long style
= wxRA_SPECIFY_COLS
,
305 const wxValidator
& validator
= wxDefaultValidator
,
306 const wxString
& name
= wxRadioBoxNameStr
)
307 : wxRadioBox(parent
, id
, title
, pos
, size
, n
, choices
, majorDim
,
308 style
, validator
, name
)
313 void OnFocusGot(wxFocusEvent
& event
)
315 wxLogMessage(wxT("MyRadioBox::OnFocusGot"));
320 void OnFocusLost(wxFocusEvent
& event
)
322 wxLogMessage(wxT("MyRadioBox::OnFocusLost"));
328 DECLARE_EVENT_TABLE()
331 // a choice which handles focus set/kill (for testing)
332 class MyChoice
: public wxChoice
335 MyChoice(wxWindow
*parent
,
337 const wxPoint
& pos
= wxDefaultPosition
,
338 const wxSize
& size
= wxDefaultSize
,
339 int n
= 0, const wxString choices
[] = NULL
,
341 const wxValidator
& validator
= wxDefaultValidator
,
342 const wxString
& name
= wxChoiceNameStr
)
343 : wxChoice(parent
, id
, pos
, size
, n
, choices
,
344 style
, validator
, name
) { }
347 void OnFocusGot(wxFocusEvent
& event
)
349 wxLogMessage(wxT("MyChoice::OnFocusGot"));
354 void OnFocusLost(wxFocusEvent
& event
)
356 wxLogMessage(wxT("MyChoice::OnFocusLost"));
362 DECLARE_EVENT_TABLE()
367 //----------------------------------------------------------------------
369 //----------------------------------------------------------------------
371 static void SetListboxClientData(const wxChar
*name
, wxListBox
*control
);
374 static void SetChoiceClientData(const wxChar
*name
, wxChoice
*control
);
375 #endif // wxUSE_CHOICE
379 //----------------------------------------------------------------------
381 //----------------------------------------------------------------------
385 CONTROLS_QUIT
= wxID_EXIT
,
386 CONTROLS_ABOUT
= wxID_ABOUT
,
391 CONTROLS_SET_TOOLTIP_DELAY
= 200,
392 CONTROLS_ENABLE_TOOLTIPS
,
393 CONTROLS_SET_TOOLTIPS_MAX_WIDTH
,
399 CONTROLS_CONTEXT_HELP
404 // use standard command line handling:
405 if ( !wxApp::OnInit() )
408 // parse the cmd line
413 wxSscanf(wxString(argv
[1]), wxT("%d"), &x
);
414 wxSscanf(wxString(argv
[2]), wxT("%d"), &y
);
418 wxHelpProvider::Set( new wxSimpleHelpProvider
);
421 // Create the main frame window
422 MyFrame
*frame
= new MyFrame(wxT("Controls wxWidgets App"), x
, y
);
428 //----------------------------------------------------------------------
430 //----------------------------------------------------------------------
432 const int ID_BOOK
= 1000;
434 const int ID_LISTBOX
= 130;
435 const int ID_LISTBOX_SEL_NUM
= 131;
436 const int ID_LISTBOX_SEL_STR
= 132;
437 const int ID_LISTBOX_CLEAR
= 133;
438 const int ID_LISTBOX_APPEND
= 134;
439 const int ID_LISTBOX_DELETE
= 135;
440 const int ID_LISTBOX_FONT
= 136;
441 const int ID_LISTBOX_ENABLE
= 137;
442 const int ID_LISTBOX_SORTED
= 138;
444 const int ID_CHOICE
= 120;
445 const int ID_CHOICE_SEL_NUM
= 121;
446 const int ID_CHOICE_SEL_STR
= 122;
447 const int ID_CHOICE_CLEAR
= 123;
448 const int ID_CHOICE_APPEND
= 124;
449 const int ID_CHOICE_DELETE
= 125;
450 const int ID_CHOICE_FONT
= 126;
451 const int ID_CHOICE_ENABLE
= 127;
452 const int ID_CHOICE_SORTED
= 128;
454 const int ID_COMBO
= 140;
455 const int ID_COMBO_SEL_NUM
= 141;
456 const int ID_COMBO_SEL_STR
= 142;
457 const int ID_COMBO_CLEAR
= 143;
458 const int ID_COMBO_APPEND
= 144;
459 const int ID_COMBO_DELETE
= 145;
460 const int ID_COMBO_FONT
= 146;
461 const int ID_COMBO_ENABLE
= 147;
462 const int ID_COMBO_SET_TEXT
= 148;
464 const int ID_RADIOBOX
= 160;
465 const int ID_RADIOBOX_SEL_NUM
= 161;
466 const int ID_RADIOBOX_SEL_STR
= 162;
467 const int ID_RADIOBOX_FONT
= 163;
468 const int ID_RADIOBOX_ENABLE
= 164;
469 const int ID_RADIOBOX2
= 165;
470 const int ID_RADIOBUTTON_1
= 166;
471 const int ID_RADIOBUTTON_2
= 167;
473 const int ID_SET_FONT
= 170;
476 const int ID_GAUGE
= 180;
477 #endif // wxUSE_GAUGE
480 const int ID_SLIDER
= 181;
481 #endif // wxUSE_SLIDER
483 const int ID_SPIN
= 182;
484 #if wxUSE_PROGRESSDLG
485 const int ID_BTNPROGRESS
= 183;
486 #endif // wxUSE_PROGRESSDLG
487 const int ID_BUTTON_LABEL
= 184;
488 const int ID_SPINCTRL
= 185;
489 const int ID_BTNNEWTEXT
= 186;
491 const int ID_BUTTON_TEST1
= 190;
492 const int ID_BUTTON_TEST2
= 191;
493 const int ID_BITMAP_BTN
= 192;
494 const int ID_BITMAP_BTN_ENABLE
= 193;
496 const int ID_CHANGE_COLOUR
= 200;
498 const int ID_SIZER_CHECK1
= 201;
499 const int ID_SIZER_CHECK2
= 202;
500 const int ID_SIZER_CHECK3
= 203;
501 const int ID_SIZER_CHECK4
= 204;
502 const int ID_SIZER_CHECK14
= 205;
503 const int ID_SIZER_CHECKBIG
= 206;
505 const int ID_HYPERLINK
= 300;
507 BEGIN_EVENT_TABLE(MyPanel
, wxPanel
)
508 EVT_IDLE ( MyPanel::OnIdle
)
509 EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK
, MyPanel::OnPageChanging
)
510 EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK
, MyPanel::OnPageChanged
)
511 EVT_LISTBOX (ID_LISTBOX
, MyPanel::OnListBox
)
512 EVT_LISTBOX (ID_LISTBOX_SORTED
, MyPanel::OnListBox
)
513 EVT_LISTBOX_DCLICK(ID_LISTBOX
, MyPanel::OnListBoxDoubleClick
)
514 EVT_BUTTON (ID_LISTBOX_SEL_NUM
, MyPanel::OnListBoxButtons
)
515 EVT_BUTTON (ID_LISTBOX_SEL_STR
, MyPanel::OnListBoxButtons
)
516 EVT_BUTTON (ID_LISTBOX_CLEAR
, MyPanel::OnListBoxButtons
)
517 EVT_BUTTON (ID_LISTBOX_APPEND
, MyPanel::OnListBoxButtons
)
518 EVT_BUTTON (ID_LISTBOX_DELETE
, MyPanel::OnListBoxButtons
)
519 EVT_BUTTON (ID_LISTBOX_FONT
, MyPanel::OnListBoxButtons
)
520 EVT_CHECKBOX (ID_LISTBOX_ENABLE
, MyPanel::OnListBoxButtons
)
522 EVT_CHOICE (ID_CHOICE
, MyPanel::OnChoice
)
523 EVT_CHOICE (ID_CHOICE_SORTED
, MyPanel::OnChoice
)
524 EVT_BUTTON (ID_CHOICE_SEL_NUM
, MyPanel::OnChoiceButtons
)
525 EVT_BUTTON (ID_CHOICE_SEL_STR
, MyPanel::OnChoiceButtons
)
526 EVT_BUTTON (ID_CHOICE_CLEAR
, MyPanel::OnChoiceButtons
)
527 EVT_BUTTON (ID_CHOICE_APPEND
, MyPanel::OnChoiceButtons
)
528 EVT_BUTTON (ID_CHOICE_DELETE
, MyPanel::OnChoiceButtons
)
529 EVT_BUTTON (ID_CHOICE_FONT
, MyPanel::OnChoiceButtons
)
530 EVT_CHECKBOX (ID_CHOICE_ENABLE
, MyPanel::OnChoiceButtons
)
532 EVT_COMBOBOX (ID_COMBO
, MyPanel::OnCombo
)
533 EVT_TEXT (ID_COMBO
, MyPanel::OnComboTextChanged
)
534 EVT_TEXT_ENTER(ID_COMBO
, MyPanel::OnComboTextEnter
)
535 EVT_BUTTON (ID_COMBO_SEL_NUM
, MyPanel::OnComboButtons
)
536 EVT_BUTTON (ID_COMBO_SEL_STR
, MyPanel::OnComboButtons
)
537 EVT_BUTTON (ID_COMBO_CLEAR
, MyPanel::OnComboButtons
)
538 EVT_BUTTON (ID_COMBO_APPEND
, MyPanel::OnComboButtons
)
539 EVT_BUTTON (ID_COMBO_DELETE
, MyPanel::OnComboButtons
)
540 EVT_BUTTON (ID_COMBO_FONT
, MyPanel::OnComboButtons
)
541 EVT_BUTTON (ID_COMBO_SET_TEXT
, MyPanel::OnComboButtons
)
542 EVT_CHECKBOX (ID_COMBO_ENABLE
, MyPanel::OnComboButtons
)
543 EVT_RADIOBOX (ID_RADIOBOX
, MyPanel::OnRadio
)
544 EVT_RADIOBOX (ID_RADIOBOX2
, MyPanel::OnRadio
)
545 EVT_BUTTON (ID_RADIOBOX_SEL_NUM
, MyPanel::OnRadioButtons
)
546 EVT_BUTTON (ID_RADIOBOX_SEL_STR
, MyPanel::OnRadioButtons
)
547 EVT_BUTTON (ID_RADIOBOX_FONT
, MyPanel::OnRadioButtons
)
548 EVT_CHECKBOX (ID_RADIOBOX_ENABLE
, MyPanel::OnRadioButtons
)
549 EVT_RADIOBUTTON(ID_RADIOBUTTON_1
, MyPanel::OnRadioButton1
)
550 EVT_RADIOBUTTON(ID_RADIOBUTTON_2
, MyPanel::OnRadioButton2
)
551 EVT_BUTTON (ID_SET_FONT
, MyPanel::OnSetFont
)
553 EVT_SLIDER (ID_SLIDER
, MyPanel::OnSliderUpdate
)
554 #endif // wxUSE_SLIDER
556 EVT_SPIN (ID_SPIN
, MyPanel::OnSpinUpdate
)
557 EVT_SPIN_UP (ID_SPIN
, MyPanel::OnSpinUp
)
558 EVT_SPIN_DOWN (ID_SPIN
, MyPanel::OnSpinDown
)
559 #if wxUSE_PROGRESSDLG
560 EVT_UPDATE_UI (ID_BTNPROGRESS
, MyPanel::OnUpdateShowProgress
)
561 EVT_BUTTON (ID_BTNPROGRESS
, MyPanel::OnShowProgress
)
562 #endif // wxUSE_PROGRESSDLG
563 #endif // wxUSE_SPINBTN
565 EVT_SPINCTRL (ID_SPINCTRL
, MyPanel::OnSpinCtrl
)
566 EVT_SPIN_UP (ID_SPINCTRL
, MyPanel::OnSpinCtrlUp
)
567 EVT_SPIN_DOWN (ID_SPINCTRL
, MyPanel::OnSpinCtrlDown
)
568 EVT_TEXT (ID_SPINCTRL
, MyPanel::OnSpinCtrlText
)
569 #endif // wxUSE_SPINCTRL
570 EVT_BUTTON (ID_BTNNEWTEXT
, MyPanel::OnNewText
)
571 EVT_TOGGLEBUTTON(ID_BUTTON_LABEL
, MyPanel::OnUpdateLabel
)
572 EVT_CHECKBOX (ID_CHANGE_COLOUR
, MyPanel::OnChangeColour
)
573 EVT_BUTTON (ID_BUTTON_TEST1
, MyPanel::OnTestButton
)
574 EVT_BUTTON (ID_BUTTON_TEST2
, MyPanel::OnTestButton
)
575 EVT_BUTTON (ID_BITMAP_BTN
, MyPanel::OnBmpButton
)
576 EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE
, MyPanel::OnBmpButtonToggle
)
578 EVT_CHECKBOX (ID_SIZER_CHECK1
, MyPanel::OnSizerCheck
)
579 EVT_CHECKBOX (ID_SIZER_CHECK2
, MyPanel::OnSizerCheck
)
580 EVT_CHECKBOX (ID_SIZER_CHECK3
, MyPanel::OnSizerCheck
)
581 EVT_CHECKBOX (ID_SIZER_CHECK4
, MyPanel::OnSizerCheck
)
582 EVT_CHECKBOX (ID_SIZER_CHECK14
, MyPanel::OnSizerCheck
)
583 EVT_CHECKBOX (ID_SIZER_CHECKBIG
, MyPanel::OnSizerCheck
)
587 BEGIN_EVENT_TABLE(MyButton
, wxButton
)
588 EVT_LEFT_DCLICK(MyButton::OnDClick
)
591 BEGIN_EVENT_TABLE(MyComboBox
, wxComboBox
)
592 EVT_CHAR(MyComboBox::OnChar
)
593 EVT_KEY_DOWN(MyComboBox::OnKeyDown
)
594 EVT_KEY_UP(MyComboBox::OnKeyUp
)
596 EVT_SET_FOCUS(MyComboBox::OnFocusGot
)
599 BEGIN_EVENT_TABLE(MyRadioBox
, wxRadioBox
)
600 EVT_SET_FOCUS(MyRadioBox::OnFocusGot
)
601 EVT_KILL_FOCUS(MyRadioBox::OnFocusLost
)
604 BEGIN_EVENT_TABLE(MyChoice
, wxChoice
)
605 EVT_SET_FOCUS(MyChoice::OnFocusGot
)
606 EVT_KILL_FOCUS(MyChoice::OnFocusLost
)
609 // ============================================================================
611 // ============================================================================
613 MyPanel::MyPanel( wxFrame
*frame
, int x
, int y
, int w
, int h
)
614 : wxPanel( frame
, wxID_ANY
, wxPoint(x
, y
), wxSize(w
, h
) )
617 m_listboxSorted
= NULL
;
620 m_choiceSorted
= NULL
;
621 #endif // wxUSE_CHOICE
627 #endif // wxUSE_GAUGE
630 #endif // wxUSE_SLIDER
632 m_lbSelectNum
= NULL
;
633 m_lbSelectThis
= NULL
;
636 #if wxUSE_PROGRESSDLG
637 m_btnProgress
= NULL
;
638 #endif // wxUSE_PROGRESSDLG
639 #endif // wxUSE_SPINBTN
642 #endif // wxUSE_SPINCTRL
649 m_text
= new wxTextCtrl(this, wxID_ANY
, wxT("This is the log window.\n"),
650 wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE
);
652 m_logTargetOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_text
));
654 m_book
= new wxBookCtrl(this, ID_BOOK
);
660 wxT("one of my long and"),
676 #endif // wxUSE_GAUGE
680 // fill the image list
681 wxBitmap
bmp(list_xpm
);
683 wxImageList
*imagelist
= new wxImageList(bmp
.GetWidth(), bmp
.GetHeight());
685 imagelist
-> Add( bmp
);
686 imagelist
-> Add( wxBitmap( choice_xpm
));
687 imagelist
-> Add( wxBitmap( combo_xpm
));
688 imagelist
-> Add( wxBitmap( text_xpm
));
689 imagelist
-> Add( wxBitmap( radio_xpm
));
691 imagelist
-> Add( wxBitmap( gauge_xpm
));
692 #endif // wxUSE_GAUGE
693 m_book
->SetImageList(imagelist
);
695 // load images from resources
705 #endif // wxUSE_GAUGE
708 wxImageList
*imagelist
= new wxImageList(16, 16, false, Image_Max
);
710 static const wxChar
*s_iconNames
[Image_Max
] =
719 #endif // wxUSE_GAUGE
722 for ( size_t n
= 0; n
< Image_Max
; n
++ )
724 wxBitmap
bmp(s_iconNames
[n
]);
725 if ( !bmp
.IsOk() || (imagelist
->Add(bmp
) == -1) )
727 wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
732 m_book
->SetImageList(imagelist
);
735 // ------------------------------------------------------------------------
737 // ------------------------------------------------------------------------
738 wxPanel
*panel
= new wxPanel(m_book
);
739 m_listbox
= new wxListBox( panel
, ID_LISTBOX
,
740 wxPoint(10,10), wxSize(120,70),
741 5, choices
, wxLB_MULTIPLE
| wxLB_ALWAYS_SB
| wxHSCROLL
);
742 m_listboxSorted
= new wxListBox( panel
, ID_LISTBOX_SORTED
,
743 wxPoint(10,90), wxSize(120,70),
744 3, choices
, wxLB_SORT
);
746 SetListboxClientData(wxT("listbox"), m_listbox
);
747 SetListboxClientData(wxT("listbox"), m_listboxSorted
);
749 m_listbox
->SetCursor(*wxCROSS_CURSOR
);
751 m_lbSelectNum
= new wxButton( panel
, ID_LISTBOX_SEL_NUM
, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
752 m_lbSelectThis
= new wxButton( panel
, ID_LISTBOX_SEL_STR
, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
753 (void)new wxButton( panel
, ID_LISTBOX_CLEAR
, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
754 (void)new MyButton( panel
, ID_LISTBOX_APPEND
, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
755 (void)new wxButton( panel
, ID_LISTBOX_DELETE
, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
756 wxButton
*button
= new MyButton( panel
, ID_LISTBOX_FONT
, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
758 button
->SetDefault();
760 m_checkbox
= new wxCheckBox( panel
, ID_LISTBOX_ENABLE
, wxT("&Disable"), wxPoint(20,170) );
761 m_checkbox
->SetValue(false);
762 button
->MoveAfterInTabOrder(m_checkbox
);
763 (void)new wxCheckBox( panel
, ID_CHANGE_COLOUR
, wxT("&Toggle colour"),
765 panel
->SetCursor(wxCursor(wxCURSOR_HAND
));
766 m_book
->AddPage(panel
, wxT("wxListBox"), true, Image_List
);
768 // ------------------------------------------------------------------------
770 // ------------------------------------------------------------------------
772 panel
= new wxPanel(m_book
);
773 m_choice
= new MyChoice( panel
, ID_CHOICE
, wxPoint(10,10), wxDefaultSize
, 5, choices
);
774 m_choiceSorted
= new MyChoice( panel
, ID_CHOICE_SORTED
, wxPoint(10,70), wxSize(120,wxDefaultCoord
),
775 5, choices
, wxCB_SORT
);
777 SetChoiceClientData(wxT("choice"), m_choice
);
778 SetChoiceClientData(wxT("choice"), m_choiceSorted
);
780 m_choice
->SetSelection(2);
781 (void)new wxButton( panel
, ID_CHOICE_SEL_NUM
, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
782 (void)new wxButton( panel
, ID_CHOICE_SEL_STR
, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
783 (void)new wxButton( panel
, ID_CHOICE_CLEAR
, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
784 (void)new wxButton( panel
, ID_CHOICE_APPEND
, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
785 (void)new wxButton( panel
, ID_CHOICE_DELETE
, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
786 (void)new wxButton( panel
, ID_CHOICE_FONT
, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
787 (void)new wxCheckBox( panel
, ID_CHOICE_ENABLE
, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
789 m_book
->AddPage(panel
, wxT("wxChoice"), false, Image_Choice
);
790 #endif // wxUSE_CHOICE
792 // ------------------------------------------------------------------------
794 // ------------------------------------------------------------------------
795 panel
= new wxPanel(m_book
);
796 m_combo
= new MyComboBox( panel
, ID_COMBO
, wxT("This"),
797 wxPoint(15,25), wxDefaultSize
,
800 wxSize
combosize(m_combo
->GetBestSize().x
+ 20, 100);
801 (void)new wxStaticBox( panel
, wxID_ANY
, wxT("&Box around combobox"),
802 wxPoint(5, 5), combosize
);
804 (void)new wxButton( panel
, ID_COMBO_SEL_NUM
, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
805 (void)new wxButton( panel
, ID_COMBO_SEL_STR
, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
806 (void)new wxButton( panel
, ID_COMBO_CLEAR
, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
807 (void)new wxButton( panel
, ID_COMBO_APPEND
, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
808 (void)new wxButton( panel
, ID_COMBO_DELETE
, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
809 (void)new wxButton( panel
, ID_COMBO_FONT
, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
810 (void)new wxButton( panel
, ID_COMBO_SET_TEXT
, wxT("Set 'Hi!' at #2"), wxPoint(380,180), wxSize(140,30) );
811 (void)new wxCheckBox( panel
, ID_COMBO_ENABLE
, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
812 m_book
->AddPage(panel
, wxT("wxComboBox"), false, Image_Combo
);
814 // ------------------------------------------------------------------------
816 // ------------------------------------------------------------------------
817 wxString choices2
[] =
819 wxT("First"), wxT("Second"),
821 "Fourth", "Fifth", "Sixth",
822 "Seventh", "Eighth", "Nineth", "Tenth" */
825 panel
= new wxPanel(m_book
);
826 wxGridBagSizer
* radio_page_sizer
= new wxGridBagSizer(5, 5);
828 m_radio
= new wxRadioBox(panel
, ID_RADIOBOX
, wxT("T&his"),
829 wxPoint(10,10), wxDefaultSize
,
830 WXSIZEOF(choices
), choices
,
831 1, wxRA_SPECIFY_COLS
);
832 MyRadioBox
* mybox
= new MyRadioBox(panel
, ID_RADIOBOX2
, wxT("&That"),
833 wxPoint(10,160), wxDefaultSize
,
834 WXSIZEOF(choices2
), choices2
,
835 1, wxRA_SPECIFY_ROWS
);
837 radio_page_sizer
->Add( m_radio
, wxGBPosition(0,0), wxGBSpan(2,1) );
838 radio_page_sizer
->Add( mybox
, wxGBPosition(2,0), wxGBSpan(2,1) );
841 for (unsigned int item
= 0; item
< WXSIZEOF(choices
); ++item
)
842 m_radio
->SetItemHelpText( item
, wxString::Format( wxT("Help text for \"%s\""),
843 choices
[item
].c_str() ) );
845 // erase help text for the second item
846 m_radio
->SetItemHelpText( 1, wxT("") );
847 // set default help text for control
848 m_radio
->SetHelpText( wxT("Default helptext for wxRadioBox") );
851 wxButton
* select_two
= new wxButton ( panel
, ID_RADIOBOX_SEL_NUM
, wxT("Select #&2") );
852 wxButton
* select_this
= new wxButton ( panel
, ID_RADIOBOX_SEL_STR
, wxT("&Select 'This'") );
853 m_fontButton
= new wxButton ( panel
, ID_SET_FONT
, wxT("Set &more Italic font") );
854 wxButton
* set_italic
= new wxButton ( panel
, ID_RADIOBOX_FONT
, wxT("Set &Italic font") );
855 wxCheckBox
* disable_cb
= new wxCheckBox( panel
, ID_RADIOBOX_ENABLE
, wxT("&Disable") );
856 wxRadioButton
*rb
= new wxRadioButton( panel
, ID_RADIOBUTTON_1
, wxT("Radiobutton1"),
857 wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
858 wxRadioButton
*rb2
= new wxRadioButton( panel
, ID_RADIOBUTTON_2
, wxT("&Radiobutton2"),
859 wxDefaultPosition
, wxDefaultSize
);
860 rb
->SetValue( false );
862 radio_page_sizer
->Add( select_two
, wxGBPosition(0, 1), wxDefaultSpan
, wxALL
, 10 );
863 radio_page_sizer
->Add( select_this
, wxGBPosition(1, 1), wxDefaultSpan
, wxALL
, 10 );
864 radio_page_sizer
->Add( m_fontButton
, wxGBPosition(0, 2), wxDefaultSpan
, wxALL
, 10 );
865 radio_page_sizer
->Add( set_italic
, wxGBPosition(1, 2), wxDefaultSpan
, wxALL
, 10 );
866 radio_page_sizer
->Add( disable_cb
, wxGBPosition(2, 2), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
867 radio_page_sizer
->Add( rb
, wxGBPosition(3, 1), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
868 radio_page_sizer
->Add( rb2
, wxGBPosition(3, 2), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
870 panel
->SetSizer( radio_page_sizer
);
872 m_book
->AddPage(panel
, wxT("wxRadioBox"), false, Image_Radio
);
874 // ------------------------------------------------------------------------
876 // ------------------------------------------------------------------------
878 #if wxUSE_SLIDER && wxUSE_GAUGE
879 panel
= new wxPanel(m_book
);
881 wxBoxSizer
*gauge_page_vsizer
= new wxBoxSizer( wxVERTICAL
);
883 wxBoxSizer
*gauge_page_first_row_sizer
= new wxBoxSizer( wxHORIZONTAL
);
885 wxStaticBoxSizer
*gauge_sizer
= new wxStaticBoxSizer( wxHORIZONTAL
, panel
, wxT("&wxGauge and wxSlider") );
886 gauge_page_first_row_sizer
->Add( gauge_sizer
, 0, wxALL
, 5 );
887 wxBoxSizer
*sz
= new wxBoxSizer( wxVERTICAL
);
888 gauge_sizer
->Add( sz
);
889 m_gauge
= new wxGauge( panel
, wxID_ANY
, 200, wxDefaultPosition
, wxSize(155, 30), wxGA_HORIZONTAL
|wxNO_BORDER
);
890 sz
->Add( m_gauge
, 0, wxALL
, 10 );
891 m_slider
= new wxSlider( panel
, ID_SLIDER
, 0, 0, 200,
892 wxDefaultPosition
, wxSize(155,wxDefaultCoord
),
893 wxSL_AUTOTICKS
| wxSL_LABELS
);
894 m_slider
->SetTickFreq(40);
895 sz
->Add( m_slider
, 0, wxALL
, 10 );
897 m_gaugeVert
= new wxGauge( panel
, wxID_ANY
, 100,
898 wxDefaultPosition
, wxSize(wxDefaultCoord
, 90),
899 wxGA_VERTICAL
| wxGA_SMOOTH
| wxNO_BORDER
);
900 gauge_sizer
->Add( m_gaugeVert
, 0, wxALL
, 10 );
904 wxStaticBox
*sb
= new wxStaticBox( panel
, wxID_ANY
, wxT("&Explanation"),
905 wxDefaultPosition
, wxDefaultSize
); //, wxALIGN_CENTER );
906 wxStaticBoxSizer
*wrapping_sizer
= new wxStaticBoxSizer( sb
, wxVERTICAL
);
907 gauge_page_first_row_sizer
->Add( wrapping_sizer
, 0, wxALL
, 5 );
910 // No wrapping text in wxStaticText yet :-(
911 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
912 wxT("Drag the slider!"),
914 wxSize(240, wxDefaultCoord
)
917 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
918 wxT("In order see the gauge (aka progress bar) ")
919 wxT("control do something you have to drag the ")
920 wxT("handle of the slider to the right.")
922 wxT("This is also supposed to demonstrate how ")
923 wxT("to use static controls with line wrapping."),
925 wxSize(240, wxDefaultCoord
)
928 wrapping_sizer
->Add( m_wrappingText
);
930 wxStaticBoxSizer
*non_wrapping_sizer
= new wxStaticBoxSizer( wxVERTICAL
, panel
, wxT("Non-wrapping") );
931 gauge_page_first_row_sizer
->Add( non_wrapping_sizer
, 0, wxALL
, 5 );
933 m_nonWrappingText
= new wxStaticText( panel
, wxID_ANY
,
934 wxT("This static text has two lines.\nThey do not wrap."),
938 non_wrapping_sizer
->Add( m_nonWrappingText
);
940 gauge_page_vsizer
->Add( gauge_page_first_row_sizer
, 1 );
941 wxBoxSizer
*gauge_page_second_row_sizer
= new wxBoxSizer( wxHORIZONTAL
);
944 int initialSpinValue
= -5;
946 s
<< initialSpinValue
;
947 m_spintext
= new wxTextCtrl( panel
, wxID_ANY
, s
);
948 gauge_page_second_row_sizer
->Add( m_spintext
, 0, wxALL
, 5 );
951 m_spinbutton
= new wxSpinButton( panel
, ID_SPIN
);
952 m_spinbutton
->SetRange(-40,30);
953 m_spinbutton
->SetValue(initialSpinValue
);
954 gauge_page_second_row_sizer
->Add( m_spinbutton
, 0, wxALL
, 5 );
955 #endif // wxUSE_SPINBTN
958 m_spinctrl
= new wxSpinCtrl( panel
, ID_SPINCTRL
, wxEmptyString
);
959 m_spinctrl
->SetRange(-10,30);
960 m_spinctrl
->SetValue(15);
961 gauge_page_second_row_sizer
->Add( m_spinctrl
, 0, wxALL
, 5 );
962 #endif // wxUSE_SPINCTRL
965 #if wxUSE_PROGRESSDLG
966 m_btnProgress
= new wxButton( panel
, ID_BTNPROGRESS
, wxT("&Show progress dialog") );
967 gauge_page_second_row_sizer
->Add( m_btnProgress
, 0, wxALL
, 5 );
968 #endif // wxUSE_PROGRESSDLG
969 #endif // wxUSE_SPINBTN
971 wxButton
* newTextButton
= new wxButton( panel
, ID_BTNNEWTEXT
, wxT("New text"));
972 gauge_page_second_row_sizer
->Add( newTextButton
, 0, wxALL
, 5 );
974 gauge_page_vsizer
->Add(gauge_page_second_row_sizer
, 1);
975 panel
->SetSizer( gauge_page_vsizer
);
977 m_book
->AddPage(panel
, wxT("wxGauge"), false, Image_Gauge
);
978 #endif // wxUSE_SLIDER && wxUSE_GAUGE
981 // ------------------------------------------------------------------------
983 // ------------------------------------------------------------------------
985 panel
= new wxPanel(m_book
);
987 #if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
988 wxIcon icon
= wxArtProvider::GetIcon(wxART_INFORMATION
);
989 (void) new wxStaticBitmap( panel
, wxID_ANY
, icon
, wxPoint(10, 10) );
991 // VZ: don't leak memory
992 // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
993 // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
996 wxBitmap
bitmap( 100, 100 );
998 dc
.SelectObject( bitmap
);
999 dc
.SetBackground(*wxGREEN
);
1000 dc
.SetPen(*wxRED_PEN
);
1002 dc
.DrawEllipse(5, 5, 90, 90);
1003 dc
.DrawText(wxT("Bitmap"), 30, 40);
1004 dc
.SelectObject( wxNullBitmap
);
1006 wxPanel
*panel2
= new wxPanel(panel
, -1, wxPoint(100, 0), wxSize(100, 200));
1007 (void)new wxBitmapButton(panel2
, ID_BITMAP_BTN
, bitmap
, wxPoint(0, 20));
1008 (void)new wxToggleButton(panel2
, ID_BITMAP_BTN_ENABLE
,
1009 wxT("Enable/disable &bitmap"), wxPoint(0, 140));
1011 #if defined(__WXMSW__) || defined(__WXMOTIF__)
1012 // test for masked bitmap display
1013 bitmap
= wxBitmap(wxT("test2.bmp"), wxBITMAP_TYPE_BMP
);
1016 bitmap
.SetMask(new wxMask(bitmap
, *wxBLUE
));
1018 (void)new wxStaticBitmap(panel
, wxID_ANY
, bitmap
, wxPoint(300, 120));
1022 wxBitmap
bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION
)),
1023 bmp2(wxArtProvider::GetBitmap(wxART_WARNING
)),
1024 bmp3(wxArtProvider::GetBitmap(wxART_QUESTION
));
1025 wxBitmapButton
*bmpBtn
= new wxBitmapButton
1032 bmpBtn
->SetBitmapSelected(bmp2
);
1033 bmpBtn
->SetBitmapFocus(bmp3
);
1035 (void)new wxToggleButton(panel
, ID_BUTTON_LABEL
,
1036 wxT("&Toggle label"), wxPoint(250, 20));
1038 m_label
= new wxStaticText(panel
, wxID_ANY
, wxT("Label with some long text"),
1039 wxPoint(250, 60), wxDefaultSize
,
1040 wxALIGN_RIGHT
/*| wxST_NO_AUTORESIZE*/);
1041 m_label
->SetForegroundColour( *wxBLUE
);
1043 m_book
->AddPage(panel
, wxT("wxBitmapXXX"));
1045 // ------------------------------------------------------------------------
1047 // ------------------------------------------------------------------------
1049 panel
= new wxPanel(m_book
);
1051 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
1053 wxStaticBoxSizer
*csizer
=
1054 new wxStaticBoxSizer (new wxStaticBox (panel
, wxID_ANY
, wxT("Show Buttons")), wxHORIZONTAL
);
1056 wxCheckBox
*check1
, *check2
, *check3
, *check4
, *check14
, *checkBig
;
1057 check1
= new wxCheckBox (panel
, ID_SIZER_CHECK1
, wxT("1"));
1058 check1
->SetValue (true);
1059 csizer
->Add (check1
);
1060 check2
= new wxCheckBox (panel
, ID_SIZER_CHECK2
, wxT("2"));
1061 check2
->SetValue (true);
1062 csizer
->Add (check2
);
1063 check3
= new wxCheckBox (panel
, ID_SIZER_CHECK3
, wxT("3"));
1064 check3
->SetValue (true);
1065 csizer
->Add (check3
);
1066 check4
= new wxCheckBox (panel
, ID_SIZER_CHECK4
, wxT("4"));
1067 check4
->SetValue (true);
1068 csizer
->Add (check4
);
1069 check14
= new wxCheckBox (panel
, ID_SIZER_CHECK14
, wxT("1-4"));
1070 check14
->SetValue (true);
1071 csizer
->Add (check14
);
1072 checkBig
= new wxCheckBox (panel
, ID_SIZER_CHECKBIG
, wxT("Big"));
1073 checkBig
->SetValue (true);
1074 csizer
->Add (checkBig
);
1076 sizer
->Add (csizer
);
1078 m_hsizer
= new wxBoxSizer( wxHORIZONTAL
);
1080 m_buttonSizer
= new wxBoxSizer (wxVERTICAL
);
1082 m_sizerBtn1
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &1 (tab order 1)") );
1083 m_buttonSizer
->Add( m_sizerBtn1
, 0, wxALL
, 10 );
1084 m_sizerBtn2
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &2 (tab order 3)") );
1085 m_buttonSizer
->Add( m_sizerBtn2
, 0, wxALL
, 10 );
1086 m_sizerBtn3
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &3 (tab order 2)") );
1087 m_buttonSizer
->Add( m_sizerBtn3
, 0, wxALL
, 10 );
1088 m_sizerBtn4
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &4 (tab order 4)") );
1089 m_buttonSizer
->Add( m_sizerBtn4
, 0, wxALL
, 10 );
1091 m_sizerBtn3
->MoveBeforeInTabOrder(m_sizerBtn2
);
1093 m_hsizer
->Add (m_buttonSizer
);
1094 m_hsizer
->Add( 20,20, 1 );
1095 m_bigBtn
= new wxButton(panel
, wxID_ANY
, wxT("Multiline\nbutton") );
1096 m_hsizer
->Add( m_bigBtn
, 3, wxGROW
|wxALL
, 10 );
1098 sizer
->Add (m_hsizer
, 1, wxGROW
);
1100 panel
->SetSizer( sizer
);
1102 m_book
->AddPage(panel
, wxT("wxSizer"));
1104 // set the sizer for the panel itself
1105 sizer
= new wxBoxSizer(wxVERTICAL
);
1106 sizer
->Add(m_book
, wxSizerFlags().Border().Expand());
1107 sizer
->Add(m_text
, wxSizerFlags(1).Border().Expand());
1112 #endif // wxUSE_TOOLTIPS
1120 void ResetToolTip(wxWindow
*win
, const char *tip
)
1122 wxCHECK_RET( win
, "NULL window?" );
1124 win
->UnsetToolTip();
1125 win
->SetToolTip(tip
);
1130 void MyPanel::SetAllToolTips()
1132 ResetToolTip(FindWindow(ID_LISTBOX_FONT
), "Press here to set italic font");
1133 ResetToolTip(m_checkbox
, "Click here to disable the listbox");
1134 ResetToolTip(m_listbox
, "This is a list box");
1135 ResetToolTip(m_combo
, "This is a natural\ncombobox - can you believe me?");
1136 ResetToolTip(m_slider
, "This is a sliding slider");
1137 ResetToolTip(FindWindow(ID_RADIOBOX2
), "Ever seen a radiobox?");
1139 //ResetToolTip(m_radio, "Tooltip for the entire radiobox");
1140 for ( unsigned int nb
= 0; nb
< m_radio
->GetCount(); nb
++ )
1142 m_radio
->SetItemToolTip(nb
, "");
1143 m_radio
->SetItemToolTip(nb
, "tooltip for\n" + m_radio
->GetString(nb
));
1146 // remove the tooltip for one of the items
1147 m_radio
->SetItemToolTip(2, "");
1149 #endif // wxUSE_TOOLTIPS
1151 void MyPanel::OnIdle(wxIdleEvent
& event
)
1153 static const int INVALID_SELECTION
= -2;
1155 static int s_selCombo
= INVALID_SELECTION
;
1157 if (!m_combo
|| !m_choice
)
1163 int sel
= m_combo
->GetSelection();
1164 if ( sel
!= s_selCombo
)
1166 if ( s_selCombo
!= INVALID_SELECTION
)
1168 wxLogMessage(wxT("EVT_IDLE: combobox selection changed from %d to %d"),
1175 static int s_selChoice
= INVALID_SELECTION
;
1176 sel
= m_choice
->GetSelection();
1177 if ( sel
!= s_selChoice
)
1179 if ( s_selChoice
!= INVALID_SELECTION
)
1181 wxLogMessage(wxT("EVT_IDLE: choice selection changed from %d to %d"),
1191 void MyPanel::OnPageChanging( wxBookCtrlEvent
&event
)
1193 int selOld
= event
.GetOldSelection();
1196 if ( wxMessageBox(wxT("This demonstrates how a program may prevent the\n")
1197 wxT("page change from taking place - if you select\n")
1198 wxT("[No] the current page will stay the third one\n"),
1199 wxT("Control sample"),
1200 wxICON_QUESTION
| wxYES_NO
, this) != wxYES
)
1208 *m_text
<< wxT("Book selection is being changed from ") << selOld
1209 << wxT(" to ") << event
.GetSelection()
1210 << wxT(" (current page from book is ")
1211 << m_book
->GetSelection() << wxT(")\n");
1214 void MyPanel::OnPageChanged( wxBookCtrlEvent
&event
)
1216 *m_text
<< wxT("Book selection is now ") << event
.GetSelection()
1217 << wxT(" (from book: ") << m_book
->GetSelection()
1221 void MyPanel::OnTestButton(wxCommandEvent
& event
)
1223 wxLogMessage(wxT("Button %c clicked."),
1224 event
.GetId() == ID_BUTTON_TEST1
? wxT('1') : wxT('2'));
1227 void MyPanel::OnBmpButton(wxCommandEvent
& WXUNUSED(event
))
1229 wxLogMessage(wxT("Bitmap button clicked."));
1232 void MyPanel::OnBmpButtonToggle(wxCommandEvent
& event
)
1234 FindWindow(ID_BITMAP_BTN
)->Enable(!event
.IsChecked());
1237 void MyPanel::OnChangeColour(wxCommandEvent
& WXUNUSED(event
))
1239 static wxColour s_colOld
;
1241 SetThemeEnabled(false);
1242 // test panel colour changing and propagation to the subcontrols
1243 if ( s_colOld
.IsOk() )
1245 SetBackgroundColour(s_colOld
);
1246 s_colOld
= wxNullColour
;
1248 m_lbSelectThis
->SetForegroundColour(wxNullColour
);
1249 m_lbSelectThis
->SetBackgroundColour(wxNullColour
);
1253 s_colOld
= wxColour(wxT("red"));
1254 SetBackgroundColour(wxT("white"));
1256 m_lbSelectThis
->SetForegroundColour(wxT("white"));
1257 m_lbSelectThis
->SetBackgroundColour(wxT("red"));
1260 m_lbSelectThis
->Refresh();
1264 void MyPanel::OnListBox( wxCommandEvent
&event
)
1266 wxListBox
*listbox
= event
.GetId() == ID_LISTBOX
? m_listbox
1269 bool deselect
= false;
1270 if (listbox
->HasFlag(wxLB_MULTIPLE
) || listbox
->HasFlag(wxLB_EXTENDED
))
1272 deselect
= !event
.IsSelection();
1274 m_text
->AppendText( wxT("ListBox deselection event\n") );
1277 m_text
->AppendText( wxT("ListBox event selection string is: '") );
1278 m_text
->AppendText( event
.GetString() );
1279 m_text
->AppendText( wxT("'\n") );
1281 // can't use GetStringSelection() with multiple selections, there could be
1282 // more than one of them
1283 if ( !listbox
->HasFlag(wxLB_MULTIPLE
) && !listbox
->HasFlag(wxLB_EXTENDED
) )
1285 m_text
->AppendText( wxT("ListBox control selection string is: '") );
1286 m_text
->AppendText( listbox
->GetStringSelection() );
1287 m_text
->AppendText( wxT("'\n") );
1290 wxStringClientData
*obj
= ((wxStringClientData
*)event
.GetClientObject());
1291 m_text
->AppendText( wxT("ListBox event client data string is: '") );
1292 if (obj
) // BC++ doesn't like use of '? .. : .. ' in this context
1293 m_text
->AppendText( obj
->GetData() );
1295 m_text
->AppendText( wxString(wxT("none")) );
1297 m_text
->AppendText( wxT("'\n") );
1298 m_text
->AppendText( wxT("ListBox control client data string is: '") );
1299 obj
= (wxStringClientData
*)listbox
->GetClientObject(event
.GetInt());
1301 m_text
->AppendText( obj
->GetData() );
1303 m_text
->AppendText( wxString(wxT("none")) );
1304 m_text
->AppendText( wxT("'\n") );
1307 void MyPanel::OnListBoxDoubleClick( wxCommandEvent
&event
)
1309 m_text
->AppendText( wxT("ListBox double click string is: ") );
1310 m_text
->AppendText( event
.GetString() );
1311 m_text
->AppendText( wxT("\n") );
1314 void MyPanel::OnListBoxButtons( wxCommandEvent
&event
)
1316 switch (event
.GetId())
1318 case ID_LISTBOX_ENABLE
:
1320 m_text
->AppendText(wxT("Checkbox clicked.\n"));
1322 wxCheckBox
*cb
= (wxCheckBox
*)event
.GetEventObject();
1324 cb
->SetToolTip( wxT("Click to enable listbox") );
1326 cb
->SetToolTip( wxT("Click to disable listbox") );
1327 #endif // wxUSE_TOOLTIPS
1328 m_listbox
->Enable( event
.GetInt() == 0 );
1329 m_lbSelectThis
->Enable( event
.GetInt() == 0 );
1330 m_lbSelectNum
->Enable( event
.GetInt() == 0 );
1331 m_listboxSorted
->Enable( event
.GetInt() == 0 );
1332 FindWindow(ID_CHANGE_COLOUR
)->Enable( event
.GetInt() == 0 );
1335 case ID_LISTBOX_SEL_NUM
:
1337 if (m_listbox
->GetCount() > 2)
1338 m_listbox
->SetSelection( 2 );
1339 if (m_listboxSorted
->GetCount() > 2)
1340 m_listboxSorted
->SetSelection( 2 );
1341 m_lbSelectThis
->WarpPointer( 40, 14 );
1344 case ID_LISTBOX_SEL_STR
:
1346 if (m_listbox
->FindString(wxT("This")) != wxNOT_FOUND
)
1347 m_listbox
->SetStringSelection( wxT("This") );
1348 if (m_listboxSorted
->FindString(wxT("This")) != wxNOT_FOUND
)
1349 m_listboxSorted
->SetStringSelection( wxT("This") );
1350 m_lbSelectNum
->WarpPointer( 40, 14 );
1353 case ID_LISTBOX_CLEAR
:
1356 m_listboxSorted
->Clear();
1359 case ID_LISTBOX_APPEND
:
1361 m_listbox
->Append( wxT("Hi kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk!") );
1362 m_listboxSorted
->Append( wxT("Hi hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!") );
1365 case ID_LISTBOX_DELETE
:
1368 idx
= m_listbox
->GetSelection();
1369 if ( idx
!= wxNOT_FOUND
)
1370 m_listbox
->Delete( idx
);
1371 idx
= m_listboxSorted
->GetSelection();
1372 if ( idx
!= wxNOT_FOUND
)
1373 m_listboxSorted
->Delete( idx
);
1376 case ID_LISTBOX_FONT
:
1378 m_listbox
->SetFont( *wxITALIC_FONT
);
1379 m_listboxSorted
->SetFont( *wxITALIC_FONT
);
1380 m_checkbox
->SetFont( *wxITALIC_FONT
);
1388 static wxString
GetDataString(wxClientData
*data
)
1390 return data
? static_cast<wxStringClientData
*>(data
)->GetData()
1394 void MyPanel::OnChoice( wxCommandEvent
&event
)
1396 wxChoice
*choice
= event
.GetId() == ID_CHOICE
? m_choice
1399 const int sel
= choice
->GetSelection();
1401 wxClientData
*dataEvt
= event
.GetClientObject(),
1402 *dataCtrl
= choice
->GetClientObject(sel
);
1404 wxLogMessage(wxT("EVT_CHOICE: item %d/%d (event/control), ")
1405 wxT("string \"%s\"/\"%s\", ")
1406 wxT("data \"%s\"/\"%s\""),
1407 (int)event
.GetInt(),
1410 choice
->GetStringSelection(),
1411 GetDataString(dataEvt
),
1412 GetDataString(dataCtrl
));
1415 void MyPanel::OnChoiceButtons( wxCommandEvent
&event
)
1417 switch (event
.GetId())
1419 case ID_CHOICE_ENABLE
:
1421 m_choice
->Enable( event
.GetInt() == 0 );
1422 m_choiceSorted
->Enable( event
.GetInt() == 0 );
1425 case ID_CHOICE_SEL_NUM
:
1427 m_choice
->SetSelection( 2 );
1428 m_choiceSorted
->SetSelection( 2 );
1431 case ID_CHOICE_SEL_STR
:
1433 m_choice
->SetStringSelection( wxT("This") );
1434 m_choiceSorted
->SetStringSelection( wxT("This") );
1437 case ID_CHOICE_CLEAR
:
1440 m_choiceSorted
->Clear();
1443 case ID_CHOICE_APPEND
:
1445 m_choice
->Append( wxT("Hi!") );
1446 m_choiceSorted
->Append( wxT("Hi!") );
1449 case ID_CHOICE_DELETE
:
1451 int idx
= m_choice
->GetSelection();
1452 if ( idx
!= wxNOT_FOUND
)
1453 m_choice
->Delete( idx
);
1454 idx
= m_choiceSorted
->GetSelection();
1455 if ( idx
!= wxNOT_FOUND
)
1456 m_choiceSorted
->Delete( idx
);
1459 case ID_CHOICE_FONT
:
1461 m_choice
->SetFont( *wxITALIC_FONT
);
1462 m_choiceSorted
->SetFont( *wxITALIC_FONT
);
1467 #endif // wxUSE_CHOICE
1469 void MyPanel::OnCombo( wxCommandEvent
&event
)
1474 wxLogMessage(wxT("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
1475 (int)event
.GetInt(),
1476 m_combo
->GetSelection(),
1477 event
.GetString().c_str(),
1478 m_combo
->GetStringSelection().c_str());
1481 void MyPanel::OnComboTextChanged(wxCommandEvent
& event
)
1485 wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
1486 event
.GetString().c_str(),
1487 m_combo
->GetValue().c_str());
1491 void MyPanel::OnComboTextEnter(wxCommandEvent
& WXUNUSED(event
))
1495 wxLogMessage(wxT("Enter pressed in the combobox: value is '%s'."),
1496 m_combo
->GetValue().c_str());
1500 void MyPanel::OnComboButtons( wxCommandEvent
&event
)
1502 switch (event
.GetId())
1504 case ID_COMBO_ENABLE
:
1506 m_combo
->Enable( event
.GetInt() == 0 );
1509 case ID_COMBO_SEL_NUM
:
1511 m_combo
->SetSelection( 2 );
1514 case ID_COMBO_SEL_STR
:
1516 m_combo
->SetStringSelection( wxT("This") );
1519 case ID_COMBO_CLEAR
:
1524 case ID_COMBO_APPEND
:
1526 m_combo
->Append( wxT("Hi!") );
1529 case ID_COMBO_DELETE
:
1531 int idx
= m_combo
->GetSelection();
1532 m_combo
->Delete( idx
);
1537 m_combo
->SetFont( *wxITALIC_FONT
);
1540 case ID_COMBO_SET_TEXT
:
1542 m_combo
->SetString( 2, wxT("Hi!") );
1548 void MyPanel::OnRadio( wxCommandEvent
&event
)
1550 m_text
->AppendText( wxT("RadioBox selection string is: ") );
1551 m_text
->AppendText( event
.GetString() );
1552 m_text
->AppendText( wxT("\n") );
1555 void MyPanel::OnRadioButton1( wxCommandEvent
& WXUNUSED(event
) )
1557 wxMessageBox(wxT("First wxRadioButton selected."), wxT("wxControl sample"));
1560 void MyPanel::OnRadioButton2( wxCommandEvent
& WXUNUSED(event
) )
1562 m_text
->AppendText(wxT("Second wxRadioButton selected.\n"));
1565 void MyPanel::OnRadioButtons( wxCommandEvent
&event
)
1567 switch (event
.GetId())
1569 case ID_RADIOBOX_ENABLE
:
1570 m_radio
->Enable( event
.GetInt() == 0 );
1573 case ID_RADIOBOX_SEL_NUM
:
1574 m_radio
->SetSelection( 2 );
1577 case ID_RADIOBOX_SEL_STR
:
1578 m_radio
->SetStringSelection( wxT("This") );
1581 case ID_RADIOBOX_FONT
:
1582 m_radio
->SetFont( *wxITALIC_FONT
);
1587 void MyPanel::OnSetFont( wxCommandEvent
&WXUNUSED(event
) )
1589 m_fontButton
->SetFont( *wxITALIC_FONT
);
1590 m_text
->SetFont( *wxITALIC_FONT
);
1593 void MyPanel::OnUpdateLabel( wxCommandEvent
&event
)
1595 m_label
->SetLabel(event
.GetInt() ? wxT("Very very very very very long text.")
1596 : wxT("Shorter text."));
1601 void MyPanel::OnSliderUpdate( wxCommandEvent
&WXUNUSED(event
) )
1604 m_gauge
->SetValue( m_slider
->GetValue() );
1605 m_gaugeVert
->SetValue( m_slider
->GetValue() / 2 );
1606 #endif // wxUSE_GAUGE
1609 #endif // wxUSE_SLIDER
1613 void MyPanel::OnSpinCtrlText(wxCommandEvent
& event
)
1618 s
.Printf( wxT("Spin ctrl text changed: now %d (from event: %s)\n"),
1619 m_spinctrl
->GetValue(), event
.GetString().c_str() );
1620 m_text
->AppendText(s
);
1624 void MyPanel::OnSpinCtrl(wxSpinEvent
& event
)
1629 s
.Printf( wxT("Spin ctrl changed: now %d (from event: %d)\n"),
1630 m_spinctrl
->GetValue(), event
.GetInt() );
1631 m_text
->AppendText(s
);
1635 void MyPanel::OnSpinCtrlUp(wxSpinEvent
& event
)
1639 m_text
->AppendText( wxString::Format(
1640 wxT("Spin up: %d (from event: %d)\n"),
1641 m_spinctrl
->GetValue(), event
.GetInt() ) );
1645 void MyPanel::OnSpinCtrlDown(wxSpinEvent
& event
)
1649 m_text
->AppendText( wxString::Format(
1650 wxT("Spin down: %d (from event: %d)\n"),
1651 m_spinctrl
->GetValue(), event
.GetInt() ) );
1655 #endif // wxUSE_SPINCTRL
1658 void MyPanel::OnSpinUp( wxSpinEvent
&event
)
1661 value
.Printf( wxT("Spin control up: current = %d\n"),
1662 m_spinbutton
->GetValue());
1664 if ( event
.GetPosition() > 17 )
1666 value
+= wxT("Preventing the spin button from going above 17.\n");
1671 m_text
->AppendText(value
);
1674 void MyPanel::OnSpinDown( wxSpinEvent
&event
)
1677 value
.Printf( wxT("Spin control down: current = %d\n"),
1678 m_spinbutton
->GetValue());
1680 if ( event
.GetPosition() < -17 )
1682 value
+= wxT("Preventing the spin button from going below -17.\n");
1687 m_text
->AppendText(value
);
1690 void MyPanel::OnSpinUpdate( wxSpinEvent
&event
)
1693 value
.Printf( wxT("%d"), event
.GetPosition() );
1694 m_spintext
->SetValue( value
);
1696 value
.Printf( wxT("Spin control range: (%d, %d), current = %d\n"),
1697 m_spinbutton
->GetMin(), m_spinbutton
->GetMax(),
1698 m_spinbutton
->GetValue());
1700 m_text
->AppendText(value
);
1703 void MyPanel::OnNewText( wxCommandEvent
& /* event */)
1705 m_nonWrappingText
->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") );
1706 m_wrappingText
->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );
1707 m_wrappingText
->GetParent()->Layout();
1710 #if wxUSE_PROGRESSDLG
1712 void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent
& event
)
1714 event
.Enable( m_spinbutton
->GetValue() > 0 );
1717 void MyPanel::OnShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1719 int max
= m_spinbutton
->GetValue();
1723 wxLogError(wxT("You must set positive range!"));
1727 wxProgressDialog
dialog(wxT("Progress dialog example"),
1728 wxT("An informative message"),
1735 wxPD_ESTIMATED_TIME
|
1736 wxPD_REMAINING_TIME
);
1740 for ( int i
= 0; i
<= max
&& cont
; i
++ )
1745 cont
= dialog
.Update(i
, wxT("That's all, folks!"));
1747 else if ( i
== max
/ 2 )
1749 cont
= dialog
.Update(i
, wxT("Only a half left (very long message)!"));
1753 cont
= dialog
.Update(i
);
1759 *m_text
<< wxT("Progress dialog aborted!\n");
1763 *m_text
<< wxT("Countdown from ") << max
<< wxT(" finished.\n");
1767 #endif // wxUSE_PROGRESSDLG
1768 #endif // wxUSE_SPINBTN
1770 void MyPanel::OnSizerCheck( wxCommandEvent
&event
)
1772 switch (event
.GetId ()) {
1773 case ID_SIZER_CHECK1
:
1774 m_buttonSizer
->Show (m_sizerBtn1
, event
.IsChecked ());
1775 m_buttonSizer
->Layout ();
1777 case ID_SIZER_CHECK2
:
1778 m_buttonSizer
->Show (m_sizerBtn2
, event
.IsChecked ());
1779 m_buttonSizer
->Layout ();
1781 case ID_SIZER_CHECK3
:
1782 m_buttonSizer
->Show (m_sizerBtn3
, event
.IsChecked ());
1783 m_buttonSizer
->Layout ();
1785 case ID_SIZER_CHECK4
:
1786 m_buttonSizer
->Show (m_sizerBtn4
, event
.IsChecked ());
1787 m_buttonSizer
->Layout ();
1789 case ID_SIZER_CHECK14
:
1790 m_hsizer
->Show (m_buttonSizer
, event
.IsChecked ());
1791 m_hsizer
->Layout ();
1793 case ID_SIZER_CHECKBIG
:
1794 m_hsizer
->Show (m_bigBtn
, event
.IsChecked ());
1795 m_hsizer
->Layout ();
1803 //wxLog::RemoveTraceMask(wxT("focus"));
1804 delete wxLog::SetActiveTarget(m_logTargetOld
);
1806 delete m_book
->GetImageList();
1809 //----------------------------------------------------------------------
1811 //----------------------------------------------------------------------
1813 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
1814 EVT_MENU(CONTROLS_QUIT
, MyFrame::OnQuit
)
1815 EVT_MENU(CONTROLS_ABOUT
, MyFrame::OnAbout
)
1816 EVT_MENU(CONTROLS_CLEAR_LOG
, MyFrame::OnClearLog
)
1818 EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY
, MyFrame::OnSetTooltipDelay
)
1819 EVT_MENU(CONTROLS_ENABLE_TOOLTIPS
, MyFrame::OnToggleTooltips
)
1821 EVT_MENU(CONTROLS_SET_TOOLTIPS_MAX_WIDTH
, MyFrame::OnSetMaxTooltipWidth
)
1823 #endif // wxUSE_TOOLTIPS
1825 EVT_MENU(CONTROLS_ENABLE_ALL
, MyFrame::OnEnableAll
)
1826 EVT_MENU(CONTROLS_HIDE_ALL
, MyFrame::OnHideAll
)
1827 EVT_MENU(CONTROLS_HIDE_LIST
, MyFrame::OnHideList
)
1828 EVT_MENU(CONTROLS_CONTEXT_HELP
, MyFrame::OnContextHelp
)
1830 EVT_ICONIZE(MyFrame::OnIconized
)
1831 EVT_MAXIMIZE(MyFrame::OnMaximized
)
1832 EVT_SIZE(MyFrame::OnSize
)
1833 EVT_MOVE(MyFrame::OnMove
)
1835 EVT_IDLE(MyFrame::OnIdle
)
1838 MyFrame::MyFrame(const wxChar
*title
, int x
, int y
)
1839 : wxFrame(NULL
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(700, 450))
1841 SetHelpText( wxT("Controls sample demonstrating various widgets") );
1844 // The wxICON() macros loads an icon from a resource under Windows
1845 // and uses an #included XPM image under GTK+ and Motif
1847 SetIcon( wxICON(sample
) );
1849 wxMenu
*file_menu
= new wxMenu
;
1851 file_menu
->Append(CONTROLS_CLEAR_LOG
, wxT("&Clear log\tCtrl-L"));
1852 file_menu
->AppendSeparator();
1853 file_menu
->Append(CONTROLS_ABOUT
, wxT("&About\tF1"));
1854 file_menu
->AppendSeparator();
1855 file_menu
->Append(CONTROLS_QUIT
, wxT("E&xit\tAlt-X"), wxT("Quit controls sample"));
1857 wxMenuBar
*menu_bar
= new wxMenuBar
;
1858 menu_bar
->Append(file_menu
, wxT("&File"));
1861 wxMenu
*tooltip_menu
= new wxMenu
;
1862 tooltip_menu
->Append(CONTROLS_SET_TOOLTIP_DELAY
, wxT("Set &delay\tCtrl-D"));
1863 tooltip_menu
->AppendSeparator();
1864 tooltip_menu
->Append(CONTROLS_ENABLE_TOOLTIPS
, wxT("&Toggle tooltips\tCtrl-T"),
1865 wxT("enable/disable tooltips"), true);
1866 tooltip_menu
->Check(CONTROLS_ENABLE_TOOLTIPS
, true);
1868 tooltip_menu
->Append(CONTROLS_SET_TOOLTIPS_MAX_WIDTH
, "Set maximal &width");
1870 menu_bar
->Append(tooltip_menu
, wxT("&Tooltips"));
1871 #endif // wxUSE_TOOLTIPS
1873 wxMenu
*panel_menu
= new wxMenu
;
1874 panel_menu
->Append(CONTROLS_ENABLE_ALL
, wxT("&Disable all\tCtrl-E"),
1875 wxT("Enable/disable all panel controls"), true);
1876 panel_menu
->Append(CONTROLS_HIDE_ALL
, wxT("&Hide all\tCtrl-I"),
1877 wxT("Show/hide thoe whole panel controls"), true);
1878 panel_menu
->Append(CONTROLS_HIDE_LIST
, wxT("Hide &list ctrl\tCtrl-S"),
1879 wxT("Enable/disable all panel controls"), true);
1880 panel_menu
->Append(CONTROLS_CONTEXT_HELP
, wxT("&Context help...\tCtrl-H"),
1881 wxT("Get context help for a control"));
1882 menu_bar
->Append(panel_menu
, wxT("&Panel"));
1884 SetMenuBar(menu_bar
);
1888 #endif // wxUSE_STATUSBAR
1890 m_panel
= new MyPanel( this, 10, 10, 300, 100 );
1893 void MyFrame::OnQuit (wxCommandEvent
& WXUNUSED(event
) )
1898 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
1902 wxMessageDialog
dialog(this, wxT("This is a control sample"), wxT("About Controls"), wxOK
);
1906 void MyFrame::OnClearLog(wxCommandEvent
& WXUNUSED(event
))
1908 m_panel
->m_text
->Clear();
1912 void MyFrame::OnSetTooltipDelay(wxCommandEvent
& WXUNUSED(event
))
1914 static long s_delay
= 5000;
1917 delay
.Printf( wxT("%ld"), s_delay
);
1919 delay
= wxGetTextFromUser(wxT("Enter delay (in milliseconds)"),
1920 wxT("Set tooltip delay"),
1924 return; // cancelled
1926 wxSscanf(delay
, wxT("%ld"), &s_delay
);
1928 wxToolTip::SetDelay(s_delay
);
1930 wxLogStatus(this, wxT("Tooltip delay set to %ld milliseconds"), s_delay
);
1933 void MyFrame::OnToggleTooltips(wxCommandEvent
& WXUNUSED(event
))
1935 static bool s_enabled
= true;
1937 s_enabled
= !s_enabled
;
1939 wxToolTip::Enable(s_enabled
);
1941 wxLogStatus(this, wxT("Tooltips %sabled"), s_enabled
? wxT("en") : wxT("dis") );
1946 void MyFrame::OnSetMaxTooltipWidth(wxCommandEvent
& WXUNUSED(event
))
1948 static int s_maxWidth
= 0;
1950 wxNumberEntryDialog dlg
1953 "Change maximal tooltip width",
1954 "&Width in pixels:",
1960 if ( dlg
.ShowModal() == wxID_CANCEL
)
1963 s_maxWidth
= dlg
.GetValue();
1964 wxToolTip::SetMaxWidth(s_maxWidth
);
1966 // we need to set the tooltip again to test the new width
1967 m_panel
->SetAllToolTips();
1972 #endif // wxUSE_TOOLTIPS
1974 void MyFrame::OnEnableAll(wxCommandEvent
& WXUNUSED(event
))
1976 static bool s_enable
= true;
1978 s_enable
= !s_enable
;
1979 m_panel
->Enable(s_enable
);
1980 static bool s_enableCheckbox
= true;
1983 // this is a test for correct behaviour of either enabling or disabling
1984 // a child when its parent is disabled: the checkbox should have the
1985 // correct state when the parent is enabled back
1986 m_panel
->m_checkbox
->Enable(s_enableCheckbox
);
1987 s_enableCheckbox
= !s_enableCheckbox
;
1991 void MyFrame::OnHideAll(wxCommandEvent
& WXUNUSED(event
))
1993 static bool s_show
= true;
1996 m_panel
->Show(s_show
);
1999 void MyFrame::OnHideList(wxCommandEvent
& WXUNUSED(event
))
2001 static bool s_show
= true;
2004 m_panel
->m_listbox
->Show(s_show
);
2007 void MyFrame::OnContextHelp(wxCommandEvent
& WXUNUSED(event
))
2009 // starts a local event loop
2010 wxContextHelp
chelp(this);
2013 void MyFrame::OnMove( wxMoveEvent
& event
)
2016 UpdateStatusBar(event
.GetPosition(), GetSize());
2017 #endif // wxUSE_STATUSBAR
2022 void MyFrame::OnIconized( wxIconizeEvent
& event
)
2024 wxLogMessage(wxT("Frame %s"), event
.IsIconized() ? wxT("iconized")
2029 void MyFrame::OnMaximized( wxMaximizeEvent
& WXUNUSED(event
) )
2031 wxLogMessage(wxT("Frame maximized"));
2034 void MyFrame::OnSize( wxSizeEvent
& event
)
2037 UpdateStatusBar(GetPosition(), event
.GetSize());
2038 #endif // wxUSE_STATUSBAR
2043 void MyFrame::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
2045 // track the window which has the focus in the status bar
2046 static wxWindow
*s_windowFocus
= NULL
;
2047 wxWindow
*focus
= wxWindow::FindFocus();
2048 if ( focus
!= s_windowFocus
)
2050 s_windowFocus
= focus
;
2060 , s_windowFocus
->GetName().c_str()
2062 , (unsigned int) s_windowFocus
->GetHWND()
2068 msg
= wxT("No focus");
2073 #endif // wxUSE_STATUSBAR
2077 void MyComboBox::OnChar(wxKeyEvent
& event
)
2079 wxLogMessage(wxT("MyComboBox::OnChar"));
2081 if ( event
.GetKeyCode() == 'w' )
2083 wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
2091 void MyComboBox::OnKeyDown(wxKeyEvent
& event
)
2093 wxLogMessage(wxT("MyComboBox::OnKeyDown"));
2095 if ( event
.GetKeyCode() == 'w' )
2097 wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
2105 void MyComboBox::OnKeyUp(wxKeyEvent
& event
)
2107 wxLogMessage(wxT("MyComboBox::OnKeyUp"));
2112 static void SetListboxClientData(const wxChar
*name
, wxListBox
*control
)
2114 size_t count
= control
->GetCount();
2115 for ( size_t n
= 0; n
< count
; n
++ )
2118 s
.Printf(wxT("%s client data for '%s'"),
2119 name
, control
->GetString(n
).c_str());
2121 control
->SetClientObject(n
, new wxStringClientData(s
));
2127 static void SetChoiceClientData(const wxChar
*name
, wxChoice
*control
)
2129 size_t count
= control
->GetCount();
2130 for ( size_t n
= 0; n
< count
; n
++ )
2133 s
.Printf(wxT("%s client data for '%s'"),
2134 name
, control
->GetString(n
).c_str());
2136 control
->SetClientObject(n
, new wxStringClientData(s
));
2140 #endif // wxUSE_CHOICE