tvplanit: New property ApplyCategoryInfos for week and month view. Some tweaking of text positions in month view.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8346 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-07-12 14:31:42 +00:00
parent cf88b7c792
commit 2e2d9f18bf
14 changed files with 133 additions and 39 deletions

View File

@ -12,6 +12,7 @@ type
TVpMonthViewPainter = class(TVpBasePainter)
private
FMonthView: TVpMonthView;
// local parameters of the old TVpMonthView method
DisplayDate: TDateTime;
DisplayMonth: Word;
@ -31,7 +32,7 @@ type
DotDotDotColor: TColor;
FCurrHoliday: String;
// protected variables of the original monthview needed only for painting
// These variables were protected in the original monthview, but are needed only for painting
mvEventTextHeight: Integer;
mvDayNumberHeight: Integer;
mvRowHeight: Integer;
@ -221,7 +222,7 @@ begin
if ACol = 6 then
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - TextMargin
else
tmpRect.Left := ATextRect.Right - TextAdjust - TextMargin;
tmpRect.Left := ATextRect.Right - TextAdjust - TextMargin + 2;
if fsItalic in RenderCanvas.Font.Style then
dec(tmpRect.Left, 2);
tmpRect.Top := ATextRect.Top + TextMargin div 2;
@ -230,6 +231,7 @@ begin
{ Highlight today by a border }
if ADate = todayDate then begin
OffsetRect(tmpRect, 2, 0);
InflateRect(tmpRect, 3, 3);
RenderCanvas.Pen.Assign(FMonthView.TodayAttributes.BorderPen);
RenderCanvas.Brush.Color := FMonthView.TodayAttributes.Color;
@ -449,7 +451,7 @@ begin
for Col := 0 to 6 do begin
ThisDate := Trunc(StartingDate + DayNumber);
{ Check and store if the this date is a holiday }
{ Check and store if this date is a holiday }
FMonthView.IsHoliday(ThisDate, FCurrHoliday);
OldBrush.Assign(RenderCanvas.Brush);
@ -490,12 +492,16 @@ procedure TVpMonthViewPainter.DrawEvents;
var
I, J: Integer;
EventList: TList;
event: TVpEvent;
eventCat: TVpCategoryInfo;
dayRect: TRect;
TextRect: TRect;
tmpRect: TRect;
Str: String;
StrLen: Integer;
P: TPoint;
visibleEvents: Integer;
brushCol: TColor;
begin
RenderCanvas.Pen.Color := RealLineColor;
RenderCanvas.Pen.Style := psSolid;
@ -518,19 +524,21 @@ begin
dayRect := TVpMonthViewOpener(FMonthView).mvMonthDayArray[I].Rec;
{ initialize TextRect for this day }
TextRect.TopLeft := Point(dayRect.Left, dayRect.Top);
TextRect.TopLeft := Point(dayRect.Left+1, dayRect.Top+1);
TextRect.BottomRight := Point(
TextRect.Left + mvColWidth,
TextRect.Top + mvEventTextHeight + TextMargin div 2
TextRect.Top + mvEventTextHeight + TextMargin// div 2
);
{ set canvas color }
if TVpMonthViewOpener(FMonthView).mvMonthDayArray[I].OffDay
then RenderCanvas.Brush.Color := RealOffDayColor
else RenderCanvas.Brush.Color := RealColor;
if TVpMonthViewOpener(FMonthView).mvMonthDayArray[I].OffDay then
RenderCanvas.Brush.Color := RealOffDayColor
else
RenderCanvas.Brush.Color := RealColor;
{ spin through the events and paint them }
for J := 0 to Pred(EventList.Count) do begin
event := TVpEvent(EventList[j]);
if (TextRect.Bottom > dayRect.Bottom) and (J <= Pred(EventList.Count)) then
begin
{ draw a little red square with a (...) at the bottom right }
@ -544,12 +552,26 @@ begin
{ to give the day number enough room }
if (TextRect.Top < dayRect.Top + mvDayNumberHeight + TextMargin div 2)
then
TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - TextMargin
TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - TextMargin * 2
else
TextRect.Right := TextRect.Left + mvColWidth;
TextRect.Right := TextRect.Left + mvColWidth - 3;
if Assigned(FMonthView.Datastore) and FMonthView.ApplyCategoryInfos then
begin
brushCol := RenderCanvas.Brush.Color;
eventCat := FMonthView.Datastore.CategoryColorMap.GetCategory(event.Category);
if Assigned(eventCat) then
begin
tmpRect := TextRect;
InflateRect(tmpRect, -1, -1);
RenderCanvas.Brush.Color := eventCat.BackgroundColor;
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
end;
RenderCanvas.Brush.Color := brushCol;
end;
{ Construct the display text }
Str := FMonthView.BuildEventString(TVpEvent(EventList[j]), FMonthView.ShowEventTime, true);
Str := FMonthView.BuildEventString(event, FMonthView.ShowEventTime, true);
{ set the event font }
RenderCanvas.Font.Assign(FMonthView.EventFont);
@ -590,12 +612,14 @@ procedure TVpMonthViewPainter.DrawFocusRect(ARect: TRect; FixRight: Boolean = fa
var
tmpRect: TRect;
begin
(*
tmpRect := ARect;
InflateRect(tmpRect, 2, 2);
TPSDrawFocusRect(RenderCanvas, Angle, RenderIn, tmpRect);
*)
tmpRect := ARect;
InflateRect(tmpRect, -2, -2);
// InflateRect(tmpRect, -2, -2);
InflateRect(tmpRect, -1, -1);
if FixRight then
inc(tmpRect.Right);
TPSDrawFocusRect(RenderCanvas, Angle, RenderIn, tmpRect);
@ -653,7 +677,7 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF}
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then
HeadTextRect.Left:= RealLeft + TextMargin * 2
HeadTextRect.Left := RealLeft + TextMargin * 2
else
if DisplayOnly then
HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2