diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 76fba05d4..9d0200873 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -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; diff --git a/components/tvplanit/source/vpganttviewpainter.pas b/components/tvplanit/source/vpganttviewpainter.pas index 7de116965..bcf1a78ce 100644 --- a/components/tvplanit/source/vpganttviewpainter.pas +++ b/components/tvplanit/source/vpganttviewpainter.pas @@ -425,6 +425,9 @@ begin R := ScaleRect(R); OffsetRect(R, -dx , 0); + if R.Right <= RealLeft + FScaledFixedColWidth then + continue; + // Clip at fixed col edge if R.Left < RealLeft + FScaledFixedColWidth then R.Left := RealLeft + FScaledFixedColWidth; @@ -433,7 +436,7 @@ begin if FGanttView.DrawingStyle = ds3D then begin R1 := R; - if i > 0 then +// if i > 0 then inc(R1.Left); dec(R1.Bottom); DrawBevelRect( @@ -616,6 +619,9 @@ begin R := ScaleRect(R); OffsetRect(R, -dx , 0); + if R.Right <= RealLeft + FScaledFixedColWidth then + Continue; + // Clip at fixed col edge if R.Left < RealLeft + FScaledFixedColWidth then R.Left := RealLeft + FScaledFixedColWidth; @@ -624,7 +630,7 @@ begin if FGanttView.DrawingStyle = ds3D then begin R1 := R; - if i > 0 then +// if i > 0 then inc(R1.Left); dec(R1.Bottom); DrawBevelLine(