You've already forked lazarus-ccr
tvplanit: Add holiday support to MonthView. Add holiday and weekend attributes to Monthview.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5198 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -57,7 +57,7 @@ object MainForm: TMainForm
|
|||||||
Height = 528
|
Height = 528
|
||||||
Top = 48
|
Top = 48
|
||||||
Width = 834
|
Width = 834
|
||||||
PageIndex = 4
|
PageIndex = 0
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
TabStop = True
|
TabStop = True
|
||||||
@ -93,17 +93,22 @@ object MainForm: TMainForm
|
|||||||
HeadAttributes.Font.Height = -13
|
HeadAttributes.Font.Height = -13
|
||||||
HeadAttributes.Font.Style = [fsItalic]
|
HeadAttributes.Font.Style = [fsItalic]
|
||||||
HeadAttributes.Color = clBtnFace
|
HeadAttributes.Color = clBtnFace
|
||||||
|
HolidayAttributes.Font.Color = clBlack
|
||||||
|
HolidayAttributes.Color = 8421631
|
||||||
LineColor = clGray
|
LineColor = clGray
|
||||||
TimeFormat = tf12Hour
|
TimeFormat = tf12Hour
|
||||||
TodayAttributes.Color = clSkyBlue
|
|
||||||
TodayAttributes.Font.Color = clBlue
|
TodayAttributes.Font.Color = clBlue
|
||||||
|
TodayAttributes.Color = 16761024
|
||||||
TodayAttributes.BorderPen.Color = clBlue
|
TodayAttributes.BorderPen.Color = clBlue
|
||||||
TodayAttributes.BorderPen.Width = 3
|
TodayAttributes.BorderPen.Width = 3
|
||||||
OffDayColor = clSilver
|
OffDayColor = 15263976
|
||||||
SelectedDayColor = clRed
|
SelectedDayColor = clRed
|
||||||
ShowEvents = True
|
ShowEvents = True
|
||||||
ShowEventTime = False
|
ShowEventTime = False
|
||||||
|
WeekendAttributes.Font.Color = clBlack
|
||||||
|
WeekendAttributes.Color = 12632319
|
||||||
WeekStartsOn = dtSunday
|
WeekStartsOn = dtSunday
|
||||||
|
OnHoliday = VpHoliday
|
||||||
end
|
end
|
||||||
object Splitter2: TSplitter
|
object Splitter2: TSplitter
|
||||||
Cursor = crVSplit
|
Cursor = crVSplit
|
||||||
|
@ -116,6 +116,8 @@ type
|
|||||||
procedure RbHideCompletedTasksChange(Sender: TObject);
|
procedure RbHideCompletedTasksChange(Sender: TObject);
|
||||||
procedure VpBufDSDataStore1PlaySound(Sender: TObject;
|
procedure VpBufDSDataStore1PlaySound(Sender: TObject;
|
||||||
const AWavFile: String; AMode: TVpPlaySoundMode);
|
const AWavFile: String; AMode: TVpPlaySoundMode);
|
||||||
|
procedure VpHoliday(Sender: TObject; ADate: TDateTime;
|
||||||
|
var AHolidayName: String);
|
||||||
procedure VpNavBar1ItemClick(Sender: TObject; Button: TMouseButton;
|
procedure VpNavBar1ItemClick(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; Index: Integer);
|
Shift: TShiftState; Index: Integer);
|
||||||
|
|
||||||
@ -306,6 +308,39 @@ begin
|
|||||||
Result := dtSunday;
|
Result := dtSunday;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function Easter(AYear: integer): TDateTime;
|
||||||
|
// Calculates the date of the Easter holiday
|
||||||
|
var
|
||||||
|
day, month: integer;
|
||||||
|
a,b,c,d,e,m,n: integer;
|
||||||
|
begin
|
||||||
|
result := 0;
|
||||||
|
case AYear div 100 of
|
||||||
|
17 : begin m := 23; n := 3; end;
|
||||||
|
18 : begin m := 23; n := 4; end;
|
||||||
|
19,20 : begin m := 24; n := 5; end;
|
||||||
|
21 : begin m := 24; n := 6; end;
|
||||||
|
else
|
||||||
|
raise Exception.Create('Easter date can only be calculated for years between 1700 and 2199');
|
||||||
|
end;
|
||||||
|
a := AYear mod 19;
|
||||||
|
b := AYear mod 4;
|
||||||
|
c := AYear mod 7;
|
||||||
|
d := (19*a + m) mod 30;
|
||||||
|
e := (2*b + 4*c + 6*d + n) mod 7;
|
||||||
|
day := 22 + d + e;
|
||||||
|
month := 3;
|
||||||
|
if day > 31 then begin
|
||||||
|
day := d + e - 9;
|
||||||
|
month := 4;
|
||||||
|
if (d = 28) and (e = 6) and (a > 10) then begin
|
||||||
|
if day = 26 then day := 19;
|
||||||
|
if day = 25 then day := 18;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
result := EncodeDate(AYear, month, day);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TMainForm }
|
{ TMainForm }
|
||||||
|
|
||||||
@ -1101,6 +1136,40 @@ begin
|
|||||||
sound.PlaySound(AWavFile, AMode);
|
sound.PlaySound(AWavFile, AMode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.VpHoliday(Sender: TObject; ADate: TDateTime;
|
||||||
|
var AHolidayName: String);
|
||||||
|
var
|
||||||
|
d,m,y: Word;
|
||||||
|
tmp: Word;
|
||||||
|
easterDate: TDate;
|
||||||
|
begin
|
||||||
|
DecodeDate(ADate, y,m,d);
|
||||||
|
if (d=1) and (m=1) then
|
||||||
|
AHolidayName := 'New Year'
|
||||||
|
else
|
||||||
|
if (d = 25) and (m = 12) then
|
||||||
|
AHolidayName := 'Christmas'
|
||||||
|
else
|
||||||
|
if m = 9 then begin
|
||||||
|
tmp := 1;
|
||||||
|
while DayOfWeek(EncodeDate(y, m, tmp)) <> 2 do inc(tmp);
|
||||||
|
if tmp = d then
|
||||||
|
AHolidayName := 'Labor Day (U.S.)'; // 1st Monday in September
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
// Holidays depending on the date of Easter.
|
||||||
|
easterDate := Easter(y);
|
||||||
|
if ADate = easterDate - 2 then
|
||||||
|
AHolidayName := 'Good Friday'
|
||||||
|
else
|
||||||
|
if ADate = easterDate then
|
||||||
|
AHolidayName := 'Easter'
|
||||||
|
else
|
||||||
|
if ADate = easterDate + 49 then
|
||||||
|
AHolidayName := 'Whitsunday'
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.ShowContacts;
|
procedure TMainForm.ShowContacts;
|
||||||
begin
|
begin
|
||||||
Notebook.PageIndex := 2;
|
Notebook.PageIndex := 2;
|
||||||
|
@ -100,6 +100,9 @@ type
|
|||||||
TVpPlaySoundEvent = procedure(Sender: TObject; const AWavFile: String;
|
TVpPlaySoundEvent = procedure(Sender: TObject; const AWavFile: String;
|
||||||
AMode: TVpPlaySoundMode) of object;
|
AMode: TVpPlaySoundMode) of object;
|
||||||
|
|
||||||
|
TVpHolidayEvent = procedure(Sender: TObject; ADate: TDateTime;
|
||||||
|
var AHolidayName: String) of object;
|
||||||
|
|
||||||
{ XML exceptions }
|
{ XML exceptions }
|
||||||
EXML = class(Exception);
|
EXML = class(Exception);
|
||||||
|
|
||||||
|
@ -94,6 +94,10 @@ const
|
|||||||
strTRUE = 'true';
|
strTRUE = 'true';
|
||||||
strFALSE = 'false';
|
strFALSE = 'false';
|
||||||
|
|
||||||
|
WEEKEND_COLOR = $C0C0FF;
|
||||||
|
HOLIDAY_COLOR = $8080FF;
|
||||||
|
TODAY_COLOR = $FFC0C0;
|
||||||
|
OFF_COLOR = $C0C0C0;
|
||||||
|
|
||||||
{virtual key constants not already defined}
|
{virtual key constants not already defined}
|
||||||
VK_NONE = 0;
|
VK_NONE = 0;
|
||||||
|
@ -58,6 +58,23 @@ type
|
|||||||
|
|
||||||
TVpOnEventClick = procedure(Sender: TObject; Event: TVpEvent) of object;
|
TVpOnEventClick = procedure(Sender: TObject; Event: TVpEvent) of object;
|
||||||
|
|
||||||
|
TVpMonthViewAttr = class(TPersistent)
|
||||||
|
private
|
||||||
|
FMonthView: TVpMonthView;
|
||||||
|
FColor: TColor;
|
||||||
|
FFont: TVpFont;
|
||||||
|
procedure SetColor(AValue: TColor);
|
||||||
|
procedure SetFont(AValue: TVpFont);
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TVpMonthView);
|
||||||
|
destructor Destroy; override;
|
||||||
|
property MonthView: TVpMonthView read FMonthVIew;
|
||||||
|
published
|
||||||
|
property Font: TVpFont read FFont write SetFont;
|
||||||
|
property Color: TColor read FColor write SetColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
TVpMvHeadAttr = class(TPersistent)
|
TVpMvHeadAttr = class(TPersistent)
|
||||||
protected{ private }
|
protected{ private }
|
||||||
FOwner: TVpMonthView;
|
FOwner: TVpMonthView;
|
||||||
@ -89,16 +106,25 @@ type
|
|||||||
property Color: TColor read FColor write SetColor;
|
property Color: TColor read FColor write SetColor;
|
||||||
property Font: TVpFont read FFont write SetFont;
|
property Font: TVpFont read FFont write SetFont;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
TVpMvTodayAttr = class(TPersistent)
|
TVpMvTodayAttr = class(TVpMonthViewAttr)
|
||||||
|
protected
|
||||||
|
FBorderPen: TPen;
|
||||||
|
procedure SetBorderPen(Value: TPen);
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TVpMonthView);
|
||||||
|
destructor Destroy; override;
|
||||||
|
published
|
||||||
|
property BorderPen: TPen read FBorderPen write SetBorderPen;
|
||||||
|
end;
|
||||||
|
(*
|
||||||
|
TVpMvHolidayAttr = class(TPersistent)
|
||||||
protected
|
protected
|
||||||
FMonthView: TVpMonthView;
|
FMonthView: TVpMonthView;
|
||||||
FFont: TVpFont;
|
FFont: TVpFont;
|
||||||
FColor: TColor;
|
FColor: TColor;
|
||||||
FBorderPen: TPen;
|
|
||||||
procedure SetColor(Value: TColor);
|
procedure SetColor(Value: TColor);
|
||||||
procedure SetFont(Value: TVpFont);
|
procedure SetFont(Value: TVpFont);
|
||||||
procedure SetBorderPen(Value: TPen);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TVpMonthView);
|
constructor Create(AOwner: TVpMonthView);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -106,8 +132,8 @@ type
|
|||||||
published
|
published
|
||||||
property Color: TColor read FColor write SetColor;
|
property Color: TColor read FColor write SetColor;
|
||||||
property Font: TVpFont read FFont write FFont;
|
property Font: TVpFont read FFont write FFont;
|
||||||
property BorderPen: TPen read FBorderPen write SetBorderPen;
|
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
{ TVpMonthView }
|
{ TVpMonthView }
|
||||||
|
|
||||||
@ -131,9 +157,17 @@ type
|
|||||||
FDateLabelFormat: string;
|
FDateLabelFormat: string;
|
||||||
FShowEventTime: Boolean;
|
FShowEventTime: Boolean;
|
||||||
FTopLine: Integer;
|
FTopLine: Integer;
|
||||||
|
FDayHeadAttr: TVpMonthViewAttr;
|
||||||
|
FHeadAttr: TVpMonthViewAttr;
|
||||||
|
FHolidayAttr: TVpMonthViewAttr;
|
||||||
|
FTodayAttr: TVpMvTodayAttr;
|
||||||
|
FWeekendAttr: TVpMonthViewAttr;
|
||||||
|
{
|
||||||
FDayHeadAttr: TVpDayHeadAttr;
|
FDayHeadAttr: TVpDayHeadAttr;
|
||||||
FHeadAttr: TVpMvHeadAttr;
|
FHeadAttr: TVpMvHeadAttr;
|
||||||
FTodayAttr: TVpMvTodayAttr;
|
FHolidayAttr: TVpMvHolidayAttr;
|
||||||
|
FTodayAttr: TVpMvTodayAttr; }
|
||||||
|
|
||||||
FDayNumberFont: TVpFont;
|
FDayNumberFont: TVpFont;
|
||||||
FEventFont: TVpFont;
|
FEventFont: TVpFont;
|
||||||
FTimeFormat: TVpTimeFormat;
|
FTimeFormat: TVpTimeFormat;
|
||||||
@ -148,6 +182,7 @@ type
|
|||||||
FOwnerDrawCells: TVpOwnerDrawDayEvent;
|
FOwnerDrawCells: TVpOwnerDrawDayEvent;
|
||||||
FOnEventClick: TVpOnEventClick;
|
FOnEventClick: TVpOnEventClick;
|
||||||
FOnEventDblClick: TVpOnEventClick;
|
FOnEventDblClick: TVpOnEventClick;
|
||||||
|
FOnHoliday: TVpHolidayEvent;
|
||||||
|
|
||||||
{ internal variables }
|
{ internal variables }
|
||||||
mvLoaded: Boolean;
|
mvLoaded: Boolean;
|
||||||
@ -178,42 +213,35 @@ type
|
|||||||
procedure SetWeekStartsOn(Value: TVpDayType);
|
procedure SetWeekStartsOn(Value: TVpDayType);
|
||||||
|
|
||||||
{ internal methods }
|
{ internal methods }
|
||||||
procedure mvHookUp;
|
function GetDateAtCoord(APoint: TPoint): TDateTime;
|
||||||
procedure mvPenChanged(Sender: TObject);
|
|
||||||
// procedure mvFontChanged(Sender: TObject);
|
|
||||||
|
|
||||||
procedure Paint; override;
|
|
||||||
procedure Loaded; override;
|
|
||||||
procedure InitializeDefaultPopup;
|
|
||||||
procedure mvPopulate;
|
procedure mvPopulate;
|
||||||
procedure mvSpinButtonClick(Sender: TObject; Button: TUDBtnType);
|
procedure mvSpinButtonClick(Sender: TObject; Button: TUDBtnType);
|
||||||
|
procedure mvSetDateByCoord(APoint: TPoint);
|
||||||
|
procedure mvHookUp;
|
||||||
|
procedure mvPenChanged(Sender: TObject);
|
||||||
|
function SelectEventAtCoord(Point: TPoint): Boolean;
|
||||||
|
|
||||||
procedure CreateParams(var Params: TCreateParams); override;
|
procedure CreateParams(var Params: TCreateParams); override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
{$IFNDEF LCL}
|
procedure Loaded; override;
|
||||||
procedure WMLButtonDown(var Msg: TWMLButtonDown); message WM_LBUTTONDOWN;
|
|
||||||
procedure WMLButtonDblClick(var Msg: TWMLButtonDblClk);message WM_LBUTTONDBLCLK;
|
|
||||||
{$ELSE}
|
|
||||||
procedure WMLButtonDown(var Msg: TLMLButtonDown); message LM_LBUTTONDOWN;
|
|
||||||
procedure WMLButtonDblClick(var Msg: TLMLButtonDblClk); message LM_LBUTTONDBLCLK;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
{ - renamed from EditEventAtCoord and re-written}
|
|
||||||
function SelectEventAtCoord(Point: TPoint): Boolean;
|
|
||||||
procedure mvSetDateByCoord(APoint: TPoint);
|
|
||||||
function GetDateAtCoord(APoint: TPoint): TDateTime;
|
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
|
||||||
procedure MouseEnter; override;
|
procedure MouseEnter; override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
|
procedure Paint; override;
|
||||||
|
|
||||||
{ message handlers }
|
{ message handlers }
|
||||||
{$IFNDEF LCL}
|
{$IFNDEF LCL}
|
||||||
|
procedure WMLButtonDown(var Msg: TWMLButtonDown); message WM_LBUTTONDOWN;
|
||||||
|
procedure WMLButtonDblClick(var Msg: TWMLButtonDblClk);message WM_LBUTTONDBLCLK;
|
||||||
procedure WMSize(var Msg: TWMSize); message WM_SIZE;
|
procedure WMSize(var Msg: TWMSize); message WM_SIZE;
|
||||||
procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS;
|
procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS;
|
||||||
procedure WMRButtonDown(var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
|
procedure WMRButtonDown(var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
|
||||||
procedure CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
procedure CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
||||||
message CM_WANTSPECIALKEY;
|
message CM_WANTSPECIALKEY;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
|
procedure WMLButtonDown(var Msg: TLMLButtonDown); message LM_LBUTTONDOWN;
|
||||||
|
procedure WMLButtonDblClick(var Msg: TLMLButtonDblClk); message LM_LBUTTONDBLCLK;
|
||||||
procedure WMSize(var Msg: TLMSize); message LM_SIZE;
|
procedure WMSize(var Msg: TLMSize); message LM_SIZE;
|
||||||
procedure WMSetFocus(var Msg: TLMSetFocus); message LM_SETFOCUS;
|
procedure WMSetFocus(var Msg: TLMSetFocus); message LM_SETFOCUS;
|
||||||
procedure WMRButtonDown(var Msg: TLMRButtonDown); message LM_RBUTTONDOWN;
|
procedure WMRButtonDown(var Msg: TLMRButtonDown); message LM_RBUTTONDOWN;
|
||||||
@ -224,6 +252,7 @@ type
|
|||||||
procedure HideHintWindow;
|
procedure HideHintWindow;
|
||||||
|
|
||||||
{ Popup menu }
|
{ Popup menu }
|
||||||
|
procedure InitializeDefaultPopup;
|
||||||
procedure PopupToday(Sender: TObject);
|
procedure PopupToday(Sender: TObject);
|
||||||
procedure PopupNextMonth(Sender: TObject);
|
procedure PopupNextMonth(Sender: TObject);
|
||||||
procedure PopupPrevMonth(Sender: TObject);
|
procedure PopupPrevMonth(Sender: TObject);
|
||||||
@ -237,6 +266,7 @@ type
|
|||||||
AShowEventTime, AStartTimeOnly: Boolean): String;
|
AShowEventTime, AStartTimeOnly: Boolean): String;
|
||||||
procedure LoadLanguage;
|
procedure LoadLanguage;
|
||||||
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;
|
||||||
@ -258,13 +288,17 @@ type
|
|||||||
property KBNavigation: Boolean read FKBNavigate write FKBNavigate;
|
property KBNavigation: Boolean read FKBNavigate write FKBNavigate;
|
||||||
property Color: TColor read FColor write SetColor;
|
property Color: TColor read FColor write SetColor;
|
||||||
property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat;
|
property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat;
|
||||||
property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttr write FDayHeadAttr;
|
property DayHeadAttributes: TVpMonthviewAttr read FDayHeadAttr write FDayHeadAttr;
|
||||||
|
// property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttr write FDayHeadAttr;
|
||||||
property DayNameStyle: TVpMVDayNameStyle read FDayNameStyle write SetDayNameStyle;
|
property DayNameStyle: TVpMVDayNameStyle read FDayNameStyle write SetDayNameStyle;
|
||||||
property DayNumberFont: TVpFont read FDayNumberFont write SetDayNumberFont;
|
property DayNumberFont: TVpFont read FDayNumberFont write SetDayNumberFont;
|
||||||
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True;
|
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True;
|
||||||
property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle;
|
property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle;
|
||||||
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 HolidayAttributes: TVpMonthViewAttr 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;
|
||||||
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat;
|
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat;
|
||||||
@ -277,10 +311,12 @@ 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 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;
|
||||||
property OnEventDblClick: TVpOnEventClick read FOnEventDblClick write FOnEventDblClick;
|
property OnEventDblClick: TVpOnEventClick read FOnEventDblClick write FOnEventDblClick;
|
||||||
|
property OnHoliday: TVpHolidayEvent read FOnHoliday write FOnHoliday;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -293,85 +329,43 @@ uses
|
|||||||
SysUtils, LazUTF8, Dialogs, StrUtils,
|
SysUtils, LazUTF8, Dialogs, StrUtils,
|
||||||
VpMonthViewPainter;
|
VpMonthViewPainter;
|
||||||
|
|
||||||
|
|
||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
{ TVpMvHeadAttr }
|
{ TVpMonthViewAttr }
|
||||||
|
(*****************************************************************************)
|
||||||
constructor TVpMvHeadAttr.Create(AOwner: TVpMonthView);
|
constructor TVpMonthViewAttr.Create(AOwner: TVpMonthView);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FOwner := AOwner;
|
FMonthView := AOwner;
|
||||||
FColor := clBtnFace;
|
FColor := clBtnFace;
|
||||||
FFont := TVpFont.Create(AOwner);
|
FFont := TVpFont.Create(AOwner);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TVpMvHeadAttr.Destroy;
|
destructor TVpMonthViewAttr.Destroy;
|
||||||
begin
|
begin
|
||||||
FFont.Free;
|
FFont.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpMvHeadAttr.SetColor(const Value: TColor);
|
procedure TVpMonthViewAttr.SetColor(AValue: TColor);
|
||||||
begin
|
begin
|
||||||
if FColor <> Value then begin
|
if FColor <> AValue then begin
|
||||||
FColor := Value;
|
FColor := AValue;
|
||||||
FOwner.Invalidate;
|
FMonthView.Invalidate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpMvHeadAttr.SetFont(Value: TVpFont);
|
procedure TVpMonthViewAttr.SetFont(AValue: TVpFont);
|
||||||
begin
|
begin
|
||||||
FFont.Assign(Value);
|
FFont.Assign(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
{ TVpContactHeadAttr }
|
{ TVpMvTodayAttr }
|
||||||
constructor TVpDayHeadAttr.Create(AOwner: TVpMonthView);
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
FMonthView := AOwner;
|
|
||||||
FFont := TVpFont.Create(AOwner);
|
|
||||||
FFont.Assign(FMonthView.Font);
|
|
||||||
FColor := clSilver;
|
|
||||||
end;
|
|
||||||
{=====}
|
|
||||||
|
|
||||||
destructor TVpDayHeadAttr.Destroy;
|
|
||||||
begin
|
|
||||||
FFont.Free;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
{=====}
|
|
||||||
|
|
||||||
procedure TVpDayHeadAttr.SetColor(Value: TColor);
|
|
||||||
begin
|
|
||||||
if Value <> FColor then begin
|
|
||||||
FColor := Value;
|
|
||||||
MonthView.Invalidate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
{=====}
|
|
||||||
|
|
||||||
procedure TVpDayHeadAttr.SetFont(Value: TVpFont);
|
|
||||||
begin
|
|
||||||
if Value <> FFont then begin
|
|
||||||
FFont.Assign(Value);
|
|
||||||
MonthView.Invalidate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
{ TVpMvTodayAttr }
|
|
||||||
|
|
||||||
constructor TVpMvTodayAttr.Create(AOwner: TVpMonthView);
|
constructor TVpMvTodayAttr.Create(AOwner: TVpMonthView);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create(AOwner);
|
||||||
FMonthView := AOwner;
|
|
||||||
FFont := TVpFont.Create(AOwner);
|
|
||||||
FFont.Assign(FMonthView.Font);
|
|
||||||
FColor := clSilver;
|
|
||||||
FBorderPen := TPen.Create;
|
FBorderPen := TPen.Create;
|
||||||
FBorderPen.Color := clRed;
|
FBorderPen.Color := clRed;
|
||||||
FBorderPen.Width := 3;
|
FBorderPen.Width := 3;
|
||||||
@ -381,26 +375,9 @@ end;
|
|||||||
destructor TVpMvTodayAttr.Destroy;
|
destructor TVpMvTodayAttr.Destroy;
|
||||||
begin
|
begin
|
||||||
FBorderPen.Free;
|
FBorderPen.Free;
|
||||||
FFont.Free;
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpMvTodayAttr.SetColor(Value: TColor);
|
|
||||||
begin
|
|
||||||
if Value <> FColor then begin
|
|
||||||
FColor := Value;
|
|
||||||
MonthView.Invalidate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpMvTodayAttr.SetFont(Value: TVpFont);
|
|
||||||
begin
|
|
||||||
if Value <> FFont then begin
|
|
||||||
FFont.Assign(Value);
|
|
||||||
MonthView.Invalidate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpMvTodayAttr.SetBorderPen(Value: TPen);
|
procedure TVpMvTodayAttr.SetBorderPen(Value: TPen);
|
||||||
begin
|
begin
|
||||||
if Value <> FBorderPen then begin
|
if Value <> FBorderPen then begin
|
||||||
@ -411,20 +388,27 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
(*****************************************************************************)
|
(*****************************************************************************)
|
||||||
{ TVpMonthView }
|
{ TVpMonthView }
|
||||||
|
(*****************************************************************************)
|
||||||
constructor TVpMonthView.Create(AOwner: TComponent);
|
constructor TVpMonthView.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
|
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
|
||||||
|
|
||||||
{ Create internal classes and stuff }
|
{ Create internal classes and stuff }
|
||||||
|
FHeadAttr := TVpMonthViewAttr.Create(self);
|
||||||
|
FDayHeadAttr := TVpMonthViewAttr.Create(self);
|
||||||
|
FHolidayAttr := TVpMonthViewAttr.Create(self);
|
||||||
|
FWeekendAttr := TVpMonthviewAttr.Create(self);
|
||||||
|
FTodayAttr := TVpMvTodayAttr.Create(Self);
|
||||||
|
mvSpinButtons := TUpDown.Create(self);
|
||||||
|
{
|
||||||
FHeadAttr := TVpMvHeadAttr.Create(self);
|
FHeadAttr := TVpMvHeadAttr.Create(self);
|
||||||
FDayHeadAttr := TVpDayHeadAttr.Create(self);
|
FDayHeadAttr := TVpDayHeadAttr.Create(self);
|
||||||
FTodayAttr := TVpMvTodayAttr.Create(self);
|
FTodayAttr := TVpMvTodayAttr.Create(self);
|
||||||
// mvEventList := TList.Create;
|
FHolidayAttr := TvpMvHolidayAttr.Create(self);
|
||||||
mvSpinButtons := TUpDown.Create(self);
|
mvSpinButtons := TUpDown.Create(self);
|
||||||
|
}
|
||||||
{ Set styles and initialize internal variables }
|
{ Set styles and initialize internal variables }
|
||||||
{$IFDEF VERSION4}
|
{$IFDEF VERSION4}
|
||||||
DoubleBuffered := true;
|
DoubleBuffered := true;
|
||||||
@ -462,9 +446,19 @@ begin
|
|||||||
{ Assign default font to DayNumberFont and EventFont }
|
{ Assign default font to DayNumberFont and EventFont }
|
||||||
FDayNumberFont := TVpFont.Create(AOwner);
|
FDayNumberFont := TVpFont.Create(AOwner);
|
||||||
FDayNumberFont.Assign(Font);
|
FDayNumberFont.Assign(Font);
|
||||||
|
|
||||||
FEventFont := TVpFont.Create(AOwner);
|
FEventFont := TVpFont.Create(AOwner);
|
||||||
FEventFont.Assign(Font);
|
FEventFont.Assign(Font);
|
||||||
|
|
||||||
FOffDayFontColor := clGray;
|
FOffDayFontColor := clGray;
|
||||||
|
FOffDayColor := OFF_COLOR;
|
||||||
|
|
||||||
|
FHolidayAttr.Font.Assign(FDayNumberFont);
|
||||||
|
FHolidayAttr.Font.Color := clBlack;
|
||||||
|
FHolidayAttr.Color := HOLIDAY_COLOR;
|
||||||
|
|
||||||
|
FWeekendAttr.Font.Assign(FHolidayAttr.Font);
|
||||||
|
FWeekendAttr.Color := WEEKEND_COLOR;
|
||||||
|
|
||||||
SetLength(mvEventArray, MaxVisibleEvents);
|
SetLength(mvEventArray, MaxVisibleEvents);
|
||||||
SetLength(mvMonthdayArray, 45);
|
SetLength(mvMonthdayArray, 45);
|
||||||
@ -485,12 +479,14 @@ destructor TVpMonthView.Destroy;
|
|||||||
begin
|
begin
|
||||||
FreeAndNil(FHintWindow);
|
FreeAndNil(FHintWindow);
|
||||||
FHeadAttr.Free;
|
FHeadAttr.Free;
|
||||||
|
FHolidayAttr.Free;
|
||||||
FTodayAttr.Free;
|
FTodayAttr.Free;
|
||||||
FDayHeadAttr.Free;
|
FDayHeadAttr.Free;
|
||||||
|
FWeekendAttr.Free;
|
||||||
FDayNumberFont.Free;
|
FDayNumberFont.Free;
|
||||||
FEventFont.Free;
|
FEventFont.Free;
|
||||||
mvSpinButtons.Free;
|
// mvSpinButtons.Free;
|
||||||
FDefaultPopup.Free;
|
// FDefaultPopup.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -553,7 +549,14 @@ procedure TVpMonthView.Invalidate;
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
function TVpMonthView.IsHoliday(ADate: TDate; out AHolidayName: String): Boolean;
|
||||||
|
begin
|
||||||
|
AHolidayName := '';
|
||||||
|
if Assigned(FOnHoliday) then
|
||||||
|
FOnHoliday(Self, ADate, AHolidayName);
|
||||||
|
Result := AHolidayName <> '';
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpMonthView.LinkHandler(Sender: TComponent;
|
procedure TVpMonthView.LinkHandler(Sender: TComponent;
|
||||||
NotificationType: TVpNotificationType; const Value: Variant);
|
NotificationType: TVpNotificationType; const Value: Variant);
|
||||||
@ -925,6 +928,8 @@ var
|
|||||||
event: TVpEvent;
|
event: TVpEvent;
|
||||||
list: TList;
|
list: TList;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
|
holiday: String = '';
|
||||||
|
todayDate: TDate;
|
||||||
begin
|
begin
|
||||||
if FHintMode = hmPlannerHint then
|
if FHintMode = hmPlannerHint then
|
||||||
begin
|
begin
|
||||||
@ -934,26 +939,40 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// If the date is a holiday we put the holidayname at the top
|
||||||
|
IsHoliday(ADate, holiday);
|
||||||
|
|
||||||
// Collect all events of this day and add them separated by line feeds to
|
// Collect all events of this day and add them separated by line feeds to
|
||||||
// the hint string (txt).
|
// the hint string (txt).
|
||||||
txt := '';
|
|
||||||
list := TList.Create;
|
list := TList.Create;
|
||||||
|
txt := '';
|
||||||
try
|
try
|
||||||
Datastore.Resource.Schedule.EventsByDate(ADate, List);
|
Datastore.Resource.Schedule.EventsByDate(ADate, List);
|
||||||
for i:=0 to list.Count-1 do begin
|
for i:=0 to list.Count-1 do begin
|
||||||
event := TVpEvent(list[i]);
|
event := TVpEvent(list[i]);
|
||||||
s := BuildEventString(event, true, false);
|
s := BuildEventString(event, true, false);
|
||||||
txt := IfThen(txt = '', s, txt + LineEnding + s);
|
txt := IfThen(txt = '', s, txt + LineEnding + s);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
list.Free;
|
list.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// If we have any events then we put the current date at the top.
|
// If we have any events then we put the current date at the top.
|
||||||
if txt <> '' then begin
|
todayDate := SysUtils.Date();
|
||||||
txt := FormatDateTime('dddddd', ADate) + LineEnding + LineEnding + txt;
|
if (txt = '') and (holiday = '') and (ADate = todayDate) then
|
||||||
if ADate = SysUtils.Date then
|
txt := RSToday + LineEnding + FormatDateTime('ddddd', ADate)
|
||||||
txt := RSToday + LineEnding + txt;
|
else
|
||||||
|
if (txt <> '') or (holiday <> '') then begin
|
||||||
|
if (txt = '') and (holiday <> '') then
|
||||||
|
txt := FormatDateTime('ddddd', ADate) + LineEnding + holiday
|
||||||
|
else begin
|
||||||
|
txt := LineEnding + txt;
|
||||||
|
if holiday <> '' then
|
||||||
|
txt := holiday + LineEnding + txt;
|
||||||
|
txt := FormatDateTime('ddddd', ADate) + LineEnding + txt;
|
||||||
|
if ADate = todayDate then
|
||||||
|
txt := RSToday + LineEnding + txt;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (txt <> '') and not (csDesigning in ComponentState) then
|
if (txt <> '') and not (csDesigning in ComponentState) then
|
||||||
|
@ -30,6 +30,7 @@ type
|
|||||||
TodayFontColor: TColor;
|
TodayFontColor: TColor;
|
||||||
TodayAttrColor: TColor;
|
TodayAttrColor: TColor;
|
||||||
DotDotDotColor: TColor;
|
DotDotDotColor: TColor;
|
||||||
|
FCurrHoliday: String;
|
||||||
|
|
||||||
// protected variables of the original monthview needed only for painting
|
// protected variables of the original monthview needed only for painting
|
||||||
mvEventTextHeight: Integer;
|
mvEventTextHeight: Integer;
|
||||||
@ -41,7 +42,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
procedure DrawBorders;
|
procedure DrawBorders;
|
||||||
procedure DrawDayCell(ADate: TDate; ACol: Integer;
|
procedure DrawDayCell(ADate: TDate; ACol, ARow: Integer;
|
||||||
var AIndex, ADayNumber: Integer; var ATextRect: TRect);
|
var AIndex, ADayNumber: Integer; var ATextRect: TRect);
|
||||||
procedure DrawDayHead;
|
procedure DrawDayHead;
|
||||||
procedure DrawDays;
|
procedure DrawDays;
|
||||||
@ -113,7 +114,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpMonthViewPainter.DrawDayCell(ADate: TDate; ACol: Integer;
|
procedure TVpMonthViewPainter.DrawDayCell(ADate: TDate; ACol, ARow: Integer;
|
||||||
var AIndex, ADayNumber: Integer; var ATextRect: TRect);
|
var AIndex, ADayNumber: Integer; var ATextRect: TRect);
|
||||||
var
|
var
|
||||||
tmpRect: TRect;
|
tmpRect: TRect;
|
||||||
@ -134,10 +135,18 @@ begin
|
|||||||
tmpRect.Bottom := RealBottom;
|
tmpRect.Bottom := RealBottom;
|
||||||
end else
|
end else
|
||||||
tmpRect := ATextRect;
|
tmpRect := ATextRect;
|
||||||
|
if ARow = 0 then
|
||||||
|
inc(tmpRect.Top);
|
||||||
|
|
||||||
if DisplayMonth <> M then begin
|
if FCurrHoliday <> '' then begin
|
||||||
|
RenderCanvas.Brush.Color := FMonthView.HolidayAttributes.Color;
|
||||||
|
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
|
||||||
|
end else if DisplayMonth <> M then begin
|
||||||
RenderCanvas.Brush.Color := RealOffDayColor;
|
RenderCanvas.Brush.Color := RealOffDayColor;
|
||||||
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
|
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
|
||||||
|
end else if DayOfWeek(ADate) in [1, 7] then begin
|
||||||
|
RenderCanvas.Brush.Color := FMonthView.WeekendAttributes.Color;
|
||||||
|
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
|
||||||
end else
|
end else
|
||||||
RenderCanvas.Brush.Color := RealColor;
|
RenderCanvas.Brush.Color := RealColor;
|
||||||
|
|
||||||
@ -157,10 +166,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Paint the day number }
|
{ Prepare the day number as string}
|
||||||
Str := FormatDateTime('d', ADate);
|
Str := FormatDateTime('d', ADate);
|
||||||
|
|
||||||
{ set the proper font and style }
|
{ Set the proper font and style }
|
||||||
if ADate = todayDate then
|
if ADate = todayDate then
|
||||||
RenderCanvas.Font.Assign(FMonthView.TodayAttributes.Font)
|
RenderCanvas.Font.Assign(FMonthView.TodayAttributes.Font)
|
||||||
else
|
else
|
||||||
@ -204,6 +213,8 @@ begin
|
|||||||
RenderCanvas.Font.Style := FontStyle;
|
RenderCanvas.Font.Style := FontStyle;
|
||||||
if DisplayMonth <> M then
|
if DisplayMonth <> M then
|
||||||
RenderCanvas.Font.Color := FMonthView.OffDayFontColor;
|
RenderCanvas.Font.Color := FMonthView.OffDayFontColor;
|
||||||
|
if FCurrHoliday <> '' then
|
||||||
|
RenderCanvas.Font.Assign(FMonthView.HolidayAttributes.Font);
|
||||||
|
|
||||||
{ Calculate size of rect for the day number at the top of the TextRect. }
|
{ Calculate size of rect for the day number at the top of the TextRect. }
|
||||||
if ACol = 6 then
|
if ACol = 6 then
|
||||||
@ -433,6 +444,9 @@ begin
|
|||||||
for Col := 0 to 6 do begin
|
for Col := 0 to 6 do begin
|
||||||
ThisDate := Trunc(StartingDate + DayNumber);
|
ThisDate := Trunc(StartingDate + DayNumber);
|
||||||
|
|
||||||
|
{ Check and store if the this date is a holiday }
|
||||||
|
FMonthView.IsHoliday(ThisDate, FCurrHoliday);
|
||||||
|
|
||||||
OldBrush.Assign(RenderCanvas.Brush);
|
OldBrush.Assign(RenderCanvas.Brush);
|
||||||
OldPen.Assign(RenderCanvas.Pen);
|
OldPen.Assign(RenderCanvas.Pen);
|
||||||
OldFont.Assign(RenderCanvas.Font);
|
OldFont.Assign(RenderCanvas.Font);
|
||||||
@ -445,7 +459,7 @@ begin
|
|||||||
if Drawn then
|
if Drawn then
|
||||||
Continue;
|
Continue;
|
||||||
end else
|
end else
|
||||||
DrawDayCell(ThisDate, Col, I, DayNumber, TextRect);
|
DrawDayCell(ThisDate, Col, Row, I, DayNumber, TextRect);
|
||||||
finally
|
finally
|
||||||
RenderCanvas.Brush.Assign(OldBrush);
|
RenderCanvas.Brush.Assign(OldBrush);
|
||||||
RenderCanvas.Pen.Assign(OldPen);
|
RenderCanvas.Pen.Assign(OldPen);
|
||||||
|
Reference in New Issue
Block a user