You've already forked lazarus-ccr
tvplanit: Holiday support in TVpGanttView.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8434 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -11,13 +11,13 @@ uses
|
||||
|
||||
type
|
||||
TVpGanttViewOption = (
|
||||
gvoActiveDate, gvoWeekends, gvoHorizGrid, gvoVertGrid
|
||||
gvoActiveDate, gvoHorizGrid, gvoVertGrid, gvoWeekends, gvoHolidays
|
||||
);
|
||||
TVpGanttViewOptions = set of TVpGanttViewOption;
|
||||
|
||||
const
|
||||
DEFAULT_GANTTVIEWOPTIONS = [
|
||||
gvoActiveDate, gvoWeekends, gvoHorizGrid, gvoVertGrid
|
||||
gvoActiveDate, gvoHorizGrid, gvoVertGrid, gvoWeekends, gvoHolidays
|
||||
];
|
||||
|
||||
type
|
||||
@ -112,6 +112,7 @@ type
|
||||
FTextMargin: Integer;
|
||||
|
||||
FColor: TColor;
|
||||
FHolidayColor: TColor;
|
||||
FLineColor: TColor;
|
||||
FWeekendColor: TColor;
|
||||
|
||||
@ -126,6 +127,7 @@ type
|
||||
|
||||
FOnAddEvent: TVpOnAddNewEvent;
|
||||
FOnDeletingEvent: TVpOnDeletingEvent;
|
||||
FOnHoliday: TVpHolidayEvent;
|
||||
FOnModifyEvent: TVpOnModifyEvent;
|
||||
FOwnerEditEvent: TVpEditEvent;
|
||||
|
||||
@ -147,6 +149,7 @@ type
|
||||
procedure SetDateFormat(AIndex: Integer; AValue: String);
|
||||
procedure SetDrawingStyle(AValue: TVpDrawingStyle);
|
||||
procedure SetFixedColWidth(AValue: Integer);
|
||||
procedure SetHolidayColor(AValue: TColor);
|
||||
procedure SetLeftCol(AValue: Integer);
|
||||
procedure SetLineColor(AValue: TColor);
|
||||
procedure SetOptions(AValue: TVpGanttViewOptions);
|
||||
@ -213,6 +216,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure DeleteActiveEvent(Prompt: Boolean);
|
||||
procedure Init;
|
||||
function IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
|
||||
procedure LoadLanguage;
|
||||
procedure LinkHandler(Sender: TComponent;
|
||||
NotificationType: TVpNotificationType; const Value: Variant); override;
|
||||
@ -264,6 +268,7 @@ type
|
||||
property DayFormat: String index 0 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
|
||||
property FixedColWidth: Integer read FFixedColWidth write SetFixedColWidth default 120;
|
||||
property HolidayColor: TColor read FHolidayColor write SetHolidayColor default HOLIDAY_COLOR;
|
||||
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
|
||||
property MonthFormat: String index 1 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||
property MonthFormat_short: String index 2 read GetDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||
@ -277,6 +282,7 @@ type
|
||||
// new events
|
||||
property OnAddEvent: TVpOnAddNewEvent read FOnAddEvent write FOnAddEvent;
|
||||
property OnDeletingEvent: TVpOnDeletingEvent read FOnDeletingEvent write FOnDeletingEvent;
|
||||
property OnHoliday: TVpHolidayEvent read FOnHoliday write FOnHoliday;
|
||||
property OnModifyEvent: TVpOnModifyEvent read FOnModifyEvent write FOnModifyEvent;
|
||||
property OwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent;
|
||||
end;
|
||||
@ -411,6 +417,7 @@ begin
|
||||
FColor := DEFAULT_COLOR;
|
||||
FLineColor := DEFAULT_LINECOLOR;
|
||||
FWeekendColor := WEEKEND_COLOR;
|
||||
FHolidayColor := HOLIDAY_COLOR;
|
||||
|
||||
FRowHeaderAttributes := TVpGanttRowHeaderAttributes.Create(self);
|
||||
FColHeaderAttributes := TVpGanttColHeaderAttributes.Create(self);
|
||||
@ -839,6 +846,14 @@ begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TVpGanttView.IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
|
||||
begin
|
||||
AHolidayName := '';
|
||||
if Assigned(FOnHoliday) then
|
||||
FOnHoliday(Self, ADate, AHolidayName);
|
||||
Result := AHolidayName <> '';
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
|
||||
procedure ScrollCols(ADelta: Integer);
|
||||
@ -1329,6 +1344,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.SetHolidayColor(AValue: TColor);
|
||||
begin
|
||||
if FHolidayColor <> AValue then
|
||||
begin
|
||||
FHolidayColor := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpGanttView.SetHScrollPos;
|
||||
var
|
||||
scrollInfo: TScrollInfo;
|
||||
|
@ -294,6 +294,9 @@ var
|
||||
i, j1, j2, nDays, nEvents: Integer;
|
||||
x1, y1, x2, y2: Integer;
|
||||
dx, dy: Integer;
|
||||
clr: TColor;
|
||||
dayRec: TVpGanttDayRec;
|
||||
holiday: String;
|
||||
begin
|
||||
with FGanttView do
|
||||
begin
|
||||
@ -307,8 +310,29 @@ begin
|
||||
y1 := TotalColHeaderHeight;
|
||||
y2 := EventRecords[nEvents-1].HeadRect.Bottom - dy;
|
||||
|
||||
RenderCanvas.Brush.style := bsSolid;
|
||||
for i := 0 to nDays-1 do
|
||||
if IsWeekend(DayRecords[i].Date) then
|
||||
begin
|
||||
dayRec := DayRecords[i];
|
||||
clr := clNone;
|
||||
if (gvoWeekends in Options) and IsWeekend(dayRec.Date) then
|
||||
clr := WeekendColor
|
||||
else
|
||||
if (gvoHolidays in Options) and IsHoliday(dayRec.Date, holiday) then
|
||||
clr := HolidayColor;
|
||||
if clr <> clNone then
|
||||
begin
|
||||
RenderCanvas.Brush.Color := clr;
|
||||
x1 := dayRec.Rect.Left - dx;
|
||||
x2 := dayRec.Rect.Right - dx;
|
||||
RenderCanvas.FillRect(x1, y1, x2, y2);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
(*
|
||||
|
||||
|
||||
|
||||
begin
|
||||
j1 := i;
|
||||
break;
|
||||
@ -341,6 +365,7 @@ begin
|
||||
inc(j1, 7);
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure TVpGanttViewPainter.DrawEvents;
|
||||
|
@ -148,7 +148,7 @@ function DaysInAMonth(Year, Month: Integer): Integer;
|
||||
|
||||
function GetJulianDate(Date: TDateTime): Word;
|
||||
function GetWeekOfYear(ADate: TDateTime): byte;
|
||||
function IsWeekEnd(ADate: TDateTime): Boolean;
|
||||
function IsWeekend(ADate: TDateTime): Boolean;
|
||||
function SameDate(dt1, dt2: TDateTime): Boolean;
|
||||
function SameTime(t1, t2: TTime): Boolean;
|
||||
function SameTimeOrEarlier(t1, t2: TTime): Boolean;
|
||||
|
Reference in New Issue
Block a user