LCL: - derived T(Float)SpinEdit from TCustomEdit to remove redundant code

- removed obsolete TSpinEdit.ClimbRate

git-svn-id: trunk@11205 -
This commit is contained in:
tombo 2007-05-26 09:57:11 +00:00
parent bce8d0a4c6
commit 5bcdc4373e
8 changed files with 154 additions and 317 deletions

View File

@ -69,7 +69,7 @@ object TableForm: TTableForm
end end
object SERows: TSpinEdit object SERows: TSpinEdit
BorderSpacing.OnChange = nil BorderSpacing.OnChange = nil
ClimbRate = 1 Increment = 1
MaxValue = 100 MaxValue = 100
TabOrder = 3 TabOrder = 3
Left = 72 Left = 72
@ -79,7 +79,7 @@ object TableForm: TTableForm
end end
object SEColumns: TSpinEdit object SEColumns: TSpinEdit
BorderSpacing.OnChange = nil BorderSpacing.OnChange = nil
ClimbRate = 1 Increment = 1
MaxValue = 100 MaxValue = 100
TabOrder = 4 TabOrder = 4
Left = 72 Left = 72

View File

@ -16,154 +16,94 @@
} }
{-----------------------------------------------------------------------------}
procedure TCustomFloatSpinEdit.UpdateControl; procedure TCustomFloatSpinEdit.UpdateControl;
begin begin
if MaxValue<MinValue then FMaxValue:=MinValue; if MaxValue < MinValue then FMaxValue := MinValue;
if (FMinValue<>0) and (FValue<FMinValue) then FValue:=fMinValue; if (FMinValue <> 0) and (FValue < FMinValue) then FValue := FMinValue;
if (FMaxValue<>0) and (FValue>FMaxValue) then FValue:=fMaxValue; if (FMaxValue <> 0) and (FValue > FMaxValue) then FValue := FMaxValue;
if (not HandleAllocated) then exit;
if ([csLoading,csDestroying]*ComponentState<>[]) then if (not HandleAllocated) then Exit;
if ([csLoading, csDestroying] * ComponentState <> []) then
FUpdatePending := True
else
begin begin
FUpdatePending := true;
exit;
end;
TWSCustomFloatSpinEditClass(WidgetSetClass).UpdateControl(Self); TWSCustomFloatSpinEditClass(WidgetSetClass).UpdateControl(Self);
FValueChanged := true; FValueChanged := True;
FUpdatePending := false; FUpdatePending := False;
end;
end; end;
function TCustomFloatSpinEdit.ValueIsStored: boolean; function TCustomFloatSpinEdit.ValueIsStored: Boolean;
begin begin
Result:=true; // fpc bug, default value is always 0 Result := True; // fpc bug, default value is always 0
end; end;
function TCustomFloatSpinEdit.RealGetText: TCaption; function TCustomFloatSpinEdit.RealGetText: TCaption;
begin begin
if HandleAllocated then if HandleAllocated then
Result:=inherited RealGetText Result := inherited RealGetText
else else
Result:=FloatToStrF(FValue, ffFixed, 20, DecimalPlaces); Result := FloatToStrF(FValue, ffFixed, 20, DecimalPlaces);
end; end;
procedure TCustomFloatSpinEdit.TextChanged; procedure TCustomFloatSpinEdit.TextChanged;
var var
lPrevValue: single; PrevValue: Single;
begin begin
lPrevValue := FValue; inherited;
FValueChanged := true;
if Value = lPrevValue then exit; PrevValue := FValue;
Modified := true; FValueChanged := True;
FValueEmpty := false;
if HandleAllocated and (not (csLoading in ComponentState)) then Change; if Value = PrevValue then Exit;
Modified := True;
FValueEmpty := False;
end; end;
procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: single); procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Single);
begin begin
if FMaxValue=AValue then exit; if FMaxValue = AValue then Exit;
FMaxValue:=AValue; FMaxValue := AValue;
UpdateControl; UpdateControl;
end; end;
function TCustomFloatSpinEdit.GetModified: Boolean; function TCustomFloatSpinEdit.MaxValueIsStored: Boolean;
begin begin
Result := FModified; Result := True; // fpc bug, default value is always 0
end; end;
function TCustomFloatSpinEdit.GetSelLength: integer; function TCustomFloatSpinEdit.MinValueIsStored: Boolean;
begin begin
if HandleAllocated then Result := True; // fpc bug, default value is always 0
FSelLength := TWSCustomFloatSpinEditClass(WidgetSetClass).GetSelLength(Self);
Result:= FSelLength;
end; end;
function TCustomFloatSpinEdit.GetSelStart: integer; procedure TCustomFloatSpinEdit.SetMinValue(const AValue: Single);
begin begin
if HandleAllocated then if FMinValue = AValue then Exit;
FSelStart:= TWSCustomFloatSpinEditClass(WidgetSetClass).GetSelStart(Self); FMinValue := AValue;
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;
UpdateControl; UpdateControl;
end; end;
procedure TCustomFloatSpinEdit.SetModified(const AValue: Boolean); procedure TCustomFloatSpinEdit.SetValueEmpty(const AValue: Boolean);
begin begin
FModified := AValue; if FValueEmpty = AValue then Exit;
end; FValueEmpty := AValue;
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;
UpdateControl; UpdateControl;
end; end;
procedure TCustomFloatSpinEdit.SetIncrement(const NewIncrement: single); procedure TCustomFloatSpinEdit.SetIncrement(const AIncrement: Single);
begin begin
if NewIncrement = FIncrement then exit; if AIncrement = FIncrement then Exit;
FIncrement := NewIncrement; FIncrement := AIncrement;
UpdateControl; UpdateControl;
end; end;
procedure TCustomFloatSpinEdit.InitializeWnd; procedure TCustomFloatSpinEdit.InitializeWnd;
var
ASelStart, ASelLength : integer;
begin begin
inherited InitializeWnd; inherited InitializeWnd;
UpdateControl; UpdateControl;
if FSelStart <> FSelLength then begin
ASelStart:= FSelStart;
ASelLength:= FSelLength;
SelStart:= ASelStart;
SelLength:= ASelLength;
end;
end; end;
procedure TCustomFloatSpinEdit.Loaded; procedure TCustomFloatSpinEdit.Loaded;
@ -172,67 +112,49 @@ begin
if FUpdatePending then UpdateControl; if FUpdatePending then UpdateControl;
end; end;
procedure TCustomFloatSpinEdit.Change; procedure TCustomFloatSpinEdit.SetValue(const AValue: Single);
begin begin
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit; if FValue = AValue then Exit;
EditingDone; FValue := AValue;
if Assigned(FOnChange) then FOnChange(Self);
end;
{-----------------------------------------------------------------------------}
Procedure TCustomFloatSpinEdit.SetValue(const num : Single);
begin
if FValue = Num then exit;
FValue := Num;
// clear FValueChanged to prevent getting the old value from the widget // clear FValueChanged to prevent getting the old value from the widget
FValueChanged := false; FValueChanged := False;
FUpdatePending := true; FUpdatePending := True;
UpdateControl; UpdateControl;
end; end;
{-----------------------------------------------------------------------------} function TCustomFloatSpinEdit.GetValue: Single;
Function TCustomFloatSpinEdit.GetValue: Single;
begin begin
if HandleAllocated and FValueChanged if HandleAllocated and FValueChanged
and not (wcfCreatingHandle in FWinControlFlags) then and not (wcfCreatingHandle in FWinControlFlags) then
begin begin
FValue := TWSCustomFloatSpinEditClass(WidgetSetClass).GetValue(Self); FValue := TWSCustomFloatSpinEditClass(WidgetSetClass).GetValue(Self);
FValueChanged := false; FValueChanged := False;
end; end;
Result := fValue; Result := FValue;
end; end;
{-----------------------------------------------------------------------------} procedure TCustomFloatSpinEdit.SetDecimals(ADecimals: Integer);
procedure TCustomFloatSpinEdit.SetDecimals(Num : Integer);
begin begin
if fDecimals = Num then exit; if FDecimals = ADecimals then Exit;
fDecimals := Num; FDecimals := ADecimals;
UpdateControl; UpdateControl;
end; end;
{-----------------------------------------------------------------------------} constructor TCustomFloatSpinEdit.Create(TheOwner: TComponent);
constructor TCustomFloatSpinEdit.Create(TheOwner : TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
fCompStyle := csSpinEdit; FCompStyle := csSpinEdit;
FIncrement := 1; FIncrement := 1;
fDecimals := 2; FDecimals := 2;
fValue := 0; FValue := 0;
fMinValue := 0; FMinValue := 0;
fMaxValue := 100; FMaxValue := 100;
FUpdatePending := true; FUpdatePending := True;
FValueChanged := true; FValueChanged := True;
SetInitialBounds(0,0,50,23); SetInitialBounds(0, 0, 50, 23);
ParentColor := false;
TabStop := true;
end;
{-----------------------------------------------------------------------------}
destructor TCustomFloatSpinEdit.Destroy;
begin
inherited Destroy;
end; end;
procedure TCustomFloatSpinEdit.FinalizeWnd; procedure TCustomFloatSpinEdit.FinalizeWnd;
@ -241,37 +163,6 @@ begin
inherited FinalizeWnd; inherited FinalizeWnd;
end; 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 } { TCustomSpinEdit }
function TCustomSpinEdit.GetIncrement: integer; function TCustomSpinEdit.GetIncrement: integer;

View File

@ -33,8 +33,8 @@ uses
glib, gdk, gtk, glib, gdk, gtk,
{$ENDIF} {$ENDIF}
GtkInt, GtkInt,
LCLProc, Spin, GtkProc, gtkExtra, GtkWSStdCtrls, WSSpin, WSLCLClasses, Controls, LCLProc, Spin, StdCtrls, GtkProc, gtkExtra, GtkWSStdCtrls, WSSpin,
LCLType; WSLCLClasses, Controls, LCLType;
type type
@ -44,21 +44,21 @@ type
private private
protected protected
public public
class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override;
class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
end; end;
function GetGtkSpinEntry(Spin: PGtkSpinButton): PGtkEntry; function GetGtkSpinEntry(Spin: PGtkSpinButton): PGtkEntry;
function GetSpinGtkEntry(Spin: TCustomFloatSpinEdit): PGtkEntry; function GetSpinGtkEntry(const Spin: TWinControl): PGtkEntry;
function GetGtkFloatSpinEditable(Spin: PGtkSpinButton): PGtkOldEditable; function GetGtkFloatSpinEditable(Spin: PGtkSpinButton): PGtkOldEditable;
function GetSpinGtkEditable(Spin: TCustomFloatSpinEdit): PGtkOldEditable; function GetSpinGtkEditable(const Spin: TWinControl): PGtkOldEditable;
implementation implementation
@ -67,7 +67,7 @@ begin
Result:=PGtkEntry(@(Spin^.entry)); Result:=PGtkEntry(@(Spin^.entry));
end; end;
function GetSpinGtkEntry(Spin: TCustomFloatSpinEdit): PGtkEntry; function GetSpinGtkEntry(const Spin: TWinControl): PGtkEntry;
begin begin
Result:=GetGtkSpinEntry(PGtkSpinButton(Spin.Handle)); Result:=GetGtkSpinEntry(PGtkSpinButton(Spin.Handle));
end; end;
@ -77,24 +77,21 @@ begin
Result:=PGtkOldEditable(@(Spin^.entry)); Result:=PGtkOldEditable(@(Spin^.entry));
end; end;
function GetSpinGtkEditable(Spin: TCustomFloatSpinEdit): PGtkOldEditable; function GetSpinGtkEditable(const Spin: TWinControl): PGtkOldEditable;
begin begin
Result:=GetGtkFloatSpinEditable(PGtkSpinButton(Spin.Handle)); Result:=GetGtkFloatSpinEditable(PGtkSpinButton(Spin.Handle));
end; end;
{ TGtkWSCustomFloatSpinEdit } { TGtkWSCustomFloatSpinEdit }
class function TGtkWSCustomFloatSpinEdit.GetSelStart( class function TGtkWSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit
): integer;
begin begin
Result :=WidgetGetSelStart(PGtkWidget(GetSpinGtkEntry(ACustomFloatSpinEdit))); Result :=WidgetGetSelStart(PGtkWidget(GetSpinGtkEntry(ACustomEdit)));
end; end;
class function TGtkWSCustomFloatSpinEdit.GetSelLength( class function TGtkWSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer;
begin begin
with GetSpinGtkEditable(ACustomFloatSpinEdit)^ do with GetSpinGtkEditable(ACustomEdit)^ do
Result := Abs(integer(selection_end_pos)-integer(selection_start_pos)); Result := Abs(integer(selection_end_pos)-integer(selection_start_pos));
end; end;
@ -105,16 +102,16 @@ begin
PGtkSpinButton(ACustomFloatSpinEdit.Handle)); PGtkSpinButton(ACustomFloatSpinEdit.Handle));
end; end;
class procedure TGtkWSCustomFloatSpinEdit.SetSelStart( class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); NewStart: integer);
begin begin
gtk_editable_set_position(GetSpinGtkEditable(ACustomFloatSpinEdit), NewStart); gtk_editable_set_position(GetSpinGtkEditable(ACustomEdit), NewStart);
end; end;
class procedure TGtkWSCustomFloatSpinEdit.SetSelLength( class procedure TGtkWSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); NewLength: integer);
begin begin
WidgetSetSelLength(PGtkWidget(GetSpinGtkEntry(ACustomFloatSpinEdit)), WidgetSetSelLength(PGtkWidget(GetSpinGtkEntry(ACustomEdit)),
NewLength); NewLength);
end; end;

View File

@ -1126,19 +1126,22 @@ begin
BN_CLICKED: LMessage.Msg := LM_CLICKED; BN_CLICKED: LMessage.Msg := LM_CLICKED;
BN_KILLFOCUS: LMessage.Msg := LM_EXIT; BN_KILLFOCUS: LMessage.Msg := LM_EXIT;
end end
else if (lWinControl is TCustomEdit) then else
case HIWORD(WParam) of if (lWinControl is TCustomEdit) then
EN_CHANGE: LMessage.Msg := CM_TEXTCHANGED; begin
end if (lWinControl is TCustomMemo) then
else if (lWinControl is TCustomFloatSpinEdit) then
case HIWORD(WParam) of
EN_CHANGE: HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl));
end
else if (lWinControl is TCustomMemo) then
case HIWORD(WParam) of case HIWORD(WParam) of
// multiline edit doesn't send EN_CHANGE, so use EN_UPDATE // multiline edit doesn't send EN_CHANGE, so use EN_UPDATE
EN_UPDATE: LMessage.Msg := CM_TEXTCHANGED; EN_UPDATE: LMessage.Msg := CM_TEXTCHANGED;
end 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 else if (lWinControl is TCustomListBox) then
case HIWORD(WParam) of case HIWORD(WParam) of
LBN_SELCHANGE: LMessage.Msg := LM_SELCHANGE; LBN_SELCHANGE: LMessage.Msg := LM_SELCHANGE;

View File

@ -33,7 +33,7 @@ uses
// To get as little as posible circles, // To get as little as posible circles,
// uncomment only when needed for registration // uncomment only when needed for registration
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
Spin, Controls, LCLType, Spin, Controls, StdCtrls, LCLType,
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
WSSpin, WSLCLClasses, Windows, Win32Int, WinExt, Win32Proc, WSSpin, WSLCLClasses, Windows, Win32Int, WinExt, Win32Proc,
Win32WSStdCtrls, Win32WSControls; Win32WSStdCtrls, Win32WSControls;
@ -50,13 +50,13 @@ type
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override; var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class function CreateHandle(const AWinControl: TWinControl; class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): 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): single; override;
class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; 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 UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
@ -163,16 +163,14 @@ begin
SuppressMove := true; SuppressMove := true;
end; end;
class function TWin32WSCustomFloatSpinEdit.GetSelStart( class function TWin32WSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer;
begin begin
Result := EditGetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); Result := EditGetSelStart(GetBuddyWindow(ACustomEdit.Handle));
end; end;
class function TWin32WSCustomFloatSpinEdit.GetSelLength( class function TWin32WSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer;
begin begin
Result := EditGetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); Result := EditGetSelLength(GetBuddyWindow(ACustomEdit.Handle));
end; end;
class function TWin32WSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl; class function TWin32WSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl;
@ -190,16 +188,16 @@ begin
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
end; end;
class procedure TWin32WSCustomFloatSpinEdit.SetSelStart( class procedure TWin32WSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); NewStart: integer);
begin begin
EditSetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewStart); EditSetSelStart(GetBuddyWindow(ACustomEdit.Handle), NewStart);
end; end;
class procedure TWin32WSCustomFloatSpinEdit.SetSelLength( class procedure TWin32WSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); NewLength: integer);
begin begin
EditSetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewLength); EditSetSelLength(GetBuddyWindow(ACustomEdit.Handle), NewLength);
end; end;
class procedure TWin32WSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl); class procedure TWin32WSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl);

View File

@ -32,7 +32,7 @@ uses
// To get as little as posible circles, // To get as little as posible circles,
// uncomment only when needed for registration // uncomment only when needed for registration
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
Spin, Controls, LCLType, Spin, Controls, StdCtrls, LCLType,
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
WSSpin, WSLCLClasses, Windows, WinCEInt, WinCEProc, WSSpin, WSLCLClasses, Windows, WinCEInt, WinCEProc,
WinCEWSStdCtrls, WinCEWSControls; WinCEWSStdCtrls, WinCEWSControls;
@ -49,13 +49,13 @@ type
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override; var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class function CreateHandle(const AWinControl: TWinControl; class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; override; class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): 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): single; override;
class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); override; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; 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 UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
@ -154,16 +154,14 @@ begin
SuppressMove := true; SuppressMove := true;
end; end;
class function TWinCEWSCustomFloatSpinEdit.GetSelStart( class function TWinCEWSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer;
begin begin
Result := EditGetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); Result := EditGetSelStart(GetBuddyWindow(ACustomEdit.Handle));
end; end;
class function TWinCEWSCustomFloatSpinEdit.GetSelLength( class function TWinCEWSCustomFloatSpinEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer;
begin begin
Result := EditGetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle)); Result := EditGetSelLength(GetBuddyWindow(ACustomEdit.Handle));
end; end;
class function TWinCEWSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl; class function TWinCEWSCustomFloatSpinEdit.GetText(const AWinControl: TWinControl;
@ -181,16 +179,16 @@ begin
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue; Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
end; end;
class procedure TWinCEWSCustomFloatSpinEdit.SetSelStart( class procedure TWinCEWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); NewStart: integer);
begin begin
EditSetSelStart(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewStart); EditSetSelStart(GetBuddyWindow(ACustomEdit.Handle), NewStart);
end; end;
class procedure TWinCEWSCustomFloatSpinEdit.SetSelLength( class procedure TWinCEWSCustomFloatSpinEdit.SetSelLength(const ACustomEdit: TCustomEdit;
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); NewLength: integer);
begin begin
EditSetSelLength(GetBuddyWindow(ACustomFloatSpinEdit.Handle), NewLength); EditSetSelLength(GetBuddyWindow(ACustomEdit.Handle), NewLength);
end; end;
class procedure TWinCEWSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl); class procedure TWinCEWSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl);

View File

@ -1,4 +1,4 @@
{ {
/*************************************************************************** /***************************************************************************
Spin.pp Spin.pp
-------- --------
@ -35,68 +35,42 @@ uses
type type
{ TCustomFloatSpinEdit } { TCustomFloatSpinEdit }
TCustomFloatSpinEdit = class(TWinControl) TCustomFloatSpinEdit = class(TCustomEdit)
private private
FIncrement: single; FIncrement: Single;
FDecimals: integer; FDecimals: Integer;
FMaxValue: single; FMaxValue: Single;
FMinValue: single; FMinValue: Single;
FModified: boolean;
FOnChange: TNotifyEvent;
FSelLength: integer;
FSelStart: integer;
FValue: Single; FValue: Single;
FValueEmpty: boolean; FValueEmpty: Boolean;
FUpdatePending: boolean; FUpdatePending: Boolean;
FValueChanged: boolean; FValueChanged: Boolean;
function GetModified: Boolean; function MaxValueIsStored: Boolean;
function GetSelLength: integer; function MinValueIsStored: Boolean;
function GetSelStart: integer; procedure SetMaxValue(const AValue: Single);
function GetSelText: String; procedure SetMinValue(const AValue: Single);
function MaxValueIsStored: boolean; procedure SetValueEmpty(const AValue: Boolean);
function MinValueIsStored: boolean; procedure UpdateControl;
procedure SetMaxValue(const AValue: single); function ValueIsStored: Boolean;
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;
protected protected
function RealGetText: TCaption; override; function RealGetText: TCaption; override;
procedure TextChanged; override; procedure TextChanged; override;
procedure SetDecimals(Num: Integer); procedure SetDecimals(ADecimals: Integer);
function GetValue: Single; function GetValue: Single;
procedure SetValue(const Num: Single); procedure SetValue(const AValue: Single);
procedure SetIncrement(const NewIncrement: single); procedure SetIncrement(const AIncrement: Single);
procedure InitializeWnd; override; procedure InitializeWnd; override;
procedure FinalizeWnd; override; procedure FinalizeWnd; override;
procedure Loaded; override; procedure Loaded; override;
procedure Change; dynamic;
public public
constructor Create(TheOwner: TComponent); override; 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 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 default 1; property Increment: Single read FIncrement write SetIncrement default 1;
property MinValue: single read FMinValue write SetMinValue default 0; property MinValue: Single read FMinValue write SetMinValue default 0;
property MaxValue: single read FMaxValue write SetMaxValue default 100; property MaxValue: Single read FMaxValue write SetMaxValue default 100;
property TabStop default true;
property Value: Single read GetValue write SetValue default 0; 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; end;
{ TFloatSpinEdit } { TFloatSpinEdit }
@ -165,7 +139,6 @@ type
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property BorderSpacing; property BorderSpacing;
property ClimbRate: integer write SetIncrement stored false; // TODO: remove, deprecated
property Constraints; property Constraints;
property Enabled; property Enabled;
property Increment; property Increment;
@ -203,7 +176,7 @@ uses
procedure Register; procedure Register;
begin begin
RegisterComponents('Misc',[TSpinEdit,TFloatSpinEdit]); RegisterComponents('Misc', [TSpinEdit, TFloatSpinEdit]);
end; end;
{$I spinedit.inc} {$I spinedit.inc}

View File

@ -46,19 +46,14 @@ uses
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
Spin, Spin,
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
WSLCLClasses, WSControls; WSLCLClasses, WSControls, WSStdCtrls;
type type
{ TWSCustomFloatSpinEdit } { TWSCustomFloatSpinEdit }
TWSCustomFloatSpinEdit = class(TWSWinControl) TWSCustomFloatSpinEdit = class(TWSCustomEdit)
class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual;
class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual;
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; virtual; 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 (* TODO: seperation into properties instead of bulk update
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual; class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: single); virtual;
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual; class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: single); virtual;
@ -80,27 +75,9 @@ implementation
{ TWSCustomFloatSpinEdit } { 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; class function TWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
begin begin
result := 0.0; 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
end; end;
class procedure TWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); class procedure TWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit);