/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 | | #include <tools/urlobj.hxx> |
26 | | |
27 | | #include <vcl/idle.hxx> |
28 | | #include <vcl/weld/ComboBox.hxx> |
29 | | #include <vcl/weld/weld.hxx> |
30 | | |
31 | | class SvtMatchContext_Impl; |
32 | | class SvtURLBox_Impl; |
33 | | |
34 | | class SVT_DLLPUBLIC SvtURLBox |
35 | | { |
36 | | friend class SvtMatchContext_Impl; |
37 | | friend class SvtURLBox_Impl; |
38 | | |
39 | | Idle aChangedIdle; |
40 | | OUString aBaseURL; |
41 | | OUString aPlaceHolder; |
42 | | rtl::Reference<SvtMatchContext_Impl> pCtx; |
43 | | std::unique_ptr<SvtURLBox_Impl> pImpl; |
44 | | INetProtocol eSmartProtocol; |
45 | | bool bOnlyDirectories : 1; |
46 | | bool bHistoryDisabled : 1; |
47 | | bool bNoSelection : 1; |
48 | | |
49 | | Link<weld::ComboBox&, void> aChangeHdl; |
50 | | Link<weld::Widget&, void> aFocusInHdl; |
51 | | Link<weld::Widget&, void> aFocusOutHdl; |
52 | | |
53 | | std::unique_ptr<weld::ComboBox> m_xWidget; |
54 | | |
55 | | DECL_DLLPRIVATE_LINK( TryAutoComplete, Timer*, void); |
56 | | SVT_DLLPRIVATE void UpdatePicklistForSmartProtocol_Impl(); |
57 | | DECL_DLLPRIVATE_LINK( ChangedHdl, weld::ComboBox&, void); |
58 | | DECL_DLLPRIVATE_LINK( FocusInHdl, weld::Widget&, void); |
59 | | DECL_DLLPRIVATE_LINK( FocusOutHdl, weld::Widget&, void); |
60 | | SVT_DLLPRIVATE void Init(); |
61 | | |
62 | | public: |
63 | | SvtURLBox(std::unique_ptr<weld::ComboBox> xWidget); |
64 | | ~SvtURLBox(); |
65 | | |
66 | 0 | void set_entry_text(const OUString& rStr) { m_xWidget->set_entry_text(rStr); } |
67 | 0 | void show() { m_xWidget->show(); } |
68 | 0 | void hide() { m_xWidget->hide(); } |
69 | 0 | void clear() { m_xWidget->clear(); } |
70 | 0 | void connect_entry_activate(const Link<weld::ComboBox&, bool>& rLink) { m_xWidget->connect_entry_activate(rLink); } |
71 | 0 | void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_xWidget->connect_key_press(rLink); } |
72 | 0 | void connect_changed(const Link<weld::ComboBox&, void>& rLink) { aChangeHdl = rLink; } |
73 | 0 | void trigger_changed() { aChangeHdl.Call(*m_xWidget); } |
74 | 0 | void connect_focus_in(const Link<weld::Widget&, void>& rLink) { aFocusInHdl = rLink; } |
75 | 0 | void connect_focus_out(const Link<weld::Widget&, void>& rLink) { aFocusOutHdl = rLink; } |
76 | 0 | void append_text(const OUString& rStr) { m_xWidget->append_text(rStr); } |
77 | 0 | int find_text(const OUString& rStr) const { return m_xWidget->find_text(rStr); } |
78 | 0 | OUString get_active_text() const { return m_xWidget->get_active_text(); } |
79 | 0 | void grab_focus() { m_xWidget->grab_focus(); } |
80 | 0 | void set_sensitive(bool bSensitive) { m_xWidget->set_sensitive(bSensitive); } |
81 | 0 | void set_help_id(const OUString& rHelpId) { m_xWidget->set_help_id(rHelpId); } |
82 | 0 | void select_entry_region(int nStartPos, int nEndPos) { m_xWidget->select_entry_region(nStartPos, nEndPos); } |
83 | 0 | Size get_preferred_size() const { return m_xWidget->get_preferred_size(); } |
84 | | |
85 | 0 | void EnableAutocomplete(bool bEnable = true) { m_xWidget->set_entry_completion(bEnable); } |
86 | | void SetBaseURL( const OUString& rURL ); |
87 | 0 | const OUString& GetBaseURL() const { return aBaseURL; } |
88 | | void SetOnlyDirectories( bool bDir ); |
89 | | void SetNoURLSelection( bool bSet ); |
90 | | void SetSmartProtocol( INetProtocol eProt ); |
91 | 0 | INetProtocol GetSmartProtocol() const { return eSmartProtocol; } |
92 | | OUString GetURL(); |
93 | | void DisableHistory(); |
94 | | |
95 | 0 | weld::ComboBox* getWidget() { return m_xWidget.get(); } |
96 | | |
97 | | static OUString ParseSmart( const OUString& aText, const OUString& aBaseURL ); |
98 | | |
99 | 0 | void SetPlaceHolder(const OUString& sPlaceHolder) { aPlaceHolder = sPlaceHolder; } |
100 | 0 | const OUString& GetPlaceHolder() const { return aPlaceHolder; } |
101 | | bool MatchesPlaceHolder(std::u16string_view sToMatch) const |
102 | 0 | { |
103 | 0 | return (!aPlaceHolder.isEmpty() && aPlaceHolder == sToMatch); |
104 | 0 | } |
105 | | |
106 | | void SetFilter(std::u16string_view _sFilter); |
107 | | }; |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |