diff --git a/doceditor/frmtable.lfm b/doceditor/frmtable.lfm index 589d415bf8..1cd8df944a 100644 --- a/doceditor/frmtable.lfm +++ b/doceditor/frmtable.lfm @@ -69,7 +69,7 @@ object TableForm: TTableForm end object SERows: TSpinEdit BorderSpacing.OnChange = nil - ClimbRate = 1 + Increment = 1 MaxValue = 100 TabOrder = 3 Left = 72 @@ -79,7 +79,7 @@ object TableForm: TTableForm end object SEColumns: TSpinEdit BorderSpacing.OnChange = nil - ClimbRate = 1 + Increment = 1 MaxValue = 100 TabOrder = 4 Left = 72 diff --git a/lcl/include/spinedit.inc b/lcl/include/spinedit.inc index c0fc9df1a3..843509c95a 100644 --- a/lcl/include/spinedit.inc +++ b/lcl/include/spinedit.inc @@ -16,154 +16,94 @@ } -{-----------------------------------------------------------------------------} procedure TCustomFloatSpinEdit.UpdateControl; begin - if MaxValue0) and (FValue0) and (FValue>FMaxValue) then FValue:=fMaxValue; - if (not HandleAllocated) then exit; - if ([csLoading,csDestroying]*ComponentState<>[]) then + if MaxValue < MinValue then FMaxValue := MinValue; + if (FMinValue <> 0) and (FValue < FMinValue) then FValue := FMinValue; + if (FMaxValue <> 0) and (FValue > FMaxValue) then FValue := FMaxValue; + + if (not HandleAllocated) then Exit; + + if ([csLoading, csDestroying] * ComponentState <> []) then + FUpdatePending := True + else begin - FUpdatePending := true; - exit; + TWSCustomFloatSpinEditClass(WidgetSetClass).UpdateControl(Self); + FValueChanged := True; + FUpdatePending := False; end; - TWSCustomFloatSpinEditClass(WidgetSetClass).UpdateControl(Self); - FValueChanged := true; - FUpdatePending := false; end; -function TCustomFloatSpinEdit.ValueIsStored: boolean; +function TCustomFloatSpinEdit.ValueIsStored: Boolean; begin - Result:=true; // fpc bug, default value is always 0 + Result := True; // fpc bug, default value is always 0 end; function TCustomFloatSpinEdit.RealGetText: TCaption; begin if HandleAllocated then - Result:=inherited RealGetText + Result := inherited RealGetText else - Result:=FloatToStrF(FValue, ffFixed, 20, DecimalPlaces); + Result := FloatToStrF(FValue, ffFixed, 20, DecimalPlaces); end; procedure TCustomFloatSpinEdit.TextChanged; var - lPrevValue: single; + PrevValue: Single; begin - lPrevValue := FValue; - FValueChanged := true; - if Value = lPrevValue then exit; - Modified := true; - FValueEmpty := false; - if HandleAllocated and (not (csLoading in ComponentState)) then Change; + inherited; + + PrevValue := FValue; + FValueChanged := True; + + if Value = PrevValue then Exit; + + Modified := True; + FValueEmpty := False; end; -procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: single); +procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Single); begin - if FMaxValue=AValue then exit; - FMaxValue:=AValue; + if FMaxValue = AValue then Exit; + FMaxValue := AValue; UpdateControl; end; -function TCustomFloatSpinEdit.GetModified: Boolean; +function TCustomFloatSpinEdit.MaxValueIsStored: Boolean; begin - Result := FModified; + Result := True; // fpc bug, default value is always 0 end; -function TCustomFloatSpinEdit.GetSelLength: integer; +function TCustomFloatSpinEdit.MinValueIsStored: Boolean; begin - if HandleAllocated then - FSelLength := TWSCustomFloatSpinEditClass(WidgetSetClass).GetSelLength(Self); - Result:= FSelLength; + Result := True; // fpc bug, default value is always 0 end; -function TCustomFloatSpinEdit.GetSelStart: integer; +procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Single); begin - if HandleAllocated then - FSelStart:= TWSCustomFloatSpinEditClass(WidgetSetClass).GetSelStart(Self); - Result:= FSelStart; -end; - -function TCustomFloatSpinEdit.GetSelText: String; -begin - Result:= Copy(Text, SelStart + 1, SelLength) -end; - -function TCustomFloatSpinEdit.MaxValueIsStored: boolean; -begin - Result:=true; // fpc bug, default value is always 0 -end; - -function TCustomFloatSpinEdit.MinValueIsStored: boolean; -begin - Result:=true; // fpc bug, default value is always 0 -end; - - -{-----------------------------------------------------------------------------} - -procedure TCustomFloatSpinEdit.SetMinValue(const AValue: single); -begin - if FMinValue=AValue then exit; - FMinValue:=AValue; + if FMinValue = AValue then Exit; + FMinValue := AValue; UpdateControl; end; -procedure TCustomFloatSpinEdit.SetModified(const AValue: Boolean); +procedure TCustomFloatSpinEdit.SetValueEmpty(const AValue: Boolean); begin - FModified := AValue; -end; - -procedure TCustomFloatSpinEdit.SetSelLength(const AValue: integer); -begin - FSelLength:= AValue; - if HandleAllocated then - TWSCustomFloatSpinEditClass(WidgetSetClass).SetSelLength(Self, FSelLength); -end; - -procedure TCustomFloatSpinEdit.SetSelStart(const AValue: integer); -begin - FSelStart:= AValue; - if HandleAllocated then - TWSCustomFloatSpinEditClass(WidgetSetClass).SetSelStart(Self, FSelStart); -end; - -procedure TCustomFloatSpinEdit.SetSelText(const AValue: String); -var - OldText, NewText: string; -begin - OldText:=Text; - NewText:=LeftStr(OldText,SelStart)+AValue - +RightStr(OldText,length(OldText)-SelStart-SelLength); - Text:=NewText; -end; - -procedure TCustomFloatSpinEdit.SetValueEmpty(const AValue: boolean); -begin - if FValueEmpty=AValue then exit; - FValueEmpty:=AValue; + if FValueEmpty = AValue then Exit; + FValueEmpty := AValue; UpdateControl; end; -procedure TCustomFloatSpinEdit.SetIncrement(const NewIncrement: single); +procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Single); begin - if NewIncrement = FIncrement then exit; - FIncrement := NewIncrement; + if AIncrement = FIncrement then Exit; + FIncrement := AIncrement; UpdateControl; end; procedure TCustomFloatSpinEdit.InitializeWnd; -var - ASelStart, ASelLength : integer; begin inherited InitializeWnd; UpdateControl; - if FSelStart <> FSelLength then begin - ASelStart:= FSelStart; - ASelLength:= FSelLength; - SelStart:= ASelStart; - SelLength:= ASelLength; - end; end; procedure TCustomFloatSpinEdit.Loaded; @@ -172,67 +112,49 @@ begin if FUpdatePending then UpdateControl; end; -procedure TCustomFloatSpinEdit.Change; +procedure TCustomFloatSpinEdit.SetValue(const AValue: Single); begin - if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit; - EditingDone; - if Assigned(FOnChange) then FOnChange(Self); -end; - -{-----------------------------------------------------------------------------} -Procedure TCustomFloatSpinEdit.SetValue(const num : Single); -begin - if FValue = Num then exit; - FValue := Num; + if FValue = AValue then Exit; + FValue := AValue; + // clear FValueChanged to prevent getting the old value from the widget - FValueChanged := false; - FUpdatePending := true; + FValueChanged := False; + FUpdatePending := True; UpdateControl; end; -{-----------------------------------------------------------------------------} -Function TCustomFloatSpinEdit.GetValue: Single; +function TCustomFloatSpinEdit.GetValue: Single; begin if HandleAllocated and FValueChanged and not (wcfCreatingHandle in FWinControlFlags) then begin FValue := TWSCustomFloatSpinEditClass(WidgetSetClass).GetValue(Self); - FValueChanged := false; + FValueChanged := False; end; - Result := fValue; + Result := FValue; end; -{-----------------------------------------------------------------------------} -procedure TCustomFloatSpinEdit.SetDecimals(Num : Integer); +procedure TCustomFloatSpinEdit.SetDecimals(ADecimals: Integer); begin - if fDecimals = Num then exit; - fDecimals := Num; + if FDecimals = ADecimals then Exit; + FDecimals := ADecimals; UpdateControl; end; -{-----------------------------------------------------------------------------} -constructor TCustomFloatSpinEdit.Create(TheOwner : TComponent); +constructor TCustomFloatSpinEdit.Create(TheOwner: TComponent); begin inherited Create(TheOwner); - fCompStyle := csSpinEdit; + FCompStyle := csSpinEdit; FIncrement := 1; - fDecimals := 2; - fValue := 0; - fMinValue := 0; - fMaxValue := 100; - FUpdatePending := true; - FValueChanged := true; + FDecimals := 2; + FValue := 0; + FMinValue := 0; + FMaxValue := 100; + FUpdatePending := True; + FValueChanged := True; - SetInitialBounds(0,0,50,23); - ParentColor := false; - TabStop := true; -end; - -{-----------------------------------------------------------------------------} -destructor TCustomFloatSpinEdit.Destroy; -begin - inherited Destroy; + SetInitialBounds(0, 0, 50, 23); end; procedure TCustomFloatSpinEdit.FinalizeWnd; @@ -241,37 +163,6 @@ begin inherited FinalizeWnd; end; -procedure TCustomFloatSpinEdit.SelectAll; -begin - if Text <> '' then begin - SetSelStart(0); - SetSelLength(Length(Text)); - end; -end; - -procedure TCustomFloatSpinEdit.ClearSelection; -begin - if SelLength > 0 then - SelText := ''; -end; - -procedure TCustomFloatSpinEdit.CopyToClipboard; -begin - Clipboard.AsText := SelText; -end; - -procedure TCustomFloatSpinEdit.CutToClipboard; -begin - CopyToClipboard; - ClearSelection; -end; - -procedure TCustomFloatSpinEdit.PasteFromClipboard; -begin - if Clipboard.HasFormat(CF_TEXT) then - SelText := Clipboard.AsText; -end; - { TCustomSpinEdit } function TCustomSpinEdit.GetIncrement: integer; diff --git a/lcl/interfaces/gtk/gtkwsspin.pp b/lcl/interfaces/gtk/gtkwsspin.pp index 76e819c073..5c613e506c 100644 --- a/lcl/interfaces/gtk/gtkwsspin.pp +++ b/lcl/interfaces/gtk/gtkwsspin.pp @@ -33,8 +33,8 @@ uses glib, gdk, gtk, {$ENDIF} GtkInt, - LCLProc, Spin, GtkProc, gtkExtra, GtkWSStdCtrls, WSSpin, WSLCLClasses, Controls, - LCLType; + LCLProc, Spin, StdCtrls, GtkProc, gtkExtra, GtkWSStdCtrls, WSSpin, + WSLCLClasses, Controls, LCLType; type @@ -44,21 +44,21 @@ type private protected public - class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; - class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; + 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 procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; - class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); override; + class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; + class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; end; function GetGtkSpinEntry(Spin: PGtkSpinButton): PGtkEntry; -function GetSpinGtkEntry(Spin: TCustomFloatSpinEdit): PGtkEntry; +function GetSpinGtkEntry(const Spin: TWinControl): PGtkEntry; function GetGtkFloatSpinEditable(Spin: PGtkSpinButton): PGtkOldEditable; -function GetSpinGtkEditable(Spin: TCustomFloatSpinEdit): PGtkOldEditable; +function GetSpinGtkEditable(const Spin: TWinControl): PGtkOldEditable; implementation @@ -67,7 +67,7 @@ begin Result:=PGtkEntry(@(Spin^.entry)); end; -function GetSpinGtkEntry(Spin: TCustomFloatSpinEdit): PGtkEntry; +function GetSpinGtkEntry(const Spin: TWinControl): PGtkEntry; begin Result:=GetGtkSpinEntry(PGtkSpinButton(Spin.Handle)); end; @@ -77,24 +77,21 @@ begin Result:=PGtkOldEditable(@(Spin^.entry)); end; -function GetSpinGtkEditable(Spin: TCustomFloatSpinEdit): PGtkOldEditable; +function GetSpinGtkEditable(const Spin: TWinControl): PGtkOldEditable; begin Result:=GetGtkFloatSpinEditable(PGtkSpinButton(Spin.Handle)); end; { TGtkWSCustomFloatSpinEdit } -class function TGtkWSCustomFloatSpinEdit.GetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit - ): integer; +class function TGtkWSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer; begin - Result :=WidgetGetSelStart(PGtkWidget(GetSpinGtkEntry(ACustomFloatSpinEdit))); + Result :=WidgetGetSelStart(PGtkWidget(GetSpinGtkEntry(ACustomEdit))); end; -class function TGtkWSCustomFloatSpinEdit.GetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; +class function TGtkWSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer; begin - with GetSpinGtkEditable(ACustomFloatSpinEdit)^ do + with GetSpinGtkEditable(ACustomEdit)^ do Result := Abs(integer(selection_end_pos)-integer(selection_start_pos)); end; @@ -105,16 +102,16 @@ begin PGtkSpinButton(ACustomFloatSpinEdit.Handle)); end; -class procedure TGtkWSCustomFloatSpinEdit.SetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); +class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit; + NewStart: integer); begin - gtk_editable_set_position(GetSpinGtkEditable(ACustomFloatSpinEdit), NewStart); + gtk_editable_set_position(GetSpinGtkEditable(ACustomEdit), NewStart); end; -class procedure TGtkWSCustomFloatSpinEdit.SetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); +class procedure TGtkWSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit; + NewLength: integer); begin - WidgetSetSelLength(PGtkWidget(GetSpinGtkEntry(ACustomFloatSpinEdit)), + WidgetSetSelLength(PGtkWidget(GetSpinGtkEntry(ACustomEdit)), NewLength); end; diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index e5800b64c9..f8ca0d7957 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -1126,19 +1126,22 @@ begin BN_CLICKED: LMessage.Msg := LM_CLICKED; BN_KILLFOCUS: LMessage.Msg := LM_EXIT; end - else if (lWinControl is TCustomEdit) then - case HIWORD(WParam) of - EN_CHANGE: LMessage.Msg := CM_TEXTCHANGED; - end - else if (lWinControl is TCustomFloatSpinEdit) then - case HIWORD(WParam) of - EN_CHANGE: HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl)); - end - else if (lWinControl is TCustomMemo) then + else + if (lWinControl is TCustomEdit) then + begin + if (lWinControl is TCustomMemo) then case HIWORD(WParam) of // multiline edit doesn't send EN_CHANGE, so use EN_UPDATE EN_UPDATE: LMessage.Msg := CM_TEXTCHANGED; end + else + case HIWORD(WParam) of + EN_CHANGE: + if (lWinControl is TCustomFloatSpinEdit) then + HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl)) + else LMessage.Msg := CM_TEXTCHANGED; + end; + end else if (lWinControl is TCustomListBox) then case HIWORD(WParam) of LBN_SELCHANGE: LMessage.Msg := LM_SELCHANGE; diff --git a/lcl/interfaces/win32/win32wsspin.pp b/lcl/interfaces/win32/win32wsspin.pp index 79839feb54..30e5c6ef05 100644 --- a/lcl/interfaces/win32/win32wsspin.pp +++ b/lcl/interfaces/win32/win32wsspin.pp @@ -33,7 +33,7 @@ uses // To get as little as posible circles, // uncomment only when needed for registration //////////////////////////////////////////////////// - Spin, Controls, LCLType, + Spin, Controls, StdCtrls, LCLType, //////////////////////////////////////////////////// WSSpin, WSLCLClasses, Windows, Win32Int, WinExt, Win32Proc, Win32WSStdCtrls, Win32WSControls; @@ -50,13 +50,13 @@ type var Left, Top, Width, Height: integer; var SuppressMove: boolean); override; class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; - class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; - class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; + 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 procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; - class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); override; + class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; + class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure ShowHide(const AWinControl: TWinControl); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; @@ -163,16 +163,14 @@ begin SuppressMove := true; end; -class function TWin32WSCustomFloatSpinEdit.GetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; +class function TWin32WSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer; begin - Result := EditGetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); + Result := EditGetSelStart(GetBuddyWindow(ACustomEdit.Handle)); end; -class function TWin32WSCustomFloatSpinEdit.GetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; +class function TWin32WSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer; begin - Result := EditGetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); + Result := EditGetSelLength(GetBuddyWindow(ACustomEdit.Handle)); end; class function TWin32WSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl; @@ -190,16 +188,16 @@ begin Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; end; -class procedure TWin32WSCustomFloatSpinEdit.SetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); +class procedure TWin32WSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit; + NewStart: integer); begin - EditSetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewStart); + EditSetSelStart(GetBuddyWindow(ACustomEdit.Handle), NewStart); end; -class procedure TWin32WSCustomFloatSpinEdit.SetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); +class procedure TWin32WSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit; + NewLength: integer); begin - EditSetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewLength); + EditSetSelLength(GetBuddyWindow(ACustomEdit.Handle), NewLength); end; class procedure TWin32WSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl); diff --git a/lcl/interfaces/wince/wincewsspin.pp b/lcl/interfaces/wince/wincewsspin.pp index 0163fdbbb6..9af78b9cf2 100644 --- a/lcl/interfaces/wince/wincewsspin.pp +++ b/lcl/interfaces/wince/wincewsspin.pp @@ -32,7 +32,7 @@ uses // To get as little as posible circles, // uncomment only when needed for registration //////////////////////////////////////////////////// - Spin, Controls, LCLType, + Spin, Controls, StdCtrls, LCLType, //////////////////////////////////////////////////// WSSpin, WSLCLClasses, Windows, WinCEInt, WinCEProc, WinCEWSStdCtrls, WinCEWSControls; @@ -49,13 +49,13 @@ type var Left, Top, Width, Height: integer; var SuppressMove: boolean); override; class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; - class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; - class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; + 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 procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; - class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); override; + class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; + class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure ShowHide(const AWinControl: TWinControl); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; @@ -154,16 +154,14 @@ begin SuppressMove := true; end; -class function TWinCEWSCustomFloatSpinEdit.GetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; +class function TWinCEWSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer; begin - Result := EditGetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); + Result := EditGetSelStart(GetBuddyWindow(ACustomEdit.Handle)); end; -class function TWinCEWSCustomFloatSpinEdit.GetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; +class function TWinCEWSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer; begin - Result := EditGetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); + Result := EditGetSelLength(GetBuddyWindow(ACustomEdit.Handle)); end; class function TWinCEWSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl; @@ -181,16 +179,16 @@ begin Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; end; -class procedure TWinCEWSCustomFloatSpinEdit.SetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); +class procedure TWinCEWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit; + NewStart: integer); begin - EditSetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewStart); + EditSetSelStart(GetBuddyWindow(ACustomEdit.Handle), NewStart); end; -class procedure TWinCEWSCustomFloatSpinEdit.SetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); +class procedure TWinCEWSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit; + NewLength: integer); begin - EditSetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewLength); + EditSetSelLength(GetBuddyWindow(ACustomEdit.Handle), NewLength); end; class procedure TWinCEWSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl); diff --git a/lcl/spin.pp b/lcl/spin.pp index 86af1ba5d6..3c533c0494 100644 --- a/lcl/spin.pp +++ b/lcl/spin.pp @@ -1,4 +1,4 @@ - { +{ /*************************************************************************** Spin.pp -------- @@ -35,68 +35,42 @@ uses type { TCustomFloatSpinEdit } - TCustomFloatSpinEdit = class(TWinControl) + TCustomFloatSpinEdit = class(TCustomEdit) private - FIncrement: single; - FDecimals: integer; - FMaxValue: single; - FMinValue: single; - FModified: boolean; - FOnChange: TNotifyEvent; - FSelLength: integer; - FSelStart: integer; + FIncrement: Single; + FDecimals: Integer; + FMaxValue: Single; + FMinValue: Single; FValue: Single; - FValueEmpty: boolean; - FUpdatePending: boolean; - FValueChanged: boolean; - function GetModified: Boolean; - function GetSelLength: integer; - function GetSelStart: integer; - function GetSelText: String; - function MaxValueIsStored: boolean; - function MinValueIsStored: boolean; - procedure SetMaxValue(const AValue: single); - procedure SetMinValue(const AValue: single); - procedure SetModified(const AValue: Boolean); - procedure SetSelLength(const AValue: integer); - procedure SetSelStart(const AValue: integer); - procedure SetSelText(const AValue: String); - procedure SetValueEmpty(const AValue: boolean); - Procedure UpdateControl; - function ValueIsStored: boolean; + FValueEmpty: Boolean; + FUpdatePending: Boolean; + FValueChanged: Boolean; + function MaxValueIsStored: Boolean; + function MinValueIsStored: Boolean; + procedure SetMaxValue(const AValue: Single); + procedure SetMinValue(const AValue: Single); + procedure SetValueEmpty(const AValue: Boolean); + procedure UpdateControl; + function ValueIsStored: Boolean; protected function RealGetText: TCaption; override; procedure TextChanged; override; - procedure SetDecimals(Num: Integer); + procedure SetDecimals(ADecimals: Integer); function GetValue: Single; - procedure SetValue(const Num: Single); - procedure SetIncrement(const NewIncrement: single); + procedure SetValue(const AValue: Single); + procedure SetIncrement(const AIncrement: Single); procedure InitializeWnd; override; procedure FinalizeWnd; override; procedure Loaded; override; - procedure Change; dynamic; public constructor Create(TheOwner: TComponent); override; - destructor Destroy; override; - procedure SelectAll; - procedure ClearSelection; virtual; - procedure CopyToClipboard; virtual; - procedure CutToClipboard; virtual; - procedure PasteFromClipboard; virtual; - property SelLength: integer read GetSelLength write SetSelLength; - property SelStart: integer read GetSelStart write SetSelStart; - property SelText: String read GetSelText write SetSelText; - property Modified: Boolean read GetModified write SetModified; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - property Text; public property DecimalPlaces: Integer read FDecimals write SetDecimals default 2; property Increment: Single read FIncrement write SetIncrement default 1; - property MinValue: single read FMinValue write SetMinValue default 0; - property MaxValue: single read FMaxValue write SetMaxValue default 100; - property TabStop default true; + property MinValue: Single read FMinValue write SetMinValue default 0; + property MaxValue: Single read FMaxValue write SetMaxValue default 100; property Value: Single read GetValue write SetValue default 0; - property ValueEmpty: boolean read FValueEmpty write SetValueEmpty default False; + property ValueEmpty: Boolean read FValueEmpty write SetValueEmpty default False; end; { TFloatSpinEdit } @@ -165,7 +139,6 @@ type property Anchors; property AutoSize; property BorderSpacing; - property ClimbRate: integer write SetIncrement stored false; // TODO: remove, deprecated property Constraints; property Enabled; property Increment; @@ -203,7 +176,7 @@ uses procedure Register; begin - RegisterComponents('Misc',[TSpinEdit,TFloatSpinEdit]); + RegisterComponents('Misc', [TSpinEdit, TFloatSpinEdit]); end; {$I spinedit.inc} diff --git a/lcl/widgetset/wsspin.pp b/lcl/widgetset/wsspin.pp index 12f3c0da3b..358e9a0736 100644 --- a/lcl/widgetset/wsspin.pp +++ b/lcl/widgetset/wsspin.pp @@ -46,19 +46,14 @@ uses //////////////////////////////////////////////////// Spin, //////////////////////////////////////////////////// - WSLCLClasses, WSControls; + WSLCLClasses, WSControls, WSStdCtrls; type { TWSCustomFloatSpinEdit } - TWSCustomFloatSpinEdit = class(TWSWinControl) - class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; - class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; + TWSCustomFloatSpinEdit = class(TWSCustomEdit) class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; virtual; - class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); virtual; - class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); 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; @@ -80,27 +75,9 @@ implementation { TWSCustomFloatSpinEdit } -class function TWSCustomFloatSpinEdit.GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; -begin - result := -1; -end; - -class function TWSCustomFloatSpinEdit.GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; -begin - result := 0; -end; - class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; begin - result := 0.0; -end; - -class procedure TWSCustomFloatSpinEdit.SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); -begin -end; - -class procedure TWSCustomFloatSpinEdit.SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); -begin + Result := 0.0; end; class procedure TWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); @@ -116,4 +93,4 @@ initialization RegisterWSComponent(TCustomFloatSpinEdit, TWSCustomFloatSpinEdit); // RegisterWSComponent(TFloatSpinEdit, TWSFloatSpinEdit); //////////////////////////////////////////////////// -end. \ No newline at end of file +end.