Don't call IAutoComplete::Init() twice for the same control as this leaks memory...
[wxWidgets.git] / include / wx / msw / textentry.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/textentry.h
3 // Purpose: wxMSW-specific wxTextEntry implementation
4 // Author: Vadim Zeitlin
5 // Created: 2007-09-26
6 // RCS-ID: $Id$
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_MSW_TEXTENTRY_H_
12 #define _WX_MSW_TEXTENTRY_H_
13
14 // ----------------------------------------------------------------------------
15 // wxTextEntry: common part of wxComboBox and (single line) wxTextCtrl
16 // ----------------------------------------------------------------------------
17
18 class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
19 {
20 public:
21 wxTextEntry()
22 {
23 #if wxUSE_OLE
24 m_enumStrings = NULL;
25 #endif // wxUSE_OLE
26 }
27
28 // implement wxTextEntryBase pure virtual methods
29 virtual void WriteText(const wxString& text);
30 virtual void Remove(long from, long to);
31
32 virtual void Copy();
33 virtual void Cut();
34 virtual void Paste();
35
36 virtual void Undo();
37 virtual void Redo();
38 virtual bool CanUndo() const;
39 virtual bool CanRedo() const;
40
41 virtual void SetInsertionPoint(long pos);
42 virtual long GetInsertionPoint() const;
43 virtual long GetLastPosition() const;
44
45 virtual void SetSelection(long from, long to)
46 { DoSetSelection(from, to); }
47 virtual void GetSelection(long *from, long *to) const;
48
49 // auto-completion uses COM under Windows so they won't work without
50 // wxUSE_OLE as OleInitialize() is not called then
51 #if wxUSE_OLE
52 virtual bool AutoComplete(const wxArrayString& choices);
53 virtual bool AutoCompleteFileNames();
54 #endif // wxUSE_OLE
55
56 virtual bool IsEditable() const;
57 virtual void SetEditable(bool editable);
58
59 virtual void SetMaxLength(unsigned long len);
60
61 #if wxUSE_UXTHEME
62 virtual bool SetHint(const wxString& hint);
63 virtual wxString GetHint() const;
64 #endif // wxUSE_UXTHEME
65
66 protected:
67 virtual wxString DoGetValue() const;
68
69 // this is really a hook for multiline text controls as the single line
70 // ones don't need to ever scroll to show the selection but having it here
71 // allows us to put Remove() in the base class
72 enum
73 {
74 SetSel_NoScroll = 0, // don't do anything special
75 SetSel_Scroll = 1 // default: scroll to make the selection visible
76 };
77 virtual void DoSetSelection(long from, long to, int flags = SetSel_Scroll);
78
79 private:
80 // implement this to return the HWND of the EDIT control
81 virtual WXHWND GetEditHWND() const = 0;
82
83 #if wxUSE_OLE
84 // enumerator for strings currently used for auto-completion or NULL
85 class wxIEnumString *m_enumStrings;
86 #endif // wxUSE_OLE
87 };
88
89 #endif // _WX_MSW_TEXTENTRY_H_
90