/src/libreoffice/vcl/source/control/FieldFormatter.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 | | * 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 | | #include <tools/gen.hxx> |
21 | | |
22 | | #include <vcl/toolkit/fmtfield.hxx> |
23 | | |
24 | | class FieldFormatter : public Formatter |
25 | | { |
26 | | private: |
27 | | FormattedField& m_rSpinButton; |
28 | | |
29 | | public: |
30 | | FieldFormatter(FormattedField& rSpinButton) |
31 | 0 | : m_rSpinButton(rSpinButton) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | // Formatter overrides |
36 | 0 | virtual Selection GetEntrySelection() const override { return m_rSpinButton.GetSelection(); } |
37 | | |
38 | 0 | virtual OUString GetEntryText() const override { return m_rSpinButton.GetText(); } |
39 | | |
40 | | void SetEntryText(const OUString& rText, const Selection& rSel) override |
41 | 0 | { |
42 | 0 | m_rSpinButton.SpinField::SetText(rText, rSel); |
43 | 0 | } |
44 | | |
45 | | virtual void SetEntryTextColor(const ::Color* pColor) override |
46 | 0 | { |
47 | 0 | if (pColor) |
48 | 0 | m_rSpinButton.SetControlForeground(*pColor); |
49 | 0 | else |
50 | 0 | m_rSpinButton.SetControlForeground(); |
51 | 0 | } |
52 | | |
53 | | virtual SelectionOptions GetEntrySelectionOptions() const override |
54 | 0 | { |
55 | 0 | return m_rSpinButton.GetSettings().GetStyleSettings().GetSelectionOptions(); |
56 | 0 | } |
57 | | |
58 | 0 | virtual void FieldModified() override { m_rSpinButton.SpinField::Modify(); } |
59 | | |
60 | | virtual void UpdateCurrentValue(double dCurrentValue) override |
61 | 0 | { |
62 | 0 | Formatter::UpdateCurrentValue(dCurrentValue); |
63 | 0 | m_rSpinButton.SetUpperEnabled(!m_bHasMax || dCurrentValue < m_dMaxValue); |
64 | 0 | m_rSpinButton.SetLowerEnabled(!m_bHasMin || dCurrentValue > m_dMinValue); |
65 | 0 | } |
66 | | }; |
67 | | |
68 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |