You've already forked lazarus-ccr
Implement EditFormat in all nondb components except timeedit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4551 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -31,6 +31,7 @@ type
|
|||||||
|
|
||||||
TJLabeledCurrencyEdit = class(TCustomLabeledEdit)
|
TJLabeledCurrencyEdit = class(TCustomLabeledEdit)
|
||||||
private
|
private
|
||||||
|
fEFormat: string;
|
||||||
theValue: currency;
|
theValue: currency;
|
||||||
fFormat: string;
|
fFormat: string;
|
||||||
fDecimals: integer;
|
fDecimals: integer;
|
||||||
@@ -55,6 +56,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: currency read getValue write setValue;
|
property Value: currency read getValue write setValue;
|
||||||
|
|
||||||
@@ -182,6 +184,9 @@ begin
|
|||||||
inherited DoEnter;
|
inherited DoEnter;
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
|
if EditFormat <> '' then
|
||||||
|
Text := FormatFloat(EditFormat, theValue)
|
||||||
|
else
|
||||||
Text := FloatToStr(theValue);
|
Text := FloatToStr(theValue);
|
||||||
SelectAll;
|
SelectAll;
|
||||||
end;
|
end;
|
||||||
|
@@ -31,15 +31,16 @@ type
|
|||||||
|
|
||||||
TJLabeledDateEdit = class(TCustomLabeledEdit)
|
TJLabeledDateEdit = class(TCustomLabeledEdit)
|
||||||
private
|
private
|
||||||
|
fEFormat: string;
|
||||||
theValue: TDateTime;
|
theValue: TDateTime;
|
||||||
fFormat: string;
|
fFormat: string;
|
||||||
FButton: TSpeedButton;
|
FButton: TSpeedButton;
|
||||||
FButtonNeedsFocus: Boolean;
|
FButtonNeedsFocus: boolean;
|
||||||
function GetButtonWidth: Integer;
|
function GetButtonWidth: integer;
|
||||||
function getFormat: string;
|
function getFormat: string;
|
||||||
function getValue: TDateTime;
|
function getValue: TDateTime;
|
||||||
procedure formatInput;
|
procedure formatInput;
|
||||||
procedure SetButtonWidth(AValue: Integer);
|
procedure SetButtonWidth(AValue: integer);
|
||||||
procedure setFormat(const AValue: string);
|
procedure setFormat(const AValue: string);
|
||||||
procedure setValue(const AValue: TDateTime);
|
procedure setValue(const AValue: TDateTime);
|
||||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||||
@@ -48,7 +49,7 @@ type
|
|||||||
{ Protected declarations }
|
{ Protected declarations }
|
||||||
procedure DoEnter; override;
|
procedure DoEnter; override;
|
||||||
procedure DoExit; override;
|
procedure DoExit; override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
||||||
procedure KeyPress(var Key: char); override;
|
procedure KeyPress(var Key: char); override;
|
||||||
procedure SetParent(AParent: TWinControl); override;
|
procedure SetParent(AParent: TWinControl); override;
|
||||||
procedure DoPositionButton; virtual;
|
procedure DoPositionButton; virtual;
|
||||||
@@ -68,9 +69,10 @@ type
|
|||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
function isNull: boolean;
|
function isNull: boolean;
|
||||||
property DisplayFormat: string read getFormat write setFormat;
|
property DisplayFormat: string read getFormat write setFormat;
|
||||||
|
property EditFormat: string read fEFormat write fEFormat;
|
||||||
property Value: TDateTime read getValue write setValue;
|
property Value: TDateTime read getValue write setValue;
|
||||||
property Button: TSpeedButton read FButton;
|
property Button: TSpeedButton read FButton;
|
||||||
property ButtonWidth : Integer read GetButtonWidth write SetButtonWidth;
|
property ButtonWidth: integer read GetButtonWidth write SetButtonWidth;
|
||||||
|
|
||||||
property Action;
|
property Action;
|
||||||
property Align;
|
property Align;
|
||||||
@@ -137,9 +139,9 @@ begin
|
|||||||
Result := fFormat;
|
Result := fFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJLabeledDateEdit.GetButtonWidth: Integer;
|
function TJLabeledDateEdit.GetButtonWidth: integer;
|
||||||
begin
|
begin
|
||||||
Result:= FButton.Width;
|
Result := FButton.Width;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJLabeledDateEdit.getValue: TDateTime;
|
function TJLabeledDateEdit.getValue: TDateTime;
|
||||||
@@ -155,9 +157,9 @@ begin
|
|||||||
Text := '';
|
Text := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.SetButtonWidth(AValue: Integer);
|
procedure TJLabeledDateEdit.SetButtonWidth(AValue: integer);
|
||||||
begin
|
begin
|
||||||
FButton.Width:=AValue;
|
FButton.Width := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.setFormat(const AValue: string);
|
procedure TJLabeledDateEdit.setFormat(const AValue: string);
|
||||||
@@ -190,7 +192,12 @@ begin
|
|||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
if theValue <> 0 then
|
if theValue <> 0 then
|
||||||
Text := FormatDateTime(DisplayFormat, theValue)
|
begin
|
||||||
|
if EditFormat <> '' then
|
||||||
|
Text := FormatDateTime(EditFormat, theValue)
|
||||||
|
else
|
||||||
|
Text := FormatDateTime(DefaultFormatSettings.ShortDateFormat, theValue);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Text := '';
|
Text := '';
|
||||||
SelectAll;
|
SelectAll;
|
||||||
@@ -215,7 +222,7 @@ begin
|
|||||||
formatInput;
|
formatInput;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TJLabeledDateEdit.KeyDown(var Key: word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
inherited KeyDown(Key, Shift);
|
inherited KeyDown(Key, Shift);
|
||||||
if (ssAlt in Shift) and (key = 40) then
|
if (ssAlt in Shift) and (key = 40) then
|
||||||
@@ -241,23 +248,23 @@ end;
|
|||||||
|
|
||||||
procedure TJLabeledDateEdit.DoPositionButton;
|
procedure TJLabeledDateEdit.DoPositionButton;
|
||||||
begin
|
begin
|
||||||
if FButton = nil then exit;
|
if FButton = nil then
|
||||||
|
exit;
|
||||||
FButton.Parent := Parent;
|
FButton.Parent := Parent;
|
||||||
FButton.Visible:= True;
|
FButton.Visible := True;
|
||||||
if BiDiMode = bdLeftToRight then
|
if BiDiMode = bdLeftToRight then
|
||||||
FButton.AnchorToCompanion(akLeft,0,Self)
|
FButton.AnchorToCompanion(akLeft, 0, Self)
|
||||||
else
|
else
|
||||||
FButton.AnchorToCompanion(akRight,0,Self);
|
FButton.AnchorToCompanion(akRight, 0, Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.CheckButtonVisible;
|
procedure TJLabeledDateEdit.CheckButtonVisible;
|
||||||
begin
|
begin
|
||||||
If Assigned(FButton) then
|
if Assigned(FButton) then
|
||||||
FButton.Visible:=True;
|
FButton.Visible := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.Notification(AComponent: TComponent;
|
procedure TJLabeledDateEdit.Notification(AComponent: TComponent; Operation: TOperation);
|
||||||
Operation: TOperation);
|
|
||||||
begin
|
begin
|
||||||
inherited Notification(AComponent, Operation);
|
inherited Notification(AComponent, Operation);
|
||||||
if (AComponent = FButton) and (Operation = opRemove) then
|
if (AComponent = FButton) and (Operation = opRemove) then
|
||||||
@@ -273,8 +280,8 @@ end;
|
|||||||
procedure TJLabeledDateEdit.CMEnabledChanged(var Msg: TLMessage);
|
procedure TJLabeledDateEdit.CMEnabledChanged(var Msg: TLMessage);
|
||||||
begin
|
begin
|
||||||
inherited CMEnabledChanged(Msg);
|
inherited CMEnabledChanged(Msg);
|
||||||
if (FButton<>nil) then
|
if (FButton <> nil) then
|
||||||
FButton.Enabled:=True;
|
FButton.Enabled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJLabeledDateEdit.CMBiDiModeChanged(var Message: TLMessage);
|
procedure TJLabeledDateEdit.CMBiDiModeChanged(var Message: TLMessage);
|
||||||
@@ -299,7 +306,7 @@ begin
|
|||||||
if isNull then
|
if isNull then
|
||||||
ADate := now
|
ADate := now
|
||||||
else
|
else
|
||||||
ADate:= Value;
|
ADate := Value;
|
||||||
ShowCalendarPopup(PopupOrigin, ADate, [dsShowHeadings, dsShowDayNames],
|
ShowCalendarPopup(PopupOrigin, ADate, [dsShowHeadings, dsShowDayNames],
|
||||||
@CalendarPopupReturnDate, nil);
|
@CalendarPopupReturnDate, nil);
|
||||||
end;
|
end;
|
||||||
@@ -307,7 +314,7 @@ end;
|
|||||||
procedure TJLabeledDateEdit.CalendarPopupReturnDate(Sender: TObject;
|
procedure TJLabeledDateEdit.CalendarPopupReturnDate(Sender: TObject;
|
||||||
const ADate: TDateTime);
|
const ADate: TDateTime);
|
||||||
begin
|
begin
|
||||||
Value:= ADate;
|
Value := ADate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TJLabeledDateEdit.Create(TheOwner: TComponent);
|
constructor TJLabeledDateEdit.Create(TheOwner: TComponent);
|
||||||
@@ -321,7 +328,7 @@ begin
|
|||||||
FButton.FreeNotification(Self);
|
FButton.FreeNotification(Self);
|
||||||
CheckButtonVisible;
|
CheckButtonVisible;
|
||||||
FButton.Cursor := crArrow;
|
FButton.Cursor := crArrow;
|
||||||
FButton.Flat:= False;
|
FButton.Flat := False;
|
||||||
|
|
||||||
FButton.OnClick := @ShowCalendar;
|
FButton.OnClick := @ShowCalendar;
|
||||||
FButton.ControlStyle := FButton.ControlStyle + [csNoDesignSelectable];
|
FButton.ControlStyle := FButton.ControlStyle + [csNoDesignSelectable];
|
||||||
|
@@ -33,6 +33,7 @@ type
|
|||||||
|
|
||||||
TJLabeledDateTimeEdit = class(TCustomLabeledEdit)
|
TJLabeledDateTimeEdit = class(TCustomLabeledEdit)
|
||||||
private
|
private
|
||||||
|
fEFormat: string;
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
theValue: TDateTime;
|
theValue: TDateTime;
|
||||||
fFormat: string;
|
fFormat: string;
|
||||||
@@ -72,6 +73,7 @@ type
|
|||||||
{ Published declarations }
|
{ Published declarations }
|
||||||
function isNull: boolean;
|
function isNull: boolean;
|
||||||
property DisplayFormat: string read getFormat write setFormat;
|
property DisplayFormat: string read getFormat write setFormat;
|
||||||
|
property EditFormat: string read fEFormat write fEFormat;
|
||||||
property Value: TDateTime read getValue write setValue;
|
property Value: TDateTime read getValue write setValue;
|
||||||
property Button: TSpeedButton read FButton;
|
property Button: TSpeedButton read FButton;
|
||||||
property ButtonWidth: integer read GetButtonWidth write SetButtonWidth;
|
property ButtonWidth: integer read GetButtonWidth write SetButtonWidth;
|
||||||
@@ -195,7 +197,13 @@ begin
|
|||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
if theValue <> 0 then
|
if theValue <> 0 then
|
||||||
Text := FormatDateTime(DisplayFormat, theValue)
|
begin
|
||||||
|
if EditFormat <> '' then
|
||||||
|
Text := FormatDateTime(EditFormat, theValue)
|
||||||
|
else
|
||||||
|
Text := FormatDateTime(DefaultFormatSettings.ShortDateFormat +
|
||||||
|
' ' + DefaultFormatSettings.ShortTimeFormat, theValue);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Text := '';
|
Text := '';
|
||||||
SelectAll;
|
SelectAll;
|
||||||
|
@@ -189,7 +189,7 @@ begin
|
|||||||
inherited DoEnter;
|
inherited DoEnter;
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
exit;
|
exit;
|
||||||
if Length(EditFormat) > 0 then
|
if EditFormat <> '' then
|
||||||
Text := FormatFloat(EditFormat, theValue)
|
Text := FormatFloat(EditFormat, theValue)
|
||||||
else
|
else
|
||||||
Text := FloatToStr(theValue);
|
Text := FloatToStr(theValue);
|
||||||
|
Reference in New Issue
Block a user