cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / fpicker / source / office / autocmpledit.hxx
blob3eb79eb14aa6d1f137edba4d7fc9a97a4c30e44b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <vcl/idle.hxx>
13 #include <vcl/weld.hxx>
14 #include <vector>
16 class AutocompleteEdit
18 private:
19 std::unique_ptr<weld::Entry> m_xEntry;
21 std::vector<OUString> m_aEntries;
22 std::vector<OUString> m_aMatching;
23 Idle m_aChangedIdle;
24 Link<weld::Entry&, void> m_aChangeHdl;
25 sal_uInt16 m_nLastCharCode;
27 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
28 DECL_LINK(ChangedHdl, weld::Entry&, void);
29 DECL_LINK(TryAutoComplete, Timer*, void);
31 bool Match(std::u16string_view rText);
33 public:
34 AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry);
36 void show() { m_xEntry->show(); }
37 void set_sensitive(bool bSensitive) { m_xEntry->set_sensitive(bSensitive); }
38 OUString get_text() const { return m_xEntry->get_text(); }
39 void set_text(const OUString& rText) { m_xEntry->set_text(rText); }
40 void grab_focus() { m_xEntry->grab_focus(); }
41 void select_region(int nStartPos, int nEndPos) { m_xEntry->select_region(nStartPos, nEndPos); }
43 void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aChangeHdl = rLink; }
44 void connect_focus_in(const Link<weld::Widget&, void>& rLink)
46 m_xEntry->connect_focus_in(rLink);
49 void AddEntry(const OUString& rEntry);
50 void ClearEntries();
53 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */