/src/libreoffice/include/vcl/weld/PatternFormatter.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/weld/Entry.hxx> |
14 | | |
15 | | namespace weld |
16 | | { |
17 | | class VCL_DLLPUBLIC PatternFormatter final |
18 | | { |
19 | | public: |
20 | | PatternFormatter(weld::Entry& rEntry); |
21 | | ~PatternFormatter(); |
22 | | |
23 | 0 | weld::Entry& get_widget() { return m_rEntry; } |
24 | | |
25 | | void SetMask(const OString& rEditMask, const OUString& rLiteralMask); |
26 | | void SetStrictFormat(bool bStrict); |
27 | | void ReformatAll(); |
28 | | |
29 | | /* PatternFormatter will set listeners to "changed", "focus-out", "focus-in" |
30 | | and "key-press" of the Entry so users that want to add their own listeners |
31 | | to those must set them through this formatter and not directly on that entry. |
32 | | */ |
33 | 0 | void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aModifyHdl = rLink; } |
34 | 0 | void connect_focus_out(const Link<weld::Widget&, void>& rLink) { m_aFocusOutHdl = rLink; } |
35 | 0 | void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_aFocusInHdl = rLink; } |
36 | 0 | void connect_key_press(const Link<const KeyEvent&, bool>& rLink) { m_aKeyPressHdl = rLink; } |
37 | | |
38 | | SAL_DLLPRIVATE void Modify(); |
39 | | |
40 | | private: |
41 | | weld::Entry& m_rEntry; |
42 | | Link<weld::Entry&, void> m_aModifyHdl; |
43 | | Link<weld::Widget&, void> m_aFocusInHdl; |
44 | | Link<weld::Widget&, void> m_aFocusOutHdl; |
45 | | Link<const KeyEvent&, bool> m_aKeyPressHdl; |
46 | | bool m_bStrictFormat; |
47 | | bool m_bSameMask; |
48 | | bool m_bReformat; |
49 | | bool m_bInPattKeyInput; |
50 | | OString m_aEditMask; |
51 | | OUString m_aLiteralMask; |
52 | | |
53 | | SAL_DLLPRIVATE void EntryGainFocus(); |
54 | | SAL_DLLPRIVATE void EntryLostFocus(); |
55 | | DECL_DLLPRIVATE_LINK(ModifyHdl, weld::Entry&, void); |
56 | | DECL_DLLPRIVATE_LINK(FocusInHdl, weld::Widget&, void); |
57 | | DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void); |
58 | | DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool); |
59 | | }; |
60 | | } |
61 | | |
62 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |