TvPlanIt: Use array of rectangle, rather than combined regions, to draw event text wrapped around event icons. (Supposed to fix rendering issue in cocoa).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8893 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-07-22 14:25:42 +00:00
parent a6b4323add
commit b211e27180
4 changed files with 250 additions and 17 deletions

View File

@ -1091,9 +1091,13 @@ end;
procedure TVpDayViewPainter.DrawEventText(const AText: String;
const AEventRect, AIconRect: TRect; ALevel: Integer);
var
{$IFDEF REGION_SUPPORT}
WorkRegion1: HRGN = 0;
WorkRegion2: HRGN = 0;
TextRegion: HRGN = 0;
{$ELSE}
TextRects: array of TRect = nil;
{$ENDIF}
CW: Integer;
begin
if (FDayView.WrapStyle <> wsNone) then begin
@ -1101,17 +1105,42 @@ begin
then begin
if FDayView.WrapStyle = wsIconFlow then
begin
{$IFDEF REGION_SUPPORT}
WorkRegion1 := CreateRectRgn(AIconRect.Right, AEventRect.Top, AEventRect.Right, AIconRect.Bottom);
WorkRegion2 := CreateRectRgn(AEventRect.Left + FScaledGutterWidth, AIconRect.Bottom, AEventRect.Right, AEventRect.Bottom);
TextRegion := CreateRectRgn(AIconRect.Right, AEventRect.Top, AEventRect.Right, AIconRect.Bottom);
CombineRgn(TextRegion, WorkRegion1, WorkRegion2, RGN_OR);
{$ELSE}
SetLength(TextRects, 2);
TextRects[0] := Rect(AIconRect.Right, AEventRect.Top, AEventRect.Right, AIconRect.Bottom);
TextRects[1] := Rect(AEventRect.Left + FScaledGutterWidth, AIconRect.Bottom, AEventRect.Right, AEventRect.Bottom);
{$ENDIF}
end else
begin
{$IFDEF REGION_SUPPORT}
TextRegion := CreateRectRgn(AIconRect.Right, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
{$ELSE}
SetLength(TextRects, 1);
TextRects[0] := Rect(AIconRect.Right, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
{$ENDIF}
end;
end else
begin
{$IFDEF REGION_SUPPORT}
TextRegion := CreateRectRgn(AIconRect.Right + FScaledGutterWidth, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
{$ELSE}
SetLength(TextRects, 1);
TextRects[0] := Rect(AIconRect.Right + FScaledGutterWidth, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
{$ENDIF}
end;
{$IFDEF REGION_SUPPORT}
try
CW := RenderTextToRegion(RenderCanvas, Angle, RenderIn, TextRegion, AText);
{$ELSE}
CW := RenderTextToRects(RenderCanvas, Angle, RenderIn, TextRects, AText);
{$ENDIF}
{ write the event string to the proper spot in the EventRect }
if CW < Length(AText) then begin
RenderCanvas.Brush.Color := FDayView.DotDotDotColor;
@ -1124,11 +1153,13 @@ begin
TPSFillRect(RenderCanvas, Angle, RenderIn,
Rect(AEventRect.Right - 6, AEventRect.Bottom - 7, AEventRect.Right - 3, AEventRect.Bottom - 4));
end;
{$IFDEF REGION_SUPPORT}
finally
if WorkRegion1 <> 0 then DeleteObject(WorkRegion1);
if WorkRegion2 <> 0 then DeleteObject(WorkRegion2);
if TextRegion <> 0 then DeleteObject(TextRegion);
end;
{$ENDIF}
end
else begin
if ALevel = 0 then
@ -1233,7 +1264,7 @@ begin
if FDayView.DrawingStyle = dsFlat then begin
RenderCanvas.Pen.Color := BevelShadow;
TPSMoveTo(RenderCanvas, Angle, RenderIn, R.Right - 6, R.Bottom- 1);
TPSLineTo(RenderCanvas, Angle, RenderIn, R.Left + 3, R.Bottom - 1);
TPSLineTo(RenderCanvas, Angle, RenderIn, R.Left + 3, R.Bottom - 1);
TPSMoveTo(RenderCanvas, Angle, RenderIn, R.Right - 2, R.Top + 6);
TPSLineTo(RenderCanvas, Angle, RenderIn, R.Right - 2, R.Bottom - 5);
end;