From 45d2ee648508a313b970a8537878f8ffd79e63bf Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 22 Jul 2023 15:47:53 +0000 Subject: [PATCH] TvPlanit: Fix clipping of too-large event images. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8896 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../tvplanit/source/vpdayviewpainter.pas | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index 20dcc82e2..0a4cc4b40 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -223,14 +223,16 @@ var w: Integer; begin w := 0; - if AlarmW <> 0 then inc(w, AlarmW + FScaledIconMargin); - if RecurringW <> 0 then inc(w, RecurringW + FScaledIconMargin); - if CategoryW <> 0 then inc(w, CategoryW + FScaledIconMargin); - if CustomW <> 0 then inc(w, CustomW + FScaledIconMargin); - if w <> 0 then inc(w, FScaledIconMargin); - - Result := AEventRect; - Result.Right := Result.Left + w; + if AlarmW <> 0 then + inc(w, AlarmW + FScaledIconMargin); + if RecurringW <> 0 then + inc(w, RecurringW + FScaledIconMargin); + if CategoryW <> 0 then + inc(w, CategoryW + FScaledIconMargin); + if CustomW <> 0 then + inc(w, CustomW + FScaledIconMargin); + if w <> 0 then + inc(w, FScaledIconMargin); MaxHeight := AlarmH + FScaledIconMargin; if RecurringH + FScaledIconMargin > MaxHeight then @@ -239,12 +241,12 @@ begin MaxHeight := dvBmpCategory.Height; if CustomH + FScaledIconMargin > MaxHeight then MaxHeight := dvBmpCustom.Height; - if MaxHeight > AEventRect.Bottom - AEventRect.Top then - MaxHeight := AEventRect.Bottom - AEventRect.Top; + if MaxHeight > AEventRect.Bottom - AEventRect.Top - 1 then + MaxHeight := AEventRect.Bottom - AEventRect.Top - 1; - Result.Bottom := AEventRect.Top + MaxHeight; - if Result.Right > AEventRect.Right then - Result.Right := AEventRect.Right; + Result := AEventRect; + Result.Bottom := Min(AEventRect.Top + MaxHeight, AEventRect.Bottom); + Result.Right := Min(Result.Left + w, AEventRect.Right); end; { Returns the imagelist attached to the datastore of the dayview. } @@ -748,6 +750,8 @@ var tmpRect: TRect; maxW: Integer; grp: TVpResourceGroup; + clipR: TRect; + didClip: Boolean; begin { Initialize, collect useful information needed later } if Assigned(FDayView.Datastore) then @@ -887,7 +891,15 @@ begin FDayView.OnPrepareEventFont(FDayView, AEvent, RenderCanvas.Font); if FDayView.IconAttributes.ShowInPrint then + begin + clipR := RenderCanvas.ClipRect; + didClip := RenderCanvas.Clipping; + RenderCanvas.ClipRect := EventRect; + RenderCanvas.Clipping := true; DrawIcons(IconRect); + RenderCanvas.ClipRect := clipR; + RenderCanvas.Clipping := didClip; + end; { Build the event string } EventString := FDayView.BuildEventString(AEvent, false);