mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
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 -
This commit is contained in:
parent
2996a3c332
commit
dcaa111227
@ -43,7 +43,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomFloatSpinEdit.TextChanged;
|
procedure TCustomFloatSpinEdit.TextChanged;
|
||||||
var
|
var
|
||||||
PrevValue: Single;
|
PrevValue: Double;
|
||||||
begin
|
begin
|
||||||
PrevValue := FValue;
|
PrevValue := FValue;
|
||||||
FValueChanged := True;
|
FValueChanged := True;
|
||||||
@ -58,7 +58,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Single);
|
procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Double);
|
||||||
begin
|
begin
|
||||||
if FMaxValue = AValue then Exit;
|
if FMaxValue = AValue then Exit;
|
||||||
FMaxValue := AValue;
|
FMaxValue := AValue;
|
||||||
@ -71,7 +71,7 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Single);
|
procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Double);
|
||||||
begin
|
begin
|
||||||
if FMinValue = AValue then Exit;
|
if FMinValue = AValue then Exit;
|
||||||
FMinValue := AValue;
|
FMinValue := AValue;
|
||||||
@ -85,7 +85,7 @@ begin
|
|||||||
UpdateControl;
|
UpdateControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Single);
|
procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Double);
|
||||||
begin
|
begin
|
||||||
if AIncrement = FIncrement then Exit;
|
if AIncrement = FIncrement then Exit;
|
||||||
FIncrement := AIncrement;
|
FIncrement := AIncrement;
|
||||||
@ -110,7 +110,7 @@ begin
|
|||||||
Result.Y:=23;
|
Result.Y:=23;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomFloatSpinEdit.SetValue(const AValue: Single);
|
procedure TCustomFloatSpinEdit.SetValue(const AValue: Double);
|
||||||
begin
|
begin
|
||||||
if FValue = AValue then Exit;
|
if FValue = AValue then Exit;
|
||||||
FValue := AValue;
|
FValue := AValue;
|
||||||
@ -121,7 +121,7 @@ begin
|
|||||||
UpdateControl;
|
UpdateControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFloatSpinEdit.GetValue: Single;
|
function TCustomFloatSpinEdit.GetValue: Double;
|
||||||
begin
|
begin
|
||||||
if HandleAllocated and FValueChanged
|
if HandleAllocated and FValueChanged
|
||||||
and not (wcfCreatingHandle in FWinControlFlags) then
|
and not (wcfCreatingHandle in FWinControlFlags) then
|
||||||
@ -155,7 +155,7 @@ begin
|
|||||||
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
|
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Single): Single;
|
function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Double): Double;
|
||||||
begin
|
begin
|
||||||
Result := AValue;
|
Result := AValue;
|
||||||
if FMaxValue > FMinValue then
|
if FMaxValue > FMinValue then
|
||||||
@ -165,12 +165,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFloatSpinEdit.ValueToStr(const AValue: Single): String;
|
function TCustomFloatSpinEdit.ValueToStr(const AValue: Double): String;
|
||||||
begin
|
begin
|
||||||
Result := FloatToStrF(GetLimitedValue(AValue), ffFixed, 20, DecimalPlaces);
|
Result := FloatToStrF(GetLimitedValue(AValue), ffFixed, 20, DecimalPlaces);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFloatSpinEdit.StrToValue(const S: String): Single;
|
function TCustomFloatSpinEdit.StrToValue(const S: String): Double;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
Result := GetLimitedValue(StrToFloatDef(S, FValue));
|
Result := GetLimitedValue(StrToFloatDef(S, FValue));
|
||||||
|
@ -117,10 +117,10 @@ type
|
|||||||
TCarbonSpinEdit = class(TCarbonCustomEdit)
|
TCarbonSpinEdit = class(TCarbonCustomEdit)
|
||||||
private
|
private
|
||||||
FUpDown: ControlRef;
|
FUpDown: ControlRef;
|
||||||
FValue: Single;
|
FValue: Double;
|
||||||
FMin: Single;
|
FMin: Double;
|
||||||
FMax: Single;
|
FMax: Double;
|
||||||
FIncrement: Single;
|
FIncrement: Double;
|
||||||
FDecimalPlaces: Integer;
|
FDecimalPlaces: Integer;
|
||||||
function UpDownThemeWidth: Integer;
|
function UpDownThemeWidth: Integer;
|
||||||
function FocusRectThemeOutset: Integer;
|
function FocusRectThemeOutset: Integer;
|
||||||
@ -141,7 +141,7 @@ type
|
|||||||
function SetText(const S: String): Boolean; override;
|
function SetText(const S: String): Boolean; override;
|
||||||
public
|
public
|
||||||
procedure UpdateControl;
|
procedure UpdateControl;
|
||||||
property Value: Single read FValue;
|
property Value: Double read FValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonEdit }
|
{ TCarbonEdit }
|
||||||
|
@ -49,7 +49,7 @@ type
|
|||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
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;
|
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ end;
|
|||||||
Params: ACustomFloatSpinEdit - LCL custom float spin edit
|
Params: ACustomFloatSpinEdit - LCL custom float spin edit
|
||||||
Returns: The float spin edit value
|
Returns: The float spin edit value
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
class function TCarbonWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Single;
|
class function TCarbonWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if not CheckHandle(ACustomFloatSpinEdit, Self, 'GetValue') then Exit;
|
if not CheckHandle(ACustomFloatSpinEdit, Self, 'GetValue') then Exit;
|
||||||
|
@ -34,7 +34,7 @@ uses
|
|||||||
glib, gdk, gtk,
|
glib, gdk, gtk,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// RTL, FCL, LCL
|
// RTL, FCL, LCL
|
||||||
Controls, LCLType, LCLProc, Spin, StdCtrls,
|
Math, Controls, LCLType, LCLProc, Spin, StdCtrls,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
GtkProc, GtkExtra, GtkDef, GtkInt, GtkWSControls, GtkWSStdCtrls,
|
GtkProc, GtkExtra, GtkDef, GtkInt, GtkWSControls, GtkWSStdCtrls,
|
||||||
WSLCLClasses, WSSpin;
|
WSLCLClasses, WSSpin;
|
||||||
@ -50,7 +50,7 @@ type
|
|||||||
public
|
public
|
||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(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 SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||||
@ -106,15 +106,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TGtkWSCustomFloatSpinEdit.GetValue(
|
class function TGtkWSCustomFloatSpinEdit.GetValue(
|
||||||
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
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));
|
Result:=gtk_spin_button_get_value_as_float(PGtkSpinButton(ACustomFloatSpinEdit.Handle));
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
|
class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
|
||||||
@ -136,7 +130,7 @@ var
|
|||||||
AnAdjustment: PGtkAdjustment;
|
AnAdjustment: PGtkAdjustment;
|
||||||
wHandle: HWND;
|
wHandle: HWND;
|
||||||
SpinWidget: PGtkSpinButton;
|
SpinWidget: PGtkSpinButton;
|
||||||
AMin, AMax: Single;
|
AMin, AMax: Double;
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]);
|
//DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]);
|
||||||
wHandle := ACustomFloatSpinEdit.Handle;
|
wHandle := ACustomFloatSpinEdit.Handle;
|
||||||
@ -149,8 +143,8 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
AMin := -3.4E38; // min single
|
AMin := -MaxDouble;
|
||||||
AMax := 3.4E38; // max single
|
AMax := MaxDouble;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget);
|
AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget);
|
||||||
|
@ -30,7 +30,7 @@ uses
|
|||||||
// Bindings
|
// Bindings
|
||||||
glib2, gdk2pixbuf, gdk2, gtk2, Pango,
|
glib2, gdk2pixbuf, gdk2, gtk2, Pango,
|
||||||
// RTL, FCL, LCL
|
// RTL, FCL, LCL
|
||||||
Controls, LCLType, LCLProc, Spin, StdCtrls,
|
Math, Controls, LCLType, LCLProc, Spin, StdCtrls,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
GtkProc, GtkExtra, GtkDef, Gtk2Int, Gtk2WSControls, Gtk2WSStdCtrls,
|
GtkProc, GtkExtra, GtkDef, Gtk2Int, Gtk2WSControls, Gtk2WSStdCtrls,
|
||||||
Gtk2Proc, WSLCLClasses, WSSpin;
|
Gtk2Proc, WSLCLClasses, WSSpin;
|
||||||
@ -46,7 +46,7 @@ type
|
|||||||
public
|
public
|
||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(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 SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||||
@ -102,11 +102,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TGtk2WSCustomFloatSpinEdit.GetValue(
|
class function TGtk2WSCustomFloatSpinEdit.GetValue(
|
||||||
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
begin
|
||||||
// developer.gnome.org/doc/API/2.2/gtk/GtkSpinButton.html:
|
// 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"
|
// "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;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
|
class procedure TGtk2WSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
|
||||||
@ -128,7 +128,7 @@ var
|
|||||||
AnAdjustment: PGtkAdjustment;
|
AnAdjustment: PGtkAdjustment;
|
||||||
wHandle: HWND;
|
wHandle: HWND;
|
||||||
SpinWidget: PGtkSpinButton;
|
SpinWidget: PGtkSpinButton;
|
||||||
AMin, AMax: Single;
|
AMin, AMax: Double;
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]);
|
//DebugLn(['TGtkWSCustomFloatSpinEdit.UpdateControl ',dbgsName(ACustomFloatSpinEdit)]);
|
||||||
wHandle := ACustomFloatSpinEdit.Handle;
|
wHandle := ACustomFloatSpinEdit.Handle;
|
||||||
@ -141,8 +141,8 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
AMin := -3.4E38; // min single
|
AMin := -MaxDouble;
|
||||||
AMax := 3.4E38; // max single
|
AMax := MaxDouble;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget);
|
AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget);
|
||||||
|
@ -716,16 +716,16 @@ type
|
|||||||
procedure setSelection(const AStart, ALength: Integer);
|
procedure setSelection(const AStart, ALength: Integer);
|
||||||
procedure Undo;
|
procedure Undo;
|
||||||
public
|
public
|
||||||
function getValue: single; virtual; abstract;
|
function getValue: Double; virtual; abstract;
|
||||||
function getReadOnly: Boolean;
|
function getReadOnly: Boolean;
|
||||||
function getText: WideString; override;
|
function getText: WideString; override;
|
||||||
function getTextStatic: Boolean; override;
|
function getTextStatic: Boolean; override;
|
||||||
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
procedure setFocusPolicy(const APolicy: QtFocusPolicy); override;
|
||||||
procedure setMinimum(const v: single); virtual; abstract;
|
procedure setMinimum(const v: Double); virtual; abstract;
|
||||||
procedure setMaximum(const v: single); virtual; abstract;
|
procedure setMaximum(const v: Double); virtual; abstract;
|
||||||
procedure setSingleStep(const v: single); virtual; abstract;
|
procedure setSingleStep(const v: Double); virtual; abstract;
|
||||||
procedure setReadOnly(const r: Boolean);
|
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;
|
procedure setText(const W: WideString); override;
|
||||||
|
|
||||||
property LineEdit: QLineEditH read GetLineEdit;
|
property LineEdit: QLineEditH read GetLineEdit;
|
||||||
@ -744,12 +744,12 @@ type
|
|||||||
protected
|
protected
|
||||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||||
public
|
public
|
||||||
function getValue: single; override;
|
function getValue: Double; override;
|
||||||
procedure setDecimals(const v: integer);
|
procedure setDecimals(const v: integer);
|
||||||
procedure setMinimum(const v: single); override;
|
procedure setMinimum(const v: Double); override;
|
||||||
procedure setMaximum(const v: single); override;
|
procedure setMaximum(const v: Double); override;
|
||||||
procedure setSingleStep(const v: single); override;
|
procedure setSingleStep(const v: Double); override;
|
||||||
procedure setValue(const v: single); override;
|
procedure setValue(const v: Double); override;
|
||||||
public
|
public
|
||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
@ -765,11 +765,11 @@ type
|
|||||||
protected
|
protected
|
||||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||||
public
|
public
|
||||||
function getValue: single; override;
|
function getValue: Double; override;
|
||||||
procedure setMinimum(const v: single); override;
|
procedure setMinimum(const v: Double); override;
|
||||||
procedure setMaximum(const v: single); override;
|
procedure setMaximum(const v: Double); override;
|
||||||
procedure setSingleStep(const v: single); override;
|
procedure setSingleStep(const v: Double); override;
|
||||||
procedure setValue(const v: single); override;
|
procedure setValue(const v: Double); override;
|
||||||
public
|
public
|
||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
@ -5814,7 +5814,7 @@ begin
|
|||||||
Result := QDoubleSpinBox_create();
|
Result := QDoubleSpinBox_create();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtFloatSpinBox.getValue: single;
|
function TQtFloatSpinBox.getValue: Double;
|
||||||
begin
|
begin
|
||||||
Result := QDoubleSpinBox_value(QDoubleSpinBoxH(Widget));
|
Result := QDoubleSpinBox_value(QDoubleSpinBoxH(Widget));
|
||||||
end;
|
end;
|
||||||
@ -5824,22 +5824,22 @@ begin
|
|||||||
QDoubleSpinBox_setDecimals(QDoubleSpinBoxH(Widget), v);
|
QDoubleSpinBox_setDecimals(QDoubleSpinBoxH(Widget), v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtFloatSpinBox.setMinimum(const v: single);
|
procedure TQtFloatSpinBox.setMinimum(const v: Double);
|
||||||
begin
|
begin
|
||||||
QDoubleSpinBox_setMinimum(QDoubleSpinBoxH(Widget), v);
|
QDoubleSpinBox_setMinimum(QDoubleSpinBoxH(Widget), v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtFloatSpinBox.setMaximum(const v: single);
|
procedure TQtFloatSpinBox.setMaximum(const v: Double);
|
||||||
begin
|
begin
|
||||||
QDoubleSpinBox_setMaximum(QDoubleSpinBoxH(Widget), v);
|
QDoubleSpinBox_setMaximum(QDoubleSpinBoxH(Widget), v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtFloatSpinBox.setSingleStep(const v: single);
|
procedure TQtFloatSpinBox.setSingleStep(const v: Double);
|
||||||
begin
|
begin
|
||||||
QDoubleSpinBox_setSingleStep(QDoubleSpinBoxH(Widget), v);
|
QDoubleSpinBox_setSingleStep(QDoubleSpinBoxH(Widget), v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtFloatSpinBox.setValue(const v: single);
|
procedure TQtFloatSpinBox.setValue(const v: Double);
|
||||||
begin
|
begin
|
||||||
QDoubleSpinBox_setValue(QDoubleSpinBoxH(Widget), v);
|
QDoubleSpinBox_setValue(QDoubleSpinBoxH(Widget), v);
|
||||||
end;
|
end;
|
||||||
@ -5880,27 +5880,27 @@ begin
|
|||||||
Result := QSpinBox_create();
|
Result := QSpinBox_create();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtSpinBox.getValue: single;
|
function TQtSpinBox.getValue: Double;
|
||||||
begin
|
begin
|
||||||
Result := QSpinBox_value(QSpinBoxH(Widget));
|
Result := QSpinBox_value(QSpinBoxH(Widget));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtSpinBox.setMinimum(const v: single);
|
procedure TQtSpinBox.setMinimum(const v: Double);
|
||||||
begin
|
begin
|
||||||
QSpinBox_setMinimum(QSpinBoxH(Widget), round(v));
|
QSpinBox_setMinimum(QSpinBoxH(Widget), round(v));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtSpinBox.setMaximum(const v: single);
|
procedure TQtSpinBox.setMaximum(const v: Double);
|
||||||
begin
|
begin
|
||||||
QSpinBox_setMaximum(QSpinBoxH(Widget), round(v));
|
QSpinBox_setMaximum(QSpinBoxH(Widget), round(v));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtSpinBox.setSingleStep(const v: single);
|
procedure TQtSpinBox.setSingleStep(const v: Double);
|
||||||
begin
|
begin
|
||||||
QSpinBox_setSingleStep(QSpinBoxH(Widget), round(v));
|
QSpinBox_setSingleStep(QSpinBoxH(Widget), round(v));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtSpinBox.setValue(const v: single);
|
procedure TQtSpinBox.setValue(const v: Double);
|
||||||
begin
|
begin
|
||||||
QSpinBox_setValue(QSpinBoxH(Widget), round(v));
|
QSpinBox_setValue(QSpinBoxH(Widget), round(v));
|
||||||
end;
|
end;
|
||||||
|
@ -51,12 +51,12 @@ type
|
|||||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); 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
|
(*TODO: seperation into properties instead of bulk update
|
||||||
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual;
|
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual;
|
||||||
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual;
|
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
||||||
class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual;
|
class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
||||||
class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual;
|
class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ begin
|
|||||||
Result := TLCLIntfHandle(QtSpinBox);
|
Result := TLCLIntfHandle(QtSpinBox);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TQtWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
class function TQtWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
begin
|
||||||
Result := TQtAbstractSpinBox(ACustomFloatSpinEdit.Handle).getValue;
|
Result := TQtAbstractSpinBox(ACustomFloatSpinEdit.Handle).getValue;
|
||||||
end;
|
end;
|
||||||
|
@ -913,7 +913,7 @@ var
|
|||||||
var
|
var
|
||||||
SpinEdit: TCustomFloatSpinEdit;
|
SpinEdit: TCustomFloatSpinEdit;
|
||||||
spinHandle: HWND;
|
spinHandle: HWND;
|
||||||
newValue: single;
|
newValue: Double;
|
||||||
begin
|
begin
|
||||||
SpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
SpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ Type
|
|||||||
DrawItemSelected: boolean;// whether this item is selected LB_GETSEL not uptodate yet
|
DrawItemSelected: boolean;// whether this item is selected LB_GETSEL not uptodate yet
|
||||||
MouseX, MouseY: smallint; // noticing spurious WM_MOUSEMOVE messages
|
MouseX, MouseY: smallint; // noticing spurious WM_MOUSEMOVE messages
|
||||||
case integer of
|
case integer of
|
||||||
0: (spinValue: single);
|
0: (spinValue: Double);
|
||||||
1: (
|
1: (
|
||||||
TrackValid: Boolean; // Set when we have a valid trackpos
|
TrackValid: Boolean; // Set when we have a valid trackpos
|
||||||
TrackPos: Integer // keeps the thumb position while tracking
|
TrackPos: Integer // keeps the thumb position while tracking
|
||||||
|
@ -55,7 +55,7 @@ type
|
|||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(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 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 SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
@ -76,7 +76,7 @@ type
|
|||||||
|
|
||||||
|
|
||||||
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
||||||
const ANewValue: single);
|
const ANewValue: Double);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
||||||
const ANewValue: single);
|
const ANewValue: Double);
|
||||||
var
|
var
|
||||||
editHandle: HWND;
|
editHandle: HWND;
|
||||||
newValueText: string;
|
newValueText: string;
|
||||||
@ -197,7 +197,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomFloatSpinEdit.GetValue(
|
class function TWin32WSCustomFloatSpinEdit.GetValue(
|
||||||
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
begin
|
||||||
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
|
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
|
||||||
end;
|
end;
|
||||||
|
@ -776,7 +776,7 @@ Var
|
|||||||
{ procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit);
|
{ procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit);
|
||||||
var
|
var
|
||||||
lWindowInfo: PWindowInfo;
|
lWindowInfo: PWindowInfo;
|
||||||
lNewValue: single;
|
lNewValue: Double;
|
||||||
begin
|
begin
|
||||||
lWindowInfo := GetWindowInfo(ASpinEdit.Handle);
|
lWindowInfo := GetWindowInfo(ASpinEdit.Handle);
|
||||||
if lWindowInfo = @DefaultWindowInfo then exit;
|
if lWindowInfo = @DefaultWindowInfo then exit;
|
||||||
@ -792,7 +792,7 @@ Var
|
|||||||
var
|
var
|
||||||
lSpinEdit: TCustomFloatSpinEdit;
|
lSpinEdit: TCustomFloatSpinEdit;
|
||||||
spinHandle: HWND;
|
spinHandle: HWND;
|
||||||
newValue: single;
|
newValue: Double;
|
||||||
begin
|
begin
|
||||||
lSpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
lSpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
||||||
newValue := WindowInfo^.spinValue + AUpDownMsg^.iDelta * lSpinEdit.Increment;
|
newValue := WindowInfo^.spinValue + AUpDownMsg^.iDelta * lSpinEdit.Increment;
|
||||||
|
@ -41,7 +41,7 @@ Type
|
|||||||
myButton : HWND;
|
myButton : HWND;
|
||||||
MouseX, MouseY: word; // noticing spurious WM_MOUSEMOVE messages
|
MouseX, MouseY: word; // noticing spurious WM_MOUSEMOVE messages
|
||||||
case integer of
|
case integer of
|
||||||
0: (spinValue: single);
|
0: (spinValue: Double);
|
||||||
1: (
|
1: (
|
||||||
TrackValid: Boolean; // Set when we have a valid trackpos
|
TrackValid: Boolean; // Set when we have a valid trackpos
|
||||||
TrackPos: Integer // keeps the thumb position while tracking
|
TrackPos: Integer // keeps the thumb position while tracking
|
||||||
|
@ -52,7 +52,7 @@ type
|
|||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(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 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 SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||||
@ -70,7 +70,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: single;
|
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double;
|
||||||
const ADecimalPlaces: integer);
|
const ADecimalPlaces: integer);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -98,7 +98,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: single;
|
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double;
|
||||||
const ADecimalPlaces: integer);
|
const ADecimalPlaces: integer);
|
||||||
var
|
var
|
||||||
editHandle: HWND;
|
editHandle: HWND;
|
||||||
@ -175,7 +175,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWinCEWSCustomFloatSpinEdit.GetValue(
|
class function TWinCEWSCustomFloatSpinEdit.GetValue(
|
||||||
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
||||||
begin
|
begin
|
||||||
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
|
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
|
||||||
end;
|
end;
|
||||||
|
32
lcl/spin.pp
32
lcl/spin.pp
@ -37,16 +37,16 @@ type
|
|||||||
|
|
||||||
TCustomFloatSpinEdit = class(TCustomEdit)
|
TCustomFloatSpinEdit = class(TCustomEdit)
|
||||||
private
|
private
|
||||||
FIncrement: Single;
|
FIncrement: Double;
|
||||||
FDecimals: Integer;
|
FDecimals: Integer;
|
||||||
FMaxValue: Single;
|
FMaxValue: Double;
|
||||||
FMinValue: Single;
|
FMinValue: Double;
|
||||||
FValue: Single;
|
FValue: Double;
|
||||||
FValueEmpty: Boolean;
|
FValueEmpty: Boolean;
|
||||||
FUpdatePending: Boolean;
|
FUpdatePending: Boolean;
|
||||||
FValueChanged: Boolean;
|
FValueChanged: Boolean;
|
||||||
procedure SetMaxValue(const AValue: Single);
|
procedure SetMaxValue(const AValue: Double);
|
||||||
procedure SetMinValue(const AValue: Single);
|
procedure SetMinValue(const AValue: Double);
|
||||||
procedure SetValueEmpty(const AValue: Boolean);
|
procedure SetValueEmpty(const AValue: Boolean);
|
||||||
procedure UpdateControl;
|
procedure UpdateControl;
|
||||||
function IsStored: Boolean; // FPC bug workaround
|
function IsStored: Boolean; // FPC bug workaround
|
||||||
@ -54,24 +54,24 @@ type
|
|||||||
function RealGetText: TCaption; override;
|
function RealGetText: TCaption; override;
|
||||||
procedure TextChanged; override;
|
procedure TextChanged; override;
|
||||||
procedure SetDecimals(ADecimals: Integer);
|
procedure SetDecimals(ADecimals: Integer);
|
||||||
function GetValue: Single;
|
function GetValue: Double;
|
||||||
procedure SetValue(const AValue: Single);
|
procedure SetValue(const AValue: Double);
|
||||||
procedure SetIncrement(const AIncrement: Single);
|
procedure SetIncrement(const AIncrement: Double);
|
||||||
procedure InitializeWnd; override;
|
procedure InitializeWnd; override;
|
||||||
procedure FinalizeWnd; override;
|
procedure FinalizeWnd; override;
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
function GetLimitedValue(const AValue: Single): Single;
|
function GetLimitedValue(const AValue: Double): Double;
|
||||||
function ValueToStr(const AValue: Single): String;
|
function ValueToStr(const AValue: Double): String;
|
||||||
function StrToValue(const S: String): Single;
|
function StrToValue(const S: String): Double;
|
||||||
public
|
public
|
||||||
property DecimalPlaces: Integer read FDecimals write SetDecimals default 2;
|
property DecimalPlaces: Integer read FDecimals write SetDecimals default 2;
|
||||||
property Increment: Single read FIncrement write SetIncrement stored IsStored default 1;
|
property Increment: Double read FIncrement write SetIncrement stored IsStored;
|
||||||
property MinValue: Single read FMinValue write SetMinValue stored IsStored default 0;
|
property MinValue: Double read FMinValue write SetMinValue stored IsStored;
|
||||||
property MaxValue: Single read FMaxValue write SetMaxValue stored IsStored default 100;
|
property MaxValue: Double read FMaxValue write SetMaxValue stored IsStored;
|
||||||
property Value: Single read GetValue write SetValue stored IsStored default 0;
|
property Value: Double read GetValue write SetValue stored IsStored;
|
||||||
property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False;
|
property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ type
|
|||||||
{ TWSCustomFloatSpinEdit }
|
{ TWSCustomFloatSpinEdit }
|
||||||
|
|
||||||
TWSCustomFloatSpinEdit = class(TWSCustomEdit)
|
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
|
(* TODO: seperation into properties instead of bulk update
|
||||||
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual;
|
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual;
|
||||||
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual;
|
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
||||||
class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual;
|
class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
||||||
class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual;
|
class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ implementation
|
|||||||
|
|
||||||
{ TWSCustomFloatSpinEdit }
|
{ TWSCustomFloatSpinEdit }
|
||||||
|
|
||||||
class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
|
class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): double;
|
||||||
begin
|
begin
|
||||||
Result := 0.0;
|
Result := 0.0;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user