T(Float)SpinEdit: implement property EditorEnabled. ATM win32/64 and wince only. Issue #0038736.

git-svn-id: trunk@64989 -
This commit is contained in:
bart 2021-04-14 07:25:00 +00:00
parent dcb4b22eef
commit a148676b51
5 changed files with 58 additions and 0 deletions

View File

@ -160,6 +160,16 @@ begin
Result := FValue;
end;
procedure TCustomFloatSpinEdit.SetEditorEnabled(AValue: Boolean);
begin
if FEditorEnabled <> AValue then
begin
FEditorEnabled := AValue;
if HandleAllocated then
TWSCustomFloatSpinEditClass(WidgetSetClass).SetEditorEnabled(Self, AValue);
end;
end;
function TCustomFloatSpinEdit.IncrementStored: Boolean;
begin
Result := not SameValue(FIncrement, DefIncrement);
@ -182,6 +192,7 @@ begin
FMaxValue := DefMaxValue;
FUpdatePending := True;
FValueChanged := True;
FEditorEnabled := True;
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);

View File

@ -65,6 +65,8 @@ type
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
end;
@ -429,6 +431,22 @@ begin
SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or VisibilityToFlag[AWinControl.HandleObjectShouldBeVisible]);
end;
class procedure TWin32WSCustomFloatSpinEdit.SetEditorEnabled(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean);
begin
if not AValue then
begin
//make the Edit readonly, without setting the property ReadOnly to True
if not ACustomFloatSpinEdit.ReadOnly then
Windows.SendMessage(ACustomFloatSpinEdit.Handle, EM_SETREADONLY, Windows.WPARAM(True), 0);
end
else
begin
if not ACustomFloatSpinEdit.ReadOnly then
Windows.SendMessage(ACustomFloatSpinEdit.Handle, EM_SETREADONLY, Windows.WPARAM(False), 0);
end;
end;
class procedure TWin32WSCustomFloatSpinEdit.UpdateControl(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit);
begin

View File

@ -50,6 +50,8 @@ type
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
end;
@ -255,6 +257,22 @@ begin
ShowWindow(Buddy, SW_HIDE);
end;
class procedure TWinCEWSCustomFloatSpinEdit.SetEditorEnabled(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean);
begin
if not AValue then
begin
//make the Edit readonly, without setting the property ReadOnly to True
if not ACustomFloatSpinEdit.ReadOnly then
Windows.SendMessage(ACustomFloatSpinEdit.Handle, EM_SETREADONLY, Windows.WPARAM(True), 0);
end
else
begin
if not ACustomFloatSpinEdit.ReadOnly then
Windows.SendMessage(ACustomFloatSpinEdit.Handle, EM_SETREADONLY, Windows.WPARAM(False), 0);
end;
end;
class procedure TWinCEWSCustomFloatSpinEdit.UpdateControl(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit);
begin

View File

@ -37,6 +37,7 @@ type
private
FIncrement: Double;
FDecimals: Integer;
FEditorEnabled: Boolean;
FMaxValue: Double;
FMinValue: Double;
FValue: Double;
@ -44,6 +45,7 @@ type
FUpdatePending: Boolean;
FValueChanged: Boolean;
function GetValue: Double;
procedure SetEditorEnabled(AValue: Boolean);
procedure UpdateControl;
function MaxValueStored: Boolean;
function IncrementStored: Boolean;
@ -70,6 +72,7 @@ type
function StrToValue(const S: String): Double; virtual;
public
property DecimalPlaces: Integer read FDecimals write SetDecimals default DefDecimals;
property EditorEnabled: Boolean read FEditorEnabled write SetEditorEnabled default True;
property Increment: Double read FIncrement write SetIncrement stored IncrementStored nodefault;
property MinValue: Double read FMinValue write SetMinValue;
property MaxValue: Double read FMaxValue write SetMaxValue stored MaxValueStored nodefault;
@ -92,6 +95,7 @@ type
property Color;
property Constraints;
property DecimalPlaces;
property EditorEnabled;
property Enabled;
property Font;
property Increment;
@ -170,6 +174,7 @@ type
property BorderSpacing;
property Color;
property Constraints;
property EditorEnabled;
property Enabled;
property Font;
property Increment;

View File

@ -58,6 +58,7 @@ type
*)
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); virtual;
class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); virtual;
end;
TWSCustomFloatSpinEditClass = class of TWSCustomFloatSpinEdit;
@ -78,6 +79,11 @@ class procedure TWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit:
begin
end;
class procedure TWSCustomFloatSpinEdit.SetEditorEnabled(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean);
begin
end;
{ WidgetSetRegistration }
procedure RegisterCustomFloatSpinEdit;