Add property Cascade (patch by teejaydub - #22989)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2598 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
zoran-vucenovic
2012-12-07 14:56:48 +00:00
parent e4379b1df0
commit 97df6a8d20
2 changed files with 133 additions and 78 deletions

View File

@ -108,6 +108,7 @@ type
accidentally added in first release. }
property DateMode;
property UseDefaultSeparators;
property Cascade;
//events:
property OnChange;
property OnCheckBoxChange;

View File

@ -115,6 +115,7 @@ type
TCustomZVDateTimePicker = class(TCustomControl)
private
FCascade: Boolean;
FCenturyFrom, FEffectiveCenturyFrom: Word;
FDateDisplayOrder: TDateDisplayOrder;
FKind: TDateTimeKind;
@ -341,6 +342,7 @@ type
property Time: TTime read GetTime write SetTime;
property Date: TDate read GetDate write SetDate;
property DateMode: TDTDateMode read FDateMode write SetDateMode;
property Cascade: Boolean read FCascade write FCascade default False;
public
constructor Create(AOwner: TComponent); override;
@ -401,6 +403,7 @@ type
property Date;
property Time;
property UseDefaultSeparators;
property Cascade;
// events:
property OnChange;
property OnCheckBoxChange;
@ -430,6 +433,8 @@ function IsNullDate(DT: TDateTime): Boolean;
implementation
uses DateUtils;
function NumberOfDaysInMonth(const Month, Year: Word): Word;
begin
Result := 0;
@ -2059,6 +2064,9 @@ var
N: Word;
begin
SelectMonth;
if Cascade then
SetDateTime(IncMonth(DateTime))
else begin
YMD := GetYYYYMMDD(True);
if YMD.Month >= 12 then
@ -2071,6 +2079,7 @@ begin
YMD.Day := N;
SetYYYYMMDD(YMD);
end;
end;
procedure TCustomZVDateTimePicker.IncreaseYear;
@ -2092,6 +2101,9 @@ var
YMD: TYMD;
begin
SelectDay;
if Cascade then
SetDateTime(IncDay(DateTime))
else begin
YMD := GetYYYYMMDD(True);
if YMD.Day >= NumberOfDaysInMonth(YMD.Month, YMD.Year) then
@ -2100,6 +2112,7 @@ begin
Inc(YMD.Day);
SetYYYYMMDD(YMD);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseMonth;
@ -2108,6 +2121,9 @@ var
N: Word;
begin
SelectMonth;
if Cascade then
SetDateTime(IncMonth(DateTime, -1))
else begin
YMD := GetYYYYMMDD(True);
if YMD.Month <= 1 then
@ -2120,6 +2136,7 @@ begin
YMD.Day := N;
SetYYYYMMDD(YMD);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseYear;
@ -2139,6 +2156,9 @@ var
YMD: TYMD;
begin
SelectDay;
if Cascade then
SetDateTime(IncDay(DateTime, -1))
else begin
YMD := GetYYYYMMDD(True);
if YMD.Day <= 1 then
@ -2147,6 +2167,7 @@ begin
Dec(YMD.Day);
SetYYYYMMDD(YMD);
end;
end;
procedure TCustomZVDateTimePicker.IncreaseHour;
@ -2154,6 +2175,9 @@ var
HMSMs: THMSMs;
begin
SelectHour;
if Cascade then
SetDateTime(IncHour(DateTime))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Hour >= 23 then
@ -2162,6 +2186,7 @@ begin
Inc(HMSMs.Hour);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.IncreaseMinute;
@ -2169,6 +2194,9 @@ var
HMSMs: THMSMs;
begin
SelectMinute;
if Cascade then
SetDateTime(IncMinute(DateTime))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Minute >= 59 then
@ -2177,6 +2205,7 @@ begin
Inc(HMSMs.Minute);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.IncreaseSecond;
@ -2184,6 +2213,9 @@ var
HMSMs: THMSMs;
begin
SelectSecond;
if Cascade then
SetDateTime(IncSecond(DateTime))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Second >= 59 then
@ -2192,6 +2224,7 @@ begin
Inc(HMSMs.Second);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.IncreaseMiliSec;
@ -2199,6 +2232,9 @@ var
HMSMs: THMSMs;
begin
SelectMiliSec;
if Cascade then
SetDateTime(IncMilliSecond(DateTime))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.MiliSec >= 999 then
@ -2207,6 +2243,7 @@ begin
Inc(HMSMs.MiliSec);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseHour;
@ -2214,6 +2251,9 @@ var
HMSMs: THMSMs;
begin
SelectHour;
if Cascade then
SetDateTime(IncHour(DateTime, -1))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Hour <= 0 then
@ -2222,6 +2262,7 @@ begin
Dec(HMSMs.Hour);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseMinute;
@ -2229,6 +2270,9 @@ var
HMSMs: THMSMs;
begin
SelectMinute;
if Cascade then
SetDateTime(IncMinute(DateTime, -1))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Minute <= 0 then
@ -2237,6 +2281,7 @@ begin
Dec(HMSMs.Minute);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseSecond;
@ -2244,6 +2289,9 @@ var
HMSMs: THMSMs;
begin
SelectSecond;
if Cascade then
SetDateTime(IncSecond(DateTime, -1))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.Second <= 0 then
@ -2252,6 +2300,7 @@ begin
Dec(HMSMs.Second);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.DecreaseMiliSec;
@ -2259,6 +2308,9 @@ var
HMSMs: THMSMs;
begin
SelectMiliSec;
if Cascade then
SetDateTime(IncMilliSecond(DateTime, -1))
else begin
HMSMs := GetHMSMs(True);
if HMSMs.MiliSec <= 0 then
@ -2267,6 +2319,7 @@ begin
Dec(HMSMs.MiliSec);
SetHMSMs(HMSMs);
end;
end;
procedure TCustomZVDateTimePicker.ChangeAMPM;
@ -3253,6 +3306,7 @@ begin
FTextEnabled := True;
FCalendarForm := nil;
FDoNotArrangeControls := True;
FCascade := False;
AdjustEffectiveDateDisplayOrder;