LibreOffice Module sw (master) 1
prcntfld.hxx
Go to the documentation of this file.
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_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
21
22#include <svtools/unitconv.hxx>
23#include <vcl/weld.hxx>
24#include <swdllapi.h>
25
27{
28 std::unique_ptr<weld::MetricSpinButton> m_pField;
29
30 sal_Int64 m_nRefValue; // 100% value for conversion (in Twips)
31 sal_Int64 m_nOldMax;
32 sal_Int64 m_nOldMin;
35 sal_Int64 m_nLastPercent;
36 sal_Int64 m_nLastValue;
37 sal_uInt16 m_nOldDigits;
39 bool m_bLockAutoCalculation; //prevent recalculation of percent values when the
40 //reference value is changed
41
42 SAL_DLLPRIVATE static int ImpPower10(sal_uInt16 n);
43
44public:
45
46 SwPercentField(std::unique_ptr<weld::MetricSpinButton> pControl);
47 const weld::MetricSpinButton* get() const { return m_pField.get(); }
48 weld::MetricSpinButton* get() { return m_pField.get(); }
49 void connect_value_changed(const Link<weld::MetricSpinButton&, void>& rLink) { m_pField->connect_value_changed(rLink); }
50 void SetMetric(FieldUnit eUnit) { ::SetFieldUnit(*m_pField, eUnit); }
51 void set_sensitive(bool bEnable) { m_pField->set_sensitive(bEnable); }
52 void show() { m_pField->show(); }
53 bool has_focus() const { return m_pField->has_focus(); }
54 void save_value() { m_pField->save_value(); }
55 bool get_value_changed_from_saved() const { return m_pField->get_value_changed_from_saved(); }
56 void set_text(const OUString& rStr) { m_pField->set_text(rStr); }
57 void set_accessible_name(const OUString& rStr) { m_pField->set_accessible_name(rStr); }
58 void SetMetricFieldMin(sal_Int64 nNewMin) { m_pField->set_min(nNewMin, FieldUnit::NONE); }
59 void SetMetricFieldMax(sal_Int64 nNewMax) { m_pField->set_max(nNewMax, FieldUnit::NONE); }
60 void SetMetricFieldRange(sal_Int64 nNewMin, sal_Int64 nNewMax) { m_pField->set_range(nNewMin, nNewMax, FieldUnit::NONE); }
61 void GetMetricFieldRange(sal_Int64 &rOldMin, sal_Int64& rOldMax) const { m_pField->get_range(rOldMin, rOldMax, FieldUnit::NONE); }
62
63 void set_value(sal_Int64 nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
64 sal_Int64 get_value(FieldUnit eOutUnit = FieldUnit::NONE);
65
66 void set_min(sal_Int64 nNewMin, FieldUnit eInUnit);
67 void set_max(sal_Int64 nNewMax, FieldUnit eInUnit);
68
69 sal_Int64 get_min(FieldUnit eOutUnit = FieldUnit::NONE) const { return m_pField->get_min(eOutUnit); }
70
71 sal_Int64 NormalizePercent(sal_Int64 nValue);
72 sal_Int64 DenormalizePercent(sal_Int64 nValue);
73
74 void SetRefValue(sal_Int64 nValue);
75 sal_Int64 GetRealValue(FieldUnit eOutUnit);
76
77 sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
78
79 void ShowPercent(bool bPercent);
80
81 void LockAutoCalculation(bool bLock) {m_bLockAutoCalculation = bLock;}
82};
83
84
85#endif // INCLUDED_SW_SOURCE_UIBASE_INC_PRCNTFLD_HXX
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void set_text(const OUString &rStr)
Definition: prcntfld.hxx:56
const weld::MetricSpinButton * get() const
Definition: prcntfld.hxx:47
sal_Int64 m_nLastValue
Definition: prcntfld.hxx:36
void SetMetric(FieldUnit eUnit)
Definition: prcntfld.hxx:50
sal_Int64 m_nRefValue
Definition: prcntfld.hxx:30
int m_nOldPageSize
Definition: prcntfld.hxx:34
int m_nOldSpinSize
Definition: prcntfld.hxx:33
void SetMetricFieldMax(sal_Int64 nNewMax)
Definition: prcntfld.hxx:59
sal_Int64 get_min(FieldUnit eOutUnit=FieldUnit::NONE) const
Definition: prcntfld.hxx:69
sal_Int64 m_nOldMin
Definition: prcntfld.hxx:32
sal_Int64 m_nOldMax
Definition: prcntfld.hxx:31
void LockAutoCalculation(bool bLock)
Definition: prcntfld.hxx:81
void save_value()
Definition: prcntfld.hxx:54
void SetMetricFieldRange(sal_Int64 nNewMin, sal_Int64 nNewMax)
Definition: prcntfld.hxx:60
sal_uInt16 m_nOldDigits
Definition: prcntfld.hxx:37
sal_Int64 m_nLastPercent
Definition: prcntfld.hxx:35
void connect_value_changed(const Link< weld::MetricSpinButton &, void > &rLink)
Definition: prcntfld.hxx:49
void SetMetricFieldMin(sal_Int64 nNewMin)
Definition: prcntfld.hxx:58
FieldUnit m_eOldUnit
Definition: prcntfld.hxx:38
void set_sensitive(bool bEnable)
Definition: prcntfld.hxx:51
void set_accessible_name(const OUString &rStr)
Definition: prcntfld.hxx:57
std::unique_ptr< weld::MetricSpinButton > m_pField
Definition: prcntfld.hxx:28
bool m_bLockAutoCalculation
Definition: prcntfld.hxx:39
weld::MetricSpinButton * get()
Definition: prcntfld.hxx:48
bool has_focus() const
Definition: prcntfld.hxx:53
void GetMetricFieldRange(sal_Int64 &rOldMin, sal_Int64 &rOldMax) const
Definition: prcntfld.hxx:61
bool get_value_changed_from_saved() const
Definition: prcntfld.hxx:55
FieldUnit
#define SW_DLLPUBLIC
Definition: swdllapi.h:28