summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-29 21:25:09 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-30 10:17:07 +0200
commit2896c5dad1799addd72b626d93d7e89b1cf19ff6 (patch)
treec78170f4ebd26af51a7d49f34c09a69798b198ee /vcl
parent4fc1f038a687e1db4319bb08367fbdbad96fcbdd (diff)
Related: tdf#89131 draw up/down spins disabled if value is at max/min
if there is a max/min set. Change-Id: I2dc7ccccad9ec2aa7eb89d8b5fa137e077a846fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135105 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/fmtfield.cxx7
-rw-r--r--vcl/source/control/spinfld.cxx31
2 files changed, 36 insertions, 2 deletions
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index c07b7e3ab3c5..3aee3317c829 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -922,6 +922,13 @@ namespace
{
m_rSpinButton.SpinField::Modify();
}
+
+ virtual void UpdateCurrentValue(double dCurrentValue) override
+ {
+ Formatter::UpdateCurrentValue(dCurrentValue);
+ m_rSpinButton.SetUpperEnabled(!m_bHasMax || dCurrentValue < m_dMaxValue);
+ m_rSpinButton.SetLowerEnabled(!m_bHasMin || dCurrentValue > m_dMinValue);
+ }
};
class DoubleNumericFormatter : public FieldFormatter
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 8db25dfbc699..6bc1fac297a9 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -298,6 +298,8 @@ void SpinField::ImplInitSpinFieldData()
mbInitialUp = false;
mbInitialDown = false;
mbInDropDown = false;
+ mbUpperEnabled = true;
+ mbLowerEnabled = true;
}
void SpinField::ImplInit(vcl::Window* pParent, WinBits nWinStyle)
@@ -578,13 +580,38 @@ void SpinField::FillLayoutData() const
Edit::FillLayoutData();
}
+void SpinField::SetUpperEnabled(bool bEnabled)
+{
+ if (mbUpperEnabled == bEnabled)
+ return;
+
+ mbUpperEnabled = bEnabled;
+
+ if (mbSpin)
+ Invalidate(maUpperRect);
+}
+
+void SpinField::SetLowerEnabled(bool bEnabled)
+{
+ if (mbLowerEnabled == bEnabled)
+ return;
+
+ mbLowerEnabled = bEnabled;
+
+ if (mbSpin)
+ Invalidate(maLowerRect);
+}
+
void SpinField::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{
if (mbSpin)
{
- bool bEnable = IsEnabled();
+ bool bEnabled = IsEnabled();
+ bool bUpperEnabled = bEnabled && IsUpperEnabled();
+ bool bLowerEnabled = bEnabled && IsLowerEnabled();
ImplDrawSpinButton(rRenderContext, this, maUpperRect, maLowerRect,
- mbUpperIn, mbLowerIn, bEnable, bEnable);
+ mbUpperIn && bUpperEnabled, mbLowerIn && bLowerEnabled,
+ bUpperEnabled, bLowerEnabled);
}
if (GetStyle() & WB_DROPDOWN)