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; Result := FValue;
end; 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; function TCustomFloatSpinEdit.IncrementStored: Boolean;
begin begin
Result := not SameValue(FIncrement, DefIncrement); Result := not SameValue(FIncrement, DefIncrement);
@ -182,6 +192,7 @@ begin
FMaxValue := DefMaxValue; FMaxValue := DefMaxValue;
FUpdatePending := True; FUpdatePending := True;
FValueChanged := True; FValueChanged := True;
FEditorEnabled := True;
with GetControlClassDefaultSize do with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY); SetInitialBounds(0, 0, CX, CY);

View File

@ -65,6 +65,8 @@ type
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure ShowHide(const AWinControl: TWinControl); override; class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
end; end;
@ -429,6 +431,22 @@ begin
SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or VisibilityToFlag[AWinControl.HandleObjectShouldBeVisible]); SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or VisibilityToFlag[AWinControl.HandleObjectShouldBeVisible]);
end; 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( class procedure TWin32WSCustomFloatSpinEdit.UpdateControl(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit); const ACustomFloatSpinEdit: TCustomFloatSpinEdit);
begin begin

View File

@ -50,6 +50,8 @@ type
class procedure SetText(const AWinControl: TWinControl; const AText: string); override; class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure ShowHide(const AWinControl: TWinControl); override; class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure SetEditorEnabled(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; AValue: Boolean); override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
end; end;
@ -255,6 +257,22 @@ begin
ShowWindow(Buddy, SW_HIDE); ShowWindow(Buddy, SW_HIDE);
end; 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( class procedure TWinCEWSCustomFloatSpinEdit.UpdateControl(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit); const ACustomFloatSpinEdit: TCustomFloatSpinEdit);
begin begin

View File

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

View File

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