1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Controls wxWidgets sample
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling, Julian Smart
8 // Licence: wxWindows license
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"
30 #include "wx/tooltip.h"
33 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
38 #include "mondrian.xpm"
39 #include "icons/choice.xpm"
40 #include "icons/combo.xpm"
41 #include "icons/list.xpm"
42 #include "icons/radio.xpm"
43 #include "icons/text.xpm"
44 #include "icons/gauge.xpm"
48 #define wxUSE_SPINBTN 1
51 #include "wx/progdlg.h"
54 #include "wx/spinctrl.h"
55 #endif // wxUSE_SPINCTRL
58 #define wxToggleButton wxCheckBox
59 #define EVT_TOGGLEBUTTON EVT_CHECKBOX
62 #include "wx/hyperlink.h"
65 //----------------------------------------------------------------------
67 //----------------------------------------------------------------------
69 class MyApp
: public wxApp
75 class MyPanel
: public wxPanel
78 MyPanel(wxFrame
*frame
, int x
, int y
, int w
, int h
);
81 void OnIdle( wxIdleEvent
&event
);
82 void OnListBox( wxCommandEvent
&event
);
83 void OnListBoxDoubleClick( wxCommandEvent
&event
);
84 void OnListBoxButtons( wxCommandEvent
&event
);
86 void OnChoice( wxCommandEvent
&event
);
87 void OnChoiceButtons( wxCommandEvent
&event
);
89 void OnCombo( wxCommandEvent
&event
);
90 void OnComboTextChanged( wxCommandEvent
&event
);
91 void OnComboTextEnter( wxCommandEvent
&event
);
92 void OnComboButtons( wxCommandEvent
&event
);
93 void OnRadio( wxCommandEvent
&event
);
94 void OnRadioButtons( wxCommandEvent
&event
);
95 void OnRadioButton1( wxCommandEvent
&event
);
96 void OnRadioButton2( wxCommandEvent
&event
);
97 void OnSetFont( wxCommandEvent
&event
);
98 void OnPageChanged( wxBookCtrlEvent
&event
);
99 void OnPageChanging( wxBookCtrlEvent
&event
);
100 void OnSliderUpdate( wxCommandEvent
&event
);
101 void OnUpdateLabel( wxCommandEvent
&event
);
103 void OnSpinUp( wxSpinEvent
&event
);
104 void OnSpinDown( wxSpinEvent
&event
);
105 void OnSpinUpdate( wxSpinEvent
&event
);
106 #if wxUSE_PROGRESSDLG
107 void OnUpdateShowProgress( wxUpdateUIEvent
& event
);
108 void OnShowProgress( wxCommandEvent
&event
);
109 #endif // wxUSE_PROGRESSDLG
110 #endif // wxUSE_SPINBTN
111 void OnNewText( wxCommandEvent
&event
);
113 void OnSpinCtrl(wxSpinEvent
& event
);
114 void OnSpinCtrlUp(wxSpinEvent
& event
);
115 void OnSpinCtrlDown(wxSpinEvent
& event
);
116 void OnSpinCtrlText(wxCommandEvent
& event
);
117 #endif // wxUSE_SPINCTRL
119 void OnEnableAll(wxCommandEvent
& event
);
120 void OnChangeColour(wxCommandEvent
& event
);
121 void OnTestButton(wxCommandEvent
& event
);
122 void OnBmpButton(wxCommandEvent
& event
);
123 void OnBmpButtonToggle(wxCommandEvent
& event
);
125 void OnSizerCheck (wxCommandEvent
&event
);
127 #if wxUSE_HYPERLINKCTRL
128 void OnHyperlink(wxHyperlinkEvent
& 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
;
179 #if wxUSE_HYPERLINKCTRL
180 wxHyperlinkCtrl
*m_hyperlink
;
184 wxLog
*m_logTargetOld
;
186 DECLARE_EVENT_TABLE()
189 class MyFrame
: public wxFrame
192 MyFrame(const wxChar
*title
, int x
, int y
);
194 void OnQuit(wxCommandEvent
& event
);
195 void OnAbout(wxCommandEvent
& event
);
196 void OnClearLog(wxCommandEvent
& event
);
199 void OnSetTooltipDelay(wxCommandEvent
& event
);
200 void OnToggleTooltips(wxCommandEvent
& event
);
201 #endif // wxUSE_TOOLTIPS
203 void OnEnableAll(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(_T("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(_T("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_HORIZONTAL
,
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(_T("MyRadioBox::OnFocusGot"));
319 void OnFocusLost(wxFocusEvent
& event
)
321 wxLogMessage(_T("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(_T("MyChoice::OnFocusGot"));
353 void OnFocusLost(wxFocusEvent
& event
)
355 wxLogMessage(_T("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
,
395 CONTROLS_CONTEXT_HELP
400 // use standard command line handling:
401 if ( !wxApp::OnInit() )
404 // parse the cmd line
409 wxSscanf(wxString(argv
[1]), wxT("%d"), &x
);
410 wxSscanf(wxString(argv
[2]), wxT("%d"), &y
);
414 wxHelpProvider::Set( new wxSimpleHelpProvider
);
417 // Create the main frame window
418 MyFrame
*frame
= new MyFrame(_T("Controls wxWidgets App"), x
, y
);
424 //----------------------------------------------------------------------
426 //----------------------------------------------------------------------
428 const int ID_BOOK
= 1000;
430 const int ID_LISTBOX
= 130;
431 const int ID_LISTBOX_SEL_NUM
= 131;
432 const int ID_LISTBOX_SEL_STR
= 132;
433 const int ID_LISTBOX_CLEAR
= 133;
434 const int ID_LISTBOX_APPEND
= 134;
435 const int ID_LISTBOX_DELETE
= 135;
436 const int ID_LISTBOX_FONT
= 136;
437 const int ID_LISTBOX_ENABLE
= 137;
438 const int ID_LISTBOX_SORTED
= 138;
440 const int ID_CHOICE
= 120;
441 const int ID_CHOICE_SEL_NUM
= 121;
442 const int ID_CHOICE_SEL_STR
= 122;
443 const int ID_CHOICE_CLEAR
= 123;
444 const int ID_CHOICE_APPEND
= 124;
445 const int ID_CHOICE_DELETE
= 125;
446 const int ID_CHOICE_FONT
= 126;
447 const int ID_CHOICE_ENABLE
= 127;
448 const int ID_CHOICE_SORTED
= 128;
450 const int ID_COMBO
= 140;
451 const int ID_COMBO_SEL_NUM
= 141;
452 const int ID_COMBO_SEL_STR
= 142;
453 const int ID_COMBO_CLEAR
= 143;
454 const int ID_COMBO_APPEND
= 144;
455 const int ID_COMBO_DELETE
= 145;
456 const int ID_COMBO_FONT
= 146;
457 const int ID_COMBO_ENABLE
= 147;
458 const int ID_COMBO_SET_TEXT
= 148;
460 const int ID_RADIOBOX
= 160;
461 const int ID_RADIOBOX_SEL_NUM
= 161;
462 const int ID_RADIOBOX_SEL_STR
= 162;
463 const int ID_RADIOBOX_FONT
= 163;
464 const int ID_RADIOBOX_ENABLE
= 164;
466 const int ID_RADIOBUTTON_1
= 166;
467 const int ID_RADIOBUTTON_2
= 167;
469 const int ID_SET_FONT
= 170;
472 const int ID_GAUGE
= 180;
473 #endif // wxUSE_GAUGE
476 const int ID_SLIDER
= 181;
477 #endif // wxUSE_SLIDER
479 const int ID_SPIN
= 182;
480 #if wxUSE_PROGRESSDLG
481 const int ID_BTNPROGRESS
= 183;
482 #endif // wxUSE_PROGRESSDLG
483 const int ID_BUTTON_LABEL
= 184;
484 const int ID_SPINCTRL
= 185;
485 const int ID_BTNNEWTEXT
= 186;
487 const int ID_BUTTON_TEST1
= 190;
488 const int ID_BUTTON_TEST2
= 191;
489 const int ID_BITMAP_BTN
= 192;
490 const int ID_BITMAP_BTN_ENABLE
= 193;
492 const int ID_CHANGE_COLOUR
= 200;
494 const int ID_SIZER_CHECK1
= 201;
495 const int ID_SIZER_CHECK2
= 202;
496 const int ID_SIZER_CHECK3
= 203;
497 const int ID_SIZER_CHECK4
= 204;
498 const int ID_SIZER_CHECK14
= 205;
499 const int ID_SIZER_CHECKBIG
= 206;
501 const int ID_HYPERLINK
= 300;
503 BEGIN_EVENT_TABLE(MyPanel
, wxPanel
)
504 EVT_IDLE ( MyPanel::OnIdle
)
505 EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK
, MyPanel::OnPageChanging
)
506 EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK
, MyPanel::OnPageChanged
)
507 EVT_LISTBOX (ID_LISTBOX
, MyPanel::OnListBox
)
508 EVT_LISTBOX (ID_LISTBOX_SORTED
, MyPanel::OnListBox
)
509 EVT_LISTBOX_DCLICK(ID_LISTBOX
, MyPanel::OnListBoxDoubleClick
)
510 EVT_BUTTON (ID_LISTBOX_SEL_NUM
, MyPanel::OnListBoxButtons
)
511 EVT_BUTTON (ID_LISTBOX_SEL_STR
, MyPanel::OnListBoxButtons
)
512 EVT_BUTTON (ID_LISTBOX_CLEAR
, MyPanel::OnListBoxButtons
)
513 EVT_BUTTON (ID_LISTBOX_APPEND
, MyPanel::OnListBoxButtons
)
514 EVT_BUTTON (ID_LISTBOX_DELETE
, MyPanel::OnListBoxButtons
)
515 EVT_BUTTON (ID_LISTBOX_FONT
, MyPanel::OnListBoxButtons
)
516 EVT_CHECKBOX (ID_LISTBOX_ENABLE
, MyPanel::OnListBoxButtons
)
518 EVT_CHOICE (ID_CHOICE
, MyPanel::OnChoice
)
519 EVT_CHOICE (ID_CHOICE_SORTED
, MyPanel::OnChoice
)
520 EVT_BUTTON (ID_CHOICE_SEL_NUM
, MyPanel::OnChoiceButtons
)
521 EVT_BUTTON (ID_CHOICE_SEL_STR
, MyPanel::OnChoiceButtons
)
522 EVT_BUTTON (ID_CHOICE_CLEAR
, MyPanel::OnChoiceButtons
)
523 EVT_BUTTON (ID_CHOICE_APPEND
, MyPanel::OnChoiceButtons
)
524 EVT_BUTTON (ID_CHOICE_DELETE
, MyPanel::OnChoiceButtons
)
525 EVT_BUTTON (ID_CHOICE_FONT
, MyPanel::OnChoiceButtons
)
526 EVT_CHECKBOX (ID_CHOICE_ENABLE
, MyPanel::OnChoiceButtons
)
528 EVT_COMBOBOX (ID_COMBO
, MyPanel::OnCombo
)
529 EVT_TEXT (ID_COMBO
, MyPanel::OnComboTextChanged
)
530 EVT_TEXT_ENTER(ID_COMBO
, MyPanel::OnComboTextEnter
)
531 EVT_BUTTON (ID_COMBO_SEL_NUM
, MyPanel::OnComboButtons
)
532 EVT_BUTTON (ID_COMBO_SEL_STR
, MyPanel::OnComboButtons
)
533 EVT_BUTTON (ID_COMBO_CLEAR
, MyPanel::OnComboButtons
)
534 EVT_BUTTON (ID_COMBO_APPEND
, MyPanel::OnComboButtons
)
535 EVT_BUTTON (ID_COMBO_DELETE
, MyPanel::OnComboButtons
)
536 EVT_BUTTON (ID_COMBO_FONT
, MyPanel::OnComboButtons
)
537 EVT_BUTTON (ID_COMBO_SET_TEXT
, MyPanel::OnComboButtons
)
538 EVT_CHECKBOX (ID_COMBO_ENABLE
, MyPanel::OnComboButtons
)
539 EVT_RADIOBOX (ID_RADIOBOX
, MyPanel::OnRadio
)
540 EVT_BUTTON (ID_RADIOBOX_SEL_NUM
, MyPanel::OnRadioButtons
)
541 EVT_BUTTON (ID_RADIOBOX_SEL_STR
, MyPanel::OnRadioButtons
)
542 EVT_BUTTON (ID_RADIOBOX_FONT
, MyPanel::OnRadioButtons
)
543 EVT_CHECKBOX (ID_RADIOBOX_ENABLE
, MyPanel::OnRadioButtons
)
544 EVT_RADIOBUTTON(ID_RADIOBUTTON_1
, MyPanel::OnRadioButton1
)
545 EVT_RADIOBUTTON(ID_RADIOBUTTON_2
, MyPanel::OnRadioButton2
)
546 EVT_BUTTON (ID_SET_FONT
, MyPanel::OnSetFont
)
548 EVT_SLIDER (ID_SLIDER
, MyPanel::OnSliderUpdate
)
549 #endif // wxUSE_SLIDER
551 EVT_SPIN (ID_SPIN
, MyPanel::OnSpinUpdate
)
552 EVT_SPIN_UP (ID_SPIN
, MyPanel::OnSpinUp
)
553 EVT_SPIN_DOWN (ID_SPIN
, MyPanel::OnSpinDown
)
554 #if wxUSE_PROGRESSDLG
555 EVT_UPDATE_UI (ID_BTNPROGRESS
, MyPanel::OnUpdateShowProgress
)
556 EVT_BUTTON (ID_BTNPROGRESS
, MyPanel::OnShowProgress
)
557 #endif // wxUSE_PROGRESSDLG
558 #endif // wxUSE_SPINBTN
560 EVT_SPINCTRL (ID_SPINCTRL
, MyPanel::OnSpinCtrl
)
561 EVT_SPIN_UP (ID_SPINCTRL
, MyPanel::OnSpinCtrlUp
)
562 EVT_SPIN_DOWN (ID_SPINCTRL
, MyPanel::OnSpinCtrlDown
)
563 EVT_TEXT (ID_SPINCTRL
, MyPanel::OnSpinCtrlText
)
564 #endif // wxUSE_SPINCTRL
565 EVT_BUTTON (ID_BTNNEWTEXT
, MyPanel::OnNewText
)
566 EVT_TOGGLEBUTTON(ID_BUTTON_LABEL
, MyPanel::OnUpdateLabel
)
567 EVT_CHECKBOX (ID_CHANGE_COLOUR
, MyPanel::OnChangeColour
)
568 EVT_BUTTON (ID_BUTTON_TEST1
, MyPanel::OnTestButton
)
569 EVT_BUTTON (ID_BUTTON_TEST2
, MyPanel::OnTestButton
)
570 EVT_BUTTON (ID_BITMAP_BTN
, MyPanel::OnBmpButton
)
571 EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE
, MyPanel::OnBmpButtonToggle
)
572 #if wxUSE_HYPERLINKCTRL
573 EVT_HYPERLINK (ID_HYPERLINK
, MyPanel::OnHyperlink
)
576 EVT_CHECKBOX (ID_SIZER_CHECK1
, MyPanel::OnSizerCheck
)
577 EVT_CHECKBOX (ID_SIZER_CHECK2
, MyPanel::OnSizerCheck
)
578 EVT_CHECKBOX (ID_SIZER_CHECK3
, MyPanel::OnSizerCheck
)
579 EVT_CHECKBOX (ID_SIZER_CHECK4
, MyPanel::OnSizerCheck
)
580 EVT_CHECKBOX (ID_SIZER_CHECK14
, MyPanel::OnSizerCheck
)
581 EVT_CHECKBOX (ID_SIZER_CHECKBIG
, MyPanel::OnSizerCheck
)
585 BEGIN_EVENT_TABLE(MyButton
, wxButton
)
586 EVT_LEFT_DCLICK(MyButton::OnDClick
)
589 BEGIN_EVENT_TABLE(MyComboBox
, wxComboBox
)
590 EVT_CHAR(MyComboBox::OnChar
)
591 EVT_KEY_DOWN(MyComboBox::OnKeyDown
)
592 EVT_KEY_UP(MyComboBox::OnKeyUp
)
594 EVT_SET_FOCUS(MyComboBox::OnFocusGot
)
597 BEGIN_EVENT_TABLE(MyRadioBox
, wxRadioBox
)
598 EVT_SET_FOCUS(MyRadioBox::OnFocusGot
)
599 EVT_KILL_FOCUS(MyRadioBox::OnFocusLost
)
602 BEGIN_EVENT_TABLE(MyChoice
, wxChoice
)
603 EVT_SET_FOCUS(MyChoice::OnFocusGot
)
604 EVT_KILL_FOCUS(MyChoice::OnFocusLost
)
607 // ============================================================================
609 // ============================================================================
611 MyPanel::MyPanel( wxFrame
*frame
, int x
, int y
, int w
, int h
)
612 : wxPanel( frame
, wxID_ANY
, wxPoint(x
, y
), wxSize(w
, h
) )
615 m_listboxSorted
= NULL
;
618 m_choiceSorted
= NULL
;
619 #endif // wxUSE_CHOICE
625 #endif // wxUSE_GAUGE
628 #endif // wxUSE_SLIDER
630 m_lbSelectNum
= NULL
;
631 m_lbSelectThis
= NULL
;
634 #if wxUSE_PROGRESSDLG
635 m_btnProgress
= NULL
;
636 #endif // wxUSE_PROGRESSDLG
637 #endif // wxUSE_SPINBTN
640 #endif // wxUSE_SPINCTRL
647 m_text
= new wxTextCtrl(this, wxID_ANY
, _T("This is the log window.\n"),
648 wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE
);
650 m_logTargetOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_text
));
652 m_book
= new wxBookCtrl(this, ID_BOOK
);
674 #endif // wxUSE_GAUGE
678 // fill the image list
679 wxBitmap
bmp(list_xpm
);
681 wxImageList
*imagelist
= new wxImageList(bmp
.GetWidth(), bmp
.GetHeight());
683 imagelist
-> Add( bmp
);
684 imagelist
-> Add( wxBitmap( choice_xpm
));
685 imagelist
-> Add( wxBitmap( combo_xpm
));
686 imagelist
-> Add( wxBitmap( text_xpm
));
687 imagelist
-> Add( wxBitmap( radio_xpm
));
689 imagelist
-> Add( wxBitmap( gauge_xpm
));
690 #endif // wxUSE_GAUGE
691 m_book
->SetImageList(imagelist
);
692 #elif defined(__WXMSW__)
693 // load images from resources
703 #endif // wxUSE_GAUGE
706 wxImageList
*imagelist
= new wxImageList(16, 16, false, Image_Max
);
708 static const wxChar
*s_iconNames
[Image_Max
] =
717 #endif // wxUSE_GAUGE
720 for ( size_t n
= 0; n
< Image_Max
; n
++ )
722 wxBitmap
bmp(s_iconNames
[n
]);
723 if ( !bmp
.Ok() || (imagelist
->Add(bmp
) == -1) )
725 wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
730 m_book
->SetImageList(imagelist
);
734 #define Image_List -1
735 #define Image_Choice -1
736 #define Image_Combo -1
737 #define Image_Text -1
738 #define Image_Radio -1
740 #define Image_Gauge -1
741 #endif // wxUSE_GAUGE
746 wxPanel
*panel
= new wxPanel(m_book
);
747 m_listbox
= new wxListBox( panel
, ID_LISTBOX
,
748 wxPoint(10,10), wxSize(120,70),
749 5, choices
, wxLB_MULTIPLE
|wxLB_ALWAYS_SB
);
750 m_listboxSorted
= new wxListBox( panel
, ID_LISTBOX_SORTED
,
751 wxPoint(10,90), wxSize(120,70),
752 5, choices
, wxLB_SORT
);
754 SetListboxClientData(wxT("listbox"), m_listbox
);
755 SetListboxClientData(wxT("listbox"), m_listboxSorted
);
757 m_listbox
->SetCursor(*wxCROSS_CURSOR
);
759 m_listbox
->SetToolTip( _T("This is a list box") );
760 #endif // wxUSE_TOOLTIPS
762 m_lbSelectNum
= new wxButton( panel
, ID_LISTBOX_SEL_NUM
, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
763 m_lbSelectThis
= new wxButton( panel
, ID_LISTBOX_SEL_STR
, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
764 (void)new wxButton( panel
, ID_LISTBOX_CLEAR
, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
765 (void)new MyButton( panel
, ID_LISTBOX_APPEND
, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
766 (void)new wxButton( panel
, ID_LISTBOX_DELETE
, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
767 wxButton
*button
= new MyButton( panel
, ID_LISTBOX_FONT
, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
769 button
->SetDefault();
772 button
->SetToolTip( _T("Press here to set italic font") );
773 #endif // wxUSE_TOOLTIPS
775 m_checkbox
= new wxCheckBox( panel
, ID_LISTBOX_ENABLE
, _T("&Disable"), wxPoint(20,170) );
776 m_checkbox
->SetValue(false);
777 button
->MoveAfterInTabOrder(m_checkbox
);
779 m_checkbox
->SetToolTip( _T("Click here to disable the listbox") );
780 #endif // wxUSE_TOOLTIPS
781 (void)new wxCheckBox( panel
, ID_CHANGE_COLOUR
, _T("&Toggle colour"),
783 panel
->SetCursor(wxCursor(wxCURSOR_HAND
));
784 m_book
->AddPage(panel
, _T("wxListBox"), true, Image_List
);
787 panel
= new wxPanel(m_book
);
788 m_choice
= new MyChoice( panel
, ID_CHOICE
, wxPoint(10,10), wxSize(120,wxDefaultCoord
), 5, choices
);
789 m_choiceSorted
= new MyChoice( panel
, ID_CHOICE_SORTED
, wxPoint(10,70), wxSize(120,wxDefaultCoord
),
790 5, choices
, wxCB_SORT
);
792 SetChoiceClientData(wxT("choice"), m_choice
);
793 SetChoiceClientData(wxT("choice"), m_choiceSorted
);
795 m_choice
->SetSelection(2);
796 (void)new wxButton( panel
, ID_CHOICE_SEL_NUM
, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
797 (void)new wxButton( panel
, ID_CHOICE_SEL_STR
, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
798 (void)new wxButton( panel
, ID_CHOICE_CLEAR
, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
799 (void)new wxButton( panel
, ID_CHOICE_APPEND
, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
800 (void)new wxButton( panel
, ID_CHOICE_DELETE
, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
801 (void)new wxButton( panel
, ID_CHOICE_FONT
, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
802 (void)new wxCheckBox( panel
, ID_CHOICE_ENABLE
, _T("&Disable"), wxPoint(20,130), wxSize(140,30) );
804 m_book
->AddPage(panel
, _T("wxChoice"), false, Image_Choice
);
805 #endif // wxUSE_CHOICE
807 panel
= new wxPanel(m_book
);
808 (void)new wxStaticBox( panel
, wxID_ANY
, _T("&Box around combobox"),
809 wxPoint(5, 5), wxSize(150, 100));
810 m_combo
= new MyComboBox( panel
, ID_COMBO
, _T("This"),
811 wxPoint(20,25), wxSize(120, wxDefaultCoord
),
815 (void)new wxButton( panel
, ID_COMBO_SEL_NUM
, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
816 (void)new wxButton( panel
, ID_COMBO_SEL_STR
, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
817 (void)new wxButton( panel
, ID_COMBO_CLEAR
, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
818 (void)new wxButton( panel
, ID_COMBO_APPEND
, _T("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
819 (void)new wxButton( panel
, ID_COMBO_DELETE
, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
820 (void)new wxButton( panel
, ID_COMBO_FONT
, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
821 (void)new wxButton( panel
, ID_COMBO_SET_TEXT
, _T("Set 'Hi!' at #2"), wxPoint(340,180), wxSize(140,30) );
822 (void)new wxCheckBox( panel
, ID_COMBO_ENABLE
, _T("&Disable"), wxPoint(20,130), wxSize(140,30) );
823 m_book
->AddPage(panel
, _T("wxComboBox"), false, Image_Combo
);
825 wxString choices2
[] =
827 _T("First"), _T("Second"),
829 "Fourth", "Fifth", "Sixth",
830 "Seventh", "Eighth", "Nineth", "Tenth" */
833 panel
= new wxPanel(m_book
);
834 wxRadioBox
*radio2
= new MyRadioBox( panel
, ID_RADIOBOX
, _T("&That"), wxPoint(10,160), wxDefaultSize
, WXSIZEOF(choices2
), choices2
, 1, wxRA_SPECIFY_ROWS
);
835 m_radio
= new wxRadioBox( panel
, ID_RADIOBOX
, _T("T&his"), wxPoint(10,10), wxDefaultSize
, WXSIZEOF(choices
), choices
, 1, wxRA_SPECIFY_COLS
);
838 m_combo
->SetToolTip(_T("This is a natural\ncombobox - can you believe me?"));
839 radio2
->SetToolTip(_T("Ever seen a radiobox?"));
841 //m_radio->SetToolTip(_T("Tooltip for the entire radiobox"));
842 for ( unsigned int nb
= 0; nb
< WXSIZEOF(choices
); nb
++ )
844 m_radio
->SetItemToolTip(nb
, _T("tooltip for\n") + choices
[nb
]);
847 // remove the tooltip for one of the items
848 m_radio
->SetItemToolTip(2, _T(""));
849 #endif // wxUSE_TOOLTIPS
852 for( unsigned int item
= 0; item
< WXSIZEOF(choices
); ++item
)
853 m_radio
->SetItemHelpText( item
, wxString::Format( _T("Help text for \"%s\""), choices
[item
].c_str() ) );
855 // erase help text for the second item
856 m_radio
->SetItemHelpText( 1, _T("") );
857 // set default help text for control
858 m_radio
->SetHelpText( _T("Default helptext for wxRadioBox") );
861 (void)new wxButton( panel
, ID_RADIOBOX_SEL_NUM
, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
862 (void)new wxButton( panel
, ID_RADIOBOX_SEL_STR
, _T("&Select 'This'"), wxPoint(180,80), wxSize(140,30) );
863 m_fontButton
= new wxButton( panel
, ID_SET_FONT
, _T("Set &more Italic font"), wxPoint(340,30), wxSize(140,30) );
864 (void)new wxButton( panel
, ID_RADIOBOX_FONT
, _T("Set &Italic font"), wxPoint(340,80), wxSize(140,30) );
865 (void)new wxCheckBox( panel
, ID_RADIOBOX_ENABLE
, _T("&Disable"), wxPoint(340,130), wxDefaultSize
);
867 wxRadioButton
*rb
= new wxRadioButton( panel
, ID_RADIOBUTTON_1
, _T("Radiobutton1"), wxPoint(210,170), wxDefaultSize
, wxRB_GROUP
);
868 rb
->SetValue( false );
869 (void)new wxRadioButton( panel
, ID_RADIOBUTTON_2
, _T("&Radiobutton2"), wxPoint(340,170), wxDefaultSize
);
870 m_book
->AddPage(panel
, _T("wxRadioBox"), false, Image_Radio
);
873 #if wxUSE_SLIDER && wxUSE_GAUGE
874 panel
= new wxPanel(m_book
);
876 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxHORIZONTAL
);
877 panel
->SetSizer( main_sizer
);
879 wxStaticBoxSizer
*gauge_sizer
= new wxStaticBoxSizer( wxHORIZONTAL
, panel
, _T("&wxGauge and wxSlider") );
880 main_sizer
->Add( gauge_sizer
, 0, wxALL
, 5 );
881 wxBoxSizer
*sz
= new wxBoxSizer( wxVERTICAL
);
882 gauge_sizer
->Add( sz
);
883 m_gauge
= new wxGauge( panel
, wxID_ANY
, 200, wxDefaultPosition
, wxSize(155, 30), wxGA_HORIZONTAL
|wxNO_BORDER
);
884 sz
->Add( m_gauge
, 0, wxALL
, 10 );
885 m_slider
= new wxSlider( panel
, ID_SLIDER
, 0, 0, 200,
886 wxDefaultPosition
, wxSize(155,wxDefaultCoord
),
887 wxSL_AUTOTICKS
| wxSL_LABELS
);
888 m_slider
->SetTickFreq(40, 0);
890 m_slider
->SetToolTip(_T("This is a sliding slider"));
891 #endif // wxUSE_TOOLTIPS
892 sz
->Add( m_slider
, 0, wxALL
, 10 );
894 m_gaugeVert
= new wxGauge( panel
, wxID_ANY
, 100,
895 wxDefaultPosition
, wxSize(wxDefaultCoord
, 90),
896 wxGA_VERTICAL
| wxGA_SMOOTH
| wxNO_BORDER
);
897 gauge_sizer
->Add( m_gaugeVert
, 0, wxALL
, 10 );
901 wxStaticBox
*sb
= new wxStaticBox( panel
, wxID_ANY
, _T("&Explanation"),
902 wxDefaultPosition
, wxDefaultSize
); //, wxALIGN_CENTER );
903 wxStaticBoxSizer
*wrapping_sizer
= new wxStaticBoxSizer( sb
, wxVERTICAL
);
904 main_sizer
->Add( wrapping_sizer
, 0, wxALL
, 5 );
907 // No wrapping text in wxStaticText yet :-(
908 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
909 _T("Drag the slider!"),
911 wxSize(240, wxDefaultCoord
)
914 m_wrappingText
= new wxStaticText( panel
, wxID_ANY
,
915 _T("In order see the gauge (aka progress bar) ")
916 _T("control do something you have to drag the ")
917 _T("handle of the slider to the right.")
919 _T("This is also supposed to demonstrate how ")
920 _T("to use static controls with line wrapping."),
922 wxSize(240, wxDefaultCoord
)
925 wrapping_sizer
->Add( m_wrappingText
);
927 wxStaticBoxSizer
*non_wrapping_sizer
= new wxStaticBoxSizer( wxVERTICAL
, panel
, wxT("Non-wrapping") );
928 main_sizer
->Add( non_wrapping_sizer
, 0, wxALL
, 5 );
930 m_nonWrappingText
= new wxStaticText( panel
, wxID_ANY
,
931 _T("This static text has two lines.\nThey do not wrap."),
935 non_wrapping_sizer
->Add( m_nonWrappingText
);
937 (void)new wxButton( panel
, ID_BTNNEWTEXT
, wxT("New text"), wxPoint(450, 160) );
939 int initialSpinValue
= -5;
941 s
<< initialSpinValue
;
942 m_spintext
= new wxTextCtrl( panel
, wxID_ANY
, s
, wxPoint(20,160), wxSize(80,wxDefaultCoord
) );
944 m_spinbutton
= new wxSpinButton( panel
, ID_SPIN
, wxPoint(103,160) );
945 m_spinbutton
->SetRange(-40,30);
946 m_spinbutton
->SetValue(initialSpinValue
);
948 #if wxUSE_PROGRESSDLG
949 m_btnProgress
= new wxButton( panel
, ID_BTNPROGRESS
, _T("&Show progress dialog"),
951 #endif // wxUSE_PROGRESSDLG
952 #endif // wxUSE_SPINBTN
955 m_spinctrl
= new wxSpinCtrl( panel
, ID_SPINCTRL
, wxEmptyString
, wxPoint(200, 160), wxSize(80, wxDefaultCoord
) );
956 //m_spinctrl->SetRange(10,30);
957 m_spinctrl
->SetValue(15);
958 #endif // wxUSE_SPINCTRL
960 m_book
->AddPage(panel
, _T("wxGauge"), false, Image_Gauge
);
961 #endif // wxUSE_SLIDER && wxUSE_GAUGE
964 panel
= new wxPanel(m_book
);
966 #if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
967 wxIcon icon
= wxArtProvider::GetIcon(wxART_INFORMATION
);
968 (void) new wxStaticBitmap( panel
, wxID_ANY
, icon
, wxPoint(10, 10) );
970 // VZ: don't leak memory
971 // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
972 // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
975 wxBitmap
bitmap( 100, 100 );
977 dc
.SetBackground(*wxGREEN
);
978 dc
.SelectObject( bitmap
);
979 dc
.SetPen(*wxGREEN_PEN
);
981 dc
.DrawEllipse(5, 5, 90, 90);
982 dc
.DrawText(_T("Bitmap"), 30, 40);
983 dc
.SelectObject( wxNullBitmap
);
985 (void)new wxBitmapButton(panel
, ID_BITMAP_BTN
, bitmap
, wxPoint(100, 20));
986 (void)new wxToggleButton(panel
, ID_BITMAP_BTN_ENABLE
,
987 _T("Enable/disable &bitmap"), wxPoint(100, 140));
989 #if defined(__WXMSW__) || defined(__WXMOTIF__)
990 // test for masked bitmap display
991 bitmap
= wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP
);
994 bitmap
.SetMask(new wxMask(bitmap
, *wxBLUE
));
996 (void)new wxStaticBitmap(panel
, wxID_ANY
, bitmap
, wxPoint(300, 120));
1000 wxBitmap
bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION
)),
1001 bmp2(wxArtProvider::GetBitmap(wxART_WARNING
)),
1002 bmp3(wxArtProvider::GetBitmap(wxART_QUESTION
));
1003 wxBitmapButton
*bmpBtn
= new wxBitmapButton
1010 bmpBtn
->SetBitmapSelected(bmp2
);
1011 bmpBtn
->SetBitmapFocus(bmp3
);
1013 (void)new wxToggleButton(panel
, ID_BUTTON_LABEL
,
1014 _T("&Toggle label"), wxPoint(250, 20));
1016 m_label
= new wxStaticText(panel
, wxID_ANY
, _T("Label with some long text"),
1017 wxPoint(250, 60), wxDefaultSize
,
1018 wxALIGN_RIGHT
/*| wxST_NO_AUTORESIZE*/);
1019 m_label
->SetForegroundColour( *wxBLUE
);
1021 m_book
->AddPage(panel
, _T("wxBitmapXXX"));
1024 #if wxUSE_HYPERLINKCTRL
1025 panel
= new wxPanel(m_book
);
1026 m_hyperlink
= new wxHyperlinkCtrl(panel
, ID_HYPERLINK
,
1027 _T("Click here to go to Google!"),
1028 _T("http://www.google.com"),
1030 m_hyperlink
->SetVisitedColour(m_hyperlink
->GetNormalColour());
1031 m_hyperlink
->SetFont(*wxITALIC_FONT
);
1032 m_hyperlink
->SetBackgroundColour(*wxWHITE
);
1034 // this hyperlink will automatically call wxLaunchDefaultBrowser on user's clicks
1035 new wxHyperlinkCtrl(panel
, wxID_ANY
, wxT("http://www.test.com"),
1036 wxEmptyString
, wxPoint(20, 50));
1038 m_book
->AddPage(panel
, _T("wxHyperlinkCtrl"));
1043 panel
= new wxPanel(m_book
);
1044 panel
->SetAutoLayout( true );
1046 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
1048 wxStaticBoxSizer
*csizer
=
1049 new wxStaticBoxSizer (new wxStaticBox (panel
, wxID_ANY
, _T("Show Buttons")), wxHORIZONTAL
);
1051 wxCheckBox
*check1
, *check2
, *check3
, *check4
, *check14
, *checkBig
;
1052 check1
= new wxCheckBox (panel
, ID_SIZER_CHECK1
, _T("1"));
1053 check1
->SetValue (true);
1054 csizer
->Add (check1
);
1055 check2
= new wxCheckBox (panel
, ID_SIZER_CHECK2
, _T("2"));
1056 check2
->SetValue (true);
1057 csizer
->Add (check2
);
1058 check3
= new wxCheckBox (panel
, ID_SIZER_CHECK3
, _T("3"));
1059 check3
->SetValue (true);
1060 csizer
->Add (check3
);
1061 check4
= new wxCheckBox (panel
, ID_SIZER_CHECK4
, _T("4"));
1062 check4
->SetValue (true);
1063 csizer
->Add (check4
);
1064 check14
= new wxCheckBox (panel
, ID_SIZER_CHECK14
, _T("1-4"));
1065 check14
->SetValue (true);
1066 csizer
->Add (check14
);
1067 checkBig
= new wxCheckBox (panel
, ID_SIZER_CHECKBIG
, _T("Big"));
1068 checkBig
->SetValue (true);
1069 csizer
->Add (checkBig
);
1071 sizer
->Add (csizer
);
1073 m_hsizer
= new wxBoxSizer( wxHORIZONTAL
);
1075 m_buttonSizer
= new wxBoxSizer (wxVERTICAL
);
1077 m_sizerBtn1
= new wxButton(panel
, wxID_ANY
, _T("Test Button &1 (tab order 1)") );
1078 m_buttonSizer
->Add( m_sizerBtn1
, 0, wxALL
, 10 );
1079 m_sizerBtn2
= new wxButton(panel
, wxID_ANY
, _T("Test Button &2 (tab order 3)") );
1080 m_buttonSizer
->Add( m_sizerBtn2
, 0, wxALL
, 10 );
1081 m_sizerBtn3
= new wxButton(panel
, wxID_ANY
, _T("Test Button &3 (tab order 2)") );
1082 m_buttonSizer
->Add( m_sizerBtn3
, 0, wxALL
, 10 );
1083 m_sizerBtn4
= new wxButton(panel
, wxID_ANY
, _T("Test Button &4 (tab order 4)") );
1084 m_buttonSizer
->Add( m_sizerBtn4
, 0, wxALL
, 10 );
1086 m_sizerBtn3
->MoveBeforeInTabOrder(m_sizerBtn2
);
1088 m_hsizer
->Add (m_buttonSizer
);
1089 m_hsizer
->Add( 20,20, 1 );
1090 m_bigBtn
= new wxButton(panel
, wxID_ANY
, _T("Multiline\nbutton") );
1091 m_hsizer
->Add( m_bigBtn
, 3, wxGROW
|wxALL
, 10 );
1093 sizer
->Add (m_hsizer
, 1, wxGROW
);
1095 panel
->SetSizer( sizer
);
1097 m_book
->AddPage(panel
, _T("wxSizer"));
1099 // set the sizer for the panel itself
1100 sizer
= new wxBoxSizer(wxVERTICAL
);
1101 sizer
->Add(m_book
, wxSizerFlags().Border().Expand());
1102 sizer
->Add(m_text
, wxSizerFlags(1).Border().Expand());
1106 void MyPanel::OnIdle(wxIdleEvent
& event
)
1108 static const int INVALID_SELECTION
= -2;
1110 static int s_selCombo
= INVALID_SELECTION
;
1112 if (!m_combo
|| !m_choice
)
1118 int sel
= m_combo
->GetSelection();
1119 if ( sel
!= s_selCombo
)
1121 if ( s_selCombo
!= INVALID_SELECTION
)
1123 wxLogMessage(_T("EVT_IDLE: combobox selection changed from %d to %d"),
1130 static int s_selChoice
= INVALID_SELECTION
;
1131 sel
= m_choice
->GetSelection();
1132 if ( sel
!= s_selChoice
)
1134 if ( s_selChoice
!= INVALID_SELECTION
)
1136 wxLogMessage(_T("EVT_IDLE: choice selection changed from %d to %d"),
1146 void MyPanel::OnPageChanging( wxBookCtrlEvent
&event
)
1148 int selOld
= event
.GetOldSelection();
1151 if ( wxMessageBox(_T("This demonstrates how a program may prevent the\n")
1152 _T("page change from taking place - if you select\n")
1153 _T("[No] the current page will stay the third one\n"),
1154 _T("Control sample"),
1155 wxICON_QUESTION
| wxYES_NO
, this) != wxYES
)
1163 *m_text
<< _T("Book selection is being changed from ") << selOld
1164 << _T(" to ") << event
.GetSelection()
1165 << _T(" (current page from book is ")
1166 << m_book
->GetSelection() << _T(")\n");
1169 void MyPanel::OnPageChanged( wxBookCtrlEvent
&event
)
1171 *m_text
<< _T("Book selection is now ") << event
.GetSelection()
1172 << _T(" (from book: ") << m_book
->GetSelection()
1176 void MyPanel::OnTestButton(wxCommandEvent
& event
)
1178 wxLogMessage(_T("Button %c clicked."),
1179 event
.GetId() == ID_BUTTON_TEST1
? _T('1') : _T('2'));
1182 void MyPanel::OnBmpButton(wxCommandEvent
& WXUNUSED(event
))
1184 wxLogMessage(_T("Bitmap button clicked."));
1187 void MyPanel::OnBmpButtonToggle(wxCommandEvent
& event
)
1189 FindWindow(ID_BITMAP_BTN
)->Enable(!event
.IsChecked());
1192 void MyPanel::OnChangeColour(wxCommandEvent
& WXUNUSED(event
))
1194 static wxColour s_colOld
;
1196 SetThemeEnabled(false);
1197 // test panel colour changing and propagation to the subcontrols
1198 if ( s_colOld
.Ok() )
1200 SetBackgroundColour(s_colOld
);
1201 s_colOld
= wxNullColour
;
1203 m_lbSelectThis
->SetForegroundColour(wxNullColour
);
1204 m_lbSelectThis
->SetBackgroundColour(wxNullColour
);
1208 s_colOld
= wxColour(wxT("red"));
1209 SetBackgroundColour(wxT("white"));
1211 m_lbSelectThis
->SetForegroundColour(wxT("white"));
1212 m_lbSelectThis
->SetBackgroundColour(wxT("red"));
1215 m_lbSelectThis
->Refresh();
1219 void MyPanel::OnListBox( wxCommandEvent
&event
)
1221 if (event
.GetInt() == -1)
1223 m_text
->AppendText( _T("ListBox has no selections anymore\n") );
1227 wxListBox
*listbox
= event
.GetId() == ID_LISTBOX
? m_listbox
1230 m_text
->AppendText( _T("ListBox event selection string is: '") );
1231 m_text
->AppendText( event
.GetString() );
1232 m_text
->AppendText( _T("'\n") );
1234 // can't use GetStringSelection() with multiple selections, there could be
1235 // more than one of them
1236 if ( !listbox
->HasFlag(wxLB_MULTIPLE
) )
1238 m_text
->AppendText( _T("ListBox control selection string is: '") );
1239 m_text
->AppendText( listbox
->GetStringSelection() );
1240 m_text
->AppendText( _T("'\n") );
1243 wxStringClientData
*obj
= ((wxStringClientData
*)event
.GetClientObject());
1244 m_text
->AppendText( _T("ListBox event client data string is: '") );
1245 if (obj
) // BC++ doesn't like use of '? .. : .. ' in this context
1246 m_text
->AppendText( obj
->GetData() );
1248 m_text
->AppendText( wxString(_T("none")) );
1250 m_text
->AppendText( _T("'\n") );
1251 m_text
->AppendText( _T("ListBox control client data string is: '") );
1252 obj
= (wxStringClientData
*)listbox
->GetClientObject(event
.GetInt());
1254 m_text
->AppendText( obj
->GetData() );
1256 m_text
->AppendText( wxString(_T("none")) );
1257 m_text
->AppendText( _T("'\n") );
1260 void MyPanel::OnListBoxDoubleClick( wxCommandEvent
&event
)
1262 m_text
->AppendText( _T("ListBox double click string is: ") );
1263 m_text
->AppendText( event
.GetString() );
1264 m_text
->AppendText( _T("\n") );
1267 void MyPanel::OnListBoxButtons( wxCommandEvent
&event
)
1269 switch (event
.GetId())
1271 case ID_LISTBOX_ENABLE
:
1273 m_text
->AppendText(_T("Checkbox clicked.\n"));
1275 wxCheckBox
*cb
= (wxCheckBox
*)event
.GetEventObject();
1277 cb
->SetToolTip( _T("Click to enable listbox") );
1279 cb
->SetToolTip( _T("Click to disable listbox") );
1280 #endif // wxUSE_TOOLTIPS
1281 m_listbox
->Enable( event
.GetInt() == 0 );
1282 m_lbSelectThis
->Enable( event
.GetInt() == 0 );
1283 m_lbSelectNum
->Enable( event
.GetInt() == 0 );
1284 m_listboxSorted
->Enable( event
.GetInt() == 0 );
1285 FindWindow(ID_CHANGE_COLOUR
)->Enable( event
.GetInt() == 0 );
1288 case ID_LISTBOX_SEL_NUM
:
1290 if (m_listbox
->GetCount() > 2)
1291 m_listbox
->SetSelection( 2 );
1292 if (m_listboxSorted
->GetCount() > 2)
1293 m_listboxSorted
->SetSelection( 2 );
1294 m_lbSelectThis
->WarpPointer( 40, 14 );
1297 case ID_LISTBOX_SEL_STR
:
1299 if (m_listbox
->FindString(_T("This")) != wxNOT_FOUND
)
1300 m_listbox
->SetStringSelection( _T("This") );
1301 if (m_listboxSorted
->FindString(_T("This")) != wxNOT_FOUND
)
1302 m_listboxSorted
->SetStringSelection( _T("This") );
1303 m_lbSelectNum
->WarpPointer( 40, 14 );
1306 case ID_LISTBOX_CLEAR
:
1309 m_listboxSorted
->Clear();
1312 case ID_LISTBOX_APPEND
:
1314 m_listbox
->Append( _T("Hi!") );
1315 m_listboxSorted
->Append( _T("Hi!") );
1318 case ID_LISTBOX_DELETE
:
1321 idx
= m_listbox
->GetSelection();
1322 if ( idx
!= wxNOT_FOUND
)
1323 m_listbox
->Delete( idx
);
1324 idx
= m_listboxSorted
->GetSelection();
1325 if ( idx
!= wxNOT_FOUND
)
1326 m_listboxSorted
->Delete( idx
);
1329 case ID_LISTBOX_FONT
:
1331 m_listbox
->SetFont( *wxITALIC_FONT
);
1332 m_listboxSorted
->SetFont( *wxITALIC_FONT
);
1333 m_checkbox
->SetFont( *wxITALIC_FONT
);
1341 static const wxChar
*GetDataString(wxClientData
*data
)
1343 return data
? wx_static_cast(wxStringClientData
*, data
)->GetData().c_str()
1347 void MyPanel::OnChoice( wxCommandEvent
&event
)
1349 wxChoice
*choice
= event
.GetId() == ID_CHOICE
? m_choice
1352 const int sel
= choice
->GetSelection();
1354 wxClientData
*dataEvt
= event
.GetClientObject(),
1355 *dataCtrl
= choice
->GetClientObject(sel
);
1357 wxLogMessage(_T("EVT_CHOICE: item %d/%d (event/control), ")
1358 _T("string \"%s\"/\"%s\", ")
1359 _T("data \"%s\"/\"%s\""),
1360 (int)event
.GetInt(),
1362 event
.GetString().c_str(),
1363 choice
->GetStringSelection().c_str(),
1364 GetDataString(dataEvt
),
1365 GetDataString(dataCtrl
));
1368 void MyPanel::OnChoiceButtons( wxCommandEvent
&event
)
1370 switch (event
.GetId())
1372 case ID_CHOICE_ENABLE
:
1374 m_choice
->Enable( event
.GetInt() == 0 );
1375 m_choiceSorted
->Enable( event
.GetInt() == 0 );
1378 case ID_CHOICE_SEL_NUM
:
1380 m_choice
->SetSelection( 2 );
1381 m_choiceSorted
->SetSelection( 2 );
1384 case ID_CHOICE_SEL_STR
:
1386 m_choice
->SetStringSelection( _T("This") );
1387 m_choiceSorted
->SetStringSelection( _T("This") );
1390 case ID_CHOICE_CLEAR
:
1393 m_choiceSorted
->Clear();
1396 case ID_CHOICE_APPEND
:
1398 m_choice
->Append( _T("Hi!") );
1399 m_choiceSorted
->Append( _T("Hi!") );
1402 case ID_CHOICE_DELETE
:
1404 int idx
= m_choice
->GetSelection();
1405 if ( idx
!= wxNOT_FOUND
)
1406 m_choice
->Delete( idx
);
1407 idx
= m_choiceSorted
->GetSelection();
1408 if ( idx
!= wxNOT_FOUND
)
1409 m_choiceSorted
->Delete( idx
);
1412 case ID_CHOICE_FONT
:
1414 m_choice
->SetFont( *wxITALIC_FONT
);
1415 m_choiceSorted
->SetFont( *wxITALIC_FONT
);
1420 #endif // wxUSE_CHOICE
1422 void MyPanel::OnCombo( wxCommandEvent
&event
)
1427 wxLogMessage(_T("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
1428 (int)event
.GetInt(),
1429 m_combo
->GetSelection(),
1430 event
.GetString().c_str(),
1431 m_combo
->GetStringSelection().c_str());
1434 void MyPanel::OnComboTextChanged(wxCommandEvent
& event
)
1437 wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
1438 event
.GetString().c_str(),
1439 m_combo
->GetValue().c_str());
1442 void MyPanel::OnComboTextEnter(wxCommandEvent
& WXUNUSED(event
))
1445 wxLogMessage(_T("Enter pressed in the combobox: value is '%s'."),
1446 m_combo
->GetValue().c_str());
1449 void MyPanel::OnComboButtons( wxCommandEvent
&event
)
1451 switch (event
.GetId())
1453 case ID_COMBO_ENABLE
:
1455 m_combo
->Enable( event
.GetInt() == 0 );
1458 case ID_COMBO_SEL_NUM
:
1460 m_combo
->SetSelection( 2 );
1463 case ID_COMBO_SEL_STR
:
1465 m_combo
->SetStringSelection( _T("This") );
1468 case ID_COMBO_CLEAR
:
1473 case ID_COMBO_APPEND
:
1475 m_combo
->Append( _T("Hi!") );
1478 case ID_COMBO_DELETE
:
1480 int idx
= m_combo
->GetSelection();
1481 m_combo
->Delete( idx
);
1486 m_combo
->SetFont( *wxITALIC_FONT
);
1489 case ID_COMBO_SET_TEXT
:
1491 m_combo
->SetString( 2, wxT("Hi!") );
1497 void MyPanel::OnRadio( wxCommandEvent
&event
)
1499 m_text
->AppendText( _T("RadioBox selection string is: ") );
1500 m_text
->AppendText( event
.GetString() );
1501 m_text
->AppendText( _T("\n") );
1504 void MyPanel::OnRadioButton1( wxCommandEvent
& WXUNUSED(event
) )
1506 wxMessageBox(_T("First wxRadioButton selected."), _T("wxControl sample"));
1509 void MyPanel::OnRadioButton2( wxCommandEvent
& WXUNUSED(event
) )
1511 m_text
->AppendText(_T("Second wxRadioButton selected.\n"));
1514 void MyPanel::OnRadioButtons( wxCommandEvent
&event
)
1516 switch (event
.GetId())
1518 case ID_RADIOBOX_ENABLE
:
1519 m_radio
->Enable( event
.GetInt() == 0 );
1522 case ID_RADIOBOX_SEL_NUM
:
1523 m_radio
->SetSelection( 2 );
1526 case ID_RADIOBOX_SEL_STR
:
1527 m_radio
->SetStringSelection( _T("This") );
1530 case ID_RADIOBOX_FONT
:
1531 m_radio
->SetFont( *wxITALIC_FONT
);
1536 void MyPanel::OnSetFont( wxCommandEvent
&WXUNUSED(event
) )
1538 m_fontButton
->SetFont( *wxITALIC_FONT
);
1539 m_text
->SetFont( *wxITALIC_FONT
);
1542 void MyPanel::OnUpdateLabel( wxCommandEvent
&event
)
1544 m_label
->SetLabel(event
.GetInt() ? _T("Very very very very very long text.")
1545 : _T("Shorter text."));
1550 void MyPanel::OnSliderUpdate( wxCommandEvent
&WXUNUSED(event
) )
1553 m_gauge
->SetValue( m_slider
->GetValue() );
1554 m_gaugeVert
->SetValue( m_slider
->GetValue() / 2 );
1555 #endif // wxUSE_GAUGE
1558 #endif // wxUSE_SLIDER
1562 void MyPanel::OnSpinCtrlText(wxCommandEvent
& event
)
1567 s
.Printf( _T("Spin ctrl text changed: now %d (from event: %s)\n"),
1568 m_spinctrl
->GetValue(), event
.GetString().c_str() );
1569 m_text
->AppendText(s
);
1573 void MyPanel::OnSpinCtrl(wxSpinEvent
& event
)
1578 s
.Printf( _T("Spin ctrl changed: now %d (from event: %d)\n"),
1579 m_spinctrl
->GetValue(), event
.GetInt() );
1580 m_text
->AppendText(s
);
1584 void MyPanel::OnSpinCtrlUp(wxSpinEvent
& event
)
1588 m_text
->AppendText( wxString::Format(
1589 _T("Spin up: %d (from event: %d)\n"),
1590 m_spinctrl
->GetValue(), event
.GetInt() ) );
1594 void MyPanel::OnSpinCtrlDown(wxSpinEvent
& event
)
1598 m_text
->AppendText( wxString::Format(
1599 _T("Spin down: %d (from event: %d)\n"),
1600 m_spinctrl
->GetValue(), event
.GetInt() ) );
1604 #endif // wxUSE_SPINCTRL
1607 void MyPanel::OnSpinUp( wxSpinEvent
&event
)
1610 value
.Printf( _T("Spin control up: current = %d\n"),
1611 m_spinbutton
->GetValue());
1613 if ( event
.GetPosition() > 17 )
1615 value
+= _T("Preventing the spin button from going above 17.\n");
1620 m_text
->AppendText(value
);
1623 void MyPanel::OnSpinDown( wxSpinEvent
&event
)
1626 value
.Printf( _T("Spin control down: current = %d\n"),
1627 m_spinbutton
->GetValue());
1629 if ( event
.GetPosition() < -17 )
1631 value
+= _T("Preventing the spin button from going below -17.\n");
1636 m_text
->AppendText(value
);
1639 void MyPanel::OnSpinUpdate( wxSpinEvent
&event
)
1642 value
.Printf( _T("%d"), event
.GetPosition() );
1643 m_spintext
->SetValue( value
);
1645 value
.Printf( _T("Spin control range: (%d, %d), current = %d\n"),
1646 m_spinbutton
->GetMin(), m_spinbutton
->GetMax(),
1647 m_spinbutton
->GetValue());
1649 m_text
->AppendText(value
);
1652 void MyPanel::OnNewText( wxCommandEvent
& /* event */)
1654 m_nonWrappingText
->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") );
1655 m_wrappingText
->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );
1656 m_wrappingText
->GetParent()->Layout();
1659 #if wxUSE_PROGRESSDLG
1661 void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent
& event
)
1663 event
.Enable( m_spinbutton
->GetValue() > 0 );
1666 void MyPanel::OnShowProgress( wxCommandEvent
& WXUNUSED(event
) )
1668 int max
= m_spinbutton
->GetValue();
1672 wxLogError(_T("You must set positive range!"));
1676 wxProgressDialog
dialog(_T("Progress dialog example"),
1677 _T("An informative message"),
1684 wxPD_ESTIMATED_TIME
|
1685 wxPD_REMAINING_TIME
);
1689 for ( int i
= 0; i
<= max
&& cont
; i
++ )
1694 cont
= dialog
.Update(i
, _T("That's all, folks!"));
1696 else if ( i
== max
/ 2 )
1698 cont
= dialog
.Update(i
, _T("Only a half left (very long message)!"));
1702 cont
= dialog
.Update(i
);
1708 *m_text
<< _T("Progress dialog aborted!\n");
1712 *m_text
<< _T("Countdown from ") << max
<< _T(" finished.\n");
1716 #endif // wxUSE_PROGRESSDLG
1717 #endif // wxUSE_SPINBTN
1719 #if wxUSE_HYPERLINKCTRL
1720 void MyPanel::OnHyperlink(wxHyperlinkEvent
& event
)
1722 wxLogMessage(wxT("Clicked on hyperlink with url '%s'"), event
.GetURL().c_str());
1723 if (!wxLaunchDefaultBrowser(event
.GetURL()))
1724 wxMessageBox(_T("Could not launch the default browser!"));
1726 #endif //wxUSE_HYPERLINK
1728 void MyPanel::OnSizerCheck( wxCommandEvent
&event
)
1730 switch (event
.GetId ()) {
1731 case ID_SIZER_CHECK1
:
1732 m_buttonSizer
->Show (m_sizerBtn1
, event
.IsChecked ());
1733 m_buttonSizer
->Layout ();
1735 case ID_SIZER_CHECK2
:
1736 m_buttonSizer
->Show (m_sizerBtn2
, event
.IsChecked ());
1737 m_buttonSizer
->Layout ();
1739 case ID_SIZER_CHECK3
:
1740 m_buttonSizer
->Show (m_sizerBtn3
, event
.IsChecked ());
1741 m_buttonSizer
->Layout ();
1743 case ID_SIZER_CHECK4
:
1744 m_buttonSizer
->Show (m_sizerBtn4
, event
.IsChecked ());
1745 m_buttonSizer
->Layout ();
1747 case ID_SIZER_CHECK14
:
1748 m_hsizer
->Show (m_buttonSizer
, event
.IsChecked ());
1749 m_hsizer
->Layout ();
1751 case ID_SIZER_CHECKBIG
:
1752 m_hsizer
->Show (m_bigBtn
, event
.IsChecked ());
1753 m_hsizer
->Layout ();
1761 //wxLog::RemoveTraceMask(_T("focus"));
1762 delete wxLog::SetActiveTarget(m_logTargetOld
);
1764 delete m_book
->GetImageList();
1767 //----------------------------------------------------------------------
1769 //----------------------------------------------------------------------
1771 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
1772 EVT_MENU(CONTROLS_QUIT
, MyFrame::OnQuit
)
1773 EVT_MENU(CONTROLS_ABOUT
, MyFrame::OnAbout
)
1774 EVT_MENU(CONTROLS_CLEAR_LOG
, MyFrame::OnClearLog
)
1776 EVT_MENU(CONTROLS_SET_TOOLTIP_DELAY
, MyFrame::OnSetTooltipDelay
)
1777 EVT_MENU(CONTROLS_ENABLE_TOOLTIPS
, MyFrame::OnToggleTooltips
)
1778 #endif // wxUSE_TOOLTIPS
1780 EVT_MENU(CONTROLS_ENABLE_ALL
, MyFrame::OnEnableAll
)
1781 EVT_MENU(CONTROLS_CONTEXT_HELP
, MyFrame::OnContextHelp
)
1783 EVT_ICONIZE(MyFrame::OnIconized
)
1784 EVT_MAXIMIZE(MyFrame::OnMaximized
)
1785 EVT_SIZE(MyFrame::OnSize
)
1786 EVT_MOVE(MyFrame::OnMove
)
1788 EVT_IDLE(MyFrame::OnIdle
)
1791 MyFrame::MyFrame(const wxChar
*title
, int x
, int y
)
1792 : wxFrame(NULL
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(700, 450))
1794 SetHelpText( _T("Controls sample demonstrating various widgets") );
1797 // The wxICON() macros loads an icon from a resource under Windows
1798 // and uses an #included XPM image under GTK+ and Motif
1801 SetIcon( wxICON(mondrian
) );
1804 wxMenu
*file_menu
= new wxMenu
;
1806 file_menu
->Append(CONTROLS_CLEAR_LOG
, _T("&Clear log\tCtrl-L"));
1807 file_menu
->AppendSeparator();
1808 file_menu
->Append(CONTROLS_ABOUT
, _T("&About\tF1"));
1809 file_menu
->AppendSeparator();
1810 file_menu
->Append(CONTROLS_QUIT
, _T("E&xit\tAlt-X"), _T("Quit controls sample"));
1812 wxMenuBar
*menu_bar
= new wxMenuBar
;
1813 menu_bar
->Append(file_menu
, _T("&File"));
1816 wxMenu
*tooltip_menu
= new wxMenu
;
1817 tooltip_menu
->Append(CONTROLS_SET_TOOLTIP_DELAY
, _T("Set &delay\tCtrl-D"));
1818 tooltip_menu
->AppendSeparator();
1819 tooltip_menu
->Append(CONTROLS_ENABLE_TOOLTIPS
, _T("&Toggle tooltips\tCtrl-T"),
1820 _T("enable/disable tooltips"), true);
1821 tooltip_menu
->Check(CONTROLS_ENABLE_TOOLTIPS
, true);
1822 menu_bar
->Append(tooltip_menu
, _T("&Tooltips"));
1823 #endif // wxUSE_TOOLTIPS
1825 wxMenu
*panel_menu
= new wxMenu
;
1826 panel_menu
->Append(CONTROLS_ENABLE_ALL
, _T("&Disable all\tCtrl-E"),
1827 _T("Enable/disable all panel controls"), true);
1828 panel_menu
->Append(CONTROLS_CONTEXT_HELP
, _T("&Context help...\tCtrl-H"),
1829 _T("Get context help for a control"));
1830 menu_bar
->Append(panel_menu
, _T("&Panel"));
1832 SetMenuBar(menu_bar
);
1836 #endif // wxUSE_STATUSBAR
1838 m_panel
= new MyPanel( this, 10, 10, 300, 100 );
1841 void MyFrame::OnQuit (wxCommandEvent
& WXUNUSED(event
) )
1846 void MyFrame::OnAbout( wxCommandEvent
& WXUNUSED(event
) )
1850 wxMessageDialog
dialog(this, _T("This is a control sample"), _T("About Controls"), wxOK
);
1854 void MyFrame::OnClearLog(wxCommandEvent
& WXUNUSED(event
))
1856 m_panel
->m_text
->Clear();
1860 void MyFrame::OnSetTooltipDelay(wxCommandEvent
& WXUNUSED(event
))
1862 static long s_delay
= 5000;
1865 delay
.Printf( _T("%ld"), s_delay
);
1867 delay
= wxGetTextFromUser(_T("Enter delay (in milliseconds)"),
1868 _T("Set tooltip delay"),
1872 return; // cancelled
1874 wxSscanf(delay
, _T("%ld"), &s_delay
);
1876 wxToolTip::SetDelay(s_delay
);
1878 wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay
);
1881 void MyFrame::OnToggleTooltips(wxCommandEvent
& WXUNUSED(event
))
1883 static bool s_enabled
= true;
1885 s_enabled
= !s_enabled
;
1887 wxToolTip::Enable(s_enabled
);
1889 wxLogStatus(this, _T("Tooltips %sabled"), s_enabled
? _T("en") : _T("dis") );
1893 void MyFrame::OnEnableAll(wxCommandEvent
& WXUNUSED(event
))
1895 static bool s_enable
= true;
1897 s_enable
= !s_enable
;
1898 m_panel
->Enable(s_enable
);
1901 void MyFrame::OnContextHelp(wxCommandEvent
& WXUNUSED(event
))
1903 // starts a local event loop
1904 wxContextHelp
chelp(this);
1907 void MyFrame::OnMove( wxMoveEvent
& event
)
1910 UpdateStatusBar(event
.GetPosition(), GetSize());
1911 #endif // wxUSE_STATUSBAR
1916 void MyFrame::OnIconized( wxIconizeEvent
& event
)
1918 wxLogMessage(_T("Frame %s"), event
.Iconized() ? _T("iconized")
1923 void MyFrame::OnMaximized( wxMaximizeEvent
& WXUNUSED(event
) )
1925 wxLogMessage(_T("Frame maximized"));
1928 void MyFrame::OnSize( wxSizeEvent
& event
)
1931 UpdateStatusBar(GetPosition(), event
.GetSize());
1932 #endif // wxUSE_STATUSBAR
1937 void MyFrame::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
1939 // track the window which has the focus in the status bar
1940 static wxWindow
*s_windowFocus
= (wxWindow
*)NULL
;
1941 wxWindow
*focus
= wxWindow::FindFocus();
1942 if ( focus
&& (focus
!= s_windowFocus
) )
1944 s_windowFocus
= focus
;
1949 _T("Focus: %s, HWND = %08x"),
1953 s_windowFocus
->GetClassInfo()->GetClassName()
1955 , (unsigned int) s_windowFocus
->GetHWND()
1961 #endif // wxUSE_STATUSBAR
1965 void MyComboBox::OnChar(wxKeyEvent
& event
)
1967 wxLogMessage(_T("MyComboBox::OnChar"));
1969 if ( event
.GetKeyCode() == 'w' )
1970 wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
1975 void MyComboBox::OnKeyDown(wxKeyEvent
& event
)
1977 wxLogMessage(_T("MyComboBox::OnKeyDown"));
1979 if ( event
.GetKeyCode() == 'w' )
1980 wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
1985 void MyComboBox::OnKeyUp(wxKeyEvent
& event
)
1987 wxLogMessage(_T("MyComboBox::OnKeyUp"));
1992 static void SetListboxClientData(const wxChar
*name
, wxListBox
*control
)
1994 size_t count
= control
->GetCount();
1995 for ( size_t n
= 0; n
< count
; n
++ )
1998 s
.Printf(wxT("%s client data for '%s'"),
1999 name
, control
->GetString(n
).c_str());
2001 control
->SetClientObject(n
, new wxStringClientData(s
));
2007 static void SetChoiceClientData(const wxChar
*name
, wxChoice
*control
)
2009 size_t count
= control
->GetCount();
2010 for ( size_t n
= 0; n
< count
; n
++ )
2013 s
.Printf(wxT("%s client data for '%s'"),
2014 name
, control
->GetString(n
).c_str());
2016 control
->SetClientObject(n
, new wxStringClientData(s
));
2020 #endif // wxUSE_CHOICE