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