LCL: TimePopupForm: keep the form in view when switchin to non-simple layout.

git-svn-id: trunk@49851 -
This commit is contained in:
bart 2015-09-19 14:22:00 +00:00
parent 108a741bb8
commit 78c3da20fa

View File

@ -40,10 +40,12 @@ type
FClosed: Boolean;
FOnReturnTime: TReturnTimeEvent;
FSimpleLayout: Boolean;
FPopupOrigin: TPoint;
procedure ActivateDoubleBuffered;
procedure CalcGridHeights;
function GetTime: TDateTime;
procedure Initialize(const PopupOrigin: TPoint; ATime: TDateTime);
procedure KeepInView(const PopupOrigin: TPoint);
procedure ReturnTime;
procedure SetLayout(SimpleLayout: Boolean);
procedure SetTime(ATime: TDateTime);
@ -76,6 +78,7 @@ begin
if not SimpleLayout then
NewForm.SetTime(ATime); //update the row and col in the grid;
NewForm.Show;
NewForm.KeepInView(Position);
end;
procedure TTimePopupForm.SetTime(ATime: TDateTime);
@ -205,6 +208,7 @@ begin
end;
CalcGridHeights;
FSimpleLayout := SimpleLayout;
KeepInView(FPopupOrigin);
finally
MinutesGrid.EndUpdate(True);
end;
@ -245,6 +249,13 @@ begin
end;
procedure TTimePopupForm.Initialize(const PopupOrigin: TPoint; ATime: TDateTime);
begin
FPopupOrigin := PopupOrigin;
KeepInView(PopupOrigin);
SetTime(ATime);
end;
procedure TTimePopupForm.KeepInView(const PopupOrigin: TPoint);
var
ABounds: TRect;
begin
@ -257,7 +268,8 @@ begin
Top := ABounds.Bottom - Height
else
Top := PopupOrigin.Y;
SetTime(ATime);
//store the fitting point, so the form won't move if it layout is changed back to simple
FPopupOrigin := Point(Left, Top);
end;
procedure TTimePopupForm.ReturnTime;