From dcaa111227f54292e1ab6b4783f718ce18cdf18e Mon Sep 17 00:00:00 2001 From: vincents Date: Tue, 22 Jul 2008 10:01:50 +0000 Subject: [PATCH] LCL: FloatSpinEdit uses double for internal representation, so that the full range of 32 bits integer can be represented without rounding problems (fixes #10844) git-svn-id: trunk@15835 - --- lcl/include/spinedit.inc | 18 +++++----- lcl/interfaces/carbon/carbonedits.pp | 10 +++--- lcl/interfaces/carbon/carbonwsspin.pp | 4 +-- lcl/interfaces/gtk/gtkwsspin.pp | 18 ++++------ lcl/interfaces/gtk2/gtk2wsspin.pp | 14 ++++---- lcl/interfaces/qt/qtwidgets.pas | 50 +++++++++++++------------- lcl/interfaces/qt/qtwsspin.pp | 10 +++--- lcl/interfaces/win32/win32callback.inc | 2 +- lcl/interfaces/win32/win32proc.pp | 2 +- lcl/interfaces/win32/win32wsspin.pp | 8 ++--- lcl/interfaces/wince/wincecallback.inc | 4 +-- lcl/interfaces/wince/winceproc.pp | 2 +- lcl/interfaces/wince/wincewsspin.pp | 8 ++--- lcl/spin.pp | 32 ++++++++--------- lcl/widgetset/wsspin.pp | 10 +++--- 15 files changed, 93 insertions(+), 99 deletions(-) diff --git a/lcl/include/spinedit.inc b/lcl/include/spinedit.inc index b83b2182b7..c110a747c6 100644 --- a/lcl/include/spinedit.inc +++ b/lcl/include/spinedit.inc @@ -43,7 +43,7 @@ end; procedure TCustomFloatSpinEdit.TextChanged; var - PrevValue: Single; + PrevValue: Double; begin PrevValue := FValue; FValueChanged := True; @@ -58,7 +58,7 @@ begin end; end; -procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Single); +procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Double); begin if FMaxValue = AValue then Exit; FMaxValue := AValue; @@ -71,7 +71,7 @@ begin Result := True; end; -procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Single); +procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Double); begin if FMinValue = AValue then Exit; FMinValue := AValue; @@ -85,7 +85,7 @@ begin UpdateControl; end; -procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Single); +procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Double); begin if AIncrement = FIncrement then Exit; FIncrement := AIncrement; @@ -110,7 +110,7 @@ begin Result.Y:=23; end; -procedure TCustomFloatSpinEdit.SetValue(const AValue: Single); +procedure TCustomFloatSpinEdit.SetValue(const AValue: Double); begin if FValue = AValue then Exit; FValue := AValue; @@ -121,7 +121,7 @@ begin UpdateControl; end; -function TCustomFloatSpinEdit.GetValue: Single; +function TCustomFloatSpinEdit.GetValue: Double; begin if HandleAllocated and FValueChanged and not (wcfCreatingHandle in FWinControlFlags) then @@ -155,7 +155,7 @@ begin SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y); end; -function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Single): Single; +function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Double): Double; begin Result := AValue; if FMaxValue > FMinValue then @@ -165,12 +165,12 @@ begin end; end; -function TCustomFloatSpinEdit.ValueToStr(const AValue: Single): String; +function TCustomFloatSpinEdit.ValueToStr(const AValue: Double): String; begin Result := FloatToStrF(GetLimitedValue(AValue), ffFixed, 20, DecimalPlaces); end; -function TCustomFloatSpinEdit.StrToValue(const S: String): Single; +function TCustomFloatSpinEdit.StrToValue(const S: String): Double; begin try Result := GetLimitedValue(StrToFloatDef(S, FValue)); diff --git a/lcl/interfaces/carbon/carbonedits.pp b/lcl/interfaces/carbon/carbonedits.pp index 3d7aadde4f..81e5a4186b 100644 --- a/lcl/interfaces/carbon/carbonedits.pp +++ b/lcl/interfaces/carbon/carbonedits.pp @@ -117,10 +117,10 @@ type TCarbonSpinEdit = class(TCarbonCustomEdit) private FUpDown: ControlRef; - FValue: Single; - FMin: Single; - FMax: Single; - FIncrement: Single; + FValue: Double; + FMin: Double; + FMax: Double; + FIncrement: Double; FDecimalPlaces: Integer; function UpDownThemeWidth: Integer; function FocusRectThemeOutset: Integer; @@ -141,7 +141,7 @@ type function SetText(const S: String): Boolean; override; public procedure UpdateControl; - property Value: Single read FValue; + property Value: Double read FValue; end; { TCarbonEdit } diff --git a/lcl/interfaces/carbon/carbonwsspin.pp b/lcl/interfaces/carbon/carbonwsspin.pp index 9860131085..aab633afb3 100644 --- a/lcl/interfaces/carbon/carbonwsspin.pp +++ b/lcl/interfaces/carbon/carbonwsspin.pp @@ -49,7 +49,7 @@ type protected public class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; end; @@ -88,7 +88,7 @@ end; Params: ACustomFloatSpinEdit - LCL custom float spin edit Returns: The float spin edit value ------------------------------------------------------------------------------} -class function TCarbonWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Single; +class function TCarbonWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin Result := 0; if not CheckHandle(ACustomFloatSpinEdit, Self, 'GetValue') then Exit; diff --git a/lcl/interfaces/gtk/gtkwsspin.pp b/lcl/interfaces/gtk/gtkwsspin.pp index 19bf5cb293..5776bcafeb 100644 --- a/lcl/interfaces/gtk/gtkwsspin.pp +++ b/lcl/interfaces/gtk/gtkwsspin.pp @@ -34,7 +34,7 @@ uses glib, gdk, gtk, {$ENDIF} // RTL, FCL, LCL - Controls, LCLType, LCLProc, Spin, StdCtrls, + Math, Controls, LCLType, LCLProc, Spin, StdCtrls, // Widgetset GtkProc, GtkExtra, GtkDef, GtkInt, GtkWSControls, GtkWSStdCtrls, WSLCLClasses, WSSpin; @@ -50,7 +50,7 @@ type public class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; @@ -106,15 +106,9 @@ begin end; class function TGtkWSCustomFloatSpinEdit.GetValue( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; + const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin -{$IFDEF GTK2} - // developer.gnome.org/doc/API/2.2/gtk/GtkSpinButton.html: - // "function gtk_spin_button_get_value_as_float is deprecated, use gtk_spin_button_get_value() instead" - Result:=Single(gtk_spin_button_get_value(PGtkSpinButton(ACustomFloatSpinEdit.Handle))); -{$ELSE} Result:=gtk_spin_button_get_value_as_float(PGtkSpinButton(ACustomFloatSpinEdit.Handle)); -{$ENDIF} end; class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit; @@ -136,7 +130,7 @@ var AnAdjustment: PGtkAdjustment; wHandle: HWND; SpinWidget: PGtkSpinButton; - AMin, AMax: Single; + AMin, AMax: Double; begin //DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]); wHandle := ACustomFloatSpinEdit.Handle; @@ -149,8 +143,8 @@ begin end else begin - AMin := -3.4E38; // min single - AMax := 3.4E38; // max single + AMin := -MaxDouble; + AMax := MaxDouble; end; AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget); diff --git a/lcl/interfaces/gtk2/gtk2wsspin.pp b/lcl/interfaces/gtk2/gtk2wsspin.pp index 08f1a46176..6874621623 100644 --- a/lcl/interfaces/gtk2/gtk2wsspin.pp +++ b/lcl/interfaces/gtk2/gtk2wsspin.pp @@ -30,7 +30,7 @@ uses // Bindings glib2, gdk2pixbuf, gdk2, gtk2, Pango, // RTL, FCL, LCL - Controls, LCLType, LCLProc, Spin, StdCtrls, + Math, Controls, LCLType, LCLProc, Spin, StdCtrls, // Widgetset GtkProc, GtkExtra, GtkDef, Gtk2Int, Gtk2WSControls, Gtk2WSStdCtrls, Gtk2Proc, WSLCLClasses, WSSpin; @@ -46,7 +46,7 @@ type public class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; @@ -102,11 +102,11 @@ begin end; class function TGtk2WSCustomFloatSpinEdit.GetValue( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; + const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin // developer.gnome.org/doc/API/2.2/gtk/GtkSpinButton.html: // "function gtk_spin_button_get_value_as_float is deprecated, use gtk_spin_button_get_value() instead" - Result:=Single(gtk_spin_button_get_value(PGtkSpinButton(ACustomFloatSpinEdit.Handle))); + Result:=gtk_spin_button_get_value(PGtkSpinButton(ACustomFloatSpinEdit.Handle)); end; class procedure TGtk2WSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit; @@ -128,7 +128,7 @@ var AnAdjustment: PGtkAdjustment; wHandle: HWND; SpinWidget: PGtkSpinButton; - AMin, AMax: Single; + AMin, AMax: Double; begin //DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]); wHandle := ACustomFloatSpinEdit.Handle; @@ -141,8 +141,8 @@ begin end else begin - AMin := -3.4E38; // min single - AMax := 3.4E38; // max single + AMin := -MaxDouble; + AMax := MaxDouble; end; AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget); diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 2438daf63a..9b8d618990 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -716,16 +716,16 @@ type procedure setSelection(const AStart, ALength: Integer); procedure Undo; public - function getValue: single; virtual; abstract; + function getValue: Double; virtual; abstract; function getReadOnly: Boolean; function getText: WideString; override; function getTextStatic: Boolean; override; procedure setFocusPolicy(const APolicy: QtFocusPolicy); override; - procedure setMinimum(const v: single); virtual; abstract; - procedure setMaximum(const v: single); virtual; abstract; - procedure setSingleStep(const v: single); virtual; abstract; + procedure setMinimum(const v: Double); virtual; abstract; + procedure setMaximum(const v: Double); virtual; abstract; + procedure setSingleStep(const v: Double); virtual; abstract; procedure setReadOnly(const r: Boolean); - procedure setValue(const v: single); virtual; abstract; + procedure setValue(const v: Double); virtual; abstract; procedure setText(const W: WideString); override; property LineEdit: QLineEditH read GetLineEdit; @@ -744,12 +744,12 @@ type protected function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - function getValue: single; override; + function getValue: Double; override; procedure setDecimals(const v: integer); - procedure setMinimum(const v: single); override; - procedure setMaximum(const v: single); override; - procedure setSingleStep(const v: single); override; - procedure setValue(const v: single); override; + procedure setMinimum(const v: Double); override; + procedure setMaximum(const v: Double); override; + procedure setSingleStep(const v: Double); override; + procedure setValue(const v: Double); override; public procedure AttachEvents; override; procedure DetachEvents; override; @@ -765,11 +765,11 @@ type protected function CreateWidget(const AParams: TCreateParams):QWidgetH; override; public - function getValue: single; override; - procedure setMinimum(const v: single); override; - procedure setMaximum(const v: single); override; - procedure setSingleStep(const v: single); override; - procedure setValue(const v: single); override; + function getValue: Double; override; + procedure setMinimum(const v: Double); override; + procedure setMaximum(const v: Double); override; + procedure setSingleStep(const v: Double); override; + procedure setValue(const v: Double); override; public procedure AttachEvents; override; procedure DetachEvents; override; @@ -5814,7 +5814,7 @@ begin Result := QDoubleSpinBox_create(); end; -function TQtFloatSpinBox.getValue: single; +function TQtFloatSpinBox.getValue: Double; begin Result := QDoubleSpinBox_value(QDoubleSpinBoxH(Widget)); end; @@ -5824,22 +5824,22 @@ begin QDoubleSpinBox_setDecimals(QDoubleSpinBoxH(Widget), v); end; -procedure TQtFloatSpinBox.setMinimum(const v: single); +procedure TQtFloatSpinBox.setMinimum(const v: Double); begin QDoubleSpinBox_setMinimum(QDoubleSpinBoxH(Widget), v); end; -procedure TQtFloatSpinBox.setMaximum(const v: single); +procedure TQtFloatSpinBox.setMaximum(const v: Double); begin QDoubleSpinBox_setMaximum(QDoubleSpinBoxH(Widget), v); end; -procedure TQtFloatSpinBox.setSingleStep(const v: single); +procedure TQtFloatSpinBox.setSingleStep(const v: Double); begin QDoubleSpinBox_setSingleStep(QDoubleSpinBoxH(Widget), v); end; -procedure TQtFloatSpinBox.setValue(const v: single); +procedure TQtFloatSpinBox.setValue(const v: Double); begin QDoubleSpinBox_setValue(QDoubleSpinBoxH(Widget), v); end; @@ -5880,27 +5880,27 @@ begin Result := QSpinBox_create(); end; -function TQtSpinBox.getValue: single; +function TQtSpinBox.getValue: Double; begin Result := QSpinBox_value(QSpinBoxH(Widget)); end; -procedure TQtSpinBox.setMinimum(const v: single); +procedure TQtSpinBox.setMinimum(const v: Double); begin QSpinBox_setMinimum(QSpinBoxH(Widget), round(v)); end; -procedure TQtSpinBox.setMaximum(const v: single); +procedure TQtSpinBox.setMaximum(const v: Double); begin QSpinBox_setMaximum(QSpinBoxH(Widget), round(v)); end; -procedure TQtSpinBox.setSingleStep(const v: single); +procedure TQtSpinBox.setSingleStep(const v: Double); begin QSpinBox_setSingleStep(QSpinBoxH(Widget), round(v)); end; -procedure TQtSpinBox.setValue(const v: single); +procedure TQtSpinBox.setValue(const v: Double); begin QSpinBox_setValue(QSpinBoxH(Widget), round(v)); end; diff --git a/lcl/interfaces/qt/qtwsspin.pp b/lcl/interfaces/qt/qtwsspin.pp index 86fbdf96cf..c29c9fa281 100644 --- a/lcl/interfaces/qt/qtwsspin.pp +++ b/lcl/interfaces/qt/qtwsspin.pp @@ -51,12 +51,12 @@ type const AParams: TCreateParams): TLCLIntfHandle; override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; (*TODO: seperation into properties instead of bulk update - class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual; - class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual; - class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual; + class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual; + class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual; + class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual; class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual; *) @@ -112,7 +112,7 @@ begin Result := TLCLIntfHandle(QtSpinBox); end; -class function TQtWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; +class function TQtWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin Result := TQtAbstractSpinBox(ACustomFloatSpinEdit.Handle).getValue; end; diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index c8eea5bbd3..e0bc341d50 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -913,7 +913,7 @@ var var SpinEdit: TCustomFloatSpinEdit; spinHandle: HWND; - newValue: single; + newValue: Double; begin SpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl); diff --git a/lcl/interfaces/win32/win32proc.pp b/lcl/interfaces/win32/win32proc.pp index 5593c5cf6d..65597a5fce 100644 --- a/lcl/interfaces/win32/win32proc.pp +++ b/lcl/interfaces/win32/win32proc.pp @@ -59,7 +59,7 @@ Type DrawItemSelected: boolean;// whether this item is selected LB_GETSEL not uptodate yet MouseX, MouseY: smallint; // noticing spurious WM_MOUSEMOVE messages case integer of - 0: (spinValue: single); + 0: (spinValue: Double); 1: ( TrackValid: Boolean; // Set when we have a valid trackpos TrackPos: Integer // keeps the thumb position while tracking diff --git a/lcl/interfaces/win32/win32wsspin.pp b/lcl/interfaces/win32/win32wsspin.pp index d1f33c4a10..1925011088 100644 --- a/lcl/interfaces/win32/win32wsspin.pp +++ b/lcl/interfaces/win32/win32wsspin.pp @@ -55,7 +55,7 @@ type class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; @@ -76,7 +76,7 @@ type procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit; - const ANewValue: single); + const ANewValue: Double); implementation @@ -121,7 +121,7 @@ begin end; procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit; - const ANewValue: single); + const ANewValue: Double); var editHandle: HWND; newValueText: string; @@ -197,7 +197,7 @@ begin end; class function TWin32WSCustomFloatSpinEdit.GetValue( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; + const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; end; diff --git a/lcl/interfaces/wince/wincecallback.inc b/lcl/interfaces/wince/wincecallback.inc index 53d389ba65..9a75394761 100644 --- a/lcl/interfaces/wince/wincecallback.inc +++ b/lcl/interfaces/wince/wincecallback.inc @@ -776,7 +776,7 @@ Var { procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit); var lWindowInfo: PWindowInfo; - lNewValue: single; + lNewValue: Double; begin lWindowInfo := GetWindowInfo(ASpinEdit.Handle); if lWindowInfo = @DefaultWindowInfo then exit; @@ -792,7 +792,7 @@ Var var lSpinEdit: TCustomFloatSpinEdit; spinHandle: HWND; - newValue: single; + newValue: Double; begin lSpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl); newValue := WindowInfo^.spinValue + AUpDownMsg^.iDelta * lSpinEdit.Increment; diff --git a/lcl/interfaces/wince/winceproc.pp b/lcl/interfaces/wince/winceproc.pp index 084d597a2f..50cb358272 100644 --- a/lcl/interfaces/wince/winceproc.pp +++ b/lcl/interfaces/wince/winceproc.pp @@ -41,7 +41,7 @@ Type myButton : HWND; MouseX, MouseY: word; // noticing spurious WM_MOUSEMOVE messages case integer of - 0: (spinValue: single); + 0: (spinValue: Double); 1: ( TrackValid: Boolean; // Set when we have a valid trackpos TrackPos: Integer // keeps the thumb position while tracking diff --git a/lcl/interfaces/wince/wincewsspin.pp b/lcl/interfaces/wince/wincewsspin.pp index 2cdd60d0e9..ab78666488 100644 --- a/lcl/interfaces/wince/wincewsspin.pp +++ b/lcl/interfaces/wince/wincewsspin.pp @@ -52,7 +52,7 @@ type class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; @@ -70,7 +70,7 @@ type end; -procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: single; +procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double; const ADecimalPlaces: integer); implementation @@ -98,7 +98,7 @@ begin end; end; -procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: single; +procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double; const ADecimalPlaces: integer); var editHandle: HWND; @@ -175,7 +175,7 @@ begin end; class function TWinCEWSCustomFloatSpinEdit.GetValue( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; + const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; begin Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; end; diff --git a/lcl/spin.pp b/lcl/spin.pp index 2fe4b40f39..7bbf3561bf 100644 --- a/lcl/spin.pp +++ b/lcl/spin.pp @@ -37,16 +37,16 @@ type TCustomFloatSpinEdit = class(TCustomEdit) private - FIncrement: Single; + FIncrement: Double; FDecimals: Integer; - FMaxValue: Single; - FMinValue: Single; - FValue: Single; + FMaxValue: Double; + FMinValue: Double; + FValue: Double; FValueEmpty: Boolean; FUpdatePending: Boolean; FValueChanged: Boolean; - procedure SetMaxValue(const AValue: Single); - procedure SetMinValue(const AValue: Single); + procedure SetMaxValue(const AValue: Double); + procedure SetMinValue(const AValue: Double); procedure SetValueEmpty(const AValue: Boolean); procedure UpdateControl; function IsStored: Boolean; // FPC bug workaround @@ -54,24 +54,24 @@ type function RealGetText: TCaption; override; procedure TextChanged; override; procedure SetDecimals(ADecimals: Integer); - function GetValue: Single; - procedure SetValue(const AValue: Single); - procedure SetIncrement(const AIncrement: Single); + function GetValue: Double; + procedure SetValue(const AValue: Double); + procedure SetIncrement(const AIncrement: Double); procedure InitializeWnd; override; procedure FinalizeWnd; override; procedure Loaded; override; class function GetControlClassDefaultSize: TPoint; override; public constructor Create(TheOwner: TComponent); override; - function GetLimitedValue(const AValue: Single): Single; - function ValueToStr(const AValue: Single): String; - function StrToValue(const S: String): Single; + function GetLimitedValue(const AValue: Double): Double; + function ValueToStr(const AValue: Double): String; + function StrToValue(const S: String): Double; public property DecimalPlaces: Integer read FDecimals write SetDecimals default 2; - property Increment: Single read FIncrement write SetIncrement stored IsStored default 1; - property MinValue: Single read FMinValue write SetMinValue stored IsStored default 0; - property MaxValue: Single read FMaxValue write SetMaxValue stored IsStored default 100; - property Value: Single read GetValue write SetValue stored IsStored default 0; + property Increment: Double read FIncrement write SetIncrement stored IsStored; + property MinValue: Double read FMinValue write SetMinValue stored IsStored; + property MaxValue: Double read FMaxValue write SetMaxValue stored IsStored; + property Value: Double read GetValue write SetValue stored IsStored; property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False; end; diff --git a/lcl/widgetset/wsspin.pp b/lcl/widgetset/wsspin.pp index a0c959e70f..b1feab1d70 100644 --- a/lcl/widgetset/wsspin.pp +++ b/lcl/widgetset/wsspin.pp @@ -52,12 +52,12 @@ type { TWSCustomFloatSpinEdit } TWSCustomFloatSpinEdit = class(TWSCustomEdit) - class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; virtual; + class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): double; virtual; (* TODO: seperation into properties instead of bulk update - class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual; - class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual; - class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual; + class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual; + class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual; + class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual; class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual; *) @@ -75,7 +75,7 @@ implementation { TWSCustomFloatSpinEdit } -class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; +class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): double; begin Result := 0.0; end;