You've already forked lazarus-ccr
tvplanit: Highlight selected day in WeekView (bold). Display holiday name in WeekView's day caption.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5201 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -101,8 +101,6 @@ type
|
|||||||
procedure DrawRowHeaderBackground(R: TRect);
|
procedure DrawRowHeaderBackground(R: TRect);
|
||||||
procedure DrawRowHeaderLabels(R: TRect);
|
procedure DrawRowHeaderLabels(R: TRect);
|
||||||
procedure DrawRowHeaderTicks(R: TRect);
|
procedure DrawRowHeaderTicks(R: TRect);
|
||||||
function FixDateStr(ADate: TDateTime; AFormat, AHoliday: String;
|
|
||||||
AWidth: Integer): String;
|
|
||||||
procedure FixFontHeights;
|
procedure FixFontHeights;
|
||||||
procedure FreeBitmaps;
|
procedure FreeBitmaps;
|
||||||
procedure GetIcons(Event: TVpEvent);
|
procedure GetIcons(Event: TVpEvent);
|
||||||
@ -670,7 +668,8 @@ begin
|
|||||||
TextRect.Left := TextRect.Left + 2;
|
TextRect.Left := TextRect.Left + 2;
|
||||||
|
|
||||||
{ Fix date string for best usage of the available width }
|
{ Fix date string for best usage of the available width }
|
||||||
DateStr := FixDateStr(ARenderDate, FDayView.DateLabelFormat, FRenderHoliday, WidthOf(TextRect));
|
DateStr := GetDateDisplayString(RenderCanvas, ARenderDate,
|
||||||
|
FDayView.DateLabelFormat, FRenderHoliday, WidthOf(TextRect));
|
||||||
DateStrLen := RenderCanvas.TextWidth(DateStr);
|
DateStrLen := RenderCanvas.TextWidth(DateStr);
|
||||||
DateStrHt := RenderCanvas.TextHeight(DateStr);
|
DateStrHt := RenderCanvas.TextHeight(DateStr);
|
||||||
|
|
||||||
@ -1559,39 +1558,6 @@ begin
|
|||||||
inc(Result, RenderCanvas.TextWidth('33'));
|
inc(Result, RenderCanvas.TextWidth('33'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpDayViewPainter.FixDateStr(ADate: TDateTime; AFormat, AHoliday: String;
|
|
||||||
AWidth: Integer): String;
|
|
||||||
begin
|
|
||||||
// Check long date format with holiday name
|
|
||||||
if AHoliday <> '' then begin
|
|
||||||
Result := Format('%s - %s', [FormatDateTime(AFormat, ADate), AHoliday]);
|
|
||||||
if RenderCanvas.TextWidth(Result) <= AWidth then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
// Check short date format with holiday name
|
|
||||||
if AFormat <> 'ddddd' then begin
|
|
||||||
Result := Format('%s - %s', [FormatDateTime('ddddd', ADate), AHoliday]);
|
|
||||||
if RenderCanvas.TextWidth(Result) <= AWidth then
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Check long date format without holiday name
|
|
||||||
Result := FormatDateTime(AFormat, ADate);
|
|
||||||
if RenderCanvas.TextWidth(Result) <= AWidth then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
// Check short date format without holiday name
|
|
||||||
if AFormat <> 'ddddd' then begin
|
|
||||||
Result := FormatDateTime('ddddd', ADate);
|
|
||||||
if RenderCanvas.TextWidth(Result) <= AWidth then
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Chop off the short-date-format string and add '...'
|
|
||||||
Result := GetDisplayString(RenderCanvas, Result, 0, AWidth);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpDayViewPainter.FixFontHeights;
|
procedure TVpDayViewPainter.FixFontHeights;
|
||||||
begin
|
begin
|
||||||
with FDayView do begin
|
with FDayView do begin
|
||||||
|
@ -106,6 +106,9 @@ function GetDisplayString(Canvas : TCanvas; const S : string;
|
|||||||
find the string that can be displayed in that width - add ellipsis to
|
find the string that can be displayed in that width - add ellipsis to
|
||||||
the end if necessary and possible }
|
the end if necessary and possible }
|
||||||
|
|
||||||
|
function GetDateDisplayString(ACanvas: TCanvas; ADate: TDateTime;
|
||||||
|
AFormat, AHoliday: String; AWidth: Integer): String;
|
||||||
|
|
||||||
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
||||||
Shadow, Highlight: TColor);
|
Shadow, Highlight: TColor);
|
||||||
{ Draws a bevel in the specified TRect, using the specified colors }
|
{ Draws a bevel in the specified TRect, using the specified colors }
|
||||||
@ -378,7 +381,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
function GetDateDisplayString(ACanvas: TCanvas; ADate: TDateTime;
|
||||||
|
AFormat, AHoliday: String; AWidth: Integer): String;
|
||||||
|
begin
|
||||||
|
// Check long date format with holiday name
|
||||||
|
if AHoliday <> '' then begin
|
||||||
|
Result := Format('%s - %s', [FormatDateTime(AFormat, ADate), AHoliday]);
|
||||||
|
if ACanvas.TextWidth(Result) <= AWidth then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Check short date format with holiday name
|
||||||
|
if AFormat <> 'ddddd' then begin
|
||||||
|
Result := Format('%s - %s', [FormatDateTime('ddddd', ADate), AHoliday]);
|
||||||
|
if ACanvas.TextWidth(Result) <= AWidth then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Check long date format without holiday name
|
||||||
|
Result := FormatDateTime(AFormat, ADate);
|
||||||
|
if ACanvas.TextWidth(Result) <= AWidth then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Check short date format without holiday name
|
||||||
|
if AFormat <> 'ddddd' then begin
|
||||||
|
Result := FormatDateTime('ddddd', ADate);
|
||||||
|
if ACanvas.TextWidth(Result) <= AWidth then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Chop off the short-date-format string and add '...'
|
||||||
|
Result := GetDisplayString(ACanvas, Result, 0, AWidth);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
||||||
Shadow, Highlight: TColor);
|
Shadow, Highlight: TColor);
|
||||||
|
@ -411,17 +411,14 @@ var
|
|||||||
dayStr: String;
|
dayStr: String;
|
||||||
strWid: Integer;
|
strWid: Integer;
|
||||||
strH: Integer;
|
strH: Integer;
|
||||||
|
savedFontstyle: TFontStyles;
|
||||||
begin
|
begin
|
||||||
dayStr := FormatDateTime(FWeekView.DayHeadAttributes.DateFormat, StartDate + ADayIndex);
|
savedFontstyle := RenderCanvas.Font.Style;
|
||||||
{$IFDEF LCL}
|
if (not DisplayOnly) and SameDate(StartDate + ADayIndex, FWeekView.Date) then
|
||||||
{$IF FPC_FULLVERSION < 30000}DayStr := SysToUTF8(DayStr); {$ENDIF}
|
RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold];
|
||||||
{$ENDIF}
|
|
||||||
if AHolidayName <> '' then
|
|
||||||
dayStr := dayStr + ' - ' + AHolidayName;
|
|
||||||
|
|
||||||
strWid := RenderCanvas.TextWidth(dayStr);
|
dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex,
|
||||||
if strWid > WidthOf(TextRect) then
|
FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - TextMargin);
|
||||||
dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin);
|
|
||||||
strWid := RenderCanvas.TextWidth(dayStr);
|
strWid := RenderCanvas.TextWidth(dayStr);
|
||||||
strH := RenderCanvas.TextHeight(dayStr);
|
strH := RenderCanvas.TextHeight(dayStr);
|
||||||
|
|
||||||
@ -434,6 +431,8 @@ begin
|
|||||||
(TextRect.Top + TextRect.Bottom - strH) div 2,
|
(TextRect.Top + TextRect.Bottom - strH) div 2,
|
||||||
dayStr
|
dayStr
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RenderCanvas.Font.Style := savedFontstyle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpWeekViewPainter.DrawDays;
|
procedure TVpWeekViewPainter.DrawDays;
|
||||||
|
Reference in New Issue
Block a user