tvplanit: Initial attempt for scrolling in TVpGanttView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8419 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-27 10:31:14 +00:00
parent 3cc502f29d
commit 4fa25ff2d3
2 changed files with 287 additions and 10 deletions

View File

@ -78,7 +78,8 @@ var
dt: TDateTime;
begin
if ADate1 > ADate2 then
raise Exception.Create('[TVpGanttViewPainter.CountMonts] Dates not in order.');
exit;
// raise Exception.Create('[TVpGanttViewPainter.CountMonts] Dates not in order.');
Result := 0;
dt := ADate1;
@ -135,6 +136,7 @@ var
dayRec: TVpGanttDayRec;
str: String;
strLen, strH: Integer;
dx: Integer;
begin
RenderCanvas.Brush.Color := RealColHeadAttrColor;
RenderCanvas.Pen.Color := RealLineColor;
@ -169,12 +171,16 @@ begin
TPSLineTo(RenderCanvas, Angle, RenderIn, RealRight, R.Bottom);
end;
dx := FGanttView.FixedColWidth - FGanttView.LeftCol * FGanttView.ColWidth;
// Draw month rectangles and month captions
for i := 0 to High(TVpGanttViewOpener(FGanttView).FMonthRecords) do
begin
monthRec := TVpGanttViewOpener(FGanttView).FMonthRecords[i];
R := monthRec.Rect;
OffsetRect(R, FGanttView.FixedColWidth, 0);
OffsetRect(R, dx , 0);
if R.Left < FGanttView.FixedColWidth then
R.Left := FGanttView.FixedColWidth;
if FGanttView.DrawingStyle = ds3D then
begin
R1 := R;
@ -215,7 +221,9 @@ begin
for dayRec in TVpGanttViewOpener(FGanttView).FDayRecords do
begin
R := dayRec.Rect;
OffsetRect(R, FGanttView.FixedColWidth, 0);
OffsetRect(R, dx, 0);
if R.Left < FGanttView.FixedColWidth then
Continue;
if (DayOf(dayRec.Date) <> DaysInMonth(dayRec.Date)) then
begin
if FGanttView.DrawingStyle = ds3D then
@ -246,7 +254,10 @@ var
event: TVpEvent;
cat: TVpCategoryInfo;
R: TRect;
dx, dy: Integer;
begin
dx := FGanttView.FixedColWidth - FGanttView.LeftCol * FGanttView.ColWidth;
dy := FColHeadHeightTotal - FGanttView.TopRow * FRowHeight;
for i := 0 to High(TVpGanttViewOpener(FGanttView).FEventRecords) do
begin
eventRec := TVpGanttViewOpener(FGanttView).FEventRecords[i];
@ -256,8 +267,10 @@ begin
RenderCanvas.Brush.Color := cat.BackgroundColor;
R := eventRec.EventRect;
if R.Left = R.Right then R.Right := R.Left + 1;
OffsetRect(R, FGanttView.FixedColWidth, FColHeadHeightTotal);
OffsetRect(R, dx, dy);
InflateRect(R, 0, -2);
if (R.Top < FColHeadHeightTotal) or (R.Left < FGanttView.FixedColWidth) then
Continue;
TPSRectangle(RenderCanvas, Angle, RenderIn, R);
end;
end;
@ -322,6 +335,7 @@ var
strH: Integer;
str: String;
i: Integer;
dy: Integer;
begin
RenderCanvas.Brush.Color := RealRowHeadAttrColor;
@ -347,11 +361,14 @@ begin
RenderCanvas.Font.Assign(FGanttView.RowHeaderAttributes.EventFont);
strH := RenderCanvas.TextHeight('Tg');
RenderCanvas.Pen.Color := RealLineColor;
dy := FColHeadHeightTotal - FGanttView.TopRow * FRowHeight;
for i := 0 to High(TVpGanttViewOpener(FGanttView).FEventRecords) do
begin
str := TVpGanttViewOpener(FGanttView).FEventRecords[i].Caption;
R := TVpGanttViewOpener(FGanttView).FEventRecords[i].HeadRect;
OffsetRect(R, 0, FColHeadHeightTotal);
OffsetRect(R, 0, dy);
if R.Top < FColHeadHeightTotal then
Continue;
if FGanttView.DrawingStyle = ds3D then
begin
R.BottomRight := R.BottomRight - Point(1, 1);
@ -490,6 +507,8 @@ begin
SetLength(TVpGanttViewOpener(FGanttView).FEventRecords, 0);
SetLength(TVpGanttViewOpener(FGanttView).FDayRecords, 0);
SetLength(TVpGanttViewOpener(FGanttView).FMonthRecords, 0);
FGanttView.VisibleRows := 0;
FGanttView.VisibleCols := 0;
end else
begin
eventCount := FGanttView.Datastore.Resource.Schedule.EventCount;
@ -516,6 +535,7 @@ begin
lastDay := trunc(t2);
end;
lastDay := lastDay + 1;
FGanttView.StartDate := firstDay;
FGanttView.EndDate := lastDay;
@ -597,6 +617,11 @@ begin
dt := IncMonth(dt, 1);
x1 := x2;
end;
FGanttView.VisibleCols := (RealRight - RealLeft + FGanttView.FixedColWidth) div FGanttView.ColWidth;
FGanttView.VisibleRows := (RealBottom - RealTop + FColHeadHeightTotal) div FRowHeight;
FGanttView.RowCount := eventCount;
FGanttView.ColCount := numdays;
end;
end;