X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/206d3a16caa7a4e626395ae52cc8f7e0225e202d..848c4eb27bacb870d97385560124970b84ee4d72:/samples/widgets/listbox.cpp diff --git a/samples/widgets/listbox.cpp b/samples/widgets/listbox.cpp index fa37386532..686cbe4021 100644 --- a/samples/widgets/listbox.cpp +++ b/samples/widgets/listbox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Program: wxWindows Widgets Sample +// Program: wxWidgets Widgets Sample // Name: listbox.cpp // Purpose: Part of the widgets sample showing wxListbox // Author: Vadim Zeitlin @@ -24,6 +24,8 @@ #pragma hdrstop #endif +#if wxUSE_LISTBOX + // for all others, include the necessary headers #ifndef WX_PRECOMP #include "wx/log.h" @@ -43,7 +45,7 @@ #include "wx/checklst.h" #include "widgets.h" -#if 1 + #include "icons/listbox.xpm" // ---------------------------------------------------------------------------- @@ -74,7 +76,9 @@ enum class ListboxWidgetsPage : public WidgetsPage { public: - ListboxWidgetsPage(wxNotebook *notebook, wxImageList *imaglist); + ListboxWidgetsPage(wxBookCtrl *book, wxImageList *imaglist); + + virtual wxControl *GetWidget() const { return m_lbox; } protected: // event handlers @@ -189,9 +193,9 @@ END_EVENT_TABLE() IMPLEMENT_WIDGETS_PAGE(ListboxWidgetsPage, _T("Listbox")); -ListboxWidgetsPage::ListboxWidgetsPage(wxNotebook *notebook, +ListboxWidgetsPage::ListboxWidgetsPage(wxBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(notebook) + : WidgetsPage(book) { imaglist->Add(wxBitmap(listbox_xpm)); @@ -493,10 +497,13 @@ void ListboxWidgetsPage::OnUpdateUIAddSeveral(wxUpdateUIEvent& event) void ListboxWidgetsPage::OnListbox(wxCommandEvent& event) { - long sel = event.GetInt(); + long sel = event.GetSelection(); m_textDelete->SetValue(wxString::Format(_T("%ld"), sel)); - wxLogMessage(_T("Listbox item %ld selected"), sel); + if (event.IsSelection()) + wxLogMessage(_T("Listbox item %ld selected"), sel); + else + wxLogMessage(_T("Listbox item %ld deselected"), sel); } void ListboxWidgetsPage::OnListboxDClick(wxCommandEvent& event) @@ -514,4 +521,4 @@ void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) CreateLbox(); } -#endif +#endif // wxUSE_LISTBOX