tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / dbaccess / source / ui / inc / curledit.hxx
blob6042f761ce2f03133947fb4f012ee173aceca805
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <vcl/weld.hxx>
23 #include <dsntypes.hxx>
25 namespace dbaui
28 class OConnectionURLEdit
30 OUString m_sSavedValue;
32 ::dbaccess::ODsnTypeCollection* m_pTypeCollection;
33 OUString m_sSaveValueNoPrefix;
34 bool m_bShowPrefix; // when <TRUE> the prefix will be visible, otherwise not
36 std::unique_ptr<weld::Entry> m_xEntry;
37 std::unique_ptr<weld::Label> m_xForcedPrefix;
39 public:
40 OConnectionURLEdit(std::unique_ptr<weld::Entry> xEntry, std::unique_ptr<weld::Label> xForcedPrefix);
41 ~OConnectionURLEdit();
43 public:
44 bool get_visible() const { return m_xEntry->get_visible(); }
45 void connect_changed(const Link<weld::Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); }
46 void set_help_id(const OUString& rName) { m_xEntry->set_help_id(rName); }
47 void hide()
49 m_xEntry->hide();
50 if (m_bShowPrefix)
51 m_xForcedPrefix->hide();
53 void show()
55 m_xEntry->show();
56 if (m_bShowPrefix)
57 m_xForcedPrefix->show();
59 void save_value() { m_sSavedValue = GetText(); }
60 bool get_value_changed_from_saved() const { return m_sSavedValue != GetText(); }
61 void grab_focus()
63 m_xEntry->grab_focus();
65 void set_sensitive(bool bSensitive)
67 m_xEntry->set_sensitive(bSensitive);
68 if (m_bShowPrefix)
69 m_xForcedPrefix->set_sensitive(bSensitive);
71 void connect_focus_in(const Link<weld::Widget&, void>& rLink)
73 m_xEntry->connect_focus_in(rLink);
75 void connect_focus_out(const Link<weld::Widget&, void>& rLink)
77 m_xEntry->connect_focus_out(rLink);
80 // Edit overridables
81 void SetText(const OUString& _rStr);
82 void SetText(const OUString& _rStr, const Selection& _rNewSelection);
83 OUString GetText() const;
85 /** Shows the Prefix
86 @param _bShowPrefix
87 If <TRUE/> than the prefix will be visible, otherwise not.
89 void ShowPrefix(bool _bShowPrefix);
90 /// get the currently set text, excluding the prefix indicating the type
91 OUString GetTextNoPrefix() const;
92 /// set a new text, leave the current prefix unchanged
93 void SetTextNoPrefix(const OUString& _rText);
95 void SaveValueNoPrefix() { m_sSaveValueNoPrefix = GetTextNoPrefix(); }
96 const OUString& GetSavedValueNoPrefix() const { return m_sSaveValueNoPrefix; }
97 void SetTypeCollection(::dbaccess::ODsnTypeCollection* _pTypeCollection) { m_pTypeCollection = _pTypeCollection; }
100 } // namespace dbaui
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */