You've already forked lazarus-ccr
Added: EditFormat property to FloatEdit components
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2834 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -33,6 +33,7 @@ type
|
|||||||
TJDBLabeledFloatEdit = class(TCustomLabeledEdit)
|
TJDBLabeledFloatEdit = class(TCustomLabeledEdit)
|
||||||
private
|
private
|
||||||
fFormat: string;
|
fFormat: string;
|
||||||
|
fEFormat: string;
|
||||||
FDataLink: TFieldDataLink;
|
FDataLink: TFieldDataLink;
|
||||||
fDecimales: integer;
|
fDecimales: integer;
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ type
|
|||||||
|
|
||||||
published
|
published
|
||||||
property DisplayFormat: string read getFormat write setFormat;
|
property DisplayFormat: string read getFormat write setFormat;
|
||||||
|
property EditFormat: string read fEFormat write fEFormat;
|
||||||
property DataField: string read GetDataField write SetDataField;
|
property DataField: string read GetDataField write SetDataField;
|
||||||
property DataSource: TDataSource read GetDataSource write SetDataSource;
|
property DataSource: TDataSource read GetDataSource write SetDataSource;
|
||||||
property Decimals: integer read getDecimals write setDecimals;
|
property Decimals: integer read getDecimals write setDecimals;
|
||||||
@@ -149,6 +151,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
if not Focused then
|
if not Focused then
|
||||||
formatInput
|
formatInput
|
||||||
|
else
|
||||||
|
if Length(EditFormat) > 0 then
|
||||||
|
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||||
else
|
else
|
||||||
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
||||||
end
|
end
|
||||||
@@ -179,7 +184,10 @@ begin
|
|||||||
theValue := StrToFloat(Text);
|
theValue := StrToFloat(Text);
|
||||||
if fDecimales > 0 then
|
if fDecimales > 0 then
|
||||||
theValue := ScaleTo(theValue, fDecimales);
|
theValue := ScaleTo(theValue, fDecimales);
|
||||||
Text := FloatToStr(theValue);
|
if Length(EditFormat) > 0 then
|
||||||
|
Caption := FormatFloat(EditFormat, theValue)
|
||||||
|
else
|
||||||
|
Caption := FloatToStr(theValue);
|
||||||
FDataLink.Field.Value := theValue;
|
FDataLink.Field.Value := theValue;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -187,7 +195,10 @@ begin
|
|||||||
if FDataLink.Field <> nil then
|
if FDataLink.Field <> nil then
|
||||||
begin
|
begin
|
||||||
ShowMessage(Format(SInvalidNumber, [Caption]));
|
ShowMessage(Format(SInvalidNumber, [Caption]));
|
||||||
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
if Length(EditFormat) > 0 then
|
||||||
|
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||||
|
else
|
||||||
|
Caption := FloatToStr(FDataLink.Field.AsFloat);
|
||||||
SelectAll;
|
SelectAll;
|
||||||
SetFocus;
|
SetFocus;
|
||||||
end;
|
end;
|
||||||
@@ -356,7 +367,10 @@ begin
|
|||||||
if not FieldIsEditable(Field) or IsReadOnly then
|
if not FieldIsEditable(Field) or IsReadOnly then
|
||||||
exit;
|
exit;
|
||||||
if FDataLink.Field <> nil then
|
if FDataLink.Field <> nil then
|
||||||
Caption := FloatToStr(FDataLink.Field.AsFloat); //FDataLink.Field.AsString;
|
if Length(EditFormat) > 0 then
|
||||||
|
Caption := FormatFloat(EditFormat, FDataLink.Field.AsFloat)
|
||||||
|
else
|
||||||
|
Caption := FloatToStr(FDataLink.Field.AsFloat); //FDataLink.Field.AsString;
|
||||||
inherited DoEnter;
|
inherited DoEnter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -369,6 +383,7 @@ begin
|
|||||||
FDataLink.OnDataChange := @DataChange;
|
FDataLink.OnDataChange := @DataChange;
|
||||||
FDataLink.OnUpdateData := @UpdateData;
|
FDataLink.OnUpdateData := @UpdateData;
|
||||||
FDataLInk.OnActiveChange := @ActiveChange;
|
FDataLInk.OnActiveChange := @ActiveChange;
|
||||||
|
fEFormat:= '';
|
||||||
// Set default values
|
// Set default values
|
||||||
//fDecimales := 2;
|
//fDecimales := 2;
|
||||||
//fFormat := '0.00';
|
//fFormat := '0.00';
|
||||||
|
@@ -34,6 +34,7 @@ type
|
|||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
theValue: double;
|
theValue: double;
|
||||||
fFormat: string;
|
fFormat: string;
|
||||||
|
fEFormat: string;
|
||||||
fDecimals: integer;
|
fDecimals: integer;
|
||||||
function getDecimals: integer;
|
function getDecimals: integer;
|
||||||
function getFormat: string;
|
function getFormat: string;
|
||||||
@@ -58,6 +59,7 @@ type
|
|||||||
published
|
published
|
||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
property DisplayFormat: string read getFormat write setFormat;
|
property DisplayFormat: string read getFormat write setFormat;
|
||||||
|
property EditFormat: string read fEFormat write fEFormat;
|
||||||
property Decimals: integer read getDecimals write setDecimals;
|
property Decimals: integer read getDecimals write setDecimals;
|
||||||
property Value: double read getValue write setValue;
|
property Value: double read getValue write setValue;
|
||||||
|
|
||||||
@@ -187,7 +189,10 @@ begin
|
|||||||
inherited DoEnter;
|
inherited DoEnter;
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
Text := FloatToStr(theValue);
|
if Length(EditFormat) > 0 then
|
||||||
|
Text := FormatFloat(EditFormat, theValue)
|
||||||
|
else
|
||||||
|
Text := FloatToStr(theValue);
|
||||||
SelectAll;
|
SelectAll;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -223,6 +228,7 @@ constructor TJLabeledFloatEdit.Create(TheOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
Text := '';
|
Text := '';
|
||||||
|
fEFormat := '';
|
||||||
fFormat := '#,0.00';
|
fFormat := '#,0.00';
|
||||||
fDecimals := 2;
|
fDecimals := 2;
|
||||||
formatInput;
|
formatInput;
|
||||||
|
Reference in New Issue
Block a user