X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0bf0b6bb87d7e15e50e0b7e1627ad9ab7af746db..c6aabd1ca9a5590d5dd8e89d83a5fba74c69c931:/samples/widgets/searchctrl.cpp diff --git a/samples/widgets/searchctrl.cpp b/samples/widgets/searchctrl.cpp index 3af8ae3e0e..4031dbd51f 100644 --- a/samples/widgets/searchctrl.cpp +++ b/samples/widgets/searchctrl.cpp @@ -72,6 +72,7 @@ public: virtual ~SearchCtrlWidgetsPage(){}; virtual wxControl *GetWidget() const { return m_srchCtrl; } + virtual wxTextEntryBase *GetTextEntry() const { return m_srchCtrl; } virtual void RecreateWidget() { CreateControl(); } // lazy creation of the content @@ -83,6 +84,8 @@ protected: void OnToggleCancelButton(wxCommandEvent&); void OnToggleSearchMenu(wxCommandEvent&); + void OnSearch(wxCommandEvent& event); + wxMenu* CreateTestMenu(); // (re)create the control @@ -110,6 +113,8 @@ BEGIN_EVENT_TABLE(SearchCtrlWidgetsPage, WidgetsPage) EVT_CHECKBOX(ID_SEARCH_CB, SearchCtrlWidgetsPage::OnToggleSearchButton) EVT_CHECKBOX(ID_CANCEL_CB, SearchCtrlWidgetsPage::OnToggleCancelButton) EVT_CHECKBOX(ID_MENU_CB, SearchCtrlWidgetsPage::OnToggleSearchMenu) + + EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, SearchCtrlWidgetsPage::OnSearch) END_EVENT_TABLE() // ============================================================================ @@ -122,8 +127,8 @@ END_EVENT_TABLE() #define FAMILY_CTRLS GENERIC_CTRLS #endif -IMPLEMENT_WIDGETS_PAGE(SearchCtrlWidgetsPage, _T("SearchCtrl"), - FAMILY_CTRLS | ALL_CTRLS); +IMPLEMENT_WIDGETS_PAGE(SearchCtrlWidgetsPage, wxT("SearchCtrl"), + FAMILY_CTRLS | EDITABLE_CTRLS | ALL_CTRLS); SearchCtrlWidgetsPage::SearchCtrlWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) @@ -180,7 +185,7 @@ wxMenu* SearchCtrlWidgetsPage::CreateTestMenu() { wxMenu* menu = new wxMenu; const int SEARCH_MENU_SIZE = 5; - wxMenuItem* menuItem = menu->Append(wxID_ANY, _T("Recent Searches"), wxT(""), wxITEM_NORMAL); + wxMenuItem* menuItem = menu->Append(wxID_ANY, wxT("Recent Searches"), wxT(""), wxITEM_NORMAL); menuItem->Enable(false); for ( int i = 0; i < SEARCH_MENU_SIZE; i++ ) { @@ -204,12 +209,12 @@ wxMenu* SearchCtrlWidgetsPage::CreateTestMenu() void SearchCtrlWidgetsPage::OnToggleSearchButton(wxCommandEvent&) { - m_srchCtrl->SetSearchButtonVisible( m_searchBtnCheck->GetValue() ); + m_srchCtrl->ShowSearchButton( m_searchBtnCheck->GetValue() ); } void SearchCtrlWidgetsPage::OnToggleCancelButton(wxCommandEvent&) { - m_srchCtrl->SetCancelButtonVisible( m_cancelBtnCheck->GetValue() ); + m_srchCtrl->ShowCancelButton( m_cancelBtnCheck->GetValue() ); } @@ -221,5 +226,9 @@ void SearchCtrlWidgetsPage::OnToggleSearchMenu(wxCommandEvent&) m_srchCtrl->SetMenu(NULL); } +void SearchCtrlWidgetsPage::OnSearch(wxCommandEvent& event) +{ + wxLogMessage("Search button: search for \"%s\".", event.GetString()); +} #endif // wxUSE_SEARCHCTRL