From e7a526604ca67e416b2c41556e3801fddb422329 Mon Sep 17 00:00:00 2001 From: Eric Jensen Date: Sat, 7 May 2016 01:49:22 +0200 Subject: [PATCH] Implement auto complete in generic wxSearchCtrl Just forward the relevant methods to the embedded wxTextCtrl. Closes #17519. --- docs/changes.txt | 1 + include/wx/generic/srchctlg.h | 5 +++++ src/generic/srchctlg.cpp | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 39a3f576e9..68c0b34a1d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -81,6 +81,7 @@ All (GUI): - Make wxDataViewCtrl::Expand() expand ancestors in native ports too. - Add wxDataViewCtrl::SetHeaderAttr(). - Add wxListCtrl::SetHeaderAttr(). +- Implement auto complete in generic wxSearchCtrl (Eric Jensen). wxGTK: diff --git a/include/wx/generic/srchctlg.h b/include/wx/generic/srchctlg.h index 3eb8d21c92..a3d0ce86fe 100644 --- a/include/wx/generic/srchctlg.h +++ b/include/wx/generic/srchctlg.h @@ -166,6 +166,11 @@ public: virtual void SelectAll() wxOVERRIDE; virtual void SetEditable(bool editable) wxOVERRIDE; + // Autocomplete + virtual bool DoAutoCompleteStrings(const wxArrayString &choices) wxOVERRIDE; + virtual bool DoAutoCompleteFileNames(int flags) wxOVERRIDE; + virtual bool DoAutoCompleteCustom(wxTextCompleter *completer) wxOVERRIDE; + #if 0 // override streambuf method diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index eed9aa7348..8a1137405f 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -820,6 +820,24 @@ bool wxSearchCtrl::SetBackgroundColour(const wxColour& colour) return true; } + +// Autocomplete +bool wxSearchCtrl::DoAutoCompleteStrings(const wxArrayString &choices) +{ + return m_text->AutoComplete( choices ); +} + +bool wxSearchCtrl::DoAutoCompleteFileNames(int flags) +{ + return flags == wxFILE ? m_text->AutoCompleteFileNames() : m_text->AutoCompleteDirectories(); +} + +bool wxSearchCtrl::DoAutoCompleteCustom(wxTextCompleter *completer) +{ + return m_text->AutoComplete(completer); +} + + // search control generic only void wxSearchCtrl::SetSearchBitmap( const wxBitmap& bitmap ) {