RxFPC: in RxCurrEdit add property EditFormat

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5804 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2017-03-13 12:32:21 +00:00
parent b8da454852
commit ed6d78b980

View File

@ -45,6 +45,7 @@ type
TCustomNumEdit = class(TCustomMaskEdit) TCustomNumEdit = class(TCustomMaskEdit)
private private
FEditFormat: string;
FFocusedDisplay: boolean; FFocusedDisplay: boolean;
FBeepOnError: Boolean; FBeepOnError: Boolean;
FCheckOnExit: Boolean; FCheckOnExit: Boolean;
@ -65,6 +66,7 @@ type
procedure SetBeepOnError(const AValue: Boolean); procedure SetBeepOnError(const AValue: Boolean);
procedure SetDecimalPlaces(const AValue: Cardinal); procedure SetDecimalPlaces(const AValue: Cardinal);
procedure SetDisplayFormat(const AValue: string); procedure SetDisplayFormat(const AValue: string);
procedure SetEditFormat(AValue: string);
// procedure SetFormatOnEditing(const AValue: Boolean); // procedure SetFormatOnEditing(const AValue: Boolean);
procedure SetMaxValue(const AValue: Extended); procedure SetMaxValue(const AValue: Extended);
procedure SetMinValue(const AValue: Extended); procedure SetMinValue(const AValue: Extended);
@ -108,6 +110,7 @@ type
property DecimalPlaces: Cardinal read FDecimalPlaces write SetDecimalPlaces property DecimalPlaces: Cardinal read FDecimalPlaces write SetDecimalPlaces
default 2; default 2;
property DisplayFormat: string read FDisplayFormat write SetDisplayFormat; property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
property EditFormat: string read FEditFormat write SetEditFormat;
property MaxValue: Extended read FMaxValue write SetMaxValue; property MaxValue: Extended read FMaxValue write SetMaxValue;
property MinValue: Extended read FMinValue write SetMinValue; property MinValue: Extended read FMinValue write SetMinValue;
// property FormatOnEditing: Boolean read FFormatOnEditing write SetFormatOnEditing default False; // property FormatOnEditing: Boolean read FFormatOnEditing write SetFormatOnEditing default False;
@ -141,11 +144,11 @@ type
property Color; property Color;
property DecimalPlaces; property DecimalPlaces;
property DisplayFormat; property DisplayFormat;
property EditFormat;
property DragCursor; property DragCursor;
property DragMode; property DragMode;
property Enabled; property Enabled;
property Font; property Font;
// property FormatOnEditing;
property HideSelection; property HideSelection;
property Anchors; property Anchors;
property BiDiMode; property BiDiMode;
@ -293,8 +296,13 @@ function TCustomNumEdit.GetText: string;
begin begin
if (FValue = 0) and FZeroEmpty then if (FValue = 0) and FZeroEmpty then
Result:='' Result:=''
else
begin
if FEditFormat <> '' then
Result := FormatFloat(FEditFormat, FValue)
else else
Result := FloatToStr(FValue); Result := FloatToStr(FValue);
end;
end; end;
function TCustomNumEdit.GetValue: Extended; function TCustomNumEdit.GetValue: Extended;
@ -336,6 +344,13 @@ begin
DataChanged; DataChanged;
end; end;
procedure TCustomNumEdit.SetEditFormat(AValue: string);
begin
if FEditFormat=AValue then Exit;
FEditFormat:=AValue;
DataChanged;
end;
{ {
procedure TCustomNumEdit.SetFormatOnEditing(const AValue: Boolean); procedure TCustomNumEdit.SetFormatOnEditing(const AValue: Boolean);
begin begin