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 #ifndef INCLUDED_SVX_RELFLD_HXX
20 #define INCLUDED_SVX_RELFLD_HXX
21 
22 #include <tools/fldunit.hxx>
23 #include <svtools/unitconv.hxx>
24 #include <vcl/field.hxx>
25 #include <vcl/weld.hxx>
26 #include <svx/svxdllapi.h>
27 
28 class SAL_DLLPUBLIC_RTTI SvxRelativeField final : public MetricField
29 {
30 public:
31     SvxRelativeField(vcl::Window* pParent, WinBits nBits, FieldUnit eUnit);
32 };
33 
34 class SVX_DLLPUBLIC RelativeField
35 {
36 private:
37     std::unique_ptr<weld::MetricSpinButton> m_xSpinButton;
38 
39     sal_uInt16          nRelMin;
40     sal_uInt16          nRelMax;
41     bool                bRelativeMode;
42     bool                bRelative;
43     bool                bNegativeEnabled;
44 
45     DECL_LINK(ModifyHdl, weld::Entry&, void);
46 
47 public:
48     RelativeField(std::unique_ptr<weld::MetricSpinButton> pControl);
49 
50     void            EnableRelativeMode( sal_uInt16 nMin, sal_uInt16 nMax );
51     void            SetRelative( bool bRelative );
IsRelative() const52     bool            IsRelative() const { return bRelative; }
EnableNegativeMode()53     void            EnableNegativeMode() {bNegativeEnabled = true;}
54 
set_sensitive(bool sensitive)55     void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); }
set_value(int nValue,FieldUnit eValueUnit)56     void set_value(int nValue, FieldUnit eValueUnit) { m_xSpinButton->set_value(nValue, eValueUnit); }
get_value(FieldUnit eDestUnit) const57     int get_value(FieldUnit eDestUnit) const { return m_xSpinButton->get_value(eDestUnit); }
get_min(FieldUnit eValueUnit) const58     int get_min(FieldUnit eValueUnit) const { return m_xSpinButton->get_min(eValueUnit); }
set_min(int min,FieldUnit eValueUnit)59     void set_min(int min, FieldUnit eValueUnit) { m_xSpinButton->set_min(min, eValueUnit); }
set_max(int max,FieldUnit eValueUnit)60     void set_max(int max, FieldUnit eValueUnit) { m_xSpinButton->set_max(max, eValueUnit); }
normalize(int nValue) const61     int normalize(int nValue) const { return m_xSpinButton->normalize(nValue); }
denormalize(int nValue) const62     int denormalize(int nValue) const { return m_xSpinButton->denormalize(nValue); }
connect_value_changed(const Link<weld::MetricSpinButton &,void> & rLink)63     void connect_value_changed(const Link<weld::MetricSpinButton&, void>& rLink) { m_xSpinButton->connect_value_changed(rLink); }
get_text() const64     OUString get_text() const { return m_xSpinButton->get_text(); }
set_text(const OUString & rText)65     void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); }
save_value()66     void save_value() { m_xSpinButton->save_value(); }
get_value_changed_from_saved() const67     bool get_value_changed_from_saved() const { return m_xSpinButton->get_value_changed_from_saved(); }
68 
GetCoreValue(MapUnit eUnit) const69     int GetCoreValue(MapUnit eUnit) const { return ::GetCoreValue(*m_xSpinButton, eUnit); }
SetFieldUnit(FieldUnit eUnit,bool bAll=false)70     void SetFieldUnit(FieldUnit eUnit, bool bAll = false) { ::SetFieldUnit(*m_xSpinButton, eUnit, bAll); }
SetMetricValue(int lCoreValue,MapUnit eUnit)71     void SetMetricValue(int lCoreValue, MapUnit eUnit) { ::SetMetricValue(*m_xSpinButton, lCoreValue, eUnit); }
72 };
73 
74 #endif
75 
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
77