tvplanit/TvpGanttView: Operational popup menu. Highlight active date. Sort events by time.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8424 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-29 15:09:38 +00:00
parent 6fdf379467
commit ab7800349c
4 changed files with 210 additions and 113 deletions

View File

@ -28,6 +28,7 @@ type
protected
procedure Clear;
procedure DrawActiveDay;
procedure DrawBorders;
procedure DrawColHeader;
procedure DrawEvents;
@ -52,9 +53,6 @@ uses
DateUtils,
VpConst, VpMisc, VpCanvasUtils, VpData;
type
TVpGanttViewOpener = class(TVpGanttView);
constructor TVpGanttViewPainter.Create(AGanttView: TVpGanttView;
ARenderCanvas: TCanvas);
begin
@ -68,6 +66,44 @@ begin
RenderCanvas.FillRect(RenderIn);
end;
procedure TVpGanttViewPainter.DrawActiveDay;
var
R: TRect;
dayRec: TVpGanttDayRec;
eventRec: TVpGanttEventRec;
dx, dy: Integer;
bs: TBrushStyle;
pw: Integer;
begin
with FGanttView do
begin
if (ActiveRow < 0) or (ActiveRow >= RowCount) then
exit;
if (ActiveCol < 0) or (ActiveCol >= ColCount) then
exit;
dayRec := DayRecords[ActiveCol];
eventRec := EventRecords[ActiveRow];
dx := LeftCol * ColWidth;
dy := TopRow * RowHeight;
end;
R := Rect(
dayRec.Rect.Left, eventRec.EventRect.Top, dayRec.Rect.Right, eventRec.EventRect.Bottom
);
OffsetRect(R, -dx, -dy);
pw := RenderCanvas.Pen.Width;
bs := RenderCanvas.Brush.Style;
RenderCanvas.Pen.Width := 3;
RenderCanvas.Pen.Color := clBlack;
RenderCanvas.Brush.Style := bsClear;
TPSRectangle(RenderCanvas, Angle, RenderIn, R);
RenderCanvas.Pen.Width := pw;
RenderCanvas.Brush.Style := bs;
end;
procedure TVpGanttViewPainter.DrawBorders;
var
R: TRect;
@ -248,10 +284,20 @@ var
cat: TVpCategoryInfo;
R: TRect;
dx, dy: Integer;
top_margin, bottom_margin: Integer;
begin
dx := FGanttView.LeftCol * FGanttView.ColWidth;
dy := FGanttView.TopRow * FGanttView.RowHeight;
if FGanttView.DrawingStyle = ds3D then
begin
top_margin := 1;
bottom_margin := 2;
end else
begin
top_margin := 2;
bottom_margin := 1;
end;
RenderCanvas.Font.Assign(FEventFont);
for i := 0 to FGanttView.NumEvents-1 do
begin
@ -259,8 +305,8 @@ begin
event := eventRec.Event;
R := eventRec.EventRect;
OffsetRect(R, -dx, -dy);
inc(R.Top, 2);
dec(R.Bottom, 1); // 1 less than top due to grid linewidth.
inc(R.Top, top_margin);
dec(R.Bottom, bottom_margin);
if R.Top < FGanttView.TotalColHeaderHeight then
Continue;
if R.Left < FGanttView.FixedColWidth then
@ -297,8 +343,9 @@ begin
if FGanttView.DrawingStyle = ds3D then dec(y0);
RenderCanvas.Line(x1, y0, x2, y0);
numEvents := FGanttView.NumEvents;
y0 := 0;
if FGanttView.DrawingStyle = ds3D then dec(y0);
numEvents := FGanttView.NumEvents;
for i := 0 to numEvents - 1 do
begin
eventRec := FGanttView.EventRecords[i];
@ -459,6 +506,9 @@ begin
{ draw events }
DrawEvents;
{ Draw active day rectangle }
DrawActiveDay;
{ Draw the borders }
DrawBorders;