85047589a9
Allow overriding either the iterator-like methods of the base class or the single and possibly more convenient, albeit slightly less efficient, method of the derived wxTextCompleterSimple class. This makes it possible to completely delegate to wxTextCompleter from wxMSW IEnumString implementation and actually makes the code there easier, even if it it still not quite trivial because of multi-threading concerns. It also would make it possible to show the completions progressively, as they are retrieved, in a future generic implementation of auto-completion (MSW native implementation doesn't do this unfortunately and waits until all of the completions become available before showing them). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/textcompleter.h
|
|
// Purpose: Declaration of wxTextCompleter class.
|
|
// Author: Vadim Zeitlin
|
|
// Created: 2011-04-13
|
|
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
|
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
// Licence: wxWindows licence
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_TEXTCOMPLETER_H_
|
|
#define _WX_TEXTCOMPLETER_H_
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// wxTextCompleter: used by wxTextEnter::AutoComplete()
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_CORE wxTextCompleter
|
|
{
|
|
public:
|
|
wxTextCompleter() { }
|
|
|
|
// The virtual functions to be implemented by the derived classes: the
|
|
// first one is called to start preparing for completions for the given
|
|
// prefix and, if it returns true, GetNext() is called until it returns an
|
|
// empty string indicating that there are no more completions.
|
|
virtual bool Start(const wxString& prefix) = 0;
|
|
virtual wxString GetNext() = 0;
|
|
|
|
virtual ~wxTextCompleter();
|
|
|
|
private:
|
|
wxDECLARE_NO_COPY_CLASS(wxTextCompleter);
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// wxTextCompleterSimple: returns the entire set of completions at once
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_CORE wxTextCompleterSimple : public wxTextCompleter
|
|
{
|
|
public:
|
|
wxTextCompleterSimple() { }
|
|
|
|
// Must be implemented to return all the completions for the given prefix.
|
|
virtual void GetCompletions(const wxString& prefix, wxArrayString& res) = 0;
|
|
|
|
virtual bool Start(const wxString& prefix);
|
|
virtual wxString GetNext();
|
|
|
|
private:
|
|
wxArrayString m_completions;
|
|
unsigned m_index;
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxTextCompleterSimple);
|
|
};
|
|
|
|
#endif // _WX_TEXTCOMPLETER_H_
|
|
|