tvplanit: Add holiday support to DayView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5199 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-22 23:12:16 +00:00
parent 9d7234c2c0
commit c5e93da15a
8 changed files with 145 additions and 89 deletions

View File

@ -94,19 +94,15 @@ object MainForm: TMainForm
HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Font.Style = [fsItalic]
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace
HolidayAttributes.Font.Color = clBlack HolidayAttributes.Font.Color = clBlack
HolidayAttributes.Color = 8421631 SelectedDayColor = clRed
LineColor = clGray ShowEvents = True
ShowEventTime = False
TimeFormat = tf12Hour TimeFormat = tf12Hour
TodayAttributes.Font.Color = clBlue TodayAttributes.Font.Color = clBlue
TodayAttributes.Color = 16761024 TodayAttributes.Color = 16761024
TodayAttributes.BorderPen.Color = clBlue TodayAttributes.BorderPen.Color = clBlue
TodayAttributes.BorderPen.Width = 3 TodayAttributes.BorderPen.Width = 3
OffDayColor = 15263976
SelectedDayColor = clRed
ShowEvents = True
ShowEventTime = False
WeekendAttributes.Font.Color = clBlack WeekendAttributes.Font.Color = clBlack
WeekendAttributes.Color = 12632319
WeekStartsOn = dtSunday WeekStartsOn = dtSunday
OnHoliday = VpHoliday OnHoliday = VpHoliday
end end
@ -141,10 +137,6 @@ object MainForm: TMainForm
ShowEventTimes = False ShowEventTimes = False
DrawingStyle = dsFlat DrawingStyle = dsFlat
TimeSlotColors.Active = clWhite TimeSlotColors.Active = clWhite
TimeSlotColors.Inactive = 8454143
TimeSlotColors.Holiday = 16744703
TimeSlotColors.Weekday = clWhite
TimeSlotColors.Weekend = 14737632
TimeSlotColors.ActiveRange.RangeBegin = h_00 TimeSlotColors.ActiveRange.RangeBegin = h_00
TimeSlotColors.ActiveRange.RangeEnd = h_00 TimeSlotColors.ActiveRange.RangeEnd = h_00
HeadAttributes.Font.Height = -13 HeadAttributes.Font.Height = -13
@ -200,11 +192,12 @@ object MainForm: TMainForm
ShowResourceName = True ShowResourceName = True
LineColor = clGray LineColor = clGray
GutterWidth = 5 GutterWidth = 5
DateLabelFormat = 'dddd, mmmm dd, yyyy' DateLabelFormat = 'dddddd'
Granularity = gr30Min Granularity = gr30Min
DefaultTopHour = h_07 DefaultTopHour = h_07
TimeFormat = tf12Hour TimeFormat = tf12Hour
WrapStyle = wsNoFlow WrapStyle = wsNoFlow
OnHoliday = VpHoliday
end end
object DaySelectorPanel: TPanel object DaySelectorPanel: TPanel
Left = 0 Left = 0

View File

@ -113,12 +113,13 @@ steps:
- Add mORMot datastore - Add mORMot datastore
- Add drag and drop of events to DayView and WeekView - Add drag and drop of events to DayView and WeekView
- Add hint support to DayView, WeekView and MonthView - Add hint support to DayView, WeekView, MonthView, and Contact Grid
- New contact fields for - New contact fields for
- three email addresses (in total) - three email addresses (in total)
- two websites - two websites
- 2nd address (work address, home address) - 2nd address (work address, home address)
- department - department
and add them to the contact editor and add them to the contact editor; redesigned contact editor.
- Activate task fields Priority and Category in task editor. - Activate task fields Priority and Category in task editor.
- Holiday support

View File

@ -361,10 +361,10 @@ type
procedure Changed; procedure Changed;
published published
property Active: TColor read FActive write SetActive; property Active: TColor read FActive write SetActive;
property Inactive: TColor read FInactive write SetInactive; property Inactive: TColor read FInactive write SetInactive default OFF_COLOR;
property Holiday: TColor read FHoliday write SetHoliday; property Holiday: TColor read FHoliday write SetHoliday default HOLIDAY_COLOR;
property Weekday: TColor read FWeekday write SetWeekday; property Weekday: TColor read FWeekday write SetWeekday default WEEKDAY_COLOR;
property Weekend: TColor read FWeekend write SetWeekend; property Weekend: TColor read FWeekend write SetWeekend default WEEKEND_COLOR;
property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange; property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange;
end; end;
@ -951,11 +951,11 @@ begin
inherited Create; inherited Create;
FOwner := AOwner; FOwner := AOwner;
FActiveRange := TVpTimeRange.Create(Self); FActiveRange := TVpTimeRange.Create(Self);
FInactive := $0080FFFF; FInactive := OFF_COLOR; //$0080FFFF;
FHoliday := $00FF80FF; FHoliday := HOLIDAY_COLOR; //$00FF80FF;
FWeekend := $00FFFF80; FWeekend := WEEKEND_COLOR; //$00FFFF80;
FActive := clWhite; FActive := clWhite;
FWeekday := clWhite; FWeekday := WEEKDAY_COLOR; //clWhite;
end; end;
{=====} {=====}

View File

@ -94,10 +94,11 @@ const
strTRUE = 'true'; strTRUE = 'true';
strFALSE = 'false'; strFALSE = 'false';
WEEKEND_COLOR = $C0C0FF; WEEKDAY_COLOR = $FFFFFF;
WEEKEND_COLOR = $C0C0C0; //$C0C0FF;
HOLIDAY_COLOR = $8080FF; HOLIDAY_COLOR = $8080FF;
TODAY_COLOR = $FFC0C0; TODAY_COLOR = $FFC0C0;
OFF_COLOR = $C0C0C0; OFF_COLOR = $E0E0E0;
{virtual key constants not already defined} {virtual key constants not already defined}
VK_NONE = 0; VK_NONE = 0;

View File

@ -226,6 +226,7 @@ type
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FHintWindow: THintWindow; FHintWindow: THintWindow;
FMouseEvent: TVpEvent; FMouseEvent: TVpEvent;
FOnHoliday: TVpHolidayEvent;
protected{ private } protected{ private }
FGranularity: TVpGranularity; FGranularity: TVpGranularity;
@ -259,6 +260,8 @@ type
FAllowInplaceEdit: Boolean; FAllowInplaceEdit: Boolean;
FDragDropTransparent: Boolean; FDragDropTransparent: Boolean;
FAllowDragAndDrop: Boolean; FAllowDragAndDrop: Boolean;
FNumDays: Integer;
FIncludeWeekends: Boolean;
{ event variables } { event variables }
FOwnerDrawRowHead: TVpOwnerDrawRowEvent; FOwnerDrawRowHead: TVpOwnerDrawRowEvent;
FOwnerDrawCells: TVpOwnerDrawRowEvent; FOwnerDrawCells: TVpOwnerDrawRowEvent;
@ -270,8 +273,6 @@ type
FOnBeforeDrawEvent: TVpOnDVBeforeDrawEvent; FOnBeforeDrawEvent: TVpOnDVBeforeDrawEvent;
FOnAfterDrawEvent: TVpOnDVAfterDrawEvent; FOnAfterDrawEvent: TVpOnDVAfterDrawEvent;
FOnAddEvent: TVpOnAddNewEvent; FOnAddEvent: TVpOnAddNewEvent;
FNumDays: Integer;
FIncludeWeekends: Boolean;
{ internal variables } { internal variables }
dvClickTimer: TTimer; dvClickTimer: TTimer;
dvLoaded: Boolean; dvLoaded: Boolean;
@ -413,12 +414,11 @@ type
destructor Destroy; override; destructor Destroy; override;
function BuildEventString(AEvent: TVpEvent; UseAsHint: Boolean): String; function BuildEventString(AEvent: TVpEvent; UseAsHint: Boolean): String;
procedure LoadLanguage;
procedure DeleteActiveEvent(Verify: Boolean); procedure DeleteActiveEvent(Verify: Boolean);
procedure DragDrop(Source: TObject; X, Y: Integer); override; procedure DragDrop(Source: TObject; X, Y: Integer); override;
// function HourToLine(const Value: TVpHours; const UseGran: TVpGranularity): Integer;
procedure Invalidate; override; procedure Invalidate; override;
function IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
procedure LoadLanguage;
procedure LinkHandler(Sender: TComponent; NotificationType: TVpNotificationType; procedure LinkHandler(Sender: TComponent; NotificationType: TVpNotificationType;
const Value: Variant); override; const Value: Variant); override;
procedure EditSelectedEvent; procedure EditSelectedEvent;
@ -484,6 +484,7 @@ type
property OnAfterDrawEvent: TVpOnDVAfterDrawEvent read FOnAfterDrawEvent write FOnAfterDrawEvent; property OnAfterDrawEvent: TVpOnDVAfterDrawEvent read FOnAfterDrawEvent write FOnAfterDrawEvent;
property OnBeforeDrawEvent: TVpOnDVBeforeDrawEvent read FOnBeforeDrawEvent write FOnBeforeDrawEvent; property OnBeforeDrawEvent: TVpOnDVBeforeDrawEvent read FOnBeforeDrawEvent write FOnBeforeDrawEvent;
property OnDrawIcons: TVpOnDVDrawIcons read FOnDrawIcons Write FOnDrawIcons; property OnDrawIcons: TVpOnDVDrawIcons read FOnDrawIcons Write FOnDrawIcons;
property OnHoliday: TVpHolidayEvent read FOnHoliday write FOnHoliday;
property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent; property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent;
property OnClick; property OnClick;
end; end;
@ -757,7 +758,7 @@ begin
FDisplayDate := Now; FDisplayDate := Now;
TopHour := FDefTopHour; TopHour := FDefTopHour;
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
FDateLabelFormat := 'dddd, mmmm dd, yyyy'; FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy';
FColumnWidth := 200; FColumnWidth := 200;
FScrollBars := ssVertical; FScrollBars := ssVertical;
FActiveRow := -1; FActiveRow := -1;
@ -966,7 +967,14 @@ procedure TVpDayView.Invalidate;
begin begin
inherited; inherited;
end; end;
{=====}
function TVpDayView.IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
begin
AHolidayName := '';
if Assigned(FOnHoliday) then
FOnHoliday(Self, ADate, AHolidayName);
Result := AHolidayName <> '';
end;
procedure TVpDayView.LinkHandler(Sender: TComponent; procedure TVpDayView.LinkHandler(Sender: TComponent;
NotificationType: TVpNotificationType; const Value: Variant); NotificationType: TVpNotificationType; const Value: Variant);
@ -1619,7 +1627,7 @@ begin
if (DayOfWeek(WorkDate) <> 1) and (DayOfWeek(WorkDate) <> 7) then if (DayOfWeek(WorkDate) <> 1) and (DayOfWeek(WorkDate) <> 7) then
Inc(i); Inc(i);
WorkDate := WorkDate + 1; WorkDate := WorkDate + 1;
Inc (Result); Inc(Result);
end; end;
end else end else
Result := FNumDays; Result := FNumDays;

View File

@ -54,6 +54,7 @@ type
RealADEventBkgColor: TColor; RealADEventBkgColor: TColor;
ADEventAttrBkgColor: TColor; ADEventAttrBkgColor: TColor;
ADEventBorderColor: TColor; ADEventBorderColor: TColor;
FRenderHoliday: String;
// variables from local procedures for better access // variables from local procedures for better access
dvBmpRecurring: TBitmap; dvBmpRecurring: TBitmap;
dvBmpCategory: TBitmap; dvBmpCategory: TBitmap;
@ -100,6 +101,8 @@ type
procedure DrawRowHeaderBackground(R: TRect); procedure DrawRowHeaderBackground(R: TRect);
procedure DrawRowHeaderLabels(R: TRect); procedure DrawRowHeaderLabels(R: TRect);
procedure DrawRowHeaderTicks(R: TRect); procedure DrawRowHeaderTicks(R: TRect);
function FixDateStr(ADate: TDateTime; AFormat, AHoliday: String;
AWidth: Integer): String;
procedure FixFontHeights; procedure FixFontHeights;
procedure FreeBitmaps; procedure FreeBitmaps;
procedure GetIcons(Event: TVpEvent); procedure GetIcons(Event: TVpEvent);
@ -518,8 +521,11 @@ begin
RenderCanvas.Brush.Color := HighlightBkg; RenderCanvas.Brush.Color := HighlightBkg;
RenderCanvas.Font.Color := HighlightText; RenderCanvas.Font.Color := HighlightText;
end else end else
if (FRenderHoliday <> '') then
RenderCanvas.Brush.Color := FDayview.TimeSlotColors.Holiday
else
if IsWeekend(ColDate) then if IsWeekend(ColDate) then
{ week end color } { weekend color }
RenderCanvas.Brush.Color := FDayView.TimeSlotColors.Weekend RenderCanvas.Brush.Color := FDayView.TimeSlotColors.Weekend
else else
{ ColDate is a weekday, so check to see if the active range is set. { ColDate is a weekday, so check to see if the active range is set.
@ -527,7 +533,7 @@ begin
If it is, then paint inactive rows the color corresponding to inactive If it is, then paint inactive rows the color corresponding to inactive
and the active rows the color corresponding to Active Rows. } and the active rows the color corresponding to Active Rows. }
if FDayView.TimeSlotColors.ActiveRange.RangeBegin = FDayView.TimeSlotColors.ActiveRange.RangeEnd then if FDayView.TimeSlotColors.ActiveRange.RangeBegin = FDayView.TimeSlotColors.ActiveRange.RangeEnd then
{ There is not active range --> Paint all time slots in the weekday color } { There is no active range --> Paint all time slots in the weekday color }
RenderCanvas.Brush.Color := FDayView.TimeSlotColors.Weekday RenderCanvas.Brush.Color := FDayView.TimeSlotColors.Weekday
else begin else begin
{ There is an active range defined, so we need to see if the current { There is an active range defined, so we need to see if the current
@ -633,9 +639,9 @@ procedure TVpDayViewPainter.DrawColHeader(R: TRect; ARenderDate: TDateTime;
Col: Integer); Col: Integer);
var var
SaveFont: TFont; SaveFont: TFont;
DateStr, ResStr: string; DateStr, DateOnlyStr, ResStr: string;
DateStrLen, ResStrLen: integer; DateStrLen, ResStrLen: integer;
StrHt: Integer; DateStrHt: Integer;
TextRect: TRect; TextRect: TRect;
X, Y: Integer; X, Y: Integer;
tmpRect: TRect; tmpRect: TRect;
@ -663,14 +669,10 @@ begin
TextRect.Right := TextRect.Right - 3; TextRect.Right := TextRect.Right - 3;
TextRect.Left := TextRect.Left + 2; TextRect.Left := TextRect.Left + 2;
{ Fix Date String } { Fix date string for best usage of the available width }
DateStr := FormatDateTime(FDayView.DateLabelFormat, ARenderDate); DateStr := FixDateStr(ARenderDate, FDayView.DateLabelFormat, FRenderHoliday, WidthOf(TextRect));
DateStrLen := RenderCanvas.TextWidth(DateStr); DateStrLen := RenderCanvas.TextWidth(DateStr);
StrHt := RenderCanvas.TextHeight(DateStr); DateStrHt := RenderCanvas.TextHeight(DateStr);
if DateStrLen > TextRect.Right - TextRect.Left then begin
DateStr := GetDisplayString(RenderCanvas, DateStr, 0, TextRect.Right - TextRect.Left);
DateStrLen := RenderCanvas.TextWidth(DateStr);
end;
if (FDayView.DataStore <> nil) and (FDayView.DataStore.Resource <> nil) if (FDayView.DataStore <> nil) and (FDayView.DataStore.Resource <> nil)
and FDayView.ShowResourceName and FDayView.ShowResourceName
@ -690,7 +692,7 @@ begin
end; end;
{ center the date string } { center the date string }
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2; X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2;
Y := TextRect.Top + (TextMargin * 2) + StrHt; Y := TextRect.Top + (TextMargin * 2) + DateStrHt;
end else begin end else begin
{ center the date string } { center the date string }
Y := TextRect.Top + TextMargin; Y := TextRect.Top + TextMargin;
@ -1291,6 +1293,9 @@ begin
DrawMe := False DrawMe := False
end; end;
if DrawMe then begin if DrawMe then begin
{ Check if the currently rendered day is a holiday and store its name }
FDayView.IsHoliday(RenderDate + i, FRenderHoliday);
{ Calculate Column Header rectangle } { Calculate Column Header rectangle }
ColHeadRect := Rect(RPos, RealTop + 2, RPos + DayWidth - 1, RealTop + RealColHeadHeight); ColHeadRect := Rect(RPos, RealTop + 2, RPos + DayWidth - 1, RealTop + RealColHeadHeight);
if (i = RealNumDays - 1) and (ExtraSpace > 0) then if (i = RealNumDays - 1) and (ExtraSpace > 0) then
@ -1554,6 +1559,39 @@ begin
inc(Result, RenderCanvas.TextWidth('33')); inc(Result, RenderCanvas.TextWidth('33'));
end; end;
function TVpDayViewPainter.FixDateStr(ADate: TDateTime; AFormat, AHoliday: String;
AWidth: Integer): String;
begin
// Check long date format with holiday name
if AHoliday <> '' then begin
Result := Format('%s - %s', [FormatDateTime(AFormat, ADate), AHoliday]);
if RenderCanvas.TextWidth(Result) <= AWidth then
exit;
// Check short date format with holiday name
if AFormat <> 'ddddd' then begin
Result := Format('%s - %s', [FormatDateTime('ddddd', ADate), AHoliday]);
if RenderCanvas.TextWidth(Result) <= AWidth then
exit;
end;
end;
// Check long date format without holiday name
Result := FormatDateTime(AFormat, ADate);
if RenderCanvas.TextWidth(Result) <= AWidth then
exit;
// Check short date format without holiday name
if AFormat <> 'ddddd' then begin
Result := FormatDateTime('ddddd', ADate);
if RenderCanvas.TextWidth(Result) <= AWidth then
exit;
end;
// Chop off the short-date-format string and add '...'
Result := GetDisplayString(RenderCanvas, Result, 0, AWidth);
end;
procedure TVpDayViewPainter.FixFontHeights; procedure TVpDayViewPainter.FixFontHeights;
begin begin
with FDayView do begin with FDayView do begin
@ -1782,22 +1820,21 @@ begin
StartLine := FDayView.TopLine; StartLine := FDayView.TopLine;
if VisibleLines < LineCount then if VisibleLines < LineCount then
ScrollbarOffset := GetSystemMetrics(SM_CYHSCROLL); ScrollbarOffset := GetSystemMetrics(SM_CYHSCROLL);
// ScrollbarOffset := 14;
end; end;
Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom);
try try
SelectClipRgn(RenderCanvas.Handle, Rgn); SelectClipRgn(RenderCanvas.Handle, Rgn);
// Calculate the RealNumDays (The number of days the control covers)
RealNumDays := TVpDayViewOpener(FDayView).GetRealNumDays(RenderDate);
// Calculate row and column header // Calculate row and column header
RealRowHeight := TVpDayViewOpener(FDayView).dvCalcRowHeight(Scale, UseGran); RealRowHeight := TVpDayViewOpener(FDayView).dvCalcRowHeight(Scale, UseGran);
RealRowHeadWidth := CalcRowHeadWidth; RealRowHeadWidth := CalcRowHeadWidth;
RealColHeadHeight := TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale); RealColHeadHeight := TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
// RowHeadRect and RealVisibleLines are calculated below... // RowHeadRect and RealVisibleLines are calculated below...
// Calculate the RealNumDays (The number of days the control covers)
RealNumDays := TVpDayViewOpener(FDayView).GetRealNumDays(RenderDate);
// Draw the all-day events // Draw the all-day events
DrawAllDayEvents; DrawAllDayEvents;

View File

@ -74,6 +74,20 @@ type
property Color: TColor read FColor write SetColor; property Color: TColor read FColor write SetColor;
end; end;
TVpMvHolidayAttr = class(TVpMonthViewAttr)
public
constructor Create(AOwner: TVpMonthView);
published
property Color default HOLIDAY_COLOR;
end;
TVpMvWeekendAttr = class(TVpMonthViewAttr)
public
constructor Create(AOwner: TVpMonthView);
published
property Color default WEEKEND_COLOR;
end;
(* (*
TVpMvHeadAttr = class(TPersistent) TVpMvHeadAttr = class(TPersistent)
protected{ private } protected{ private }
@ -117,29 +131,14 @@ type
published published
property BorderPen: TPen read FBorderPen write SetBorderPen; property BorderPen: TPen read FBorderPen write SetBorderPen;
end; end;
(*
TVpMvHolidayAttr = class(TPersistent)
protected
FMonthView: TVpMonthView;
FFont: TVpFont;
FColor: TColor;
procedure SetColor(Value: TColor);
procedure SetFont(Value: TVpFont);
public
constructor Create(AOwner: TVpMonthView);
destructor Destroy; override;
property MonthView: TVpMonthView read FMonthView;
published
property Color: TColor read FColor write SetColor;
property Font: TVpFont read FFont write FFont;
end;
*)
{ TVpMonthView } { TVpMonthView }
TVpMonthView = class(TVpLinkableControl) TVpMonthView = class(TVpLinkableControl)
private private
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FOnHoliday: TVpHolidayEvent;
protected{ private } protected{ private }
FKBNavigate: Boolean; FKBNavigate: Boolean;
FColumnWidth: Integer; FColumnWidth: Integer;
@ -159,15 +158,9 @@ type
FTopLine: Integer; FTopLine: Integer;
FDayHeadAttr: TVpMonthViewAttr; FDayHeadAttr: TVpMonthViewAttr;
FHeadAttr: TVpMonthViewAttr; FHeadAttr: TVpMonthViewAttr;
FHolidayAttr: TVpMonthViewAttr;
FTodayAttr: TVpMvTodayAttr;
FWeekendAttr: TVpMonthViewAttr;
{
FDayHeadAttr: TVpDayHeadAttr;
FHeadAttr: TVpMvHeadAttr;
FHolidayAttr: TVpMvHolidayAttr; FHolidayAttr: TVpMvHolidayAttr;
FTodayAttr: TVpMvTodayAttr; } FTodayAttr: TVpMvTodayAttr;
FWeekendAttr: TVpMvWeekendAttr;
FDayNumberFont: TVpFont; FDayNumberFont: TVpFont;
FEventFont: TVpFont; FEventFont: TVpFont;
FTimeFormat: TVpTimeFormat; FTimeFormat: TVpTimeFormat;
@ -182,7 +175,6 @@ type
FOwnerDrawCells: TVpOwnerDrawDayEvent; FOwnerDrawCells: TVpOwnerDrawDayEvent;
FOnEventClick: TVpOnEventClick; FOnEventClick: TVpOnEventClick;
FOnEventDblClick: TVpOnEventClick; FOnEventDblClick: TVpOnEventClick;
FOnHoliday: TVpHolidayEvent;
{ internal variables } { internal variables }
mvLoaded: Boolean; mvLoaded: Boolean;
@ -297,13 +289,10 @@ type
property EventFont: TVpFont read FEventFont write SetEventFont; property EventFont: TVpFont read FEventFont write SetEventFont;
// property HeadAttributes: TVpMvHeadAttr read FHeadAttr write FHeadAttr; // property HeadAttributes: TVpMvHeadAttr read FHeadAttr write FHeadAttr;
property HeadAttributes: TVpMonthViewAttr read FHeadAttr write FHeadAttr; property HeadAttributes: TVpMonthViewAttr read FHeadAttr write FHeadAttr;
property HolidayAttributes: TVpMonthViewAttr read FHolidayAttr write FHolidayAttr; property HolidayAttributes: TVpMvHolidayAttr read FHolidayAttr write FHolidayAttr;
// property HolidayAttributes: TVpMvHolidayAttr read FHolidayAttr write FHolidayAttr;
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
property LineColor: TColor read FLineColor write SetLineColor; property LineColor: TColor read FLineColor write SetLineColor default clGray;
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat; property OffDayColor: TColor read FOffDayColor write SetOffDayColor default OFF_COLOR;
property TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr;
property OffDayColor: TColor read FOffDayColor write SetOffDayColor;
property OffDayFontColor: TColor read FOffDayFontColor write SetOffDayFontColor default clGray; property OffDayFontColor: TColor read FOffDayFontColor write SetOffDayFontColor default clGray;
property OwnerDrawCells: TVpOwnerDrawDayEvent read FOwnerDrawCells write FOwnerDrawCells; property OwnerDrawCells: TVpOwnerDrawDayEvent read FOwnerDrawCells write FOwnerDrawCells;
property RightClickChangeDate: Boolean property RightClickChangeDate: Boolean
@ -311,7 +300,9 @@ type
property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor; property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor;
property ShowEvents: Boolean read FShowEvents write SetShowEvents; property ShowEvents: Boolean read FShowEvents write SetShowEvents;
property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime; property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime;
property WeekendAttributes: TVpMonthViewAttr read FWeekendAttr write FWeekendAttr; property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat;
property TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr;
property WeekendAttributes: TVpMvWeekendAttr read FWeekendAttr write FWeekendAttr;
property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn; property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn;
{events} {events}
property OnEventClick: TVpOnEventClick read FOnEventClick write FOnEventClick; property OnEventClick: TVpOnEventClick read FOnEventClick write FOnEventClick;
@ -360,6 +351,26 @@ begin
end; end;
(*****************************************************************************)
{ TVpMvHolidayAttr }
(*****************************************************************************)
constructor TVpMvHolidayAttr.Create(AOwner: TVpMonthView);
begin
inherited Create(AOwner);
FColor := HOLIDAY_COLOR;
end;
(*****************************************************************************)
{ TVpMvWeekendAttr }
(*****************************************************************************)
constructor TVpMvWeekendAttr.Create(AOwner: TVpMonthView);
begin
inherited Create(AOwner);
FColor := WEEKEND_COLOR;
end;
(*****************************************************************************) (*****************************************************************************)
{ TVpMvTodayAttr } { TVpMvTodayAttr }
(*****************************************************************************) (*****************************************************************************)
@ -398,8 +409,8 @@ begin
{ Create internal classes and stuff } { Create internal classes and stuff }
FHeadAttr := TVpMonthViewAttr.Create(self); FHeadAttr := TVpMonthViewAttr.Create(self);
FDayHeadAttr := TVpMonthViewAttr.Create(self); FDayHeadAttr := TVpMonthViewAttr.Create(self);
FHolidayAttr := TVpMonthViewAttr.Create(self); FHolidayAttr := TVpMvHolidayAttr.Create(self);
FWeekendAttr := TVpMonthviewAttr.Create(self); FWeekendAttr := TVpMvWeekendAttr.Create(self);
FTodayAttr := TVpMvTodayAttr.Create(Self); FTodayAttr := TVpMvTodayAttr.Create(Self);
mvSpinButtons := TUpDown.Create(self); mvSpinButtons := TUpDown.Create(self);
{ {
@ -428,7 +439,6 @@ begin
FDrawingStyle := ds3d; FDrawingStyle := ds3d;
// mvPainting := false; // mvPainting := false;
FColor := clWindow; FColor := clWindow;
FOffDayColor := clSilver;
FLineColor := clGray; FLineColor := clGray;
FDate := Trunc(Now); FDate := Trunc(Now);
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
@ -454,11 +464,8 @@ begin
FOffDayColor := OFF_COLOR; FOffDayColor := OFF_COLOR;
FHolidayAttr.Font.Assign(FDayNumberFont); FHolidayAttr.Font.Assign(FDayNumberFont);
FHolidayAttr.Font.Color := clBlack;
FHolidayAttr.Color := HOLIDAY_COLOR;
FWeekendAttr.Font.Assign(FHolidayAttr.Font); FWeekendAttr.Font.Assign(FHolidayAttr.Font);
FWeekendAttr.Color := WEEKEND_COLOR;
SetLength(mvEventArray, MaxVisibleEvents); SetLength(mvEventArray, MaxVisibleEvents);
SetLength(mvMonthdayArray, 45); SetLength(mvMonthdayArray, 45);

View File

@ -121,6 +121,7 @@ type
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FMouseEvent: TVpEvent; FMouseEvent: TVpEvent;
FHintWindow: THintWindow; FHintWindow: THintWindow;
FOnHoliday: TVpHolidayEvent;
procedure SetActiveEvent(AValue: TVpEvent); procedure SetActiveEvent(AValue: TVpEvent);
protected{ private } protected{ private }
FActiveDate: TDateTime; FActiveDate: TDateTime;
@ -247,6 +248,7 @@ type
procedure DeleteActiveEvent(Verify: Boolean); procedure DeleteActiveEvent(Verify: Boolean);
procedure DragDrop(Source: TObject; X, Y: Integer); override; procedure DragDrop(Source: TObject; X, Y: Integer); override;
procedure Invalidate; override; procedure Invalidate; override;
function IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
procedure LinkHandler(Sender: TComponent; procedure LinkHandler(Sender: TComponent;
NotificationType: TVpNotificationType; const Value: Variant); override; NotificationType: TVpNotificationType; const Value: Variant); override;
function GetControlType: TVpItemType; override; function GetControlType: TVpItemType; override;
@ -289,6 +291,7 @@ type
property AfterEdit : TVpAfterEditEvent read FAfterEdit write FAfterEdit; property AfterEdit : TVpAfterEditEvent read FAfterEdit write FAfterEdit;
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit; property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
property OnAddEvent: TVpOnAddNewEvent read FOnAddEvent write FOnAddEvent; property OnAddEvent: TVpOnAddNewEvent read FOnAddEvent write FOnAddEvent;
property OnHoliday: TVpHolidayEvent read FOnHoliday write FOnHoliday;
property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent; property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent;
end; end;
@ -612,7 +615,14 @@ procedure TVpWeekView.Invalidate;
begin begin
inherited; inherited;
end; end;
{=====}
function TVpWeekView.IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
begin
AHolidayName := '';
if Assigned(FOnHoliday) then
FOnHoliday(Self, ADate, AHolidayName);
Result := AHolidayName <> '';
end;
procedure TVpWeekView.LinkHandler(Sender: TComponent; procedure TVpWeekView.LinkHandler(Sender: TComponent;
NotificationType: TVpNotificationType; const Value: Variant); NotificationType: TVpNotificationType; const Value: Variant);
@ -628,7 +638,6 @@ begin
wvInLinkHandler := false; wvInLinkHandler := false;
end; end;
end; end;
{=====}
procedure TVpWeekView.wvHookUp; procedure TVpWeekView.wvHookUp;
var var