summaryrefslogtreecommitdiffstats
path: root/fpicker/source/office/autocmpledit.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /fpicker/source/office/autocmpledit.hxx
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fpicker/source/office/autocmpledit.hxx')
-rw-r--r--fpicker/source/office/autocmpledit.hxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/fpicker/source/office/autocmpledit.hxx b/fpicker/source/office/autocmpledit.hxx
new file mode 100644
index 0000000000..3eb79eb14a
--- /dev/null
+++ b/fpicker/source/office/autocmpledit.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <vcl/idle.hxx>
+#include <vcl/weld.hxx>
+#include <vector>
+
+class AutocompleteEdit
+{
+private:
+ std::unique_ptr<weld::Entry> m_xEntry;
+
+ std::vector<OUString> m_aEntries;
+ std::vector<OUString> m_aMatching;
+ Idle m_aChangedIdle;
+ Link<weld::Entry&, void> m_aChangeHdl;
+ sal_uInt16 m_nLastCharCode;
+
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+ DECL_LINK(ChangedHdl, weld::Entry&, void);
+ DECL_LINK(TryAutoComplete, Timer*, void);
+
+ bool Match(std::u16string_view rText);
+
+public:
+ AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry);
+
+ void show() { m_xEntry->show(); }
+ void set_sensitive(bool bSensitive) { m_xEntry->set_sensitive(bSensitive); }
+ OUString get_text() const { return m_xEntry->get_text(); }
+ void set_text(const OUString& rText) { m_xEntry->set_text(rText); }
+ void grab_focus() { m_xEntry->grab_focus(); }
+ void select_region(int nStartPos, int nEndPos) { m_xEntry->select_region(nStartPos, nEndPos); }
+
+ void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aChangeHdl = rLink; }
+ void connect_focus_in(const Link<weld::Widget&, void>& rLink)
+ {
+ m_xEntry->connect_focus_in(rLink);
+ }
+
+ void AddEntry(const OUString& rEntry);
+ void ClearEntries();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */