You've already forked lazarus-ccr
tvplanit: Refactor of dayview painting (preps)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4910 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -62,6 +62,9 @@ const
|
|||||||
HoursInDay = 24; { Number of hours in a day }
|
HoursInDay = 24; { Number of hours in a day }
|
||||||
MinutesInHour = 60; { Number of minutes in an hour }
|
MinutesInHour = 60; { Number of minutes in an hour }
|
||||||
MinutesInDay = 1440; { Number of minutes in a day }
|
MinutesInDay = 1440; { Number of minutes in a day }
|
||||||
|
OneSecond = 1.0 / SecondsInDay;
|
||||||
|
OneMinute = 1.0 / MinutesInDay;
|
||||||
|
OneHour = 1.0 / HoursInDay;
|
||||||
MaxDateLen = 40; { maximum length of date picture strings }
|
MaxDateLen = 40; { maximum length of date picture strings }
|
||||||
MaxMonthName = 15; { maximum length for month names }
|
MaxMonthName = 15; { maximum length for month names }
|
||||||
MaxDayName = 15; { maximum length for day names }
|
MaxDayName = 15; { maximum length for day names }
|
||||||
|
@ -103,6 +103,8 @@ function MonthOfTheYear(TheDate: TDateTime): Word;
|
|||||||
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
||||||
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
||||||
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
|
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
|
||||||
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
|
|
||||||
function GetJulianDate(Date: TDateTime): Word;
|
function GetJulianDate(Date: TDateTime): Word;
|
||||||
@ -127,11 +129,14 @@ function EncodeLineEndings(const AText: String): String;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF LCL}
|
||||||
|
DateUtils,
|
||||||
|
{$ENDIF}
|
||||||
VpException, VpSR;
|
VpException, VpSR;
|
||||||
|
|
||||||
procedure StripString(var Str: string);
|
procedure StripString(var Str: string);
|
||||||
begin
|
begin
|
||||||
if Length (Str) < 1 then
|
if Length(Str) < 1 then
|
||||||
Exit;
|
Exit;
|
||||||
while (Length(Str) > 0) and (not (Str[1] in ['A'..'Z', 'a'..'z', '0'..'9'])) do
|
while (Length(Str) > 0) and (not (Str[1] in ['A'..'Z', 'a'..'z', '0'..'9'])) do
|
||||||
delete(Str, 1, 1);
|
delete(Str, 1, 1);
|
||||||
@ -368,20 +373,20 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{$IFDEF DELPHI} {$IFNDEF Delphi6}
|
{$IFDEF DELPHI} {$IFNDEF Delphi6}
|
||||||
function MonthOfTheYear (TheDate : TDateTime) : Word;
|
function MonthOfTheYear(TheDate: TDateTime): Word;
|
||||||
var
|
var
|
||||||
Year, Day: Word;
|
Year, Day: Word;
|
||||||
begin
|
begin
|
||||||
DecodeDate (TheDate, Year, Result, Day);
|
DecodeDate(TheDate, Year, Result, Day);
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
procedure IncAMonth (var Year, Month, Day : Word; NumMonths : Integer);
|
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
||||||
type
|
type
|
||||||
PMonthDayTable = ^TMonthDayTable;
|
PMonthDayTable = ^TMonthDayTable;
|
||||||
TMonthDayTable = array[1..12] of Word;
|
TMonthDayTable = array[1..12] of Word;
|
||||||
const
|
const
|
||||||
MonthDays: array [Boolean] of TMonthDayTable =
|
MonthDays: array[Boolean] of TMonthDayTable =
|
||||||
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
|
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
|
||||||
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
|
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
|
||||||
var
|
var
|
||||||
@ -392,34 +397,45 @@ begin
|
|||||||
Sign := 1
|
Sign := 1
|
||||||
else
|
else
|
||||||
Sign := -1;
|
Sign := -1;
|
||||||
Year := Year + (NumMonths div 12);
|
Year := Year + NumMonths div 12;
|
||||||
NumMonths := NumMonths mod 12;
|
NumMonths := NumMonths mod 12;
|
||||||
Inc (Month, NumMonths);
|
Inc (Month, NumMonths);
|
||||||
if Word (Month-1) > 11 then
|
if Word(Month-1) > 11 then
|
||||||
begin
|
begin
|
||||||
Inc (Year, Sign);
|
Inc(Year, Sign);
|
||||||
Inc (Month, -12 * Sign);
|
Inc(Month, -12 * Sign);
|
||||||
end;
|
end;
|
||||||
DayTable := @MonthDays[IsLeapYear (Year)];
|
DayTable := @MonthDays[IsLeapYear(Year)];
|
||||||
if Day > DayTable^[Month] then
|
if Day > DayTable^[Month] then
|
||||||
Day := DayTable^[Month];
|
Day := DayTable^[Month];
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
function IncMonth(const TheDate : TDateTime; NumberOfMonths : Integer) : TDateTime;
|
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
||||||
var
|
var
|
||||||
Year, Month, Day : Word;
|
Year, Month, Day: Word;
|
||||||
begin
|
begin
|
||||||
DecodeDate (TheDate, Year, Month, Day);
|
DecodeDate(TheDate, Year, Month, Day);
|
||||||
IncAMonth (Year, Month, Day, NumberOfMonths);
|
IncAMonth(Year, Month, Day, NumberOfMonths);
|
||||||
Result := EncodeDate (Year, Month, Day);
|
Result := EncodeDate(Year, Month, Day);
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
function IncYear (TheDate : TDateTime; NumYears : Integer) : TDateTime;
|
function IncYea (TheDate: TDateTime; NumYear : Integer) : TDateTime;
|
||||||
begin
|
begin
|
||||||
Result := IncMonth (TheDate, NumYears * 12);
|
Result := IncMont (TheDate, NumYears * 12);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
begin
|
||||||
|
Result := trunc(ADateTime);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
begin
|
||||||
|
Result := frac(ADateTime);
|
||||||
|
end;
|
||||||
|
|
||||||
{=====}
|
{=====}
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
|
|
||||||
@ -455,7 +471,7 @@ var
|
|||||||
Time: Double;
|
Time: Double;
|
||||||
begin
|
begin
|
||||||
{ remove the date part, and add one minute to the time }
|
{ remove the date part, and add one minute to the time }
|
||||||
Time := frac(StartTime) + 1 / MinutesInDay;
|
Time := TimeOf(StartTime) + OneMinute;
|
||||||
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
||||||
result := trunc(Time / LineDuration);
|
result := trunc(Time / LineDuration);
|
||||||
end;
|
end;
|
||||||
@ -467,7 +483,7 @@ var
|
|||||||
Time: Double;
|
Time: Double;
|
||||||
begin
|
begin
|
||||||
{ remove the date part, and subtract one minute from the time }
|
{ remove the date part, and subtract one minute from the time }
|
||||||
Time := frac(EndTime) - 1 / MinutesInDay;
|
Time := TimeOf(EndTime) - OneMinute;
|
||||||
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
||||||
result := trunc(Time / LineDuration);
|
result := trunc(Time / LineDuration);
|
||||||
end;
|
end;
|
||||||
@ -478,8 +494,8 @@ function GetAlarmAdvanceTime(Advance: Integer;
|
|||||||
begin
|
begin
|
||||||
result := 0.0;
|
result := 0.0;
|
||||||
case AdvanceType of
|
case AdvanceType of
|
||||||
atMinutes : result := Advance / MinutesInDay;
|
atMinutes : result := Advance * OneMinute;
|
||||||
atHours : result := Advance * 60 / MinutesInDay;
|
atHours : result := Advance * OneHour;
|
||||||
atDays : result := Advance;
|
atDays : result := Advance;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -691,17 +691,17 @@ begin
|
|||||||
if PageNum < FPageInfo.Count then
|
if PageNum < FPageInfo.Count then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
if not Assigned (FControlLink) then
|
if not Assigned(FControlLink) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
if not Assigned (FControlLink.Printer) then
|
if not Assigned(FControlLink.Printer) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
i := FPageInfo.Count - 1;
|
i := FPageInfo.Count - 1;
|
||||||
LastPage := False;
|
LastPage := False;
|
||||||
|
|
||||||
if FPageInfo.Count = 0 then begin
|
if FPageInfo.Count = 0 then begin
|
||||||
GetMem(PPageInfo, SizeOf (TVpPageInfo));
|
GetMem(PPageInfo, SizeOf(TVpPageInfo));
|
||||||
PPageInfo.Date := StartDate;
|
PPageInfo.Date := StartDate;
|
||||||
PPageInfo.Contact := 0;
|
PPageInfo.Contact := 0;
|
||||||
PPageInfo.Task := 0;
|
PPageInfo.Task := 0;
|
||||||
|
Reference in New Issue
Block a user