EditButton: Implement property SimpleLayout for TTimeEdit. Patch by Janusz Tomczak, slighty modified by me (Issue #0028561).

git-svn-id: trunk@49850 -
This commit is contained in:
bart 2015-09-19 14:01:40 +00:00
parent e8704af162
commit 108a741bb8
2 changed files with 24 additions and 8 deletions

View File

@ -39,8 +39,6 @@ const
type
{ TEbEdit }
TEbEdit = class(TCustomMaskedit)
@ -873,11 +871,14 @@ type
IsEmptyTime: Boolean;
FDefaultNow: Boolean;
FDroppedDown: Boolean;
FSimpleLayout: Boolean;
FOnAcceptTime: TAcceptTimeEvent;
FOnCustomTime: TCustomTimeEvent;
function GetTime: TDateTime;
procedure SetTime(AValue: TDateTime);
procedure SetEmptyTime;
function GetLayout: Boolean;
procedure SetLayout(AValue: Boolean);
procedure TimePopupReturnTime(Sender: TObject; const ATime: TDateTime);
procedure TimePopupShowHide(Sender: TObject);
procedure OpenTimePopup;
@ -949,6 +950,7 @@ type
property ParentShowHint;
property PopupMenu;
property ShowHint;
property SimpleLayout: Boolean read GetLayout write SetLayout default True;
property TabStop;
property TabOrder;
property Visible;
@ -2947,6 +2949,16 @@ begin
end;
end;
function TTimeEdit.GetLayout: Boolean;
begin
Result := FSimpleLayout;
end;
procedure TTimeEdit.SetLayout(AValue: Boolean);
begin
FSimpleLayout := AValue;
end;
procedure TTimeEdit.SetTime(AValue: TDateTime);
var
Output: String;
@ -2997,7 +3009,7 @@ begin
ATime := GetTime;
if ATime = NullDate then
ATime := SysUtils.Time;
ShowTimePopup(PopupOrigin, ATime, Self.DoubleBuffered, @TimePopupReturnTime, @TimePopupShowHide);
ShowTimePopup(PopupOrigin, ATime, Self.DoubleBuffered, @TimePopupReturnTime, @TimePopupShowHide, FSimpleLayout);
end;
function TTimeEdit.TryParseInput(AInput: String; out ParseResult: TDateTime): Boolean;
@ -3043,18 +3055,17 @@ begin
OpenTimePopup;
end;
procedure TTimeEdit.EditEditingDone;
begin
ParseInput;
inherited EditEditingDone;
end;
constructor TTimeEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
SetEmptyTime;
FSimpleLayout := True;
end;
{ TCalcEdit }

View File

@ -36,7 +36,6 @@ type
procedure GridsDblClick(Sender: TObject);
procedure GridsKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure MoreLessBtnClick(Sender: TObject);
procedure SetLayout(SimpleLayout: Boolean);
private
FClosed: Boolean;
FOnReturnTime: TReturnTimeEvent;
@ -46,6 +45,7 @@ type
function GetTime: TDateTime;
procedure Initialize(const PopupOrigin: TPoint; ATime: TDateTime);
procedure ReturnTime;
procedure SetLayout(SimpleLayout: Boolean);
procedure SetTime(ATime: TDateTime);
published
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
@ -54,14 +54,14 @@ type
end;
procedure ShowTimePopup(const Position: TPoint; ATime: TDateTime; const DoubleBufferedForm: Boolean;
const OnReturnTime: TReturnTimeEvent; const OnShowHide: TNotifyEvent = nil);
const OnReturnTime: TReturnTimeEvent; const OnShowHide: TNotifyEvent = nil; SimpleLayout: Boolean = True);
implementation
{$R *.lfm}
procedure ShowTimePopup(const Position: TPoint; ATime: TDateTime; const DoubleBufferedForm: Boolean; const OnReturnTime: TReturnTimeEvent;
const OnShowHide: TNotifyEvent);
const OnShowHide: TNotifyEvent; SimpleLayout: Boolean);
var
NewForm: TTimePopupForm;
begin
@ -72,6 +72,9 @@ begin
NewForm.OnHide := OnShowHide;
if DoubleBufferedForm then
NewForm.ActivateDoubleBuffered;
NewForm.SetLayout(SimpleLayout);
if not SimpleLayout then
NewForm.SetTime(ATime); //update the row and col in the grid;
NewForm.Show;
end;
@ -178,6 +181,7 @@ begin
try
if SimpleLayout then
begin
MoreLessBtn.Caption := '>>';
MinutesGrid.RowCount := 2;
MinutesGrid.ColCount := 6;
for r := 0 to MinutesGrid.RowCount - 1 do
@ -189,6 +193,7 @@ begin
end
else
begin
MoreLessBtn.Caption := '<<';
MinutesGrid.RowCount := 12;
MinutesGrid.ColCount := 5;
for r := 0 to MinutesGrid.RowCount - 1 do