From 35584e4dd2300ee32ed7c7b477285eabb7182ee3 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 4 Sep 2022 22:27:33 +0000 Subject: [PATCH] tvplanit: Fix some more drawing glitches in monthview git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8444 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../tvplanit/source/vpmonthviewpainter.pas | 25 ++++++++++--------- .../tvplanit/source/vpweekviewpainter.pas | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index af769a77c..83d09b1d4 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -102,7 +102,7 @@ procedure TVpMonthViewPainter.DrawDayCell(ADate: TDate; ACol, ARow: Integer; var tmpRect: TRect; Y, M, D: Word; - Str: String; + str: String; todayDate: TDate; fontStyle: TFontStyles; textAdjust: Integer; @@ -150,7 +150,7 @@ begin end; { Prepare the day number as string} - Str := FormatDateTime('d', ADate); + str := FormatDateTime('d', ADate); { Set the proper font and style } if ADate = todayDate then @@ -190,25 +190,25 @@ begin RenderCanvas.Font.Style := FMonthView.DayNumberFont.Style; end; end; - - FontStyle := RenderCanvas.Font.Style; - RenderCanvas.Font.Style := [fsBold, fsItalic]; - textAdjust := RenderCanvas.TextWidth(Str); - textHeight := RenderCanvas.TextHeight(Str); - RenderCanvas.Font.Style := FontStyle; if DisplayMonth <> M then RenderCanvas.Font.Color := FMonthView.OffDayFontColor; if FCurrHoliday <> '' then RenderCanvas.Font.Assign(FMonthView.HolidayAttributes.Font); + FontStyle := RenderCanvas.Font.Style; + RenderCanvas.Font.Style := [fsBold, fsItalic]; + textAdjust := RenderCanvas.TextWidth(str); + textHeight := RenderCanvas.TextHeight(str); + RenderCanvas.Font.Style := FontStyle; + { Calculate size of rect for the day number at the top of the TextRect. } if ACol = 6 then tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.DaysMargin else - tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.DaysMargin + 2; + tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.DaysMargin; if fsItalic in RenderCanvas.Font.Style then dec(tmpRect.Left, 2); - tmpRect.Top := ATextRect.Top + FMonthView.DaysMargin div 2; + tmpRect.Top := ATextRect.Top + FMonthView.DaysMargin; tmpRect.Right := tmpRect.Left + textAdjust; tmpRect.Bottom := tmpRect.Top + textHeight; @@ -233,6 +233,7 @@ begin mvMonthDayArray[AIndex].Date := ADate; mvMonthDayArray[AIndex].OffDay := DisplayMonth <> M; end; + Inc(ADayNumber); Inc(AIndex); @@ -510,7 +511,7 @@ begin TextRect.TopLeft := Point(dayRect.Left+1, dayRect.Top+1); TextRect.BottomRight := Point( TextRect.Left + mvColWidth, - TextRect.Top + mvEventTextHeight + txtMargin// div 2 + TextRect.Top + mvEventTextHeight + txtMargin ); { set canvas color } @@ -533,7 +534,7 @@ begin { shorten events that are next to the day number, in order } { to give the day number enough room } - if (TextRect.Top < dayRect.Top + mvDayNumberHeight + txtMargin div 2) + if (TextRect.Top < dayRect.Top + mvDayNumberHeight + txtMargin) then TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - txtMargin * 2 else diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index 8b6b0090f..c54d512ae 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -586,7 +586,7 @@ end; procedure TVpWeekViewPainter.DrawHeader; var headRect, R: TRect; - headTextRect: TRect; +// headTextRect: TRect; headStr: string = ''; headStrLen: Integer; maxStrLen: Integer;