2011-04-16 13:27:16 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/textcompleter.h
|
|
|
|
// Purpose: Declaration of wxTextCompleter class.
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2011-04-13
|
|
|
|
// 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() { }
|
|
|
|
|
2011-04-16 13:27:34 -04:00
|
|
|
// 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;
|
2011-04-16 13:27:16 -04:00
|
|
|
|
|
|
|
virtual ~wxTextCompleter();
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxTextCompleter);
|
|
|
|
};
|
|
|
|
|
2011-04-16 13:27:34 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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;
|
|
|
|
|
2016-09-25 16:21:28 -04:00
|
|
|
virtual bool Start(const wxString& prefix) wxOVERRIDE;
|
|
|
|
virtual wxString GetNext() wxOVERRIDE;
|
2011-04-16 13:27:34 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxArrayString m_completions;
|
|
|
|
unsigned m_index;
|
|
|
|
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxTextCompleterSimple);
|
|
|
|
};
|
|
|
|
|
2011-04-17 19:14:11 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxTextCompleterFixed: Trivial wxTextCompleter implementation which always
|
|
|
|
// returns the same fixed array of completions.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// NB: This class is private and intentionally not documented as it is
|
|
|
|
// currently used only for implementation of completion with the fixed list
|
|
|
|
// of strings only by wxWidgets itself, do not use it outside of wxWidgets.
|
|
|
|
|
|
|
|
class wxTextCompleterFixed : public wxTextCompleterSimple
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void SetCompletions(const wxArrayString& strings)
|
|
|
|
{
|
|
|
|
m_strings = strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetCompletions(const wxString& WXUNUSED(prefix),
|
2016-09-25 16:21:28 -04:00
|
|
|
wxArrayString& res) wxOVERRIDE
|
2011-04-17 19:14:11 -04:00
|
|
|
{
|
|
|
|
res = m_strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxArrayString m_strings;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-16 13:27:16 -04:00
|
|
|
#endif // _WX_TEXTCOMPLETER_H_
|
2011-04-16 13:27:34 -04:00
|
|
|
|