From 0afcfc7a6618f9b970eb646b581922780567702f Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 16 Aug 2022 19:58:12 +0000 Subject: [PATCH] tvplanit: Allow to draw all-day events in the category color (CategoryInfo.UseForAllDayEvents). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8394 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpbase.pas | 2 ++ .../tvplanit/source/vpdayviewpainter.pas | 13 +++++++-- .../tvplanit/source/vpweekviewpainter.pas | 27 +++++++++++-------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/components/tvplanit/source/vpbase.pas b/components/tvplanit/source/vpbase.pas index 04b238a09..d4d5dee8b 100644 --- a/components/tvplanit/source/vpbase.pas +++ b/components/tvplanit/source/vpbase.pas @@ -243,6 +243,7 @@ type FImageIndex: TImageIndex; FIndex: Integer; FBitmap: TBitmap; + FAllDayEvents: Boolean; procedure SetBackgroundColor(const v: TColor); procedure SetBitmap(v: TBitmap); procedure SetColor(Value: TColor); @@ -260,6 +261,7 @@ type property Description: string read FDescription write SetDescription; property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1; property CategoryIndex: Integer read FCategoryIndex; + property UseForAllDayEvents: Boolean read FAllDayEvents write FAllDayEvents default false; end; TVpCategoryColorMap = class(TPersistent) diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index bb117d2df..eae505a3b 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -308,6 +308,7 @@ var AllDayWidth: Integer; OldTop: LongInt; txtDist: Integer; + cat: TVpCategoryInfo; begin // Initialize the rectangle to be used for all-day events ADEventsRect := InitAllDayEventsRect; @@ -397,8 +398,16 @@ begin AdEvRect.Left := AdEventsRect.Left + DayWidth * I + txtDist; AdEvRect.Right := AdEventsRect.Left + DayWidth * (I + 1) - txtDist; - RenderCanvas.Brush.Color := ADEventAttrBkgColor; - RenderCanvas.Pen.Color := ADEventBorderColor; + cat := FDayView.Datastore.CategoryColorMap.GetCategory(Event.Category); + if cat.UseForAllDayEvents then + begin + RenderCanvas.Brush.Color := cat.BackgroundColor; + RenderCanvas.Pen.Color := cat.Color; + end else + begin + RenderCanvas.Brush.Color := ADEventAttrBkgColor; + RenderCanvas.Pen.Color := ADEventBorderColor; + end; TPSRectangle(RenderCanvas, Angle, RenderIn, ADEvRect.Left + txtDist, ADEvRect.Top + txtDist, diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index affb19a57..7314caba5 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -94,6 +94,9 @@ var ADTextHeight: Integer; EventStr: string; txtDist: Integer; + cat: TVpCategoryInfo; + savedBrushColor: TColor; + savedPenColor: TColor; begin Result := False; @@ -107,6 +110,8 @@ begin { number of all day events for the range of days covered by the control. } NumADEvents := 0; + savedPenColor := RenderCanvas.Pen.Color; + savedBrushColor := RenderCanvas.Brush.Color; ADEventsList := TList.Create; try TempList := TList.Create; @@ -168,16 +173,6 @@ begin if ADEventsRect.Top + ((I + 1) * ADTextHeight) > DayRect.Bottom then begin DrawDotDotDot(DayRect, DotDotDotColor); - - { - RenderCanvas.Brush.Color := DotDotDotColor; - TPSFillRect(RenderCanvas, Angle, RenderIn, - Rect(DayRect.Right - 20, DayRect.Bottom - 7, DayRect.Right - 17, DayRect.Bottom - 4)); - TPSFillRect(RenderCanvas, Angle, RenderIn, - Rect(DayRect.Right - 13, DayRect.Bottom - 7, DayRect.Right - 10, DayRect.Bottom - 4)); - TPSFillRect(RenderCanvas, Angle, RenderIn, - Rect(DayRect.Right - 6, DayRect.Bottom - 7, DayRect.Right - 3, DayRect.Bottom - 4)); - } break; end; @@ -194,6 +189,15 @@ begin // Paint the background of the event rect RenderCanvas.Brush.Color := ADEventBackgroundColor; RenderCanvas.Pen.Color := ADEventBorderColor; + if FWeekView.ApplyCategoryInfos then + begin + cat := FWeekView.Datastore.CategoryColorMap.GetCategory(Event.Category); + if cat.UseForAllDayEvents then + begin + RenderCanvas.Brush.Color := cat.BackgroundColor; + RenderCanvas.Pen.Color := cat.Color; + end; + end; TPSRectangle(RenderCanvas, Angle, RenderIn, ADEvRect.Left + TextMargin, ADEvRect.Top + txtDist, @@ -222,10 +226,11 @@ begin TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := Event; Inc(EAIndex); end; { for I := 0 to pred(ADEventsList.Count) do ... } - end; { if NumADEvents > 0 } finally + RenderCanvas.Brush.Color := savedBrushColor; + RenderCanvas.Pen.Color := savedPenColor; ADEventsList.Free; end; end;