From e4c54c9f40f9e0892c9193257aaaa3f805e153ff Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 14 Feb 2016 09:08:06 +0000 Subject: [PATCH] QT+GTK2: Fix TFloatSpinEdit not being unconstrained when MinValue = MaxValue. Issue #29645 git-svn-id: branches/fixes_1_6@51621 - --- lcl/interfaces/gtk2/gtk2wsspin.pp | 14 +++++++++++--- lcl/interfaces/qt/qtwsspin.pp | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2wsspin.pp b/lcl/interfaces/gtk2/gtk2wsspin.pp index 32a9f37478..6cf095fbb4 100644 --- a/lcl/interfaces/gtk2/gtk2wsspin.pp +++ b/lcl/interfaces/gtk2/gtk2wsspin.pp @@ -155,8 +155,16 @@ begin end else begin - AnAdjustment^.lower := TCustomFloatSpinEdit(ACustomEdit).MinValue; - AnAdjustment^.upper := TCustomFloatSpinEdit(ACustomEdit).MaxValue; + if (TCustomFloatSpinEdit(ACustomEdit).MaxValue > TCustomFloatSpinEdit(ACustomEdit).MinValue) then + begin + AnAdjustment^.lower := TCustomFloatSpinEdit(ACustomEdit).MinValue; + AnAdjustment^.upper := TCustomFloatSpinEdit(ACustomEdit).MaxValue; + end + else + begin + AnAdjustment^.lower := -MaxDouble; + AnAdjustment^.upper := MaxDouble; + end; end; gtk_spin_button_update(GTK_SPIN_BUTTON(Widget)); end; @@ -175,7 +183,7 @@ begin wHandle := ACustomFloatSpinEdit.Handle; SpinWidget:=GTK_SPIN_BUTTON({%H-}Pointer(wHandle)); - if ACustomFloatSpinEdit.MaxValue >= ACustomFloatSpinEdit.MinValue then + if ACustomFloatSpinEdit.MaxValue > ACustomFloatSpinEdit.MinValue then begin AMin := ACustomFloatSpinEdit.MinValue; AMax := ACustomFloatSpinEdit.MaxValue; diff --git a/lcl/interfaces/qt/qtwsspin.pp b/lcl/interfaces/qt/qtwsspin.pp index 43399f05bc..3c5c911e08 100644 --- a/lcl/interfaces/qt/qtwsspin.pp +++ b/lcl/interfaces/qt/qtwsspin.pp @@ -28,6 +28,8 @@ uses qtwidgets, // LCL Spin, SysUtils, Controls, Classes, LCLType, LCLProc, LCLIntf, Forms, StdCtrls, + //RTL + Math, // Widgetset WsProc, WSSpin, WSLCLClasses; @@ -69,9 +71,16 @@ begin try if ASpinWidget is TQtFloatSpinBox then TQtFloatSpinBox(ASpinWidget).setDecimals(ACustomFloatSpinEdit.DecimalPlaces); - - ASpinWidget.setMinimum(ACustomFloatSpinEdit.MinValue); - ASpinWidget.setMaximum(ACustomFloatSpinEdit.MaxValue); + if (ACustomFloatSpinEdit.MaxValue > ACustomFloatSpinEdit.MinValue) then + begin + ASpinWidget.setMinimum(ACustomFloatSpinEdit.MinValue); + ASpinWidget.setMaximum(ACustomFloatSpinEdit.MaxValue); + end + else + begin + ASpinWidget.setMinimum(-MaxDouble); + ASpinWidget.setMaximum(MaxDouble); + end; ASpinWidget.setSingleStep(ACustomFloatSpinEdit.Increment); finally ASpinWidget.EndUpdate;