You've already forked lazarus-ccr
CalLite: Add new options coShowDayNames and coShowTopLine.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6958 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -24,12 +24,10 @@ object Form1: TForm1
|
|||||||
Height = 384
|
Height = 384
|
||||||
Top = 40
|
Top = 40
|
||||||
Width = 160
|
Width = 160
|
||||||
AutoFill = True
|
AutoFill = False
|
||||||
Caption = 'Set calendar Options'
|
Caption = 'Set calendar Options'
|
||||||
ChildSizing.LeftRightSpacing = 6
|
ChildSizing.LeftRightSpacing = 6
|
||||||
ChildSizing.TopBottomSpacing = -1
|
ChildSizing.TopBottomSpacing = -1
|
||||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
|
||||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
|
||||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
@ -49,12 +47,14 @@ object Form1: TForm1
|
|||||||
'coShowTodayName'
|
'coShowTodayName'
|
||||||
'coShowTodayRow'
|
'coShowTodayRow'
|
||||||
'coShowWeekend'
|
'coShowWeekend'
|
||||||
|
'coShowDayNames'
|
||||||
|
'coShowTopRow'
|
||||||
'coUseTopRowColors'
|
'coUseTopRowColors'
|
||||||
)
|
)
|
||||||
OnItemClick = cgOptionsItemClick
|
OnItemClick = cgOptionsItemClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Data = {
|
Data = {
|
||||||
0D00000002020202020202020202020202
|
0F000000020202020202020202020202020202
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
object cbUseHolidays: TCheckBox
|
object cbUseHolidays: TCheckBox
|
||||||
@ -120,11 +120,9 @@ object Form1: TForm1
|
|||||||
Height = 216
|
Height = 216
|
||||||
Top = 208
|
Top = 208
|
||||||
Width = 160
|
Width = 160
|
||||||
AutoFill = True
|
AutoFill = False
|
||||||
Caption = 'Language to use'
|
Caption = 'Language to use'
|
||||||
ChildSizing.LeftRightSpacing = 6
|
ChildSizing.LeftRightSpacing = 6
|
||||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
|
||||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
|
||||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
@ -152,11 +150,9 @@ object Form1: TForm1
|
|||||||
Height = 160
|
Height = 160
|
||||||
Top = 40
|
Top = 40
|
||||||
Width = 160
|
Width = 160
|
||||||
AutoFill = True
|
AutoFill = False
|
||||||
Caption = 'Starting day of the week'
|
Caption = 'Starting day of the week'
|
||||||
ChildSizing.LeftRightSpacing = 6
|
ChildSizing.LeftRightSpacing = 6
|
||||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
|
||||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
|
||||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
|
@ -295,7 +295,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.cgOptionsItemClick(Sender: TObject; Index: integer);
|
procedure TForm1.cgOptionsItemClick(Sender: TObject; Index: integer);
|
||||||
var opt: TCalOption;
|
var
|
||||||
|
opt: TCalOption;
|
||||||
begin
|
begin
|
||||||
opt := TCalOption(Index);
|
opt := TCalOption(Index);
|
||||||
if (opt in demoCal.Options) then
|
if (opt in demoCal.Options) then
|
||||||
|
@ -88,7 +88,8 @@ type
|
|||||||
TCalOption = (coBoldDayNames, coBoldHolidays, coBoldToday, coBoldTopRow,
|
TCalOption = (coBoldDayNames, coBoldHolidays, coBoldToday, coBoldTopRow,
|
||||||
coBoldWeekend, coDayLine, coShowBorder, coShowHolidays,
|
coBoldWeekend, coDayLine, coShowBorder, coShowHolidays,
|
||||||
coShowTodayFrame, coShowTodayName, coShowTodayRow,
|
coShowTodayFrame, coShowTodayName, coShowTodayRow,
|
||||||
coShowWeekend, coUseTopRowColors);
|
coShowWeekend, coShowDayNames, coShowTopRow, coUseTopRowColors
|
||||||
|
);
|
||||||
TCalOptions = set of TCalOption;
|
TCalOptions = set of TCalOption;
|
||||||
|
|
||||||
TCalDateArray = array of TDate;
|
TCalDateArray = array of TDate;
|
||||||
@ -135,6 +136,7 @@ type
|
|||||||
FColPositions: TColArray;
|
FColPositions: TColArray;
|
||||||
FOwner: TCalendarLite;
|
FOwner: TCalendarLite;
|
||||||
FRowPositions: TRowArray;
|
FRowPositions: TRowArray;
|
||||||
|
FLastRow: Integer;
|
||||||
FStartDate: TDateTime;
|
FStartDate: TDateTime;
|
||||||
FThisDay: word;
|
FThisDay: word;
|
||||||
FThisMonth: word;
|
FThisMonth: word;
|
||||||
@ -362,7 +364,8 @@ type
|
|||||||
property MultiSelect: Boolean read FMultiSelect write SetMultiSelect
|
property MultiSelect: Boolean read FMultiSelect write SetMultiSelect
|
||||||
default false;
|
default false;
|
||||||
property Options: TCalOptions read FOptions write SetOptions
|
property Options: TCalOptions read FOptions write SetOptions
|
||||||
default [coShowTodayFrame, coBoldHolidays, coShowWeekend, coShowHolidays, coShowTodayRow];
|
default [coShowTodayFrame, coBoldHolidays, coShowWeekend, coShowHolidays,
|
||||||
|
coShowTodayRow, coShowDayNames, coShowTopRow];
|
||||||
property StartingDayOfWeek: TDayOfWeek read FStartingDayOfWeek
|
property StartingDayOfWeek: TDayOfWeek read FStartingDayOfWeek
|
||||||
write SetStartingDayOfWeek default dowSunday;
|
write SetStartingDayOfWeek default dowSunday;
|
||||||
property WeekendDays: TDaysOfWeek read FWeekendDays
|
property WeekendDays: TDaysOfWeek read FWeekendDays
|
||||||
@ -430,7 +433,6 @@ const
|
|||||||
FirstDateRow = 2;
|
FirstDateRow = 2;
|
||||||
LastDateRow = 7;
|
LastDateRow = 7;
|
||||||
TodayRow = 8;
|
TodayRow = 8;
|
||||||
LastRow: word = 0;
|
|
||||||
DefCalHeight = 160;
|
DefCalHeight = 160;
|
||||||
DefCalWidth = 210;
|
DefCalWidth = 210;
|
||||||
DefMinHeight = 120;
|
DefMinHeight = 120;
|
||||||
@ -695,6 +697,7 @@ var
|
|||||||
ch: Integer = 0;
|
ch: Integer = 0;
|
||||||
sp: Integer = 0;
|
sp: Integer = 0;
|
||||||
cw: Integer = 0;
|
cw: Integer = 0;
|
||||||
|
cy: Integer = 0;
|
||||||
bit: integer = 0;
|
bit: integer = 0;
|
||||||
i, cellWidths, totalSpace, cellHeights,
|
i, cellWidths, totalSpace, cellHeights,
|
||||||
adjSpace, borderh, borderv, numRows: integer;
|
adjSpace, borderh, borderv, numRows: integer;
|
||||||
@ -706,10 +709,10 @@ begin
|
|||||||
FTextStyle.RightToLeft:= True;
|
FTextStyle.RightToLeft:= True;
|
||||||
SetLength(FRowPositions, 0);
|
SetLength(FRowPositions, 0);
|
||||||
if (coShowTodayRow in FOwner.Options) then
|
if (coShowTodayRow in FOwner.Options) then
|
||||||
LastRow := TodayRow
|
FLastRow := TodayRow
|
||||||
else
|
else
|
||||||
LastRow := LastDateRow;
|
FLastRow := LastDateRow;
|
||||||
SetLength(FRowPositions, LastRow+1);
|
SetLength(FRowPositions, FLastRow+1);
|
||||||
|
|
||||||
totalspace := Succ(LastCol)*3;
|
totalspace := Succ(LastCol)*3;
|
||||||
sz := Size(FBoundsRect);
|
sz := Size(FBoundsRect);
|
||||||
@ -724,13 +727,15 @@ begin
|
|||||||
False : FColPositions[8-i]:= borderh + Pred(i)*cw + hSpc*i;
|
False : FColPositions[8-i]:= borderh + Pred(i)*cw + hSpc*i;
|
||||||
True : FColPositions[i]:= borderh + Pred(i)*cw + hSpc*i;
|
True : FColPositions[i]:= borderh + Pred(i)*cw + hSpc*i;
|
||||||
end;
|
end;
|
||||||
case LastRow of
|
|
||||||
|
case FLastRow of
|
||||||
LastDateRow : totalSpace := 12;
|
LastDateRow : totalSpace := 12;
|
||||||
TodayRow : totalSpace := 14;
|
TodayRow : totalSpace := 14;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
cellHeights := sz.cy - totalSpace;
|
cellHeights := sz.cy - totalSpace;
|
||||||
numRows := Succ(LastRow);
|
numRows := Succ(FLastRow);
|
||||||
|
if not (coShowDayNames in FOwner.Options) then dec(numRows);
|
||||||
|
if not (coShowTopRow in FOwner.Options) then dec(numRows);
|
||||||
DivMod(cellHeights, numRows, ch, rem);
|
DivMod(cellHeights, numRows, ch, rem);
|
||||||
FCellSize.cy := ch;
|
FCellSize.cy := ch;
|
||||||
adjSpace := sz.cy - numRows*ch;
|
adjSpace := sz.cy - numRows*ch;
|
||||||
@ -740,13 +745,16 @@ begin
|
|||||||
if (borderv = 0) then
|
if (borderv = 0) then
|
||||||
bit := rem + 1;
|
bit := rem + 1;
|
||||||
rem := sp shl 1;
|
rem := sp shl 1;
|
||||||
cw := bit + borderv + rem;
|
cy := bit + borderv + rem;
|
||||||
FRowPositions[TopRow] := cw;
|
FRowPositions[TopRow] := cy;
|
||||||
inc(cw, rem);
|
if coShowTopRow in FOwner.Options then inc(cy, rem + ch);
|
||||||
FRowPositions[DayRow] := cw + ch;
|
FRowPositions[DayRow] := cy;
|
||||||
for i := FirstDateRow to LastDateRow do
|
if coShowDayNames in FOwner.Options then inc(cy, ch);
|
||||||
FRowPositions[i] := cw + i*ch + (i-1)*sp;
|
for i := FirstDateRow to LastDateRow do begin
|
||||||
if (LastRow = TodayRow) then
|
FRowPositions[i] := cy;
|
||||||
|
inc(cy, ch + sp);
|
||||||
|
end;
|
||||||
|
if (FLastRow = TodayRow) then
|
||||||
FRowPositions[TodayRow] := FRowPositions[LastDateRow] + borderv + ch + rem;
|
FRowPositions[TodayRow] := FRowPositions[LastDateRow] + borderv + ch + rem;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -993,6 +1001,9 @@ var
|
|||||||
rec: TRect;
|
rec: TRect;
|
||||||
lbls: TWeekNameArray;
|
lbls: TWeekNameArray;
|
||||||
begin
|
begin
|
||||||
|
if not (coShowDayNames in FOwner.Options) then
|
||||||
|
exit;
|
||||||
|
|
||||||
FCanvas.Font.Color:= FOwner.Colors.TextColor;
|
FCanvas.Font.Color:= FOwner.Colors.TextColor;
|
||||||
if (coBoldDayNames in FOwner.Options) then
|
if (coBoldDayNames in FOwner.Options) then
|
||||||
FCanvas.Font.Style := FCanvas.Font.Style + [fsBold]
|
FCanvas.Font.Style := FCanvas.Font.Style + [fsBold]
|
||||||
@ -1026,9 +1037,10 @@ var
|
|||||||
s: String;
|
s: String;
|
||||||
ds: String;
|
ds: String;
|
||||||
begin
|
begin
|
||||||
if (LastRow <> TodayRow) then Exit;
|
if (FLastRow <> TodayRow) then
|
||||||
r1 := GetCellAtColRow(2, TodayRow);
|
exit;
|
||||||
|
|
||||||
|
r1 := GetCellAtColRow(2, TodayRow);
|
||||||
if coUseTopRowColors in FOwner.Options then begin
|
if coUseTopRowColors in FOwner.Options then begin
|
||||||
if (FCanvas.Font.Color <> FOwner.Colors.TopRowTextColor)
|
if (FCanvas.Font.Color <> FOwner.Colors.TopRowTextColor)
|
||||||
then FCanvas.Font.Color:= FOwner.Colors.TopRowTextColor;
|
then FCanvas.Font.Color:= FOwner.Colors.TopRowTextColor;
|
||||||
@ -1065,13 +1077,14 @@ begin
|
|||||||
Dec(r1.Right, halfRem);
|
Dec(r1.Right, halfRem);
|
||||||
rem := 0;
|
rem := 0;
|
||||||
end;
|
end;
|
||||||
r2:= r1;
|
r2 := r1;
|
||||||
|
|
||||||
r1.Left := r1.Left + halfRem;
|
r1.Left := r1.Left + halfRem;
|
||||||
r1.Right := r1.Left + w1;
|
r1.Right := r1.Left + w1;
|
||||||
InflateRect(r1, 0, -FCellSize.cy div 5);
|
InflateRect(r1, 0, -FCellSize.cy div 5);
|
||||||
if (FCanvas.Pen.Color <> FOwner.Colors.TodayFrameColor) then
|
if (FCanvas.Pen.Color <> FOwner.Colors.TodayFrameColor) then
|
||||||
FCanvas.Pen.Color := FOwner.Colors.TodayFrameColor;
|
FCanvas.Pen.Color := FOwner.Colors.TodayFrameColor;
|
||||||
|
FCanvas.Pen.Style := psSolid;
|
||||||
FCanvas.Pen.Width := 2;
|
FCanvas.Pen.Width := 2;
|
||||||
FCanvas.Frame(r1);
|
FCanvas.Frame(r1);
|
||||||
FCanvas.Pen.Width := 1;
|
FCanvas.Pen.Width := 1;
|
||||||
@ -1091,6 +1104,9 @@ var
|
|||||||
s: String;
|
s: String;
|
||||||
dt: TDateTime;
|
dt: TDateTime;
|
||||||
begin
|
begin
|
||||||
|
if not (coShowTopRow in FOwner.Options) then
|
||||||
|
exit;
|
||||||
|
|
||||||
if coUseTopRowColors in FOwner.Options then begin
|
if coUseTopRowColors in FOwner.Options then begin
|
||||||
FCanvas.Font.Color := FOwner.Colors.TopRowTextColor;
|
FCanvas.Font.Color := FOwner.Colors.TopRowTextColor;
|
||||||
FCanvas.Brush.Color := FOwner.Colors.TopRowColor;
|
FCanvas.Brush.Color := FOwner.Colors.TopRowColor;
|
||||||
@ -1233,8 +1249,8 @@ end;
|
|||||||
|
|
||||||
function TCalDrawer.GetColRowPosition(aCol, aRow: integer): TSize;
|
function TCalDrawer.GetColRowPosition(aCol, aRow: integer): TSize;
|
||||||
begin
|
begin
|
||||||
Result.cy:= FRowPositions[aRow];
|
Result.cy := FRowPositions[aRow];
|
||||||
Result.cx:= FColPositions[aCol];
|
Result.cx := FColPositions[aCol];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCalDrawer.GetDateOfCell(ACell: TSize): TDate;
|
function TCalDrawer.GetDateOfCell(ACell: TSize): TDate;
|
||||||
@ -1449,7 +1465,7 @@ begin
|
|||||||
FDblClickTimer.OnTimer := @TimerExpired;
|
FDblClickTimer.OnTimer := @TimerExpired;
|
||||||
FWeekendDays := [dowSunday, dowSaturday];
|
FWeekendDays := [dowSunday, dowSaturday];
|
||||||
FOptions := [coShowTodayFrame, coBoldHolidays, coShowWeekend, coShowHolidays,
|
FOptions := [coShowTodayFrame, coBoldHolidays, coShowWeekend, coShowHolidays,
|
||||||
coShowTodayRow];
|
coShowTodayRow, coShowDayNames, coShowTopRow];
|
||||||
SetLanguage(lgEnglish);
|
SetLanguage(lgEnglish);
|
||||||
FPrevMouseDate := 0;
|
FPrevMouseDate := 0;
|
||||||
Date := SysUtils.Date;
|
Date := SysUtils.Date;
|
||||||
@ -2140,14 +2156,14 @@ end;
|
|||||||
|
|
||||||
procedure TCalendarLite.SetOptions(AValue: TCalOptions);
|
procedure TCalendarLite.SetOptions(AValue: TCalOptions);
|
||||||
begin
|
begin
|
||||||
if FOptions = AValue then Exit;
|
//if FOptions = AValue then Exit;
|
||||||
FOptions := AValue;
|
FOptions := AValue;
|
||||||
case (coShowTodayRow in FOptions) of
|
case (coShowTodayRow in FOptions) of
|
||||||
False: if LastRow <> LastDateRow then LastRow := LastDateRow;
|
False: if FCalDrawer.FLastRow <> LastDateRow then FCalDrawer.FLastRow := LastDateRow;
|
||||||
True : if LastRow <> TodayRow then LastRow := TodayRow;
|
True : if FCalDrawer.FLastRow <> TodayRow then FCalDrawer.FLastRow := TodayRow;
|
||||||
end;
|
end;
|
||||||
if Length(FCalDrawer.FRowPositions) <> LastRow+1 then
|
if High(FCalDrawer.FRowPositions) <> FCalDrawer.FLastRow then
|
||||||
SetLength(FCalDrawer.FRowPositions, LastRow+1);
|
SetLength(FCalDrawer.FRowPositions, FCalDrawer.FLastRow+1);
|
||||||
Draw;
|
Draw;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user