/src/libreoffice/include/svtools/inettbc.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <memory> |
23 | | #include <rtl/ref.hxx> |
24 | | #include <svtools/svtdllapi.h> |
25 | | |
26 | | #include <vcl/idle.hxx> |
27 | | #include <vcl/weld/ComboBox.hxx> |
28 | | |
29 | | class SvtMatchContext_Impl; |
30 | | class SvtURLBox_Impl; |
31 | | |
32 | | enum class INetProtocol; |
33 | | |
34 | | namespace weld { class Widget; } |
35 | | |
36 | | class SVT_DLLPUBLIC SvtURLBox |
37 | | { |
38 | | friend class SvtMatchContext_Impl; |
39 | | friend class SvtURLBox_Impl; |
40 | | |
41 | | Idle aChangedIdle; |
42 | | OUString aBaseURL; |
43 | | OUString aPlaceHolder; |
44 | | rtl::Reference<SvtMatchContext_Impl> pCtx; |
45 | | std::unique_ptr<SvtURLBox_Impl> pImpl; |
46 | | INetProtocol eSmartProtocol; |
47 | | bool bOnlyDirectories : 1; |
48 | | bool bHistoryDisabled : 1; |
49 | | bool bNoSelection : 1; |
50 | | |
51 | | Link<weld::ComboBox&, void> aChangeHdl; |
52 | | Link<weld::Widget&, void> aFocusInHdl; |
53 | | Link<weld::Widget&, void> aFocusOutHdl; |
54 | | |
55 | | std::unique_ptr<weld::ComboBox> m_xWidget; |
56 | | |
57 | | DECL_DLLPRIVATE_LINK( TryAutoComplete, Timer*, void); |
58 | | SVT_DLLPRIVATE void UpdatePicklistForSmartProtocol_Impl(); |
59 | | DECL_DLLPRIVATE_LINK( ChangedHdl, weld::ComboBox&, void); |
60 | | DECL_DLLPRIVATE_LINK( FocusInHdl, weld::Widget&, void); |
61 | | DECL_DLLPRIVATE_LINK( FocusOutHdl, weld::Widget&, void); |
62 | | SVT_DLLPRIVATE void Init(); |
63 | | |
64 | | public: |
65 | | SvtURLBox(std::unique_ptr<weld::ComboBox> xWidget); |
66 | | ~SvtURLBox(); |
67 | | |
68 | 0 | void set_entry_text(const OUString& rStr) { m_xWidget->set_entry_text(rStr); } |
69 | 0 | void show() { m_xWidget->show(); } |
70 | 0 | void hide() { m_xWidget->hide(); } |
71 | 0 | void clear() { m_xWidget->clear(); } |
72 | 0 | void connect_entry_activate(const Link<weld::ComboBox&, bool>& rLink) { m_xWidget->connect_entry_activate(rLink); } |
73 | 0 | void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_xWidget->connect_key_press(rLink); } |
74 | 0 | void connect_changed(const Link<weld::ComboBox&, void>& rLink) { aChangeHdl = rLink; } |
75 | 0 | void trigger_changed() { aChangeHdl.Call(*m_xWidget); } |
76 | 0 | void connect_focus_in(const Link<weld::Widget&, void>& rLink) { aFocusInHdl = rLink; } |
77 | 0 | void connect_focus_out(const Link<weld::Widget&, void>& rLink) { aFocusOutHdl = rLink; } |
78 | 0 | void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); } |
79 | 0 | int find_text(const OUString& rStr) const { return m_xWidget->find_text(rStr); } |
80 | 0 | OUString get_active_text() const { return m_xWidget->get_active_text(); } |
81 | 0 | void grab_focus() { m_xWidget->grab_focus(); } |
82 | 0 | void set_sensitive(bool bSensitive) { m_xWidget->set_sensitive(bSensitive); } |
83 | 0 | void set_help_id(const OUString& rHelpId) { m_xWidget->set_help_id(rHelpId); } |
84 | 0 | void select_entry_region(int nStartPos, int nEndPos) { m_xWidget->select_entry_region(nStartPos, nEndPos); } |
85 | 0 | Size get_preferred_size() const { return m_xWidget->get_preferred_size(); } |
86 | | |
87 | 0 | void EnableAutocomplete(bool bEnable = true) { m_xWidget->set_entry_completion(bEnable); } |
88 | | void SetBaseURL( const OUString& rURL ); |
89 | 0 | const OUString& GetBaseURL() const { return aBaseURL; } |
90 | | void SetOnlyDirectories( bool bDir ); |
91 | | void SetNoURLSelection( bool bSet ); |
92 | | void SetSmartProtocol( INetProtocol eProt ); |
93 | 0 | INetProtocol GetSmartProtocol() const { return eSmartProtocol; } |
94 | | OUString GetURL(); |
95 | | void DisableHistory(); |
96 | | |
97 | 0 | weld::ComboBox* getWidget() { return m_xWidget.get(); } |
98 | | |
99 | | static OUString ParseSmart( const OUString& aText, const OUString& aBaseURL ); |
100 | | |
101 | 0 | void SetPlaceHolder(const OUString& sPlaceHolder) { aPlaceHolder = sPlaceHolder; } |
102 | 0 | const OUString& GetPlaceHolder() const { return aPlaceHolder; } |
103 | | bool MatchesPlaceHolder(std::u16string_view sToMatch) const |
104 | 0 | { |
105 | 0 | return (!aPlaceHolder.isEmpty() && aPlaceHolder == sToMatch); |
106 | 0 | } |
107 | | |
108 | | void SetFilter(std::u16string_view _sFilter); |
109 | | }; |
110 | | |
111 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |