]> git.saurik.com Git - wxWidgets.git/blame - include/wx/textcompleter.h
avoid creating and immediately destroying a wxGraphicsContext when creating a wxDC...
[wxWidgets.git] / include / wx / textcompleter.h
CommitLineData
ea98f11c
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/textcompleter.h
3// Purpose: Declaration of wxTextCompleter class.
4// Author: Vadim Zeitlin
5// Created: 2011-04-13
6// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_TEXTCOMPLETER_H_
12#define _WX_TEXTCOMPLETER_H_
13
14// ----------------------------------------------------------------------------
15// wxTextCompleter: used by wxTextEnter::AutoComplete()
16// ----------------------------------------------------------------------------
17
18class WXDLLIMPEXP_CORE wxTextCompleter
19{
20public:
21 wxTextCompleter() { }
22
85047589
VZ
23 // The virtual functions to be implemented by the derived classes: the
24 // first one is called to start preparing for completions for the given
25 // prefix and, if it returns true, GetNext() is called until it returns an
26 // empty string indicating that there are no more completions.
27 virtual bool Start(const wxString& prefix) = 0;
28 virtual wxString GetNext() = 0;
ea98f11c
VZ
29
30 virtual ~wxTextCompleter();
31
32private:
33 wxDECLARE_NO_COPY_CLASS(wxTextCompleter);
34};
35
85047589
VZ
36// ----------------------------------------------------------------------------
37// wxTextCompleterSimple: returns the entire set of completions at once
38// ----------------------------------------------------------------------------
39
40class WXDLLIMPEXP_CORE wxTextCompleterSimple : public wxTextCompleter
41{
42public:
43 wxTextCompleterSimple() { }
44
45 // Must be implemented to return all the completions for the given prefix.
46 virtual void GetCompletions(const wxString& prefix, wxArrayString& res) = 0;
47
48 virtual bool Start(const wxString& prefix);
49 virtual wxString GetNext();
50
51private:
52 wxArrayString m_completions;
53 unsigned m_index;
54
55 wxDECLARE_NO_COPY_CLASS(wxTextCompleterSimple);
56};
57
ed7dda92
VZ
58// ----------------------------------------------------------------------------
59// wxTextCompleterFixed: Trivial wxTextCompleter implementation which always
60// returns the same fixed array of completions.
61// ----------------------------------------------------------------------------
62
63// NB: This class is private and intentionally not documented as it is
64// currently used only for implementation of completion with the fixed list
65// of strings only by wxWidgets itself, do not use it outside of wxWidgets.
66
67class wxTextCompleterFixed : public wxTextCompleterSimple
68{
69public:
70 void SetCompletions(const wxArrayString& strings)
71 {
72 m_strings = strings;
73 }
74
75 virtual void GetCompletions(const wxString& WXUNUSED(prefix),
76 wxArrayString& res)
77 {
78 res = m_strings;
79 }
80
81private:
82 wxArrayString m_strings;
83};
84
85
ea98f11c 86#endif // _WX_TEXTCOMPLETER_H_
85047589 87