tvplanit/TVpGanttView: Highlight weekends.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8427 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-29 22:00:20 +00:00
parent 3de78ed971
commit 9af978b9fb
3 changed files with 71 additions and 2 deletions

View File

@ -31,6 +31,7 @@ type
procedure DrawActiveDate;
procedure DrawBorders;
procedure DrawColHeader;
procedure DrawDays;
procedure DrawEvents;
procedure DrawGrid;
procedure DrawRowHeader;
@ -282,6 +283,56 @@ begin
end;
end;
procedure TVpGanttViewPainter.DrawDays;
var
i, j1, j2, nDays, nEvents: Integer;
x1, y1, x2, y2: Integer;
dx, dy: Integer;
begin
with FGanttView do
begin
if StartDate = NO_DATE then
exit;
nEvents := NumEvents;
nDays := NumDays;
dx := LeftCol * ColWidth;
dy := TopRow * RowHeight;
y1 := TotalColHeaderHeight;
y2 := EventRecords[nEvents-1].HeadRect.Bottom - dy;
for i := 0 to nDays-1 do
if IsWeekend(DayRecords[i].Date) then
begin
j1 := i;
break;
end;
end;
if y2 > RealBottom then
y2 := RealBottom;
RenderCanvas.Brush.Color := FGanttView.WeekendColor;
RenderCanvas.Brush.Style := bsSolid;
while j1 < nDays do
begin
if j1 < nDays-1 then
j2 := j1 + 1
else
j2 := j1;
x2 := FGanttView.DayRecords[j2].Rect.Right - dx;
if x2 >= FGanttView.FixedColWidth then
begin
x1 := FGanttView.DayRecords[j1].Rect.Left - dx;
if x1 < FGanttView.FixedColWidth then
x1 := FGanttView.FixedColWidth;
RenderCanvas.FillRect(x1, y1, x2, y2);
end;
inc(j1, 7);
end;
end;
procedure TVpGanttViewPainter.DrawEvents;
var
i: Integer;
@ -315,8 +366,10 @@ begin
dec(R.Bottom, bottom_margin);
if R.Top < FGanttView.TotalColHeaderHeight then
Continue;
if R.Left < FGanttView.FixedColWidth then
if R.Right < FGanttView.FixedColWidth then
Continue;
if R.Left < FGanttView.FixedColWidth then
R.Left := FGanttView.FixedColWidth;
cat := FGanttView.DataStore.CategoryColorMap.GetCategory(event.Category);
RenderCanvas.Pen.Color := cat.Color;
RenderCanvas.Brush.Color := cat.BackgroundColor;
@ -508,6 +561,9 @@ begin
DrawRowHeader;
DrawColHeader;
{ Draw weekends }
DrawDays;
{ Draw grid }
DrawGrid;