diff --git a/lcl/include/spinedit.inc b/lcl/include/spinedit.inc index a5cf7f7059..b59e289a5d 100644 --- a/lcl/include/spinedit.inc +++ b/lcl/include/spinedit.inc @@ -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); diff --git a/lcl/interfaces/win32/win32wsspin.pp b/lcl/interfaces/win32/win32wsspin.pp index 352142b566..6303d19065 100644 --- a/lcl/interfaces/win32/win32wsspin.pp +++ b/lcl/interfaces/win32/win32wsspin.pp @@ -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 diff --git a/lcl/interfaces/wince/wincewsspin.pp b/lcl/interfaces/wince/wincewsspin.pp index ff91e22017..1101b823ab 100644 --- a/lcl/interfaces/wince/wincewsspin.pp +++ b/lcl/interfaces/wince/wincewsspin.pp @@ -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 diff --git a/lcl/spin.pp b/lcl/spin.pp index cc9a5c31de..9d979f4c94 100644 --- a/lcl/spin.pp +++ b/lcl/spin.pp @@ -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; diff --git a/lcl/widgetset/wsspin.pp b/lcl/widgetset/wsspin.pp index d5806e75cb..ae5f70eccc 100644 --- a/lcl/widgetset/wsspin.pp +++ b/lcl/widgetset/wsspin.pp @@ -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;