/src/libreoffice/include/vcl/weld/EntryFormatter.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include <vcl/dllapi.h> |
13 | | #include <vcl/formatter.hxx> |
14 | | |
15 | | namespace weld |
16 | | { |
17 | | class Entry; |
18 | | class FormattedSpinButton; |
19 | | class TextWidget; |
20 | | class Widget; |
21 | | |
22 | | class VCL_DLLPUBLIC EntryFormatter : public Formatter |
23 | | { |
24 | | public: |
25 | | EntryFormatter(weld::Entry& rEntry); |
26 | | EntryFormatter(weld::FormattedSpinButton& rSpinButton); |
27 | | |
28 | 0 | weld::Entry& get_widget() { return m_rEntry; } |
29 | | |
30 | | // public Formatter overrides, drives interactions with the Entry |
31 | | SAL_DLLPRIVATE virtual Selection GetEntrySelection() const override; |
32 | | SAL_DLLPRIVATE virtual OUString GetEntryText() const override; |
33 | | SAL_DLLPRIVATE virtual void SetEntryText(const OUString& rText, const Selection& rSel) override; |
34 | | SAL_DLLPRIVATE virtual void SetEntryTextColor(const Color* pColor) override; |
35 | | SAL_DLLPRIVATE virtual SelectionOptions GetEntrySelectionOptions() const override; |
36 | | SAL_DLLPRIVATE virtual void FieldModified() override; |
37 | | |
38 | | // public Formatter overrides, drives optional SpinButton settings |
39 | | SAL_DLLPRIVATE virtual void ClearMinValue() override; |
40 | | SAL_DLLPRIVATE virtual void SetMinValue(double dMin) override; |
41 | | SAL_DLLPRIVATE virtual void ClearMaxValue() override; |
42 | | SAL_DLLPRIVATE virtual void SetMaxValue(double dMin) override; |
43 | | |
44 | | SAL_DLLPRIVATE virtual void SetSpinSize(double dStep) override; |
45 | | |
46 | 0 | void SetEntrySelectionOptions(SelectionOptions eOptions) { m_eOptions = eOptions; } |
47 | | |
48 | | /* EntryFormatter will set listeners to "changed" and "focus-out" of the |
49 | | Entry so users that want to add their own listeners to those must set |
50 | | them through this formatter and not directly on that entry. |
51 | | |
52 | | If EntryFormatter is used with a weld::FormattedSpinButton this is |
53 | | handled transparently by the FormattedSpinButton for the user and the |
54 | | handlers can be set on the FormattedSpinButton |
55 | | */ |
56 | 0 | void connect_changed(const Link<weld::TextWidget&, void>& rLink) { m_aModifyHdl = rLink; } |
57 | 0 | void connect_focus_out(const Link<weld::Widget&, void>& rLink) { m_aFocusOutHdl = rLink; } |
58 | | |
59 | | SAL_DLLPRIVATE virtual ~EntryFormatter() override; |
60 | | |
61 | | private: |
62 | | weld::Entry& m_rEntry; |
63 | | weld::FormattedSpinButton* m_pSpinButton; |
64 | | Link<weld::TextWidget&, void> m_aModifyHdl; |
65 | | Link<weld::Widget&, void> m_aFocusOutHdl; |
66 | | SelectionOptions m_eOptions; |
67 | | DECL_DLLPRIVATE_LINK(ModifyHdl, weld::TextWidget&, void); |
68 | | DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void); |
69 | | SAL_DLLPRIVATE void Init(); |
70 | | |
71 | | // private Formatter overrides |
72 | | SAL_DLLPRIVATE virtual void UpdateCurrentValue(double dCurrentValue) override; |
73 | | }; |
74 | | } |
75 | | |
76 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |