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 DrawRowHeaderLabels(R: TRect);
|
||||
procedure DrawRowHeaderTicks(R: TRect);
|
||||
function FixDateStr(ADate: TDateTime; AFormat, AHoliday: String;
|
||||
AWidth: Integer): String;
|
||||
procedure FixFontHeights;
|
||||
procedure FreeBitmaps;
|
||||
procedure GetIcons(Event: TVpEvent);
|
||||
@ -670,7 +668,8 @@ begin
|
||||
TextRect.Left := TextRect.Left + 2;
|
||||
|
||||
{ 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);
|
||||
DateStrHt := RenderCanvas.TextHeight(DateStr);
|
||||
|
||||
@ -1559,39 +1558,6 @@ begin
|
||||
inc(Result, RenderCanvas.TextWidth('33'));
|
||||
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;
|
||||
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
|
||||
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;
|
||||
Shadow, Highlight: TColor);
|
||||
{ Draws a bevel in the specified TRect, using the specified colors }
|
||||
@ -378,7 +381,40 @@ begin
|
||||
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;
|
||||
Shadow, Highlight: TColor);
|
||||
|
@ -411,17 +411,14 @@ var
|
||||
dayStr: String;
|
||||
strWid: Integer;
|
||||
strH: Integer;
|
||||
savedFontstyle: TFontStyles;
|
||||
begin
|
||||
dayStr := FormatDateTime(FWeekView.DayHeadAttributes.DateFormat, StartDate + ADayIndex);
|
||||
{$IFDEF LCL}
|
||||
{$IF FPC_FULLVERSION < 30000}DayStr := SysToUTF8(DayStr); {$ENDIF}
|
||||
{$ENDIF}
|
||||
if AHolidayName <> '' then
|
||||
dayStr := dayStr + ' - ' + AHolidayName;
|
||||
savedFontstyle := RenderCanvas.Font.Style;
|
||||
if (not DisplayOnly) and SameDate(StartDate + ADayIndex, FWeekView.Date) then
|
||||
RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold];
|
||||
|
||||
strWid := RenderCanvas.TextWidth(dayStr);
|
||||
if strWid > WidthOf(TextRect) then
|
||||
dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin);
|
||||
dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex,
|
||||
FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - TextMargin);
|
||||
strWid := RenderCanvas.TextWidth(dayStr);
|
||||
strH := RenderCanvas.TextHeight(dayStr);
|
||||
|
||||
@ -434,6 +431,8 @@ begin
|
||||
(TextRect.Top + TextRect.Bottom - strH) div 2,
|
||||
dayStr
|
||||
);
|
||||
|
||||
RenderCanvas.Font.Style := savedFontstyle;
|
||||
end;
|
||||
|
||||
procedure TVpWeekViewPainter.DrawDays;
|
||||
|
Reference in New Issue
Block a user