From c60122bf37a65f07f517e14a98ce988a3eae8305 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Mon, 11 Dec 2006 20:32:16 +0000 Subject: [PATCH] Change event names to clarify that they are only fired by button clicks, and note ways of retrieving search queries in the docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/srchctrl.tex | 11 ++++++----- include/wx/srchctrl.h | 12 ++++++------ src/common/srchcmn.cpp | 4 ++-- src/generic/srchctlg.cpp | 8 +++++--- src/mac/carbon/srchctrl.cpp | 4 ++-- wxPython/demo/SearchCtrl.py | 4 ++-- wxPython/src/_srchctrl.i | 9 ++++----- 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/latex/wx/srchctrl.tex b/docs/latex/wx/srchctrl.tex index 0d7b769ae3..e341103e49 100644 --- a/docs/latex/wx/srchctrl.tex +++ b/docs/latex/wx/srchctrl.tex @@ -7,7 +7,7 @@ control, and a cancel button. \wxheading{Derived from} -\helpref{wxTextCtrl}{wxsearchctrl}\\ +\helpref{wxTextCtrl}{wxtextctrl}\\ streambuf\\ \helpref{wxControl}{wxcontrol}\\ \helpref{wxWindow}{wxwindow}\\ @@ -44,13 +44,14 @@ See also \helpref{window styles overview}{windowstyles} and \helpref{wxSearchCtr \wxheading{Event handling} To process input from a search control, use these event handler macros to direct input to member -functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument. +functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument. To retrieve actual search +queries, use EVT\_TEXT and EVT\_TEXT\_ENTER events, just as you would with \helpref{wxTextCtrl}{wxtextctrl}. \twocolwidtha{9cm}% \begin{twocollist}\itemsep=0pt -\twocolitem{{\bf EVT\_SEARCHCTRL\_SEARCH(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_SEARCH event, -generated when the search button is clicked.} -\twocolitem{{\bf EVT\_SEARCHCTRL\_CANCEL(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_CANCEL event, +\twocolitem{{\bf EVT\_SEARCHCTRL\_SEARCH\_BTN(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_SEARCH\_BTN event, +generated when the search button is clicked. Note that this does not initiate a search.} +\twocolitem{{\bf EVT\_SEARCHCTRL\_CANCEL\_BTN(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_CANCEL\_BTN event, generated when the cancel button is clicked.} \end{twocollist}% diff --git a/include/wx/srchctrl.h b/include/wx/srchctrl.h index e9d2a277c5..5ec9336f3f 100644 --- a/include/wx/srchctrl.h +++ b/include/wx/srchctrl.h @@ -37,8 +37,8 @@ extern WXDLLEXPORT_DATA(const wxChar) wxSearchCtrlNameStr[]; BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL, 1119) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH, 1120) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1119) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1120) END_DECLARE_EVENT_TYPES() // ---------------------------------------------------------------------------- @@ -78,11 +78,11 @@ public: // macros for handling search events // ---------------------------------------------------------------------------- -#define EVT_SEARCHCTRL_CANCEL(id, fn) \ - wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_CANCEL, id, wxCommandEventHandler(fn)) +#define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn)) -#define EVT_SEARCHCTRL_SEARCH(id, fn) \ - wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_SEARCH, id, wxCommandEventHandler(fn)) +#define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn)) #endif // wxUSE_SEARCHCTRL diff --git a/src/common/srchcmn.cpp b/src/common/srchcmn.cpp index f42771c753..8cdbaf7e0a 100644 --- a/src/common/srchcmn.cpp +++ b/src/common/srchcmn.cpp @@ -35,8 +35,8 @@ const wxChar wxSearchCtrlNameStr[] = wxT("searchCtrl"); -DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL) -DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN) #endif // wxUSE_SEARCHCTRL diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index b09517beda..d622f78795 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -137,7 +137,7 @@ protected: m_search->SetFocus(); - if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH ) + if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN ) { // this happens automatically, just like on Mac OS X m_search->PopupSearchMenu(); @@ -230,8 +230,10 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK); - m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH,m_searchBitmap); - m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL,m_cancelBitmap); + wxSize sizeText = m_text->GetBestSize(); + + m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,m_searchBitmap); + m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,m_cancelBitmap); SetForegroundColour( m_text->GetForegroundColour() ); m_searchButton->SetForegroundColour( m_text->GetForegroundColour() ); diff --git a/src/mac/carbon/srchctrl.cpp b/src/mac/carbon/srchctrl.cpp index 6ec0a7b394..b8a450ef40 100644 --- a/src/mac/carbon/srchctrl.cpp +++ b/src/mac/carbon/srchctrl.cpp @@ -341,7 +341,7 @@ bool wxSearchCtrl::IsCancelButtonVisible() const wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { - wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH, m_windowId ); + wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId ); event.SetEventObject(this); ProcessCommand(event); return eventNotHandledErr ; @@ -349,7 +349,7 @@ wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler wxInt32 wxSearchCtrl::MacSearchFieldCancelHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) ) { - wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL, m_windowId ); + wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId ); event.SetEventObject(this); ProcessCommand(event); return eventNotHandledErr ; diff --git a/wxPython/demo/SearchCtrl.py b/wxPython/demo/SearchCtrl.py index 53d600c907..dfadb43a28 100644 --- a/wxPython/demo/SearchCtrl.py +++ b/wxPython/demo/SearchCtrl.py @@ -39,8 +39,8 @@ class TestPanel(wx.Panel): self.Bind(wx.EVT_CHECKBOX, self.OnToggleCancelButton, cancelBtnOpt) self.Bind(wx.EVT_CHECKBOX, self.OnToggleSearchMenu, menuBtnOpt) - self.Bind(wx.EVT_SEARCHCTRL_SEARCH, self.OnSearch, self.search) - self.Bind(wx.EVT_SEARCHCTRL_CANCEL, self.OnCancel, self.search) + self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search) + self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel, self.search) self.search.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch) #, self.search) diff --git a/wxPython/src/_srchctrl.i b/wxPython/src/_srchctrl.i index cac34b3cfd..83a244b345 100644 --- a/wxPython/src/_srchctrl.i +++ b/wxPython/src/_srchctrl.i @@ -158,7 +158,6 @@ v10.3", ""); attached, the search button will be visible regardless of the search button visibility value. This always returns false in Mac OS X v10.3", ""); - DocDeclStr( virtual void , ShowCancelButton( bool show ), "Shows or hides the cancel button.", ""); @@ -200,12 +199,12 @@ work on the Mac.", ""); -%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL; -%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH; +%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN; +%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN; %pythoncode { - EVT_SEARCHCTRL_CANCEL = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL, 1) - EVT_SEARCHCTRL_SEARCH = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH, 1) + EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1) + EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1) } //--------------------------------------------------------------------------- -- 2.45.2