tvplanit: Fix week painting artefacts due to scrolling. Fix truncation error of all-day events at limits of date range.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8502 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-24 10:50:26 +00:00
parent 31a2f25a42
commit a02d733cec
2 changed files with 27 additions and 9 deletions

View File

@@ -1370,17 +1370,25 @@ begin
begin
event := TVpEvent(list[i]);
// The time range of events reaching out of the displayed date range
// must be clipped at the edges.
t1 := IfThen(event.StartTime >= FRealStartDate, event.StartTime, FRealStartDate);
t2 := IfThen(event.EndTime <= FRealEndDate + 1, event.EndTime, FRealEndDate + 1);
// Get start and end time of the event. Handle all-day-events correctly.
if event.AllDayEvent then
begin
t1 := DatePart(t1);
t2 := DatePart(t2) + 1;
if TimePart(t2) = 0 then t2 := t2 + 1;
t1 := DatePart(event.StartTime);
t2 := DatePart(event.EndTime) + 1;
if frac(event.EndTime) = 0 then t2 := t2 + 1;
end else
begin
t1 := event.StartTime;
t2 := event.EndTime;
end;
// The time range of events reaching out of the displayed date range
// must be clipped at the edges.
if t1 < FRealStartDate then
t1 := FRealStartDate;
if t2 > FRealEndDate + 1 then
t2 := FRealEndDate + 1;
// Store event, caption and its rectangle coordinates in the EventRec
y2 := y1 + FRowHeight;
xe1 := round((t1 - FRealStartDate) / numDays * totalWidth) + FixedColWidth;
@@ -1390,8 +1398,12 @@ begin
FEventRecords[i].Caption := event.Description;
FEventRecords[i].HeadRect := Rect(xh1, y1, xh2, y2);
FEventRecords[i].EventRect := Rect(xe1, y1, xe2, y2);
// Find the active row. This is the row with the active event.
if event = FActiveEvent then
FActiveRow := i;
// Prepare for next row
y1 := y2;
end;