You've already forked lazarus-ccr
tvplanit: Implement TVpGanttView.Options (show date, show weekends, show vertical/horizontal grid).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8428 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -9,6 +9,17 @@ uses
|
|||||||
Classes, SysUtils, Graphics, Types, Controls, StdCtrls, Menus,
|
Classes, SysUtils, Graphics, Types, Controls, StdCtrls, Menus,
|
||||||
VpConst, VpMisc, VpBase, VpBaseDS, VpData;
|
VpConst, VpMisc, VpBase, VpBaseDS, VpData;
|
||||||
|
|
||||||
|
type
|
||||||
|
TVpGanttViewOption = (
|
||||||
|
gvoActiveDate, gvoWeekends, gvoHorizGrid, gvoVertGrid
|
||||||
|
);
|
||||||
|
TVpGanttViewOptions = set of TVpGanttViewOption;
|
||||||
|
|
||||||
|
const
|
||||||
|
DEFAULT_GANTTVIEWOPTIONS = [
|
||||||
|
gvoActiveDate, gvoWeekends, gvoHorizGrid, gvoVertGrid
|
||||||
|
];
|
||||||
|
|
||||||
type
|
type
|
||||||
TVpGanttView = class;
|
TVpGanttView = class;
|
||||||
|
|
||||||
@ -111,7 +122,7 @@ type
|
|||||||
FDrawingStyle: TVpDrawingStyle;
|
FDrawingStyle: TVpDrawingStyle;
|
||||||
FDefaultPopup: TPopupMenu;
|
FDefaultPopup: TPopupMenu;
|
||||||
FExternalPopup: TPopupMenu;
|
FExternalPopup: TPopupMenu;
|
||||||
FShowActiveDate: Boolean;
|
FOptions: TVpGanttViewOptions;
|
||||||
|
|
||||||
FOnAddEvent: TVpOnAddNewEvent;
|
FOnAddEvent: TVpOnAddNewEvent;
|
||||||
FOnDeletingEvent: TVpOnDeletingEvent;
|
FOnDeletingEvent: TVpOnDeletingEvent;
|
||||||
@ -138,8 +149,8 @@ type
|
|||||||
procedure SetFixedColWidth(AValue: Integer);
|
procedure SetFixedColWidth(AValue: Integer);
|
||||||
procedure SetLeftCol(AValue: Integer);
|
procedure SetLeftCol(AValue: Integer);
|
||||||
procedure SetLineColor(AValue: TColor);
|
procedure SetLineColor(AValue: TColor);
|
||||||
|
procedure SetOptions(AValue: TVpGanttViewOptions);
|
||||||
procedure SetPopupMenu(AValue: TPopupMenu);
|
procedure SetPopupMenu(AValue: TPopupMenu);
|
||||||
procedure SetShowActiveDate(AValue: Boolean);
|
|
||||||
procedure SetTextMargin(AValue: Integer);
|
procedure SetTextMargin(AValue: Integer);
|
||||||
procedure SetTopRow(AValue: Integer);
|
procedure SetTopRow(AValue: Integer);
|
||||||
procedure SetWeekendColor(AValue: TColor);
|
procedure SetWeekendColor(AValue: TColor);
|
||||||
@ -256,9 +267,9 @@ type
|
|||||||
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
|
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
|
||||||
property MonthFormat: String index 1 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
property MonthFormat: String index 1 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||||
property MonthFormat_short: String index 2 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
property MonthFormat_short: String index 2 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||||
|
property Options: TVpGanttViewOptions read FOptions write SetOptions default DEFAULT_GANTTVIEWOPTIONS;
|
||||||
property PopupMenu: TPopupMenu read GetPopupMenu write SetPopupMenu;
|
property PopupMenu: TPopupMenu read GetPopupMenu write SetPopupMenu;
|
||||||
property RowHeaderAttributes: TVpGanttRowHeaderAttributes read FRowHeaderAttributes write FRowHeaderAttributes;
|
property RowHeaderAttributes: TVpGanttRowHeaderAttributes read FRowHeaderAttributes write FRowHeaderAttributes;
|
||||||
property ShowActiveDate: Boolean read FShowActiveDate write SetShowActiveDate default true;
|
|
||||||
property TextMargin: Integer read FTextMargin write SetTextMargin default 2;
|
property TextMargin: Integer read FTextMargin write SetTextMargin default 2;
|
||||||
property WeekendColor: TColor read FWeekendColor write SetWeekendColor default WEEKEND_COLOR;
|
property WeekendColor: TColor read FWeekendColor write SetWeekendColor default WEEKEND_COLOR;
|
||||||
// inherited events
|
// inherited events
|
||||||
@ -392,7 +403,6 @@ begin
|
|||||||
|
|
||||||
SetActiveDate(Now);
|
SetActiveDate(Now);
|
||||||
FStartDate := FActiveDate;
|
FStartDate := FActiveDate;
|
||||||
FShowActiveDate := true;
|
|
||||||
|
|
||||||
FColWidth := DEFAULT_COLWIDTH;
|
FColWidth := DEFAULT_COLWIDTH;
|
||||||
FFixedColWidth := 120;
|
FFixedColWidth := 120;
|
||||||
@ -411,6 +421,8 @@ begin
|
|||||||
FDrawingStyle := ds3d;
|
FDrawingStyle := ds3d;
|
||||||
FScrollBars := ssBoth;
|
FScrollBars := ssBoth;
|
||||||
|
|
||||||
|
FOptions := DEFAULT_GANTTVIEWOPTIONS;
|
||||||
|
|
||||||
// Popup menu
|
// Popup menu
|
||||||
FDefaultPopup := TPopupMenu.Create(Self);
|
FDefaultPopup := TPopupMenu.Create(Self);
|
||||||
FDefaultPopup.Name := 'default';
|
FDefaultPopup.Name := 'default';
|
||||||
@ -1311,6 +1323,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpGanttView.SetHScrollPos;
|
||||||
|
var
|
||||||
|
scrollInfo: TScrollInfo;
|
||||||
|
begin
|
||||||
|
if not HandleAllocated then
|
||||||
|
Exit;
|
||||||
|
with scrollInfo do
|
||||||
|
begin
|
||||||
|
cbSize := SizeOf(scrollInfo);
|
||||||
|
fMask := SIF_RANGE or SIF_PAGE or SIF_POS;
|
||||||
|
nMin := 0;
|
||||||
|
nMax := FColCount;
|
||||||
|
if FVisibleCols >= FColCount then
|
||||||
|
nPage := nMax
|
||||||
|
else
|
||||||
|
nPage := FVisibleCols;
|
||||||
|
if FLeftCol = pred(ColCount) - VisibleCols then
|
||||||
|
nPos := ColCount
|
||||||
|
else
|
||||||
|
nPos := FLeftCol;
|
||||||
|
nTrackPos := nPos;
|
||||||
|
end;
|
||||||
|
SetScrollInfo(Handle, SB_HORZ, scrollInfo, True);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpGanttView.SetLeftCol(AValue: Integer);
|
procedure TVpGanttView.SetLeftCol(AValue: Integer);
|
||||||
begin
|
begin
|
||||||
if AValue <> FLeftCol then begin
|
if AValue <> FLeftCol then begin
|
||||||
@ -1339,36 +1376,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpGanttView.SetHScrollPos;
|
procedure TVpGanttView.SetOptions(AValue: TVpGanttViewOptions);
|
||||||
var
|
|
||||||
scrollInfo: TScrollInfo;
|
|
||||||
begin
|
begin
|
||||||
if not HandleAllocated then
|
if FOptions <> AValue then
|
||||||
Exit;
|
|
||||||
with scrollInfo do
|
|
||||||
begin
|
begin
|
||||||
cbSize := SizeOf(scrollInfo);
|
FOptions := AValue;
|
||||||
fMask := SIF_RANGE or SIF_PAGE or SIF_POS;
|
|
||||||
nMin := 0;
|
|
||||||
nMax := FColCount;
|
|
||||||
if FVisibleCols >= FColCount then
|
|
||||||
nPage := nMax
|
|
||||||
else
|
|
||||||
nPage := FVisibleCols;
|
|
||||||
if FLeftCol = pred(ColCount) - VisibleCols then
|
|
||||||
nPos := ColCount
|
|
||||||
else
|
|
||||||
nPos := FLeftCol;
|
|
||||||
nTrackPos := nPos;
|
|
||||||
end;
|
|
||||||
SetScrollInfo(Handle, SB_HORZ, scrollInfo, True);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpGanttView.SetShowActiveDate(AValue: Boolean);
|
|
||||||
begin
|
|
||||||
if FShowActiveDate <> AValue then
|
|
||||||
begin
|
|
||||||
FShowActiveDate := AValue;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -291,8 +291,9 @@ var
|
|||||||
begin
|
begin
|
||||||
with FGanttView do
|
with FGanttView do
|
||||||
begin
|
begin
|
||||||
if StartDate = NO_DATE then
|
if (StartDate = NO_DATE) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
nEvents := NumEvents;
|
nEvents := NumEvents;
|
||||||
nDays := NumDays;
|
nDays := NumDays;
|
||||||
dx := LeftCol * ColWidth;
|
dx := LeftCol * ColWidth;
|
||||||
@ -311,25 +312,28 @@ begin
|
|||||||
if y2 > RealBottom then
|
if y2 > RealBottom then
|
||||||
y2 := RealBottom;
|
y2 := RealBottom;
|
||||||
|
|
||||||
RenderCanvas.Brush.Color := FGanttView.WeekendColor;
|
if (gvoWeekends in FGanttView.Options) then
|
||||||
RenderCanvas.Brush.Style := bsSolid;
|
|
||||||
|
|
||||||
while j1 < nDays do
|
|
||||||
begin
|
begin
|
||||||
if j1 < nDays-1 then
|
RenderCanvas.Brush.Color := FGanttView.WeekendColor;
|
||||||
j2 := j1 + 1
|
RenderCanvas.Brush.Style := bsSolid;
|
||||||
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);
|
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;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -391,7 +395,7 @@ begin
|
|||||||
dx := FGanttView.LeftCol * FGanttView.ColWidth;
|
dx := FGanttView.LeftCol * FGanttView.ColWidth;
|
||||||
dy := FGanttView.TopRow * FGanttView.RowHeight;
|
dy := FGanttView.TopRow * FGanttView.RowHeight;
|
||||||
|
|
||||||
// Horizontal lines
|
// Horizontal line terminating the col header block
|
||||||
x1 := RealLeft + FGanttView.FixedColWidth;
|
x1 := RealLeft + FGanttView.FixedColWidth;
|
||||||
n := FGanttView.NumMonths;
|
n := FGanttView.NumMonths;
|
||||||
if n > 0 then
|
if n > 0 then
|
||||||
@ -404,33 +408,40 @@ begin
|
|||||||
if FGanttView.DrawingStyle = ds3D then dec(y0);
|
if FGanttView.DrawingStyle = ds3D then dec(y0);
|
||||||
RenderCanvas.Line(x1, y0, x2, y0);
|
RenderCanvas.Line(x1, y0, x2, y0);
|
||||||
|
|
||||||
y0 := -dy;
|
// Horizontal lines
|
||||||
if FGanttView.DrawingStyle = ds3D then dec(y0);
|
if (gvoHorizGrid in FGanttView.Options) then
|
||||||
numEvents := FGanttView.NumEvents;
|
|
||||||
for i := 0 to numEvents - 1 do
|
|
||||||
begin
|
begin
|
||||||
eventRec := FGanttView.EventRecords[i];
|
y0 := -dy;
|
||||||
y1 := y0 + eventRec.EventRect.Bottom;
|
if FGanttView.DrawingStyle = ds3D then dec(y0);
|
||||||
if y1 >= FGanttView.TotalColHeaderHeight then
|
numEvents := FGanttView.NumEvents;
|
||||||
RenderCanvas.Line(x1, y1, x2, y1);
|
for i := 0 to numEvents - 1 do
|
||||||
|
begin
|
||||||
|
eventRec := FGanttView.EventRecords[i];
|
||||||
|
y1 := y0 + eventRec.EventRect.Bottom;
|
||||||
|
if y1 >= FGanttView.TotalColHeaderHeight then
|
||||||
|
RenderCanvas.Line(x1, y1, x2, y1);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Vertical lines
|
// Vertical lines
|
||||||
y1 := RealTop + FGanttView.TotalColHeaderHeight;
|
if (gvoVertGrid in FGanttView.Options) then
|
||||||
if numEvents > 0 then
|
|
||||||
begin
|
begin
|
||||||
eventRec := FGanttView.EventRecords[numEvents-1];
|
y1 := RealTop + FGanttView.TotalColHeaderHeight;
|
||||||
y2 := eventRec.EventRect.Bottom - dy;
|
if numEvents > 0 then
|
||||||
end else
|
begin
|
||||||
y2 := RealBottom;
|
eventRec := FGanttView.EventRecords[numEvents-1];
|
||||||
n := FGanttView.NumDays;
|
y2 := eventRec.EventRect.Bottom - dy;
|
||||||
for i := 0 to n-1 do
|
end else
|
||||||
begin
|
y2 := RealBottom;
|
||||||
dayRec := FGanttView.DayRecords[i];
|
n := FGanttView.NumDays;
|
||||||
x1 := dayRec.Rect.Right - dx;
|
for i := 0 to n-1 do
|
||||||
x2 := x1;
|
begin
|
||||||
if x1 >= FGanttView.FixedColWidth then
|
dayRec := FGanttView.DayRecords[i];
|
||||||
RenderCanvas.Line(x1, y1, x2, y2);
|
x1 := dayRec.Rect.Right - dx;
|
||||||
|
x2 := x1;
|
||||||
|
if x1 >= FGanttView.FixedColWidth then
|
||||||
|
RenderCanvas.Line(x1, y1, x2, y2);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -571,7 +582,7 @@ begin
|
|||||||
DrawEvents;
|
DrawEvents;
|
||||||
|
|
||||||
{ Draw active day rectangle }
|
{ Draw active day rectangle }
|
||||||
if FGanttView.ShowActiveDate then
|
if (gvoActiveDate in FGanttView.Options) then
|
||||||
DrawActiveDate;
|
DrawActiveDate;
|
||||||
|
|
||||||
{ Draw the borders }
|
{ Draw the borders }
|
||||||
|
Reference in New Issue
Block a user