CalLite: Enforce redrawing of control when font changes.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6957 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-05-27 08:38:15 +00:00
parent ff899abd44
commit 99e1ca4940

View File

@ -268,6 +268,7 @@ type
const AXProportion, AYProportion: Double); override; const AXProportion, AYProportion: Double); override;
{$endif} {$endif}
procedure DblClick; override; procedure DblClick; override;
procedure FontChanged(Sender: TObject); override;
class function GetControlClassDefaultSize: TSize; override; class function GetControlClassDefaultSize: TSize; override;
procedure InternalClick; procedure InternalClick;
procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override;
@ -754,6 +755,7 @@ begin
if not Assigned(FCanvas) then Exit; if not Assigned(FCanvas) then Exit;
DecodeDate(FOwner.FDate, FThisYear, FThisMonth, FThisDay); DecodeDate(FOwner.FDate, FThisYear, FThisMonth, FThisDay);
CalcSettings; CalcSettings;
FCanvas.Font.Assign(FOwner.Font);
DrawBackground; DrawBackground;
DrawTopRow; DrawTopRow;
DrawDayLabels; DrawDayLabels;
@ -905,7 +907,7 @@ begin
begin begin
FCanvas.Font.Color := FOwner.Colors.HolidayColor; FCanvas.Font.Color := FOwner.Colors.HolidayColor;
if coBoldHolidays in FOwner.Options then if coBoldHolidays in FOwner.Options then
FCanvas.Font.Style := [fsBold]; FCanvas.Font.Style := FCanvas.Font.Style + [fsBold];
end else end else
{ Special case: override weekend } { Special case: override weekend }
if (coShowWeekend in FOwner.Options) and if (coShowWeekend in FOwner.Options) and
@ -913,21 +915,21 @@ begin
begin begin
FCanvas.Font.Color := FOwner.Colors.WeekendColor; FCanvas.Font.Color := FOwner.Colors.WeekendColor;
if coBoldWeekend in FOwner.Options then if coBoldWeekend in FOwner.Options then
FCanvas.Font.Style := [fsBold]; FCanvas.Font.Style := FCanvas.Font.Style + [fsBold];
end; end;
end else end else
begin begin
{ color of days from previous and next months } { color of days from previous and next months }
FCanvas.Font.Color:= FOwner.Colors.PastMonthColor; FCanvas.Font.Color := FOwner.Colors.PastMonthColor;
Include(state, csOtherMonth); Include(state, csOtherMonth);
end; end;
{ Set default background color } { Set default background color }
if FOwner.IsSelected(dt) then begin if FOwner.IsSelected(dt) then begin
FCanvas.Brush.Color:= FOwner.FColors.SelectedDateColor; FCanvas.Brush.Color := FOwner.FColors.SelectedDateColor;
Include(state, csSelectedDay); Include(state, csSelectedDay);
end else end else
FCanvas.Brush.Color:= FOwner.Colors.BackgroundColor; FCanvas.Brush.Color := FOwner.Colors.BackgroundColor;
{ Set border pen of "today" cell } { Set border pen of "today" cell }
if (dt = todayDate) and (coShowTodayFrame in FOwner.Options) then if (dt = todayDate) and (coShowTodayFrame in FOwner.Options) then
@ -993,9 +995,9 @@ var
begin begin
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 := [fsBold] FCanvas.Font.Style := FCanvas.Font.Style + [fsBold]
else else
FCanvas.Font.Style := []; FCanvas.Font.Style := FCanvas.Font.Style - [fsBold];
map := Integer(FOwner.FStartingDayOfWeek); map := Integer(FOwner.FStartingDayOfWeek);
for c:= Low(TWeekNameArray) to High(TWeekNameArray) do for c:= Low(TWeekNameArray) to High(TWeekNameArray) do
begin begin
@ -1037,8 +1039,8 @@ begin
FCanvas.Font.Color:= FOwner.Colors.TextColor; FCanvas.Font.Color:= FOwner.Colors.TextColor;
if coBoldToday in FOwner.Options then if coBoldToday in FOwner.Options then
FCanvas.Font.Style := [fsBold] else FCanvas.Font.Style := FCanvas.Font.Style + [fsBold] else
FCanvas.Font.Style := []; FCanvas.Font.Style := FCanvas.Font.Style - [fsBold];
s:= FOwner.GetDisplayText(dtToday); s:= FOwner.GetDisplayText(dtToday);
if pos('%s', s) = 0 then begin if pos('%s', s) = 0 then begin
@ -1090,18 +1092,18 @@ var
dt: TDateTime; dt: TDateTime;
begin begin
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;
r := GetCellAtColRow(GetLeftColIndex, TopRow); r := GetCellAtColRow(GetLeftColIndex, TopRow);
r.Right := GetCellAtColRow(GetRightColIndex, TopRow).Right; r.Right := GetCellAtColRow(GetRightColIndex, TopRow).Right;
FCanvas.FillRect(r); FCanvas.FillRect(r);
end else end else
if (FCanvas.Font.Color <> FOwner.Colors.TextColor) then if (FCanvas.Font.Color <> FOwner.Colors.TextColor) then
FCanvas.Font.Color:= FOwner.Colors.TextColor; FCanvas.Font.Color := FOwner.Colors.TextColor;
if (coBoldTopRow in FOwner.Options) then if (coBoldTopRow in FOwner.Options) then
FCanvas.Font.Style := [fsBold] FCanvas.Font.Style := FCanvas.Font.Style + [fsBold]
else else
FCanvas.Font.Style := []; FCanvas.Font.Style := FCanvas.Font.Style - [fsBold];
case (FOwner.BiDiMode = bdLeftToRight) of case (FOwner.BiDiMode = bdLeftToRight) of
False: begin False: begin
@ -1590,6 +1592,12 @@ begin
Invalidate; Invalidate;
end; end;
procedure TCalendarLite.FontChanged(Sender: TObject);
begin
inherited;
Draw;
end;
class function TCalendarLite.GetControlClassDefaultSize: TSize; class function TCalendarLite.GetControlClassDefaultSize: TSize;
begin begin
{$ifdef lcl_scaling} {$ifdef lcl_scaling}