diff --git a/docs/changes.txt b/docs/changes.txt index d6ae9203dc..03fbc91981 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -177,7 +177,8 @@ All (GUI): - Add Set/GetFooter/Text/Icon() to wxRichMessageDialog (Tobias Taschner) - Add wxFloatingPointValidator::SetFactor(). - Add "hint" property to wxSearchCtrl XRC handler. -- Generate wxEVT_SEARCHCTRL_SEARCH_BTN on Enter under all platforms. +- Add wxEVT_SEARCH[_CANCEL] synonyms for wxSearchCtrl events. +- Generate wxEVT_SEARCH on Enter under all platforms. wxGTK: diff --git a/include/wx/srchctrl.h b/include/wx/srchctrl.h index 791fcb8092..8a0fa4da73 100644 --- a/include/wx/srchctrl.h +++ b/include/wx/srchctrl.h @@ -41,8 +41,8 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxSearchCtrlNameStr[]; -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent); -wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCH_CANCEL, wxCommandEvent); +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCH, wxCommandEvent); // ---------------------------------------------------------------------------- // a search ctrl is a text control with a search button and a cancel button @@ -90,13 +90,20 @@ private: // macros for handling search events // ---------------------------------------------------------------------------- -#define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn)) +#define EVT_SEARCH_CANCEL(id, fn) \ + wx__DECLARE_EVT1(wxEVT_SEARCH_CANCEL, id, wxCommandEventHandler(fn)) -#define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \ - wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn)) +#define EVT_SEARCH(id, fn) \ + wx__DECLARE_EVT1(wxEVT_SEARCH, id, wxCommandEventHandler(fn)) -// old wxEVT_COMMAND_* constants +// old synonyms +#define wxEVT_SEARCHCTRL_CANCEL_BTN wxEVT_SEARCH_CANCEL +#define wxEVT_SEARCHCTRL_SEARCH_BTN wxEVT_SEARCH + +#define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) EVT_SEARCH_CANCEL(id, fn) +#define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) EVT_SEARCH(id, fn) + +// even older wxEVT_COMMAND_* constants #define wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN wxEVT_SEARCHCTRL_CANCEL_BTN #define wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN wxEVT_SEARCHCTRL_SEARCH_BTN diff --git a/interface/wx/srchctrl.h b/interface/wx/srchctrl.h index d888d581fa..975a137703 100644 --- a/interface/wx/srchctrl.h +++ b/interface/wx/srchctrl.h @@ -35,19 +35,19 @@ @endStyleTable @beginEventEmissionTable{wxCommandEvent} - To react to the changes in the control contents, use EVT_TEXT event, just + To react to the changes in the control contents, use wxEVT_TEXT event, just as you would do with wxTextCtrl. However it is recommended to use - EVT_SEARCHCTRL_SEARCH_BTN to actually start searching to avoid doing it too - soon, while the user is still typing (note that EVT_SEARCHCTRL_SEARCH_BTN - is also triggered by pressing Enter in the control). - @event{EVT_SEARCHCTRL_SEARCH_BTN(id, func)} - Respond to a @c wxEVT_SEARCHCTRL_SEARCH_BTN event, generated when the + wxEVT_SEARCH to actually start searching to avoid doing it too soon, while + the user is still typing (note that wxEVT_SEARCH is also triggered by + pressing Enter in the control). + @event{EVT_SEARCH(id, func)} + Respond to a @c wxEVT_SEARCH event, generated when the search button is clicked. Note that this does not initiate a search on its own, you need to perform the appropriate action in your event handler. You may use @code event.GetString() @endcode to retrieve the string to search for in the event handler code. - @event{EVT_SEARCHCTRL_CANCEL_BTN(id, func)} - Respond to a @c wxEVT_SEARCHCTRL_CANCEL_BTN event, generated when the + @event{EVT_SEARCH_CANCEL(id, func)} + Respond to a @c wxEVT_SEARCH_CANCEL event, generated when the cancel button is clicked. @endEventTable @@ -161,5 +161,5 @@ public: }; -wxEventType wxEVT_SEARCHCTRL_CANCEL_BTN; -wxEventType wxEVT_SEARCHCTRL_SEARCH_BTN; +wxEventType wxEVT_SEARCH_CANCEL; +wxEventType wxEVT_SEARCH; diff --git a/samples/widgets/searchctrl.cpp b/samples/widgets/searchctrl.cpp index a647835ed8..7252ab078d 100644 --- a/samples/widgets/searchctrl.cpp +++ b/samples/widgets/searchctrl.cpp @@ -120,8 +120,8 @@ wxBEGIN_EVENT_TABLE(SearchCtrlWidgetsPage, WidgetsPage) EVT_TEXT(wxID_ANY, SearchCtrlWidgetsPage::OnText) EVT_TEXT_ENTER(wxID_ANY, SearchCtrlWidgetsPage::OnTextEnter) - EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, SearchCtrlWidgetsPage::OnSearch) - EVT_SEARCHCTRL_CANCEL_BTN(wxID_ANY, SearchCtrlWidgetsPage::OnSearchCancel) + EVT_SEARCH(wxID_ANY, SearchCtrlWidgetsPage::OnSearch) + EVT_SEARCH_CANCEL(wxID_ANY, SearchCtrlWidgetsPage::OnSearchCancel) wxEND_EVENT_TABLE() // ============================================================================ diff --git a/src/common/srchcmn.cpp b/src/common/srchcmn.cpp index 1e524b5394..788b466937 100644 --- a/src/common/srchcmn.cpp +++ b/src/common/srchcmn.cpp @@ -34,8 +34,8 @@ const char wxSearchCtrlNameStr[] = "searchCtrl"; -wxDEFINE_EVENT(wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent); -wxDEFINE_EVENT(wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent); +wxDEFINE_EVENT(wxEVT_SEARCH_CANCEL, wxCommandEvent); +wxDEFINE_EVENT(wxEVT_SEARCH, wxCommandEvent); #endif // wxUSE_SEARCHCTRL diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 6775f9bcae..074bee8722 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -96,7 +96,7 @@ protected: { if ( !IsEmpty() ) { - wxCommandEvent event(wxEVT_SEARCHCTRL_SEARCH_BTN, m_search->GetId()); + wxCommandEvent event(wxEVT_SEARCH, m_search->GetId()); event.SetEventObject(m_search); event.SetString(m_search->GetValue()); @@ -196,7 +196,7 @@ protected: wxCommandEvent event(m_eventType, m_search->GetId()); event.SetEventObject(m_search); - if ( m_eventType == wxEVT_SEARCHCTRL_SEARCH_BTN ) + if ( m_eventType == wxEVT_SEARCH ) { // it's convenient to have the string to search for directly in the // event instead of having to retrieve it from the control in the @@ -209,7 +209,7 @@ protected: m_search->SetFocus(); #if wxUSE_MENUS - if ( m_eventType == wxEVT_SEARCHCTRL_SEARCH_BTN ) + if ( m_eventType == wxEVT_SEARCH ) { // this happens automatically, just like on Mac OS X m_search->PopupSearchMenu(); @@ -238,7 +238,7 @@ wxBEGIN_EVENT_TABLE(wxSearchButton, wxControl) wxEND_EVENT_TABLE() wxBEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase) - EVT_SEARCHCTRL_CANCEL_BTN(wxID_ANY, wxSearchCtrl::OnCancelButton) + EVT_SEARCH_CANCEL(wxID_ANY, wxSearchCtrl::OnCancelButton) EVT_SIZE(wxSearchCtrl::OnSize) wxEND_EVENT_TABLE() @@ -322,10 +322,10 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, m_text = new wxSearchTextCtrl(this, value, style); m_searchButton = new wxSearchButton(this, - wxEVT_SEARCHCTRL_SEARCH_BTN, + wxEVT_SEARCH, m_searchBitmap); m_cancelButton = new wxSearchButton(this, - wxEVT_SEARCHCTRL_CANCEL_BTN, + wxEVT_SEARCH_CANCEL, m_cancelBitmap); SetBackgroundColour( m_text->GetBackgroundColour() ); diff --git a/src/osx/srchctrl_osx.cpp b/src/osx/srchctrl_osx.cpp index 928bb9340e..fa3101f42e 100644 --- a/src/osx/srchctrl_osx.cpp +++ b/src/osx/srchctrl_osx.cpp @@ -209,7 +209,7 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, bool wxSearchCtrl::HandleSearchFieldSearchHit() { - wxCommandEvent event(wxEVT_SEARCHCTRL_SEARCH_BTN, m_windowId ); + wxCommandEvent event(wxEVT_SEARCH, m_windowId ); event.SetEventObject(this); // provide the string to search for directly in the event, this is more @@ -221,7 +221,7 @@ bool wxSearchCtrl::HandleSearchFieldSearchHit() bool wxSearchCtrl::HandleSearchFieldCancelHit() { - wxCommandEvent event(wxEVT_SEARCHCTRL_CANCEL_BTN, m_windowId ); + wxCommandEvent event(wxEVT_SEARCH_CANCEL, m_windowId ); event.SetEventObject(this); return ProcessCommand(event); }