tvplanit: Support printing of TVpGanttView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8460 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-07 22:20:13 +00:00
parent 1122864942
commit e435fdb67d
2 changed files with 131 additions and 72 deletions

View File

@ -260,8 +260,8 @@ type
{$ENDIF} {$ENDIF}
// Methods to be called by painter // Methods to be called by painter
function CalcVisibleCols(AWidth: Integer): Integer; function CalcVisibleCols(AWidth, AFixedColWidth, AColWidth: Integer): Integer;
function CalcVisibleRows(AHeight: Integer): Integer; function CalcVisibleRows(AHeight, AHeaderHeight, ARowHeight: Integer): Integer;
property ActiveCol: Integer read FActiveCol write SetActiveCol; property ActiveCol: Integer read FActiveCol write SetActiveCol;
property ActiveEvent: TVpEvent read FActiveEvent write SetActiveEvent; property ActiveEvent: TVpEvent read FActiveEvent write SetActiveEvent;
@ -542,39 +542,53 @@ end;
procedure TVpGanttView.CalcColHeaderHeight; procedure TVpGanttView.CalcColHeaderHeight;
var var
s: String; s: String;
h: Integer;
begin begin
FMonthColHeaderHeight := GetCanvasTextHeight(Canvas, FColHeaderAttributes.MonthFont) + 2 * FTextMargin; h := GetCanvasTextHeight(Canvas, FColHeaderAttributes.MonthFont);
FMonthColHeaderHeight := h + 2 * FTextMargin;
// A typical date string to measure the text height (line breaks in DayFormat allowed) // A typical date string to measure the text height (line breaks in DayFormat allowed)
s := FormatDateTime(DayFormat, EncodeDate(2000, 12, 28)); s := FormatDateTime(DayFormat, EncodeDate(2000, 12, 28));
FDayColHeaderHeight := GetCanvasTextHeight(Canvas, FColHeaderAttributes.DayFont, s) + FTextMargin; h := GetCanvasTextHeight(Canvas, FColHeaderAttributes.DayFont, s);
FDayColHeaderHeight := h + FTextMargin;
FTotalColHeaderHeight := FMonthColHeaderHeight + FDayColHeaderHeight; FTotalColHeaderHeight := FMonthColHeaderHeight + FDayColHeaderHeight;
end; end;
procedure TVpGanttView.CalcRowHeight; procedure TVpGanttView.CalcRowHeight;
var
h: Integer;
begin begin
FRowHeight := GetCanvasTextHeight(Canvas, FRowHeaderAttributes.EventFont) + 2 * FTextMargin; h := GetCanvasTextHeight(Canvas, FRowHeaderAttributes.EventFont);
FRowHeight := h + 2 * FTextMargin;
end; end;
function TVpGanttView.CalcVisibleCols(AWidth: Integer): Integer; function TVpGanttView.CalcVisibleCols(AWidth, AFixedColWidth, AColWidth: Integer): Integer;
var var
d: Integer = 0; // Result of div d: Integer = 0; // Result of div
m: Integer = 0; // Result of mod m: Integer = 0; // Result of mod
begin begin
DivMod(AWidth - FixedColWidth, ColWidth, d, m); if AColWidth <> 0 then
begin
DivMod(AWidth - AFixedColWidth, AColWidth, d, m);
if (m = 0) and (d > 1) then dec(d); if (m = 0) and (d > 1) then dec(d);
Result := d; Result := d;
end else
Result := 0;
end; end;
function TVpGanttView.CalcVisibleRows(AHeight: Integer): Integer; function TVpGanttView.CalcVisibleRows(AHeight, AHeaderHeight, ARowHeight: Integer): Integer;
var var
d: Integer = 0; // Result of div d: Integer = 0; // Result of div
m: Integer = 0; // Result of mod m: Integer = 0; // Result of mod
begin begin
DivMod(AHeight - TotalColHeaderHeight, FRowHeight, d, m); if ARowHeight <> 0 then
begin
DivMod(AHeight - AHeaderHeight, ARowHeight, d, m);
if (m = 0) and (d > 1) then dec(d); if (m = 0) and (d > 1) then dec(d);
Result := d; Result := d;
end else
Result := 0;
end; end;
procedure TVpGanttView.CreateParams(var AParams: TCreateParams); procedure TVpGanttView.CreateParams(var AParams: TCreateParams);
@ -736,12 +750,12 @@ begin
if (FRowHeight > 0) and (Length(FEventRecords) > 0) then if (FRowHeight > 0) and (Length(FEventRecords) > 0) then
begin begin
VisibleRows := CalcVisibleRows(ClientHeight); VisibleRows := CalcVisibleRows(ClientHeight, FTotalColHeaderHeight, FRowHeight);
emptyRows := VisibleRows - (Length(FEventRecords) - FTopRow); emptyRows := VisibleRows - (Length(FEventRecords) - FTopRow);
if emptyRows > 0 then if emptyRows > 0 then
ScrollVertical(-emptyRows); ScrollVertical(-emptyRows);
VisibleCols := CalcVisibleCols(ClientWidth); VisibleCols := CalcVisibleCols(ClientWidth, FFixedColWidth, FColWidth);
emptyCols := VisibleCols - (Length(FDayRecords) - FLeftCol); emptyCols := VisibleCols - (Length(FDayRecords) - FLeftCol);
if emptyCols > 0 then if emptyCols > 0 then
ScrollHorizontal(-emptyCols); ScrollHorizontal(-emptyCols);

View File

@ -17,6 +17,12 @@ type
FMonthFont: TFont; FMonthFont: TFont;
FEventFont: TFont; FEventFont: TFont;
FScaledColWidth: Integer;
FScaledFixedColWidth: Integer;
FScaledTextMargin: Integer;
FScaledTotalColHeaderHeight: Integer;
FScaledRowHeight: Integer;
BevelHighlight: TColor; BevelHighlight: TColor;
BevelShadow: TColor; BevelShadow: TColor;
BevelDarkShadow: TColor; BevelDarkShadow: TColor;
@ -26,6 +32,8 @@ type
RealLineColor: TColor; RealLineColor: TColor;
RealRowHeadAttrColor: TColor; RealRowHeadAttrColor: TColor;
function ScaleRect(ARect: TRect): TRect;
protected protected
procedure Clear; procedure Clear;
procedure DrawActiveDate; procedure DrawActiveDate;
@ -86,8 +94,8 @@ begin
dayRec := DayRecords[ActiveCol]; dayRec := DayRecords[ActiveCol];
eventRec := EventRecords[ActiveRow]; eventRec := EventRecords[ActiveRow];
dx := LeftCol * ColWidth; dx := LeftCol * FScaledColWidth;
dy := TopRow * RowHeight; dy := TopRow * FScaledRowHeight;
end; end;
R := Rect( R := Rect(
@ -95,7 +103,7 @@ begin
); );
OffsetRect(R, -dx, -dy); OffsetRect(R, -dx, -dy);
if R.Top < FGanttView.TotalColHeaderHeight then if R.Top < FScaledTotalColHeaderHeight then
exit; exit;
pw := RenderCanvas.Pen.Width; pw := RenderCanvas.Pen.Width;
@ -141,21 +149,21 @@ begin
RenderCanvas.Brush.Color := RealColHeadAttrColor; RenderCanvas.Brush.Color := RealColHeadAttrColor;
RenderCanvas.Pen.Color := RealLineColor; RenderCanvas.Pen.Color := RealLineColor;
R := Rect(RealLeft, RealTop, RealRight, FGanttView.TotalColHeaderHeight); R := Rect(RealLeft, RealTop, RealRight, RealTop + FScaledTotalColHeaderHeight);
TPSFillRect(RenderCanvas, Angle, RenderIn, R); TPSFillRect(RenderCanvas, Angle, RenderIn, R);
if FGanttView.DrawingStyle = ds3D then if FGanttView.DrawingStyle = ds3D then
begin begin
R1 := R; R1 := R;
InflateRect(R1, -1, -1); InflateRect(R1, -1, -1);
R1.Right := FGanttView.FixedColWidth-1; R1.Right := RealLeft + FScaledFixedColWidth - 1;
DrawBevelRect( DrawBevelRect(
RenderCanvas, RenderCanvas,
TPSRotateRectangle(Angle, RenderIn, R1), TPSRotateRectangle(Angle, RenderIn, R1),
BevelHighlight, BevelHighlight,
BevelShadow BevelShadow
); );
R1.Left := FGanttView.FixedColWidth; R1.Left := RealLeft + FScaledFixedColWidth;
R1.Right := RealRight - 2; R1.Right := RealRight - 2;
DrawBevelRect( DrawBevelRect(
RenderCanvas, RenderCanvas,
@ -165,14 +173,14 @@ begin
); );
end else end else
begin begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, FGanttView.FixedColWidth, R.Top); TPSMoveTo(RenderCanvas, Angle, RenderIn, RealLeft + FScaledFixedColWidth, R.Top);
TPSLineTo(RenderCanvas, Angle, RenderIn, FGanttView.FixedColWidth, R.Bottom); TPSLineTo(RenderCanvas, Angle, RenderIn, RealLeft + FScaledFixedColWidth, R.Bottom);
TPSMoveTo(RenderCanvas, Angle, RenderIn, RealLeft, R.Bottom); TPSMoveTo(RenderCanvas, Angle, RenderIn, RealLeft, R.Bottom);
TPSLineTo(RenderCanvas, Angle, RenderIn, RealRight, R.Bottom); TPSLineTo(RenderCanvas, Angle, RenderIn, RealRight, R.Bottom);
end; end;
// Offset due to scrolling // Offset due to scrolling
dx := FGanttView.LeftCol * FGanttView.ColWidth; dx := FGanttView.LeftCol * FScaledColWidth;
// Draw month rectangles and month captions // Draw month rectangles and month captions
RenderCanvas.Font.Assign(FMonthFont); RenderCanvas.Font.Assign(FMonthFont);
@ -181,11 +189,12 @@ begin
begin begin
monthRec := FGanttView.MonthRecords[i]; monthRec := FGanttView.MonthRecords[i];
R := monthRec.Rect; R := monthRec.Rect;
R := ScaleRect(R);
OffsetRect(R, -dx , 0); OffsetRect(R, -dx , 0);
// Clip at fixed col edge // Clip at fixed col edge
if R.Left < FGanttView.FixedColWidth then if R.Left < RealLeft + FScaledFixedColWidth then
R.Left := FGanttView.FixedColWidth; R.Left := RealLeft + FScaledFixedColWidth;
// Draw month box // Draw month box
if FGanttView.DrawingStyle = ds3D then if FGanttView.DrawingStyle = ds3D then
@ -209,16 +218,16 @@ begin
// Paint month name. Use short format if space is too small for long format. // Paint month name. Use short format if space is too small for long format.
str := FormatDateTime(FGanttView.MonthFormat, monthRec.Date); str := FormatDateTime(FGanttView.MonthFormat, monthRec.Date);
strLen := RenderCanvas.TextWidth(str); strLen := RenderCanvas.TextWidth(str);
if strLen > R.Width - 2 * FGanttView.TextMargin then if strLen > R.Width - 2 * FScaledTextMargin then
begin begin
str := FormatDateTime(FGanttView.MonthFormat_short, monthRec.Date); str := FormatDateTime(FGanttView.MonthFormat_short, monthRec.Date);
strLen := RenderCanvas.TextWidth(str); strLen := RenderCanvas.TextWidth(str);
end; end;
if strLen > R.Width - 2 * FGanttView.TextMargin then if strLen > R.Width - 2 * FScaledTextMargin then
str := ''; str := '';
if str <> '' then if str <> '' then
begin begin
P := Point((R.Left + R.Right - strLen) div 2, R.Top + FGanttView.TextMargin); P := Point((R.Left + R.Right - strLen) div 2, R.Top + FScaledTextMargin);
TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, str); TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, str);
end; end;
end; end;
@ -230,9 +239,9 @@ begin
for i := 0 to n - 1 do for i := 0 to n - 1 do
begin begin
dayRec := FGanttView.DayRecords[i]; dayRec := FGanttView.DayRecords[i];
R := dayRec.Rect; R := ScaleRect(dayRec.Rect);
OffsetRect(R, -dx, 0); OffsetRect(R, -dx, 0);
if R.Left < FGanttView.FixedColWidth then if R.Left < RealLeft + FScaledFixedColWidth then
Continue; Continue;
// In sdmHeader SpecialDayMode we must repaint the background of the // In sdmHeader SpecialDayMode we must repaint the background of the
@ -301,9 +310,14 @@ var
dx, dy: Integer; dx, dy: Integer;
top_margin, bottom_margin: Integer; top_margin, bottom_margin: Integer;
begin begin
dx := FGanttView.LeftCol * FGanttView.ColWidth; dx := FGanttView.LeftCol * FScaledColWidth;
dy := FGanttView.TopRow * FGanttView.RowHeight; dy := FGanttView.TopRow * FScaledRowHeight;
if DisplayOnly then
begin
top_margin := round(2*scale);
bottom_margin := top_margin;
end else
if FGanttView.DrawingStyle = ds3D then if FGanttView.DrawingStyle = ds3D then
begin begin
top_margin := 1; top_margin := 1;
@ -313,23 +327,25 @@ begin
top_margin := 2; top_margin := 2;
bottom_margin := 1; bottom_margin := 1;
end; end;
RenderCanvas.Font.Assign(FEventFont); RenderCanvas.Font.Assign(FEventFont);
for i := 0 to FGanttView.NumEvents-1 do for i := 0 to FGanttView.NumEvents-1 do
begin begin
eventRec := FGanttView.EventRecords[i]; eventRec := FGanttView.EventRecords[i];
event := eventRec.Event; event := eventRec.Event;
R := eventRec.EventRect; R := ScaleRect(eventRec.EventRect);
OffsetRect(R, -dx, -dy); OffsetRect(R, -dx, -dy);
inc(R.Top, top_margin); inc(R.Top, top_margin);
dec(R.Bottom, bottom_margin); dec(R.Bottom, bottom_margin);
if R.Top < FGanttView.TotalColHeaderHeight then if R.Top < FScaledTotalColHeaderHeight then
Continue; Continue;
if R.Right < FGanttView.FixedColWidth then if R.Right < FScaledFixedColWidth then
Continue; Continue;
if R.Left < FGanttView.FixedColWidth then if R.Left < FScaledFixedColWidth then
R.Left := FGanttView.FixedColWidth; R.Left := FScaledFixedColWidth;
cat := FGanttView.DataStore.CategoryColorMap.GetCategory(event.Category); cat := FGanttView.DataStore.CategoryColorMap.GetCategory(event.Category);
RenderCanvas.Pen.Color := cat.Color; RenderCanvas.Pen.Color := cat.Color;
RenderCanvas.Pen.Width := round(Scale);
RenderCanvas.Brush.Color := cat.BackgroundColor; RenderCanvas.Brush.Color := cat.BackgroundColor;
TPSRectangle(RenderCanvas, Angle, RenderIn, R); TPSRectangle(RenderCanvas, Angle, RenderIn, R);
end; end;
@ -343,24 +359,27 @@ var
eventRec: TVpGanttEventRec; eventRec: TVpGanttEventRec;
dayRec: TVpGanttDayRec; dayRec: TVpGanttDayRec;
monthRec: TVpGanttMonthRec; monthRec: TVpGanttMonthRec;
R: TRect;
begin begin
RenderCanvas.Pen.Color := RealLineColor; RenderCanvas.Pen.Color := RealLineColor;
dx := FGanttView.LeftCol * FGanttView.ColWidth; dx := FGanttView.LeftCol * FScaledColWidth;
dy := FGanttView.TopRow * FGanttView.RowHeight; dy := FGanttView.TopRow * FScaledRowHeight;
// Horizontal line terminating the col header block // Horizontal line terminating the col header block
x1 := RealLeft + FGanttView.FixedColWidth; x1 := RealLeft + FScaledFixedColWidth;
n := FGanttView.NumMonths; n := FGanttView.NumMonths;
if n > 0 then if n > 0 then
begin begin
monthRec := FGanttView.MonthRecords[n-1]; monthRec := FGanttView.MonthRecords[n-1];
x2 := monthRec.Rect.Right - dx; R := ScaleRect(monthRec.Rect);
x2 := R.Right - dx;
end else end else
x2 := RealRight; x2 := RealRight;
y0 := FGanttView.TotalColHeaderHeight; y0 := RealTop + FScaledTotalColHeaderHeight;
if FGanttView.DrawingStyle = ds3D then dec(y0); if FGanttView.DrawingStyle = ds3D then dec(y0);
RenderCanvas.Line(x1, y0, x2, y0); TPSMoveTo(RenderCanvas, Angle, RenderIn, x1, y0);
TPSLineTo(RenderCanvas, Angle, RenderIn, x2, y0);
// Horizontal lines // Horizontal lines
if (gvoHorizGrid in FGanttView.Options) then if (gvoHorizGrid in FGanttView.Options) then
@ -371,30 +390,38 @@ begin
for i := 0 to numEvents - 1 do for i := 0 to numEvents - 1 do
begin begin
eventRec := FGanttView.EventRecords[i]; eventRec := FGanttView.EventRecords[i];
y1 := y0 + eventRec.EventRect.Bottom; R := ScaleRect(eventRec.EventRect);
if y1 >= FGanttView.TotalColHeaderHeight then y1 := y0 + R.Bottom;
RenderCanvas.Line(x1, y1, x2, y1); if y1 >= FScaledTotalColHeaderHeight then
begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, x1, y1);
TPSLineTo(RenderCanvas, Angle, RenderIn, x2, y1);
end;
end; end;
end; end;
// Vertical lines // Vertical lines
if (gvoVertGrid in FGanttView.Options) then if (gvoVertGrid in FGanttView.Options) then
begin begin
y1 := RealTop + FGanttView.TotalColHeaderHeight; y1 := RealTop + FScaledTotalColHeaderHeight;
if numEvents > 0 then if numEvents > 0 then
begin begin
eventRec := FGanttView.EventRecords[numEvents-1]; eventRec := FGanttView.EventRecords[numEvents-1];
y2 := eventRec.EventRect.Bottom - dy; R := ScaleRect(eventRec.EventRect);
y2 := R.Bottom - dy;
end else end else
y2 := RealBottom; y2 := RealBottom;
n := FGanttView.NumDays; n := FGanttView.NumDays;
for i := 0 to n-1 do for i := 0 to n-1 do
begin begin
dayRec := FGanttView.DayRecords[i]; dayRec := FGanttView.DayRecords[i];
x1 := dayRec.Rect.Right - dx; R := ScaleRect(dayRec.Rect);
x2 := x1; x1 := R.Right - dx;
if x1 >= FGanttView.FixedColWidth then if x1 >= FScaledFixedColWidth then
RenderCanvas.Line(x1, y1, x2, y2); begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, x1, y1);
TPSLineTo(RenderCanvas, Angle, RenderIn, x1, y2)
end;
end; end;
end; end;
end; end;
@ -414,7 +441,7 @@ begin
if FGanttView.DrawingStyle = ds3d then begin if FGanttView.DrawingStyle = ds3d then begin
R.Left := RealLeft + 1; R.Left := RealLeft + 1;
R.Top := RealTop; R.Top := RealTop;
R.Right := RealLeft + FGanttView.FixedColWidth - 1; R.Right := RealLeft + FScaledFixedColWidth - 1;
R.Bottom := RealBottom - 1; R.Bottom := RealBottom - 1;
TPSFillRect(RenderCanvas, Angle, RenderIn, R); TPSFillRect(RenderCanvas, Angle, RenderIn, R);
DrawBevelRect( DrawBevelRect(
@ -424,10 +451,11 @@ begin
BevelShadow BevelShadow
); );
end else begin end else begin
R := Rect(RealLeft, RealTop + 1, RealLeft + FGanttView.FixedColWidth, RealBottom); R := Rect(RealLeft, RealTop + 1, RealLeft + FScaledFixedColWidth, RealBottom);
TPSFillRect(RenderCanvas, Angle, RenderIn, R); TPSFillRect(RenderCanvas, Angle, RenderIn, R);
RenderCanvas.Pen.Color := RealLineColor; RenderCanvas.Pen.Color := RealLineColor;
RenderCanvas.Line(R.Right, R.Top, R.Right, R.Bottom); TPSMoveTo(RenderCanvas, Angle, RenderIn, R.Right, R.Top);
TPSLineTo(RenderCanvas, Angle, RenderIn, R.Right, R.Bottom);
end; end;
RenderCanvas.Font.Assign(FEventFont); RenderCanvas.Font.Assign(FEventFont);
@ -435,15 +463,15 @@ begin
RenderCanvas.Pen.Color := RealLineColor; RenderCanvas.Pen.Color := RealLineColor;
// Offset due to scrolling // Offset due to scrolling
dy := FGanttView.TopRow * FGanttView.RowHeight; dy := FGanttView.TopRow * FScaledRowHeight;
for i := 0 to FGanttView.NumEvents-1 do for i := 0 to FGanttView.NumEvents-1 do
begin begin
eventRec := FGanttView.EventRecords[i]; eventRec := FGanttView.EventRecords[i];
str := eventRec.Caption; str := eventRec.Caption;
R := eventRec.HeadRect; R := ScaleRect(eventRec.HeadRect);
OffsetRect(R, 0, -dy); OffsetRect(R, 0, -dy);
if R.Top < FGanttView.TotalColHeaderHeight then if R.Top < FScaledTotalColHeaderHeight then
Continue; Continue;
if FGanttView.DrawingStyle = ds3D then if FGanttView.DrawingStyle = ds3D then
begin begin
@ -456,11 +484,12 @@ begin
); );
end else end else
begin begin
RenderCanvas.Line(R.Left, R.Bottom, R.Right, R.Bottom); TPSMoveTo(RenderCanvas, Angle, RenderIn, R.Left, R.Bottom);
TPSLineTo(RenderCanvas, Angle, RenderIn, R.Right, R.Bottom);
end; end;
// Paint event description as header // Paint event description as header
inc(R.Left, FGanttView.TextMargin + 2); inc(R.Left, FScaledTextMargin + 2);
P := Point(R.Left, (R.Top + R.Bottom - strH) div 2); P := Point(R.Left, (R.Top + R.Bottom - strH) div 2);
TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str); TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str);
end; end;
@ -474,6 +503,7 @@ var
clr: TColor; clr: TColor;
dayRec: TVpGanttDayRec; dayRec: TVpGanttDayRec;
holiday: String; holiday: String;
R: TRect;
begin begin
with FGanttView do with FGanttView do
begin begin
@ -482,11 +512,12 @@ begin
nEvents := NumEvents; nEvents := NumEvents;
nDays := NumDays; nDays := NumDays;
dx := LeftCol * ColWidth; dx := LeftCol * FScaledColWidth;
dy := TopRow * RowHeight; dy := TopRow * FScaledRowHeight;
y1 := TotalColHeaderHeight; R := ScaleRect(EventRecords[nEvents-1].HeadRect);
y2 := EventRecords[nEvents-1].HeadRect.Bottom - dy; y1 := RealTop + FScaledTotalColHeaderHeight;
y2 := R.Bottom - dy;
RenderCanvas.Brush.style := bsSolid; RenderCanvas.Brush.style := bsSolid;
for i := 0 to nDays-1 do for i := 0 to nDays-1 do
@ -501,8 +532,9 @@ begin
if clr <> clNone then if clr <> clNone then
begin begin
RenderCanvas.Brush.Color := clr; RenderCanvas.Brush.Color := clr;
x1 := dayRec.Rect.Left - dx; R := ScaleRect(dayRec.Rect);
x2 := dayRec.Rect.Right - dx; x1 := R.Left - dx;
x2 := R.Right - dx;
RenderCanvas.FillRect(x1, y1, x2, y2); RenderCanvas.FillRect(x1, y1, x2, y2);
end; end;
end; end;
@ -595,17 +627,30 @@ begin
{ Restore canvas settings} { Restore canvas settings}
RestorePenBrush; RestorePenBrush;
end;
//RenderCanvas.Textout(0, 0, FormatDateTime('c', ARenderDate)); function TVpGanttViewPainter.ScaleRect(ARect: TRect): TRect;
//RenderCanvas.TextOut(0, 20, FormatDateTime('c', FGanttView.Date)); begin
Result.Left := RealLeft + round(ARect.Left * Scale);
Result.Top := RealTop + round(ARect.Top * Scale);
Result.Right := RealLeft + round(ARect.Right * Scale);
Result.Bottom := RealTop + round(ARect.Bottom * Scale);
end; end;
procedure TVpGanttViewPainter.SetMeasurements; procedure TVpGanttViewPainter.SetMeasurements;
begin begin
inherited; inherited;
FGanttView.Init; FGanttView.Init;
FGanttView.VisibleCols := FGanttView.CalcVisibleCols(RealRight - RealLeft);
FGanttView.VisibleRows := FGanttView.CalcVisibleRows(RealBottom - RealTop); FScaledFixedColWidth := round(FGanttView.FixedColWidth * Scale);
FScaledColWidth := round(FGanttView.ColWidth * Scale);
FScaledTextMargin := round(FGanttView.TextMargin * Scale);
FScaledTotalColHeaderHeight := round(FGanttView.TotalColHeaderHeight * Scale);
FScaledRowHeight := round(FGanttView.RowHeight * Scale);
FGanttView.VisibleCols := FGanttView.CalcVisibleCols(RealRight - RealLeft, FScaledFixedColWidth, FScaledColWidth);
FGanttView.VisibleRows := FGanttView.CalcVisibleRows(RealBottom - RealTop, FScaledTotalColHeaderHeight, FScaledRowHeight);
end; end;
end. end.