1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Controls wxWidgets sample
4 // Author: Robert Roebling
6 // Copyright: (c) Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
21 #include "wx/spinbutt.h"
22 #include "wx/tglbtn.h"
23 #include "wx/bookctrl.h"
24 #include "wx/imaglist.h"
25 #include "wx/artprov.h"
26 #include "wx/cshelp.h"
27 #include "wx/gbsizer.h"
30 #include "wx/tooltip.h"
32 #include "wx/numdlg.h"
34 #endif // wxUSE_TOOLTIPS
37 #include "icons/choice.xpm"
38 #include "icons/combo.xpm"
39 #include "icons/list.xpm"
40 #include "icons/radio.xpm"
41 #include "icons/text.xpm"
42 #include "icons/gauge.xpm"
46 #define wxUSE_SPINBTN 1
49 #include "wx/progdlg.h"
52 #include "wx/spinctrl.h"
53 #endif // wxUSE_SPINCTRL
56 #define wxToggleButton wxCheckBox
57 #define EVT_TOGGLEBUTTON EVT_CHECKBOX
60 #ifndef wxHAS_IMAGES_IN_RESOURCES
61 #include "../sample.xpm"
64 //----------------------------------------------------------------------
66 //----------------------------------------------------------------------
68 class MyApp
: public wxApp
74 class MyPanel
: public wxPanel
77 MyPanel(wxFrame
*frame
, int x
, int y
, int w
, int h
);
81 void SetAllToolTips();
82 #endif // wxUSE_TOOLTIPS
84 void OnIdle( wxIdleEvent
&event
);
85 void OnListBox( wxCommandEvent
&event
);
86 void OnListBoxDoubleClick( wxCommandEvent
&event
);
87 void OnListBoxButtons( wxCommandEvent
&event
);
89 void OnChoice( wxCommandEvent
&event
);
90 void OnChoiceButtons( wxCommandEvent
&event
);
92 void OnCombo( wxCommandEvent
&event
);
93 void OnComboTextChanged( wxCommandEvent
&event
);
94 void OnComboTextEnter( wxCommandEvent
&event
);
95 void OnComboButtons( wxCommandEvent
&event
);
96 void OnRadio( wxCommandEvent
&event
);
97 void OnRadioButtons( wxCommandEvent
&event
);
98 void OnRadioButton1( wxCommandEvent
&event
);
99 void OnRadioButton2( wxCommandEvent
&event
);
100 void OnSetFont( wxCommandEvent
&event
);
101 void OnPageChanged( wxBookCtrlEvent
&event
);
102 void OnPageChanging( wxBookCtrlEvent
&event
);
103 void OnSliderUpdate( wxCommandEvent
&event
);
104 void OnUpdateLabel( wxCommandEvent
&event
);
106 void OnSpinUp( wxSpinEvent
&event
);
107 void OnSpinDown( wxSpinEvent
&event
);
108 void OnSpinUpdate( wxSpinEvent
&event
);
109 #if wxUSE_PROGRESSDLG
110 void OnUpdateShowProgress( wxUpdateUIEvent
& event
);
111 void OnShowProgress( wxCommandEvent
&event
);
112 #endif // wxUSE_PROGRESSDLG
113 #endif // wxUSE_SPINBTN
114 void OnNewText( wxCommandEvent
&event
);
116 void OnSpinCtrl(wxSpinEvent
& event
);
117 void OnSpinCtrlUp(wxSpinEvent
& event
);
118 void OnSpinCtrlDown(wxSpinEvent
& event
);
119 void OnSpinCtrlText(wxCommandEvent
& event
);
120 #endif // wxUSE_SPINCTRL
122 void OnEnableAll(wxCommandEvent
& event
);
123 void OnChangeColour(wxCommandEvent
& event
);
124 void OnTestButton(wxCommandEvent
& event
);
125 void OnBmpButton(wxCommandEvent
& event
);
126 void OnBmpButtonToggle(wxCommandEvent
& event
);
128 void OnSizerCheck (wxCommandEvent
&event
);
130 wxListBox
*m_listbox
,
135 #endif // wxUSE_CHOICE
142 #endif // wxUSE_GAUGE
145 #endif // wxUSE_SLIDER
146 wxButton
*m_fontButton
;
147 wxButton
*m_lbSelectNum
;
148 wxButton
*m_lbSelectThis
;
150 wxSpinButton
*m_spinbutton
;
151 #if wxUSE_PROGRESSDLG
152 wxButton
*m_btnProgress
;
153 #endif // wxUSE_PROGRESSDLG
154 #endif // wxUSE_SPINBTN
155 wxStaticText
*m_wrappingText
;
156 wxStaticText
*m_nonWrappingText
;
159 wxSpinCtrl
*m_spinctrl
;
160 #endif // wxUSE_SPINCTRL
162 wxTextCtrl
*m_spintext
;
163 wxCheckBox
*m_checkbox
;
168 wxStaticText
*m_label
;
170 wxBoxSizer
*m_buttonSizer
;
171 wxButton
*m_sizerBtn1
;
172 wxButton
*m_sizerBtn2
;
173 wxButton
*m_sizerBtn3
;
174 wxButton
*m_sizerBtn4
;
175 wxBoxSizer
*m_hsizer
;
179 wxLog
*m_logTargetOld
;
181 DECLARE_EVENT_TABLE()
184 class MyFrame
: public wxFrame
187 MyFrame(const wxChar
*title
, int x
, int y
);
189 void OnQuit(wxCommandEvent
& event
);
190 void OnAbout(wxCommandEvent
& event
);
191 void OnClearLog(wxCommandEvent
& event
);
194 void OnSetTooltipDelay(wxCommandEvent
& event
);
195 void OnToggleTooltips(wxCommandEvent
& event
);
197 void OnSetMaxTooltipWidth(wxCommandEvent
& event
);
199 #endif // wxUSE_TOOLTIPS
201 void OnEnableAll(wxCommandEvent
& event
);
202 void OnHideAll(wxCommandEvent
& event
);
203 void OnHideList(wxCommandEvent
& event
);
204 void OnContextHelp(wxCommandEvent
& event
);
206 void OnIdle( wxIdleEvent
& event
);
207 void OnIconized( wxIconizeEvent
& event
);
208 void OnMaximized( wxMaximizeEvent
& event
);
209 void OnSize( wxSizeEvent
& event
);
210 void OnMove( wxMoveEvent
& event
);
212 MyPanel
*GetPanel() const { return m_panel
; }
216 void UpdateStatusBar(const wxPoint
& pos
, const wxSize
& size
)
218 if ( m_frameStatusBar
)
221 wxSize sizeAll
= GetSize(),
222 sizeCl
= GetClientSize();
223 msg
.Printf(_("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)"),
226 sizeAll
.x
, sizeAll
.y
,
228 SetStatusText(msg
, 1);
231 #endif // wxUSE_STATUSBAR
235 DECLARE_EVENT_TABLE()
238 // a button which intercepts double clicks (for testing...)
239 class MyButton
: public wxButton
242 MyButton(wxWindow
*parent
,
244 const wxString
& label
= wxEmptyString
,
245 const wxPoint
& pos
= wxDefaultPosition
,
246 const wxSize
& size
= wxDefaultSize
)
247 : wxButton(parent
, id
, label
, pos
, size
)
251 void OnDClick(wxMouseEvent
& event
)
253 wxLogMessage(wxT("MyButton::OnDClick"));
259 DECLARE_EVENT_TABLE()
262 // a combo which intercepts chars (to test Windows behaviour)
263 class MyComboBox
: public wxComboBox
266 MyComboBox(wxWindow
*parent
, wxWindowID id
,
267 const wxString
& value
= wxEmptyString
,
268 const wxPoint
& pos
= wxDefaultPosition
,
269 const wxSize
& size
= wxDefaultSize
,
270 int n
= 0, const wxString choices
[] = NULL
,
272 const wxValidator
& validator
= wxDefaultValidator
,
273 const wxString
& name
= wxComboBoxNameStr
)
274 : wxComboBox(parent
, id
, value
, pos
, size
, n
, choices
, style
,
278 void OnChar(wxKeyEvent
& event
);
279 void OnKeyDown(wxKeyEvent
& event
);
280 void OnKeyUp(wxKeyEvent
& event
);
281 void OnFocusGot(wxFocusEvent
& event
)
283 wxLogMessage(wxT("MyComboBox::OnFocusGot"));
289 DECLARE_EVENT_TABLE()
292 // a radiobox which handles focus set/kill (for testing)
293 class MyRadioBox
: public wxRadioBox
296 MyRadioBox(wxWindow
*parent
,
298 const wxString
& title
= wxEmptyString
,
299 const wxPoint
& pos
= wxDefaultPosition
,
300 const wxSize
& size
= wxDefaultSize
,
301 int n
= 0, const wxString choices
[] = NULL
,
303 long style
= wxRA_SPECIFY_COLS
,
304 const wxValidator
& validator
= wxDefaultValidator
,
305 const wxString
& name
= wxRadioBoxNameStr
)
306 : wxRadioBox(parent
, id
, title
, pos
, size
, n
, choices
, majorDim
,
307 style
, validator
, name
)
312 void OnFocusGot(wxFocusEvent
& event
)
314 wxLogMessage(wxT("MyRadioBox::OnFocusGot"));
319 void OnFocusLost(wxFocusEvent
& event
)
321 wxLogMessage(wxT("MyRadioBox::OnFocusLost"));
327 DECLARE_EVENT_TABLE()
330 // a choice which handles focus set/kill (for testing)
331 class MyChoice
: public wxChoice
334 MyChoice(wxWindow
*parent
,
336 const wxPoint
& pos
= wxDefaultPosition
,
337 const wxSize
& size
= wxDefaultSize
,
338 int n
= 0, const wxString choices
[] = NULL
,
340 const wxValidator
& validator
= wxDefaultValidator
,
341 const wxString
& name
= wxChoiceNameStr
)
342 : wxChoice(parent
, id
, pos
, size
, n
, choices
,
343 style
, validator
, name
) { }
346 void OnFocusGot(wxFocusEvent
& event
)
348 wxLogMessage(wxT("MyChoice::OnFocusGot"));
353 void OnFocusLost(wxFocusEvent
& event
)
355 wxLogMessage(wxT("MyChoice::OnFocusLost"));
361 DECLARE_EVENT_TABLE()
366 //----------------------------------------------------------------------
368 //----------------------------------------------------------------------
370 static void SetListboxClientData(const wxChar
*name
, wxListBox
*control
);
373 static void SetChoiceClientData(const wxChar
*name
, wxChoice
*control
);
374 #endif // wxUSE_CHOICE
378 //----------------------------------------------------------------------
380 //----------------------------------------------------------------------
384 CONTROLS_QUIT
= wxID_EXIT
,
385 CONTROLS_ABOUT
= wxID_ABOUT
,
390 CONTROLS_SET_TOOLTIP_DELAY
= 200,
391 CONTROLS_ENABLE_TOOLTIPS
,
392 CONTROLS_SET_TOOLTIPS_MAX_WIDTH
,
398 CONTROLS_CONTEXT_HELP
403 // use standard command line handling:
404 if ( !wxApp::OnInit() )
407 // parse the cmd line
412 wxSscanf(wxString(argv
[1]), wxT("%d"), &x
);
413 wxSscanf(wxString(argv
[2]), wxT("%d"), &y
);
417 wxHelpProvider::Set( new wxSimpleHelpProvider
);
420 // Create the main frame window
421 MyFrame
*frame
= new MyFrame(wxT("Controls wxWidgets App"), x
, y
);
427 //----------------------------------------------------------------------
429 //----------------------------------------------------------------------
431 const int ID_BOOK
= 1000;
433 const int ID_LISTBOX
= 130;
434 const int ID_LISTBOX_SEL_NUM
= 131;
435 const int ID_LISTBOX_SEL_STR
= 132;
436 const int ID_LISTBOX_CLEAR
= 133;
437 const int ID_LISTBOX_APPEND
= 134;
438 const int ID_LISTBOX_DELETE
= 135;
439 const int ID_LISTBOX_FONT
= 136;
440 const int ID_LISTBOX_ENABLE
= 137;
441 const int ID_LISTBOX_SORTED
= 138;
443 const int ID_CHOICE
= 120;
444 const int ID_CHOICE_SEL_NUM
= 121;
445 const int ID_CHOICE_SEL_STR
= 122;
446 const int ID_CHOICE_CLEAR
= 123;
447 const int ID_CHOICE_APPEND
= 124;
448 const int ID_CHOICE_DELETE
= 125;
449 const int ID_CHOICE_FONT
= 126;
450 const int ID_CHOICE_ENABLE
= 127;
451 const int ID_CHOICE_SORTED
= 128;
453 const int ID_COMBO
= 140;
454 const int ID_COMBO_SEL_NUM
= 141;
455 const int ID_COMBO_SEL_STR
= 142;
456 const int ID_COMBO_CLEAR
= 143;
457 const int ID_COMBO_APPEND
= 144;
458 const int ID_COMBO_DELETE
= 145;
459 const int ID_COMBO_FONT
= 146;
460 const int ID_COMBO_ENABLE
= 147;
461 const int ID_COMBO_SET_TEXT
= 148;
463 const int ID_RADIOBOX
= 160;
464 const int ID_RADIOBOX_SEL_NUM
= 161;
465 const int ID_RADIOBOX_SEL_STR
= 162;
466 const int ID_RADIOBOX_FONT
= 163;
467 const int ID_RADIOBOX_ENABLE
= 164;
468 const int ID_RADIOBOX2
= 165;
469 const int ID_RADIOBUTTON_1
= 166;
470 const int ID_RADIOBUTTON_2
= 167;
472 const int ID_SET_FONT
= 170;
475 const int ID_GAUGE
= 180;
476 #endif // wxUSE_GAUGE
479 const int ID_SLIDER
= 181;
480 #endif // wxUSE_SLIDER
482 const int ID_SPIN
= 182;
483 #if wxUSE_PROGRESSDLG
484 const int ID_BTNPROGRESS
= 183;
485 #endif // wxUSE_PROGRESSDLG
486 const int ID_BUTTON_LABEL
= 184;
487 const int ID_SPINCTRL
= 185;
488 const int ID_BTNNEWTEXT
= 186;
490 const int ID_BUTTON_TEST1
= 190;
491 const int ID_BUTTON_TEST2
= 191;
492 const int ID_BITMAP_BTN
= 192;
493 const int ID_BITMAP_BTN_ENABLE
= 193;
495 const int ID_CHANGE_COLOUR
= 200;
497 const int ID_SIZER_CHECK1
= 201;
498 const int ID_SIZER_CHECK2
= 202;
499 const int ID_SIZER_CHECK3
= 203;
500 const int ID_SIZER_CHECK4
= 204;
501 const int ID_SIZER_CHECK14
= 205;
502 const int ID_SIZER_CHECKBIG
= 206;
504 const int ID_HYPERLINK
= 300;
506 BEGIN_EVENT_TABLE(MyPanel
, wxPanel
)
507 EVT_IDLE ( MyPanel::OnIdle
)
508 EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK
, MyPanel::OnPageChanging
)
509 EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK
, MyPanel::OnPageChanged
)
510 EVT_LISTBOX (ID_LISTBOX
, MyPanel::OnListBox
)
511 EVT_LISTBOX (ID_LISTBOX_SORTED
, MyPanel::OnListBox
)
512 EVT_LISTBOX_DCLICK(ID_LISTBOX
, MyPanel::OnListBoxDoubleClick
)
513 EVT_BUTTON (ID_LISTBOX_SEL_NUM
, MyPanel::OnListBoxButtons
)
514 EVT_BUTTON (ID_LISTBOX_SEL_STR
, MyPanel::OnListBoxButtons
)
515 EVT_BUTTON (ID_LISTBOX_CLEAR
, MyPanel::OnListBoxButtons
)
516 EVT_BUTTON (ID_LISTBOX_APPEND
, MyPanel::OnListBoxButtons
)
517 EVT_BUTTON (ID_LISTBOX_DELETE
, MyPanel::OnListBoxButtons
)
518 EVT_BUTTON (ID_LISTBOX_FONT
, MyPanel::OnListBoxButtons
)
519 EVT_CHECKBOX (ID_LISTBOX_ENABLE
, MyPanel::OnListBoxButtons
)
521 EVT_CHOICE (ID_CHOICE
, MyPanel::OnChoice
)
522 EVT_CHOICE (ID_CHOICE_SORTED
, MyPanel::OnChoice
)
523 EVT_BUTTON (ID_CHOICE_SEL_NUM
, MyPanel::OnChoiceButtons
)
524 EVT_BUTTON (ID_CHOICE_SEL_STR
, MyPanel::OnChoiceButtons
)
525 EVT_BUTTON (ID_CHOICE_CLEAR
, MyPanel::OnChoiceButtons
)
526 EVT_BUTTON (ID_CHOICE_APPEND
, MyPanel::OnChoiceButtons
)
527 EVT_BUTTON (ID_CHOICE_DELETE
, MyPanel::OnChoiceButtons
)
528 EVT_BUTTON (ID_CHOICE_FONT
, MyPanel::OnChoiceButtons
)
529 EVT_CHECKBOX (ID_CHOICE_ENABLE
, MyPanel::OnChoiceButtons
)
531 EVT_COMBOBOX (ID_COMBO
, MyPanel::OnCombo
)
532 EVT_TEXT (ID_COMBO
, MyPanel::OnComboTextChanged
)
533 EVT_TEXT_ENTER(ID_COMBO
, MyPanel::OnComboTextEnter
)
534 EVT_BUTTON (ID_COMBO_SEL_NUM
, MyPanel::OnComboButtons
)
535 EVT_BUTTON (ID_COMBO_SEL_STR
, MyPanel::OnComboButtons
)
536 EVT_BUTTON (ID_COMBO_CLEAR
, MyPanel::OnComboButtons
)
537 EVT_BUTTON (ID_COMBO_APPEND
, MyPanel::OnComboButtons
)
538 EVT_BUTTON (ID_COMBO_DELETE
, MyPanel::OnComboButtons
)
539 EVT_BUTTON (ID_COMBO_FONT
, MyPanel::OnComboButtons
)
540 EVT_BUTTON (ID_COMBO_SET_TEXT
, MyPanel::OnComboButtons
)
541 EVT_CHECKBOX (ID_COMBO_ENABLE
, MyPanel::OnComboButtons
)
542 EVT_RADIOBOX (ID_RADIOBOX
, MyPanel::OnRadio
)
543 EVT_RADIOBOX (ID_RADIOBOX2
, MyPanel::OnRadio
)
544 EVT_BUTTON (ID_RADIOBOX_SEL_NUM
, MyPanel::OnRadioButtons
)
545 EVT_BUTTON (ID_RADIOBOX_SEL_STR
, MyPanel::OnRadioButtons
)
546 EVT_BUTTON (ID_RADIOBOX_FONT
, MyPanel::OnRadioButtons
)
547 EVT_CHECKBOX (ID_RADIOBOX_ENABLE
, MyPanel::OnRadioButtons
)
548 EVT_RADIOBUTTON(ID_RADIOBUTTON_1
, MyPanel::OnRadioButton1
)
549 EVT_RADIOBUTTON(ID_RADIOBUTTON_2
, MyPanel::OnRadioButton2
)
550 EVT_BUTTON (ID_SET_FONT
, MyPanel::OnSetFont
)
552 EVT_SLIDER (ID_SLIDER
, MyPanel::OnSliderUpdate
)
553 #endif // wxUSE_SLIDER
555 EVT_SPIN (ID_SPIN
, MyPanel::OnSpinUpdate
)
556 EVT_SPIN_UP (ID_SPIN
, MyPanel::OnSpinUp
)
557 EVT_SPIN_DOWN (ID_SPIN
, MyPanel::OnSpinDown
)
558 #if wxUSE_PROGRESSDLG
559 EVT_UPDATE_UI (ID_BTNPROGRESS
, MyPanel::OnUpdateShowProgress
)
560 EVT_BUTTON (ID_BTNPROGRESS
, MyPanel::OnShowProgress
)
561 #endif // wxUSE_PROGRESSDLG
562 #endif // wxUSE_SPINBTN
564 EVT_SPINCTRL (ID_SPINCTRL
, MyPanel::OnSpinCtrl
)
565 EVT_SPIN_UP (ID_SPINCTRL
, MyPanel::OnSpinCtrlUp
)
566 EVT_SPIN_DOWN (ID_SPINCTRL
, MyPanel::OnSpinCtrlDown
)
567 EVT_TEXT (ID_SPINCTRL
, MyPanel::OnSpinCtrlText
)
568 #endif // wxUSE_SPINCTRL
569 EVT_BUTTON (ID_BTNNEWTEXT
, MyPanel::OnNewText
)
570 EVT_TOGGLEBUTTON(ID_BUTTON_LABEL
, MyPanel::OnUpdateLabel
)
571 EVT_CHECKBOX (ID_CHANGE_COLOUR
, MyPanel::OnChangeColour
)
572 EVT_BUTTON (ID_BUTTON_TEST1
, MyPanel::OnTestButton
)
573 EVT_BUTTON (ID_BUTTON_TEST2
, MyPanel::OnTestButton
)
574 EVT_BUTTON (ID_BITMAP_BTN
, MyPanel::OnBmpButton
)
575 EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE
, MyPanel::OnBmpButtonToggle
)
577 EVT_CHECKBOX (ID_SIZER_CHECK1
, MyPanel::OnSizerCheck
)
578 EVT_CHECKBOX (ID_SIZER_CHECK2
, MyPanel::OnSizerCheck
)
579 EVT_CHECKBOX (ID_SIZER_CHECK3
, MyPanel::OnSizerCheck
)
580 EVT_CHECKBOX (ID_SIZER_CHECK4
, MyPanel::OnSizerCheck
)
581 EVT_CHECKBOX (ID_SIZER_CHECK14
, MyPanel::OnSizerCheck
)
582 EVT_CHECKBOX (ID_SIZER_CHECKBIG
, MyPanel::OnSizerCheck
)
586 BEGIN_EVENT_TABLE(MyButton
, wxButton
)
587 EVT_LEFT_DCLICK(MyButton::OnDClick
)
590 BEGIN_EVENT_TABLE(MyComboBox
, wxComboBox
)
591 EVT_CHAR(MyComboBox::OnChar
)
592 EVT_KEY_DOWN(MyComboBox::OnKeyDown
)
593 EVT_KEY_UP(MyComboBox::OnKeyUp
)
595 EVT_SET_FOCUS(MyComboBox::OnFocusGot
)
598 BEGIN_EVENT_TABLE(MyRadioBox
, wxRadioBox
)
599 EVT_SET_FOCUS(MyRadioBox::OnFocusGot
)
600 EVT_KILL_FOCUS(MyRadioBox::OnFocusLost
)
603 BEGIN_EVENT_TABLE(MyChoice
, wxChoice
)
604 EVT_SET_FOCUS(MyChoice::OnFocusGot
)
605 EVT_KILL_FOCUS(MyChoice::OnFocusLost
)
608 // ============================================================================
610 // ============================================================================
612 MyPanel::MyPanel( wxFrame
*frame
, int x
, int y
, int w
, int h
)
613 : wxPanel( frame
, wxID_ANY
, wxPoint(x
, y
), wxSize(w
, h
) )
616 m_listboxSorted
= NULL
;
619 m_choiceSorted
= NULL
;
620 #endif // wxUSE_CHOICE
626 #endif // wxUSE_GAUGE
629 #endif // wxUSE_SLIDER
631 m_lbSelectNum
= NULL
;
632 m_lbSelectThis
= NULL
;
635 #if wxUSE_PROGRESSDLG
636 m_btnProgress
= NULL
;
637 #endif // wxUSE_PROGRESSDLG
638 #endif // wxUSE_SPINBTN
641 #endif // wxUSE_SPINCTRL
648 m_text
= new wxTextCtrl(this, wxID_ANY
, wxT("This is the log window.\n"),
649 wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE
);
651 m_logTargetOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_text
));
653 m_book
= new wxBookCtrl(this, ID_BOOK
);
659 wxT("one of my long and"),
675 #endif // wxUSE_GAUGE
679 // fill the image list
680 wxBitmap
bmp(list_xpm
);
682 wxImageList
*imagelist
= new wxImageList(bmp
.GetWidth(), bmp
.GetHeight());
684 imagelist
-> Add( bmp
);
685 imagelist
-> Add( wxBitmap( choice_xpm
));
686 imagelist
-> Add( wxBitmap( combo_xpm
));
687 imagelist
-> Add( wxBitmap( text_xpm
));
688 imagelist
-> Add( wxBitmap( radio_xpm
));
690 imagelist
-> Add( wxBitmap( gauge_xpm
));
691 #endif // wxUSE_GAUGE
692 m_book
->SetImageList(imagelist
);
694 // load images from resources
704 #endif // wxUSE_GAUGE
707 wxImageList
*imagelist
= new wxImageList(16, 16, false, Image_Max
);
709 static const wxChar
*s_iconNames
[Image_Max
] =
718 #endif // wxUSE_GAUGE
721 for ( size_t n
= 0; n
< Image_Max
; n
++ )
723 wxBitmap
bmp(s_iconNames
[n
]);
724 if ( !bmp
.IsOk() || (imagelist
->Add(bmp
) == -1) )
726 wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
731 m_book
->SetImageList(imagelist
);
734 // ------------------------------------------------------------------------
736 // ------------------------------------------------------------------------
737 wxPanel
*panel
= new wxPanel(m_book
);
738 m_listbox
= new wxListBox( panel
, ID_LISTBOX
,
739 wxPoint(10,10), wxSize(120,70),
740 5, choices
, wxLB_MULTIPLE
| wxLB_ALWAYS_SB
| wxHSCROLL
);
741 m_listboxSorted
= new wxListBox( panel
, ID_LISTBOX_SORTED
,
742 wxPoint(10,90), wxSize(120,70),
743 3, choices
, wxLB_SORT
);
745 SetListboxClientData(wxT("listbox"), m_listbox
);
746 SetListboxClientData(wxT("listbox"), m_listboxSorted
);
748 m_listbox
->SetCursor(*wxCROSS_CURSOR
);
750 m_lbSelectNum
= new wxButton( panel
, ID_LISTBOX_SEL_NUM
, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
751 m_lbSelectThis
= new wxButton( panel
, ID_LISTBOX_SEL_STR
, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
752 (void)new wxButton( panel
, ID_LISTBOX_CLEAR
, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
753 (void)new MyButton( panel
, ID_LISTBOX_APPEND
, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
754 (void)new wxButton( panel
, ID_LISTBOX_DELETE
, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
755 wxButton
*button
= new MyButton( panel
, ID_LISTBOX_FONT
, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
757 button
->SetDefault();
759 m_checkbox
= new wxCheckBox( panel
, ID_LISTBOX_ENABLE
, wxT("&Disable"), wxPoint(20,170) );
760 m_checkbox
->SetValue(false);
761 button
->MoveAfterInTabOrder(m_checkbox
);
762 (void)new wxCheckBox( panel
, ID_CHANGE_COLOUR
, wxT("&Toggle colour"),
764 panel
->SetCursor(wxCursor(wxCURSOR_HAND
));
765 m_book
->AddPage(panel
, wxT("wxListBox"), true, Image_List
);
767 // ------------------------------------------------------------------------
769 // ------------------------------------------------------------------------
771 panel
= new wxPanel(m_book
);
772 m_choice
= new MyChoice( panel
, ID_CHOICE
, wxPoint(10,10), wxDefaultSize
, 5, choices
);
773 m_choiceSorted
= new MyChoice( panel
, ID_CHOICE_SORTED
, wxPoint(10,70), wxSize(120,wxDefaultCoord
),
774 5, choices
, wxCB_SORT
);
776 SetChoiceClientData(wxT("choice"), m_choice
);
777 SetChoiceClientData(wxT("choice"), m_choiceSorted
);
779 m_choice
->SetSelection(2);
780 (void)new wxButton( panel
, ID_CHOICE_SEL_NUM
, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
781 (void)new wxButton( panel
, ID_CHOICE_SEL_STR
, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
782 (void)new wxButton( panel
, ID_CHOICE_CLEAR
, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
783 (void)new wxButton( panel
, ID_CHOICE_APPEND
, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
784 (void)new wxButton( panel
, ID_CHOICE_DELETE
, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
785 (void)new wxButton( panel
, ID_CHOICE_FONT
, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
786 (void)new wxCheckBox( panel
, ID_CHOICE_ENABLE
, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
788 m_book
->AddPage(panel
, wxT("wxChoice"), false, Image_Choice
);
789 #endif // wxUSE_CHOICE
791 // ------------------------------------------------------------------------
793 // ------------------------------------------------------------------------
794 panel
= new wxPanel(m_book
);
795 m_combo
= new MyComboBox( panel
, ID_COMBO
, wxT("This"),
796 wxPoint(15,25), wxDefaultSize
,
799 wxSize
combosize(m_combo
->GetBestSize().x
+ 20, 100);
800 (void)new wxStaticBox( panel
, wxID_ANY
, wxT("&Box around combobox"),
801 wxPoint(5, 5), combosize
);
803 (void)new wxButton( panel
, ID_COMBO_SEL_NUM
, wxT("Select #&2"), wxPoint(220,30), wxSize(140,30) );
804 (void)new wxButton( panel
, ID_COMBO_SEL_STR
, wxT("&Select 'This'"), wxPoint(380,30), wxSize(140,30) );
805 (void)new wxButton( panel
, ID_COMBO_CLEAR
, wxT("&Clear"), wxPoint(220,80), wxSize(140,30) );
806 (void)new wxButton( panel
, ID_COMBO_APPEND
, wxT("&Append 'Hi!'"), wxPoint(380,80), wxSize(140,30) );
807 (void)new wxButton( panel
, ID_COMBO_DELETE
, wxT("D&elete selected item"), wxPoint(220,130), wxSize(140,30) );
808 (void)new wxButton( panel
, ID_COMBO_FONT
, wxT("Set &Italic font"), wxPoint(380,130), wxSize(140,30) );
809 (void)new wxButton( panel
, ID_COMBO_SET_TEXT
, wxT("Set 'Hi!' at #2"), wxPoint(380,180), wxSize(140,30) );
810 (void)new wxCheckBox( panel
, ID_COMBO_ENABLE
, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
811 m_book
->AddPage(panel
, wxT("wxComboBox"), false, Image_Combo
);
813 // ------------------------------------------------------------------------
815 // ------------------------------------------------------------------------
816 wxString choices2
[] =
818 wxT("First"), wxT("Second"),
820 "Fourth", "Fifth", "Sixth",
821 "Seventh", "Eighth", "Nineth", "Tenth" */
824 panel
= new wxPanel(m_book
);
825 wxGridBagSizer
* radio_page_sizer
= new wxGridBagSizer(5, 5);
827 m_radio
= new wxRadioBox(panel
, ID_RADIOBOX
, wxT("T&his"),
828 wxPoint(10,10), wxDefaultSize
,
829 WXSIZEOF(choices
), choices
,
830 1, wxRA_SPECIFY_COLS
);
831 MyRadioBox
* mybox
= new MyRadioBox(panel
, ID_RADIOBOX2
, wxT("&That"),
832 wxPoint(10,160), wxDefaultSize
,
833 WXSIZEOF(choices2
), choices2
,
834 1, wxRA_SPECIFY_ROWS
);
836 radio_page_sizer
->Add( m_radio
, wxGBPosition(0,0), wxGBSpan(2,1) );
837 radio_page_sizer
->Add( mybox
, wxGBPosition(2,0), wxGBSpan(2,1) );
840 for (unsigned int item
= 0; item
< WXSIZEOF(choices
); ++item
)
841 m_radio
->SetItemHelpText( item
, wxString::Format( wxT("Help text for \"%s\""),
842 choices
[item
].c_str() ) );
844 // erase help text for the second item
845 m_radio
->SetItemHelpText( 1, wxT("") );
846 // set default help text for control
847 m_radio
->SetHelpText( wxT("Default helptext for wxRadioBox") );
850 wxButton
* select_two
= new wxButton ( panel
, ID_RADIOBOX_SEL_NUM
, wxT("Select #&2") );
851 wxButton
* select_this
= new wxButton ( panel
, ID_RADIOBOX_SEL_STR
, wxT("&Select 'This'") );
852 m_fontButton
= new wxButton ( panel
, ID_SET_FONT
, wxT("Set &more Italic font") );
853 wxButton
* set_italic
= new wxButton ( panel
, ID_RADIOBOX_FONT
, wxT("Set &Italic font") );
854 wxCheckBox
* disable_cb
= new wxCheckBox( panel
, ID_RADIOBOX_ENABLE
, wxT("&Disable") );
855 wxRadioButton
*rb
= new wxRadioButton( panel
, ID_RADIOBUTTON_1
, wxT("Radiobutton1"),
856 wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
);
857 wxRadioButton
*rb2
= new wxRadioButton( panel
, ID_RADIOBUTTON_2
, wxT("&Radiobutton2"),
858 wxDefaultPosition
, wxDefaultSize
);
859 rb
->SetValue( false );
861 radio_page_sizer
->Add( select_two
, wxGBPosition(0, 1), wxDefaultSpan
, wxALL
, 10 );
862 radio_page_sizer
->Add( select_this
, wxGBPosition(1, 1), wxDefaultSpan
, wxALL
, 10 );
863 radio_page_sizer
->Add( m_fontButton
, wxGBPosition(0, 2), wxDefaultSpan
, wxALL
, 10 );
864 radio_page_sizer
->Add( set_italic
, wxGBPosition(1, 2), wxDefaultSpan
, wxALL
, 10 );
865 radio_page_sizer
->Add( disable_cb
, wxGBPosition(2, 2), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
866 radio_page_sizer
->Add( rb
, wxGBPosition(3, 1), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
867 radio_page_sizer
->Add( rb2
, wxGBPosition(3, 2), wxDefaultSpan
, wxLEFT
| wxRIGHT
, 10 );
869 panel
->SetSizer( radio_page_sizer
);
871 m_book
->AddPage(panel
, wxT("wxRadioBox"), false, Image_Radio
);
873 // ------------------------------------------------------------------------
875 // ------------------------------------------------------------------------
877 #if wxUSE_SLIDER && wxUSE_GAUGE
878 panel
= new wxPanel(m_book
);
880 wxBoxSizer
*gauge_page_vsizer
= new wxBoxSizer( wxVERTICAL
);
882 wxBoxSizer
*gauge_page_first_row_sizer
= new wxBoxSizer( wxHORIZONTAL
);
884 wxStaticBoxSizer
*gauge_sizer
= new wxStaticBoxSizer( wxHORIZONTAL
, panel
, wxT("&wxGauge and wxSlider") );
885 gauge_page_first_row_sizer
->Add( gauge_sizer
, 0, wxALL
, 5 );
886 wxBoxSizer
*sz
= new wxBoxSizer( wxVERTICAL
);
887 gauge_sizer
->Add( sz
);
888 m_gauge
= new wxGauge( panel
, wxID_ANY
, 200, wxDefaultPosition
, wxSize(155, 30), wxGA_HORIZONTAL
|wxNO_BORDER
);
889 sz
->Add( m_gauge
, 0, wxALL
, 10 );
890 m_slider
= new wxSlider( panel
, ID_SLIDER
, 0, 0, 200,
891 wxDefaultPosition
, wxSize(155,wxDefaultCoord
),
892 wxSL_AUTOTICKS
| wxSL_LABELS
);
893 m_slider
->SetTickFreq(40);
894 sz
->Add( m_slider
, 0, wxALL
, 10 );
896 m_gaugeVert
= new wxGauge( panel
, wxID_ANY
, 100,
897 wxDefaultPosition
, wxSize(wxDefaultCoord
, 90),
898 wxGA_VERTICAL
| wxGA_SMOOTH
| wxNO_BORDER
);
899 gauge_sizer
->Add( m_gaugeVert
, 0, wxALL
, 10 );
903 wxStaticBox
*sb
= new wxStaticBox( panel
, wxID_ANY
, wxT("&Explanation"),
904 wxDefaultPosition
, wxDefaultSize
); //, wxALIGN_CENTER );
905 wxStaticBoxSizer
*wrapping_sizer
= new wxStaticBoxSizer( sb
, wxVERTICAL
);
906 gauge_page_first_row_sizer
->Add( wrapping_sizer
, 0, wxALL
, 5 );
909 // No wrapping text in wxStaticText yet :-(
910 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
911 wxT("Drag the slider!"),
913 wxSize(240, wxDefaultCoord
)
916 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
917 wxT("In order see the gauge (aka progress bar) ")
918 wxT("control do something you have to drag the ")
919 wxT("handle of the slider to the right.")
921 wxT("This is also supposed to demonstrate how ")
922 wxT("to use static controls with line wrapping."),
924 wxSize(240, wxDefaultCoord
)
927 wrapping_sizer
->Add( m_wrappingText
);
929 wxStaticBoxSizer
*non_wrapping_sizer
= new wxStaticBoxSizer( wxVERTICAL
, panel
, wxT("Non-wrapping") );
930 gauge_page_first_row_sizer
->Add( non_wrapping_sizer
, 0, wxALL
, 5 );
932 m_nonWrappingText
= new wxStaticText( panel
, wxID_ANY
,
933 wxT("This static text has two lines.\nThey do not wrap."),
937 non_wrapping_sizer
->Add( m_nonWrappingText
);
939 gauge_page_vsizer
->Add( gauge_page_first_row_sizer
, 1 );
940 wxBoxSizer
*gauge_page_second_row_sizer
= new wxBoxSizer( wxHORIZONTAL
);
943 int initialSpinValue
= -5;
945 s
<< initialSpinValue
;
946 m_spintext
= new wxTextCtrl( panel
, wxID_ANY
, s
);
947 gauge_page_second_row_sizer
->Add( m_spintext
, 0, wxALL
, 5 );
950 m_spinbutton
= new wxSpinButton( panel
, ID_SPIN
);
951 m_spinbutton
->SetRange(-40,30);
952 m_spinbutton
->SetValue(initialSpinValue
);
953 gauge_page_second_row_sizer
->Add( m_spinbutton
, 0, wxALL
, 5 );
954 #endif // wxUSE_SPINBTN
957 m_spinctrl
= new wxSpinCtrl( panel
, ID_SPINCTRL
, wxEmptyString
);
958 m_spinctrl
->SetRange(-10,30);
959 m_spinctrl
->SetValue(15);
960 gauge_page_second_row_sizer
->Add( m_spinctrl
, 0, wxALL
, 5 );
961 #endif // wxUSE_SPINCTRL
964 #if wxUSE_PROGRESSDLG
965 m_btnProgress
= new wxButton( panel
, ID_BTNPROGRESS
, wxT("&Show progress dialog") );
966 gauge_page_second_row_sizer
->Add( m_btnProgress
, 0, wxALL
, 5 );
967 #endif // wxUSE_PROGRESSDLG
968 #endif // wxUSE_SPINBTN
970 wxButton
* newTextButton
= new wxButton( panel
, ID_BTNNEWTEXT
, wxT("New text"));
971 gauge_page_second_row_sizer
->Add( newTextButton
, 0, wxALL
, 5 );
973 gauge_page_vsizer
->Add(gauge_page_second_row_sizer
, 1);
974 panel
->SetSizer( gauge_page_vsizer
);
976 m_book
->AddPage(panel
, wxT("wxGauge"), false, Image_Gauge
);
977 #endif // wxUSE_SLIDER && wxUSE_GAUGE
980 // ------------------------------------------------------------------------
982 // ------------------------------------------------------------------------
984 panel
= new wxPanel(m_book
);
986 #if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
987 wxIcon icon
= wxArtProvider::GetIcon(wxART_INFORMATION
);
988 (void) new wxStaticBitmap( panel
, wxID_ANY
, icon
, wxPoint(10, 10) );
990 // VZ: don't leak memory
991 // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
992 // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
995 wxBitmap
bitmap( 100, 100 );
997 dc
.SelectObject( bitmap
);
998 dc
.SetBackground(*wxGREEN
);
999 dc
.SetPen(*wxRED_PEN
);
1001 dc
.DrawEllipse(5, 5, 90, 90);
1002 dc
.DrawText(wxT("Bitmap"), 30, 40);
1003 dc
.SelectObject( wxNullBitmap
);
1005 wxPanel
*panel2
= new wxPanel(panel
, -1, wxPoint(100, 0), wxSize(100, 200));
1006 (void)new wxBitmapButton(panel2
, ID_BITMAP_BTN
, bitmap
, wxPoint(0, 20));
1007 (void)new wxToggleButton(panel2
, ID_BITMAP_BTN_ENABLE
,
1008 wxT("Enable/disable &bitmap"), wxPoint(0, 140));
1010 #if defined(__WXMSW__) || defined(__WXMOTIF__)
1011 // test for masked bitmap display
1012 bitmap
= wxBitmap(wxT("test2.bmp"), wxBITMAP_TYPE_BMP
);
1015 bitmap
.SetMask(new wxMask(bitmap
, *wxBLUE
));
1017 (void)new wxStaticBitmap(panel
, wxID_ANY
, bitmap
, wxPoint(300, 120));
1021 wxBitmap
bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION
)),
1022 bmp2(wxArtProvider::GetBitmap(wxART_WARNING
)),
1023 bmp3(wxArtProvider::GetBitmap(wxART_QUESTION
));
1024 wxBitmapButton
*bmpBtn
= new wxBitmapButton
1031 bmpBtn
->SetBitmapSelected(bmp2
);
1032 bmpBtn
->SetBitmapFocus(bmp3
);
1034 (void)new wxToggleButton(panel
, ID_BUTTON_LABEL
,
1035 wxT("&Toggle label"), wxPoint(250, 20));
1037 m_label
= new wxStaticText(panel
, wxID_ANY
, wxT("Label with some long text"),
1038 wxPoint(250, 60), wxDefaultSize
,
1039 wxALIGN_RIGHT
/*| wxST_NO_AUTORESIZE*/);
1040 m_label
->SetForegroundColour( *wxBLUE
);
1042 m_book
->AddPage(panel
, wxT("wxBitmapXXX"));
1044 // ------------------------------------------------------------------------
1046 // ------------------------------------------------------------------------
1048 panel
= new wxPanel(m_book
);
1050 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
1052 wxStaticBoxSizer
*csizer
=
1053 new wxStaticBoxSizer (new wxStaticBox (panel
, wxID_ANY
, wxT("Show Buttons")), wxHORIZONTAL
);
1055 wxCheckBox
*check1
, *check2
, *check3
, *check4
, *check14
, *checkBig
;
1056 check1
= new wxCheckBox (panel
, ID_SIZER_CHECK1
, wxT("1"));
1057 check1
->SetValue (true);
1058 csizer
->Add (check1
);
1059 check2
= new wxCheckBox (panel
, ID_SIZER_CHECK2
, wxT("2"));
1060 check2
->SetValue (true);
1061 csizer
->Add (check2
);
1062 check3
= new wxCheckBox (panel
, ID_SIZER_CHECK3
, wxT("3"));
1063 check3
->SetValue (true);
1064 csizer
->Add (check3
);
1065 check4
= new wxCheckBox (panel
, ID_SIZER_CHECK4
, wxT("4"));
1066 check4
->SetValue (true);
1067 csizer
->Add (check4
);
1068 check14
= new wxCheckBox (panel
, ID_SIZER_CHECK14
, wxT("1-4"));
1069 check14
->SetValue (true);
1070 csizer
->Add (check14
);
1071 checkBig
= new wxCheckBox (panel
, ID_SIZER_CHECKBIG
, wxT("Big"));
1072 checkBig
->SetValue (true);
1073 csizer
->Add (checkBig
);
1075 sizer
->Add (csizer
);
1077 m_hsizer
= new wxBoxSizer( wxHORIZONTAL
);
1079 m_buttonSizer
= new wxBoxSizer (wxVERTICAL
);
1081 m_sizerBtn1
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &1 (tab order 1)") );
1082 m_buttonSizer
->Add( m_sizerBtn1
, 0, wxALL
, 10 );
1083 m_sizerBtn2
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &2 (tab order 3)") );
1084 m_buttonSizer
->Add( m_sizerBtn2
, 0, wxALL
, 10 );
1085 m_sizerBtn3
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &3 (tab order 2)") );
1086 m_buttonSizer
->Add( m_sizerBtn3
, 0, wxALL
, 10 );
1087 m_sizerBtn4
= new wxButton(panel
, wxID_ANY
, wxT("Test Button &4 (tab order 4)") );
1088 m_buttonSizer
->Add( m_sizerBtn4
, 0, wxALL
, 10 );
1090 m_sizerBtn3
->MoveBeforeInTabOrder(m_sizerBtn2
);
1092 m_hsizer
->Add (m_buttonSizer
);
1093 m_hsizer
->Add( 20,20, 1 );
1094 m_bigBtn
= new wxButton(panel
, wxID_ANY
, wxT("Multiline\nbutton") );
1095 m_hsizer
->Add( m_bigBtn
, 3, wxGROW
|wxALL
, 10 );
1097 sizer
->Add (m_hsizer
, 1, wxGROW
);
1099 panel
->SetSizer( sizer
);
1101 m_book
->AddPage(panel
, wxT("wxSizer"));
1103 // set the sizer for the panel itself
1104 sizer
= new wxBoxSizer(wxVERTICAL
);
1105 sizer
->Add(m_book
, wxSizerFlags().Border().Expand());
1106 sizer
->Add(m_text
, wxSizerFlags(1).Border().Expand());
1111 #endif // wxUSE_TOOLTIPS
1119 void ResetToolTip(wxWindow
*win
, const char *tip
)
1121 wxCHECK_RET( win
, "NULL window?" );
1123 win
->UnsetToolTip();
1124 win
->SetToolTip(tip
);
1129 void MyPanel::SetAllToolTips()
1131 ResetToolTip(FindWindow(ID_LISTBOX_FONT
), "Press here to set italic font");
1132 ResetToolTip(m_checkbox
, "Click here to disable the listbox");
1133 ResetToolTip(m_listbox
, "This is a list box");
1134 ResetToolTip(m_combo
, "This is a natural\ncombobox - can you believe me?");
1135 ResetToolTip(m_slider
, "This is a sliding slider");
1136 ResetToolTip(FindWindow(ID_RADIOBOX2
), "Ever seen a radiobox?");
1138 //ResetToolTip(m_radio, "Tooltip for the entire radiobox");
1139 for ( unsigned int nb
= 0; nb
< m_radio
->GetCount(); nb
++ )
1141 m_radio
->SetItemToolTip(nb
, "");
1142 m_radio
->SetItemToolTip(nb
, "tooltip for\n" + m_radio
->GetString(nb
));
1145 // remove the tooltip for one of the items
1146 m_radio
->SetItemToolTip(2, "");
1148 #endif // wxUSE_TOOLTIPS
1150 void MyPanel::OnIdle(wxIdleEvent
& event
)
1152 static const int INVALID_SELECTION
= -2;
1154 static int s_selCombo
= INVALID_SELECTION
;
1156 if (!m_combo
|| !m_choice
)
1162 int sel
= m_combo
->GetSelection();
1163 if ( sel
!= s_selCombo
)
1165 if ( s_selCombo
!= INVALID_SELECTION
)
1167 wxLogMessage(wxT("EVT_IDLE: combobox selection changed from %d to %d"),
1174 static int s_selChoice
= INVALID_SELECTION
;
1175 sel
= m_choice
->GetSelection();
1176 if ( sel
!= s_selChoice
)
1178 if ( s_selChoice
!= INVALID_SELECTION
)
1180 wxLogMessage(wxT("EVT_IDLE: choice selection changed from %d to %d"),
1190 void MyPanel::OnPageChanging( wxBookCtrlEvent
&event
)
1192 int selOld
= event
.GetOldSelection();
1195 if ( wxMessageBox(wxT("This demonstrates how a program may prevent the\n")
1196 wxT("page change from taking place - if you select\n")
1197 wxT("[No] the current page will stay the third one\n"),
1198 wxT("Control sample"),
1199 wxICON_QUESTION
| wxYES_NO
, this) != wxYES
)
1207 *m_text
<< wxT("Book selection is being changed from ") << selOld
1208 << wxT(" to ") << event
.GetSelection()
1209 << wxT(" (current page from book is ")
1210 << m_book
->GetSelection() << wxT(")\n");
1213 void MyPanel::OnPageChanged( wxBookCtrlEvent
&event
)
1215 *m_text
<< wxT("Book selection is now ") << event
.GetSelection()
1216 << wxT(" (from book: ") << m_book
->GetSelection()
1220 void MyPanel::OnTestButton(wxCommandEvent
& event
)
1222 wxLogMessage(wxT("Button %c clicked."),
1223 event
.GetId() == ID_BUTTON_TEST1
? wxT('1') : wxT('2'));
1226 void MyPanel::OnBmpButton(wxCommandEvent
& WXUNUSED(event
))
1228 wxLogMessage(wxT("Bitmap button clicked."));
1231 void MyPanel::OnBmpButtonToggle(wxCommandEvent
& event
)
1233 FindWindow(ID_BITMAP_BTN
)->Enable(!event
.IsChecked());
1236 void MyPanel::OnChangeColour(wxCommandEvent
& WXUNUSED(event
))
1238 static wxColour s_colOld
;
1240 SetThemeEnabled(false);
1241 // test panel colour changing and propagation to the subcontrols
1242 if ( s_colOld
.IsOk() )
1244 SetBackgroundColour(s_colOld
);
1245 s_colOld
= wxNullColour
;
1247 m_lbSelectThis
->SetForegroundColour(wxNullColour
);
1248 m_lbSelectThis
->SetBackgroundColour(wxNullColour
);
1253 SetBackgroundColour(*wxWHITE
);
1255 m_lbSelectThis
->SetForegroundColour(wxT("white"));
1256 m_lbSelectThis
->SetBackgroundColour(wxT("red"));
1259 m_lbSelectThis
->Refresh();
1263 void MyPanel::OnListBox( wxCommandEvent
&event
)
1265 wxListBox
*listbox
= event
.GetId() == ID_LISTBOX
? m_listbox
1268 bool deselect
= false;
1269 if (listbox
->HasFlag(wxLB_MULTIPLE
) || listbox
->HasFlag(wxLB_EXTENDED
))
1271 deselect
= !event
.IsSelection();
1273 m_text
->AppendText( wxT("ListBox deselection event\n") );
1276 m_text
->AppendText( wxT("ListBox event selection string is: '") );
1277 m_text
->AppendText( event
.GetString() );
1278 m_text
->AppendText( wxT("'\n") );
1280 // can't use GetStringSelection() with multiple selections, there could be
1281 // more than one of them
1282 if ( !listbox
->HasFlag(wxLB_MULTIPLE
) && !listbox
->HasFlag(wxLB_EXTENDED
) )
1284 m_text
->AppendText( wxT("ListBox control selection string is: '") );
1285 m_text
->AppendText( listbox
->GetStringSelection() );
1286 m_text
->AppendText( wxT("'\n") );
1289 wxStringClientData
*obj
= ((wxStringClientData
*)event
.GetClientObject());
1290 m_text
->AppendText( wxT("ListBox event client data string is: '") );
1291 if (obj
) // BC++ doesn't like use of '? .. : .. ' in this context
1292 m_text
->AppendText( obj
->GetData() );
1294 m_text
->AppendText( wxString(wxT("none")) );
1296 m_text
->AppendText( wxT("'\n") );
1297 m_text
->AppendText( wxT("ListBox control client data string is: '") );
1298 obj
= (wxStringClientData
*)listbox
->GetClientObject(event
.GetInt());
1300 m_text
->AppendText( obj
->GetData() );
1302 m_text
->AppendText( wxString(wxT("none")) );
1303 m_text
->AppendText( wxT("'\n") );
1306 void MyPanel::OnListBoxDoubleClick( wxCommandEvent
&event
)
1308 m_text
->AppendText( wxT("ListBox double click string is: ") );
1309 m_text
->AppendText( event
.GetString() );
1310 m_text
->AppendText( wxT("\n") );
1313 void MyPanel::OnListBoxButtons( wxCommandEvent
&event
)
1315 switch (event
.GetId())
1317 case ID_LISTBOX_ENABLE
:
1319 m_text
->AppendText(wxT("Checkbox clicked.\n"));
1321 wxCheckBox
*cb
= (wxCheckBox
*)event
.GetEventObject();
1323 cb
->SetToolTip( wxT("Click to enable listbox") );
1325 cb
->SetToolTip( wxT("Click to disable listbox") );
1326 #endif // wxUSE_TOOLTIPS
1327 m_listbox
->Enable( event
.GetInt() == 0 );
1328 m_lbSelectThis
->Enable( event
.GetInt() == 0 );
1329 m_lbSelectNum
->Enable( event
.GetInt() == 0 );
1330 m_listboxSorted
->Enable( event
.GetInt() == 0 );
1331 FindWindow(ID_CHANGE_COLOUR
)->Enable( event
.GetInt() == 0 );
1334 case ID_LISTBOX_SEL_NUM
:
1336 if (m_listbox
->GetCount() > 2)
1337 m_listbox
->SetSelection( 2 );
1338 if (m_listboxSorted
->GetCount() > 2)
1339 m_listboxSorted
->SetSelection( 2 );
1340 m_lbSelectThis
->WarpPointer( 40, 14 );
1343 case ID_LISTBOX_SEL_STR
:
1345 if (m_listbox
->FindString(wxT("This")) != wxNOT_FOUND
)
1346 m_listbox
->SetStringSelection( wxT("This") );
1347 if (m_listboxSorted
->FindString(wxT("This")) != wxNOT_FOUND
)
1348 m_listboxSorted
->SetStringSelection( wxT("This") );
1349 m_lbSelectNum
->WarpPointer( 40, 14 );
1352 case ID_LISTBOX_CLEAR
:
1355 m_listboxSorted
->Clear();
1358 case ID_LISTBOX_APPEND
:
1360 m_listbox
->Append( wxT("Hi kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk!") );
1361 m_listboxSorted
->Append( wxT("Hi hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!") );
1364 case ID_LISTBOX_DELETE
:
1367 idx
= m_listbox
->GetSelection();
1368 if ( idx
!= wxNOT_FOUND
)
1369 m_listbox
->Delete( idx
);
1370 idx
= m_listboxSorted
->GetSelection();
1371 if ( idx
!= wxNOT_FOUND
)
1372 m_listboxSorted
->Delete( idx
);
1375 case ID_LISTBOX_FONT
:
1377 m_listbox
->SetFont( *wxITALIC_FONT
);
1378 m_listboxSorted
->SetFont( *wxITALIC_FONT
);
1379 m_checkbox
->SetFont( *wxITALIC_FONT
);
1387 static wxString
GetDataString(wxClientData
*data
)
1389 return data
? static_cast<wxStringClientData
*>(data
)->GetData()
1393 void MyPanel::OnChoice( wxCommandEvent
&event
)
1395 wxChoice
*choice
= event
.GetId() == ID_CHOICE
? m_choice
1398 const int sel
= choice
->GetSelection();
1400 wxClientData
*dataEvt
= event
.GetClientObject(),
1401 *dataCtrl
= choice
->GetClientObject(sel
);
1403 wxLogMessage(wxT("EVT_CHOICE: item %d/%d (event/control), ")
1404 wxT("string \"%s\"/\"%s\", ")
1405 wxT("data \"%s\"/\"%s\""),
1406 (int)event
.GetInt(),
1409 choice
->GetStringSelection(),
1410 GetDataString(dataEvt
),
1411 GetDataString(dataCtrl
));
1414 void MyPanel::OnChoiceButtons( wxCommandEvent
&event
)
1416 switch (event
.GetId())
1418 case ID_CHOICE_ENABLE
:
1420 m_choice
->Enable( event
.GetInt() == 0 );
1421 m_choiceSorted
->Enable( event
.GetInt() == 0 );
1424 case ID_CHOICE_SEL_NUM
:
1426 m_choice
->SetSelection( 2 );
1427 m_choiceSorted
->SetSelection( 2 );
1430 case ID_CHOICE_SEL_STR
:
1432 m_choice
->SetStringSelection( wxT("This") );
1433 m_choiceSorted
->SetStringSelection( wxT("This") );
1436 case ID_CHOICE_CLEAR
:
1439 m_choiceSorted
->Clear();
1442 case ID_CHOICE_APPEND
:
1444 m_choice
->Append( wxT("Hi!") );
1445 m_choiceSorted
->Append( wxT("Hi!") );
1448 case ID_CHOICE_DELETE
:
1450 int idx
= m_choice
->GetSelection();
1451 if ( idx
!= wxNOT_FOUND
)
1452 m_choice
->Delete( idx
);
1453 idx
= m_choiceSorted
->GetSelection();
1454 if ( idx
!= wxNOT_FOUND
)
1455 m_choiceSorted
->Delete( idx
);
1458 case ID_CHOICE_FONT
:
1460 m_choice
->SetFont( *wxITALIC_FONT
);
1461 m_choiceSorted
->SetFont( *wxITALIC_FONT
);
1466 #endif // wxUSE_CHOICE
1468 void MyPanel::OnCombo( wxCommandEvent
&event
)
1473 wxLogMessage(wxT("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
1474 (int)event
.GetInt(),
1475 m_combo
->GetSelection(),
1476 event
.GetString().c_str(),
1477 m_combo
->GetStringSelection().c_str());
1480 void MyPanel::OnComboTextChanged(wxCommandEvent
& event
)
1484 wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
1485 event
.GetString().c_str(),
1486 m_combo
->GetValue().c_str());
1490 void MyPanel::OnComboTextEnter(wxCommandEvent
& WXUNUSED(event
))
1494 wxLogMessage(wxT("Enter pressed in the combobox: value is '%s'."),
1495 m_combo
->GetValue().c_str());
1499 void MyPanel::OnComboButtons( wxCommandEvent
&event
)
1501 switch (event
.GetId())
1503 case ID_COMBO_ENABLE
:
1505 m_combo
->Enable( event
.GetInt() == 0 );
1508 case ID_COMBO_SEL_NUM
:
1510 m_combo
->SetSelection( 2 );
1513 case ID_COMBO_SEL_STR
:
1515 m_combo
->SetStringSelection( wxT("This") );
1518 case ID_COMBO_CLEAR
:
1523 case ID_COMBO_APPEND
:
1525 m_combo
->Append( wxT("Hi!") );
1528 case ID_COMBO_DELETE
:
1530 int idx
= m_combo
->GetSelection();
1531 m_combo
->Delete( idx
);
1536 m_combo
->SetFont( *wxITALIC_FONT
);
1539 case ID_COMBO_SET_TEXT
:
1541 m_combo
->SetString( 2, wxT("Hi!") );
1547 void MyPanel::OnRadio( wxCommandEvent
&event
)
1549 m_text
->AppendText( wxT("RadioBox selection string is: ") );
1550 m_text
->AppendText( event
.GetString() );
1551 m_text
->AppendText( wxT("\n") );
1554 void MyPanel::OnRadioButton1( wxCommandEvent
& WXUNUSED(event
) )
1556 wxMessageBox(wxT("First wxRadioButton selected."), wxT("wxControl sample"));
1559 void MyPanel::OnRadioButton2( wxCommandEvent
& WXUNUSED(event
) )
1561 m_text
->AppendText(wxT("Second wxRadioButton selected.\n"));
1564 void MyPanel::OnRadioButtons( wxCommandEvent
&event
)
1566 switch (event
.GetId())
1568 case ID_RADIOBOX_ENABLE
:
1569 m_radio
->Enable( event
.GetInt() == 0 );
1572 case ID_RADIOBOX_SEL_NUM
:
1573 m_radio
->SetSelection( 2 );
1576 case ID_RADIOBOX_SEL_STR
:
1577 m_radio
->SetStringSelection( wxT("This") );
1580 case ID_RADIOBOX_FONT
:
1581 m_radio
->SetFont( *wxITALIC_FONT
);
1586 void MyPanel::OnSetFont( wxCommandEvent
&WXUNUSED(event
) )
1588 m_fontButton
->SetFont( *wxITALIC_FONT
);
1589 m_text
->SetFont( *wxITALIC_FONT
);
1592 void MyPanel::OnUpdateLabel( wxCommandEvent
&event
)
1594 m_label
->SetLabel(event
.GetInt() ? wxT("Very very very very very long text.")
1595 : wxT("Shorter text."));
1600 void MyPanel::OnSliderUpdate( wxCommandEvent
&WXUNUSED(event
) )
1603 m_gauge
->SetValue( m_slider
->GetValue() );
1604 m_gaugeVert
->SetValue( m_slider
->GetValue() / 2 );
1605 #endif // wxUSE_GAUGE
1608 #endif // wxUSE_SLIDER
1612 void MyPanel::OnSpinCtrlText(wxCommandEvent
& event
)
1617 s
.Printf( wxT("Spin ctrl text changed: now %d (from event: %s)\n"),
1618 m_spinctrl
->GetValue(), event
.GetString().c_str() );
1619 m_text
->AppendText(s
);
1623 void MyPanel::OnSpinCtrl(wxSpinEvent
& event
)
1628 s
.Printf( wxT("Spin ctrl changed: now %d (from event: %d)\n"),
1629 m_spinctrl
->GetValue(), event
.GetInt() );
1630 m_text
->AppendText(s
);
1634 void MyPanel::OnSpinCtrlUp(wxSpinEvent
& event
)
1638 m_text
->AppendText( wxString::Format(
1639 wxT("Spin up: %d (from event: %d)\n"),
1640 m_spinctrl
->GetValue(), event
.GetInt() ) );
1644 void MyPanel::OnSpinCtrlDown(wxSpinEvent
& event
)
1648 m_text
->AppendText( wxString::Format(
1649 wxT("Spin down: %d (from event: %d)\n"),
1650 m_spinctrl
->GetValue(), event
.GetInt() ) );
1654 #endif // wxUSE_SPINCTRL
1657 void MyPanel::OnSpinUp( wxSpinEvent
&event
)
1660 value
.Printf( wxT("Spin control up: current = %d\n"),
1661 m_spinbutton
->GetValue());
1663 if ( event
.GetPosition() > 17 )
1665 value
+= wxT("Preventing the spin button from going above 17.\n");
1670 m_text
->AppendText(value
);
1673 void MyPanel::OnSpinDown( wxSpinEvent
&event
)
1676 value
.Printf( wxT("Spin control down: current = %d\n"),
1677 m_spinbutton
->GetValue());
1679 if ( event
.GetPosition() < -17 )
1681 value
+= wxT("Preventing the spin button from going below -17.\n");
1686 m_text
->AppendText(value
);
1689 void MyPanel::OnSpinUpdate( wxSpinEvent
&event
)
1692 value
.Printf( wxT("%d"), event
.GetPosition() );
1693 m_spintext
->SetValue( value
);
1695 value
.Printf( wxT("Spin control range: (%d, %d), current = %d\n"),
1696 m_spinbutton
->GetMin(), m_spinbutton
->GetMax(),
1697 m_spinbutton
->GetValue());
1699 m_text
->AppendText(value
);
1702 void MyPanel::OnNewText( wxCommandEvent
& /* event */)
1704 m_nonWrappingText
->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") );
1705 m_wrappingText
->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );
1706 m_wrappingText
->GetParent()->Layout();
1709 #if wxUSE_PROGRESSDLG
1711 void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent
& event
)
1713 event
.Enable( m_spinbutton
->GetValue() > 0 );
1716 void MyPanel::OnShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1718 int max
= m_spinbutton
->GetValue();
1722 wxLogError(wxT("You must set positive range!"));
1726 wxProgressDialog
dialog(wxT("Progress dialog example"),
1727 wxT("An informative message"),
1734 wxPD_ESTIMATED_TIME
|
1735 wxPD_REMAINING_TIME
);
1739 for ( int i
= 0; i
<= max
&& cont
; i
++ )
1744 cont
= dialog
.Update(i
, wxT("That's all, folks!"));
1746 else if ( i
== max
/ 2 )
1748 cont
= dialog
.Update(i
, wxT("Only a half left (very long message)!"));
1752 cont
= dialog
.Update(i
);
1758 *m_text
<< wxT("Progress dialog aborted!\n");
1762 *m_text
<< wxT("Countdown from ") << max
<< wxT(" finished.\n");
1766 #endif // wxUSE_PROGRESSDLG
1767 #endif // wxUSE_SPINBTN
1769 void MyPanel::OnSizerCheck( wxCommandEvent
&event
)
1771 switch (event
.GetId ()) {
1772 case ID_SIZER_CHECK1
:
1773 m_buttonSizer
->Show (m_sizerBtn1
, event
.IsChecked ());
1774 m_buttonSizer
->Layout ();
1776 case ID_SIZER_CHECK2
:
1777 m_buttonSizer
->Show (m_sizerBtn2
, event
.IsChecked ());
1778 m_buttonSizer
->Layout ();
1780 case ID_SIZER_CHECK3
:
1781 m_buttonSizer
->Show (m_sizerBtn3
, event
.IsChecked ());
1782 m_buttonSizer
->Layout ();
1784 case ID_SIZER_CHECK4
:
1785 m_buttonSizer
->Show (m_sizerBtn4
, event
.IsChecked ());
1786 m_buttonSizer
->Layout ();
1788 case ID_SIZER_CHECK14
:
1789 m_hsizer
->Show (m_buttonSizer
, event
.IsChecked ());
1790 m_hsizer
->Layout ();
1792 case ID_SIZER_CHECKBIG
:
1793 m_hsizer
->Show (m_bigBtn
, event
.IsChecked ());
1794 m_hsizer
->Layout ();
1802 //wxLog::RemoveTraceMask(wxT("focus"));
1803 delete wxLog::SetActiveTarget(m_logTargetOld
);
1805 delete m_book
->GetImageList();
1808 //----------------------------------------------------------------------
1810 //----------------------------------------------------------------------
1812 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
1813 EVT_MENU(CONTROLS_QUIT
, MyFrame::OnQuit
)
1814 EVT_MENU(CONTROLS_ABOUT
, MyFrame::OnAbout
)
1815 EVT_MENU(CONTROLS_CLEAR_LOG
, MyFrame::OnClearLog
)
1817 EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY
, MyFrame::OnSetTooltipDelay
)
1818 EVT_MENU(CONTROLS_ENABLE_TOOLTIPS
, MyFrame::OnToggleTooltips
)
1820 EVT_MENU(CONTROLS_SET_TOOLTIPS_MAX_WIDTH
, MyFrame::OnSetMaxTooltipWidth
)
1822 #endif // wxUSE_TOOLTIPS
1824 EVT_MENU(CONTROLS_ENABLE_ALL
, MyFrame::OnEnableAll
)
1825 EVT_MENU(CONTROLS_HIDE_ALL
, MyFrame::OnHideAll
)
1826 EVT_MENU(CONTROLS_HIDE_LIST
, MyFrame::OnHideList
)
1827 EVT_MENU(CONTROLS_CONTEXT_HELP
, MyFrame::OnContextHelp
)
1829 EVT_ICONIZE(MyFrame::OnIconized
)
1830 EVT_MAXIMIZE(MyFrame::OnMaximized
)
1831 EVT_SIZE(MyFrame::OnSize
)
1832 EVT_MOVE(MyFrame::OnMove
)
1834 EVT_IDLE(MyFrame::OnIdle
)
1837 MyFrame::MyFrame(const wxChar
*title
, int x
, int y
)
1838 : wxFrame(NULL
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(700, 450))
1840 SetHelpText( wxT("Controls sample demonstrating various widgets") );
1843 // The wxICON() macros loads an icon from a resource under Windows
1844 // and uses an #included XPM image under GTK+ and Motif
1846 SetIcon( wxICON(sample
) );
1848 wxMenu
*file_menu
= new wxMenu
;
1850 file_menu
->Append(CONTROLS_CLEAR_LOG
, wxT("&Clear log\tCtrl-L"));
1851 file_menu
->AppendSeparator();
1852 file_menu
->Append(CONTROLS_ABOUT
, wxT("&About\tF1"));
1853 file_menu
->AppendSeparator();
1854 file_menu
->Append(CONTROLS_QUIT
, wxT("E&xit\tAlt-X"), wxT("Quit controls sample"));
1856 wxMenuBar
*menu_bar
= new wxMenuBar
;
1857 menu_bar
->Append(file_menu
, wxT("&File"));
1860 wxMenu
*tooltip_menu
= new wxMenu
;
1861 tooltip_menu
->Append(CONTROLS_SET_TOOLTIP_DELAY
, wxT("Set &delay\tCtrl-D"));
1862 tooltip_menu
->AppendSeparator();
1863 tooltip_menu
->Append(CONTROLS_ENABLE_TOOLTIPS
, wxT("&Toggle tooltips\tCtrl-T"),
1864 wxT("enable/disable tooltips"), true);
1865 tooltip_menu
->Check(CONTROLS_ENABLE_TOOLTIPS
, true);
1867 tooltip_menu
->Append(CONTROLS_SET_TOOLTIPS_MAX_WIDTH
, "Set maximal &width");
1869 menu_bar
->Append(tooltip_menu
, wxT("&Tooltips"));
1870 #endif // wxUSE_TOOLTIPS
1872 wxMenu
*panel_menu
= new wxMenu
;
1873 panel_menu
->Append(CONTROLS_ENABLE_ALL
, wxT("&Disable all\tCtrl-E"),
1874 wxT("Enable/disable all panel controls"), true);
1875 panel_menu
->Append(CONTROLS_HIDE_ALL
, wxT("&Hide all\tCtrl-I"),
1876 wxT("Show/hide thoe whole panel controls"), true);
1877 panel_menu
->Append(CONTROLS_HIDE_LIST
, wxT("Hide &list ctrl\tCtrl-S"),
1878 wxT("Enable/disable all panel controls"), true);
1879 panel_menu
->Append(CONTROLS_CONTEXT_HELP
, wxT("&Context help...\tCtrl-H"),
1880 wxT("Get context help for a control"));
1881 menu_bar
->Append(panel_menu
, wxT("&Panel"));
1883 SetMenuBar(menu_bar
);
1887 #endif // wxUSE_STATUSBAR
1889 m_panel
= new MyPanel( this, 10, 10, 300, 100 );
1892 void MyFrame::OnQuit (wxCommandEvent
& WXUNUSED(event
) )
1897 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
1901 wxMessageDialog
dialog(this, wxT("This is a control sample"), wxT("About Controls"), wxOK
);
1905 void MyFrame::OnClearLog(wxCommandEvent
& WXUNUSED(event
))
1907 m_panel
->m_text
->Clear();
1911 void MyFrame::OnSetTooltipDelay(wxCommandEvent
& WXUNUSED(event
))
1913 static long s_delay
= 5000;
1916 delay
.Printf( wxT("%ld"), s_delay
);
1918 delay
= wxGetTextFromUser(wxT("Enter delay (in milliseconds)"),
1919 wxT("Set tooltip delay"),
1923 return; // cancelled
1925 wxSscanf(delay
, wxT("%ld"), &s_delay
);
1927 wxToolTip::SetDelay(s_delay
);
1929 wxLogStatus(this, wxT("Tooltip delay set to %ld milliseconds"), s_delay
);
1932 void MyFrame::OnToggleTooltips(wxCommandEvent
& WXUNUSED(event
))
1934 static bool s_enabled
= true;
1936 s_enabled
= !s_enabled
;
1938 wxToolTip::Enable(s_enabled
);
1940 wxLogStatus(this, wxT("Tooltips %sabled"), s_enabled
? wxT("en") : wxT("dis") );
1945 void MyFrame::OnSetMaxTooltipWidth(wxCommandEvent
& WXUNUSED(event
))
1947 static int s_maxWidth
= 0;
1949 wxNumberEntryDialog dlg
1952 "Change maximal tooltip width",
1953 "&Width in pixels:",
1959 if ( dlg
.ShowModal() == wxID_CANCEL
)
1962 s_maxWidth
= dlg
.GetValue();
1963 wxToolTip::SetMaxWidth(s_maxWidth
);
1965 // we need to set the tooltip again to test the new width
1966 m_panel
->SetAllToolTips();
1971 #endif // wxUSE_TOOLTIPS
1973 void MyFrame::OnEnableAll(wxCommandEvent
& WXUNUSED(event
))
1975 static bool s_enable
= true;
1977 s_enable
= !s_enable
;
1978 m_panel
->Enable(s_enable
);
1979 static bool s_enableCheckbox
= true;
1982 // this is a test for correct behaviour of either enabling or disabling
1983 // a child when its parent is disabled: the checkbox should have the
1984 // correct state when the parent is enabled back
1985 m_panel
->m_checkbox
->Enable(s_enableCheckbox
);
1986 s_enableCheckbox
= !s_enableCheckbox
;
1990 void MyFrame::OnHideAll(wxCommandEvent
& WXUNUSED(event
))
1992 static bool s_show
= true;
1995 m_panel
->Show(s_show
);
1998 void MyFrame::OnHideList(wxCommandEvent
& WXUNUSED(event
))
2000 static bool s_show
= true;
2003 m_panel
->m_listbox
->Show(s_show
);
2006 void MyFrame::OnContextHelp(wxCommandEvent
& WXUNUSED(event
))
2008 // starts a local event loop
2009 wxContextHelp
chelp(this);
2012 void MyFrame::OnMove( wxMoveEvent
& event
)
2015 UpdateStatusBar(event
.GetPosition(), GetSize());
2016 #endif // wxUSE_STATUSBAR
2021 void MyFrame::OnIconized( wxIconizeEvent
& event
)
2023 wxLogMessage(wxT("Frame %s"), event
.IsIconized() ? wxT("iconized")
2028 void MyFrame::OnMaximized( wxMaximizeEvent
& WXUNUSED(event
) )
2030 wxLogMessage(wxT("Frame maximized"));
2033 void MyFrame::OnSize( wxSizeEvent
& event
)
2036 UpdateStatusBar(GetPosition(), event
.GetSize());
2037 #endif // wxUSE_STATUSBAR
2042 void MyFrame::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
2044 // track the window which has the focus in the status bar
2045 static wxWindow
*s_windowFocus
= NULL
;
2046 wxWindow
*focus
= wxWindow::FindFocus();
2047 if ( focus
!= s_windowFocus
)
2049 s_windowFocus
= focus
;
2059 , s_windowFocus
->GetName().c_str()
2061 , (unsigned int) s_windowFocus
->GetHWND()
2067 msg
= wxT("No focus");
2072 #endif // wxUSE_STATUSBAR
2076 void MyComboBox::OnChar(wxKeyEvent
& event
)
2078 wxLogMessage(wxT("MyComboBox::OnChar"));
2080 if ( event
.GetKeyCode() == 'w' )
2082 wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
2090 void MyComboBox::OnKeyDown(wxKeyEvent
& event
)
2092 wxLogMessage(wxT("MyComboBox::OnKeyDown"));
2094 if ( event
.GetKeyCode() == 'w' )
2096 wxLogMessage(wxT("MyComboBox: 'w' will be ignored."));
2104 void MyComboBox::OnKeyUp(wxKeyEvent
& event
)
2106 wxLogMessage(wxT("MyComboBox::OnKeyUp"));
2111 static void SetListboxClientData(const wxChar
*name
, wxListBox
*control
)
2113 size_t count
= control
->GetCount();
2114 for ( size_t n
= 0; n
< count
; n
++ )
2117 s
.Printf(wxT("%s client data for '%s'"),
2118 name
, control
->GetString(n
).c_str());
2120 control
->SetClientObject(n
, new wxStringClientData(s
));
2126 static void SetChoiceClientData(const wxChar
*name
, wxChoice
*control
)
2128 size_t count
= control
->GetCount();
2129 for ( size_t n
= 0; n
< count
; n
++ )
2132 s
.Printf(wxT("%s client data for '%s'"),
2133 name
, control
->GetString(n
).c_str());
2135 control
->SetClientObject(n
, new wxStringClientData(s
));
2139 #endif // wxUSE_CHOICE