tvplanit: Fix events being painted over the "today" border in TVpMonthView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8470 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-10 21:33:53 +00:00
parent d2fe2df1e7
commit 6dc51adcc2

View File

@ -34,6 +34,8 @@ type
FCurrHoliday: String; FCurrHoliday: String;
FDayHeadHeight: Integer; FDayHeadHeight: Integer;
FMonthHeadHeight: Integer; FMonthHeadHeight: Integer;
FTodayRect: TRect;
FTodayStr: String;
// These variables were protected in the original monthview, but are needed only for painting // These variables were protected in the original monthview, but are needed only for painting
mvEventTextHeight: Integer; mvEventTextHeight: Integer;
@ -52,6 +54,7 @@ type
procedure DrawEvents; procedure DrawEvents;
procedure DrawFocusRect(ARect: TRect; FixRight: Boolean = false); procedure DrawFocusRect(ARect: TRect; FixRight: Boolean = false);
procedure DrawHeader; procedure DrawHeader;
procedure DrawTodayRect;
procedure FixFontHeights; procedure FixFontHeights;
procedure InitColors; procedure InitColors;
procedure SetMeasurements; override; procedure SetMeasurements; override;
@ -134,11 +137,11 @@ begin
RenderCanvas.Brush.Color := RealColor; RenderCanvas.Brush.Color := RealColor;
if ACol = 6 then begin if ACol = 6 then begin
{ draw bottom line } // Draw bottom line
TPSMoveTo(RenderCanvas, Angle, RenderIn, ATextRect.Left, ATextRect.Bottom); TPSMoveTo(RenderCanvas, Angle, RenderIn, ATextRect.Left, ATextRect.Bottom);
TPSLineTo(RenderCanvas, Angle, RenderIn, RealRight - 2, ATextRect.Bottom); TPSLineTo(RenderCanvas, Angle, RenderIn, RealRight - 2, ATextRect.Bottom);
end else begin end else begin
{ draw right side and bottom lines } // Draw right side and bottom lines
TPSMoveTo(RenderCanvas, Angle, RenderIn, ATextRect.Right, ATextRect.top); TPSMoveTo(RenderCanvas, Angle, RenderIn, ATextRect.Right, ATextRect.top);
if ATextRect.Bottom > RealBottom then begin if ATextRect.Bottom > RealBottom then begin
TPSLineTo(RenderCanvas, Angle, RenderIn, ATextRect.Right, RealBottom); TPSLineTo(RenderCanvas, Angle, RenderIn, ATextRect.Right, RealBottom);
@ -149,10 +152,10 @@ begin
end; end;
end; end;
{ Prepare the day number as string} // Prepare the day number as string
str := FormatDateTime('d', ADate); str := FormatDateTime('d', ADate);
{ Set the proper font and style } // Set the proper font and style
if ADate = todayDate then if ADate = todayDate then
RenderCanvas.Font.Assign(FMonthView.TodayAttributes.Font) RenderCanvas.Font.Assign(FMonthView.TodayAttributes.Font)
else else
@ -179,7 +182,7 @@ begin
then then
RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle; RenderCanvas.Font.Style := RenderCanvas.Font.Style + FMonthView.EventDayStyle;
end else begin end else begin
{ Set the font style for days which have events. } // Set the font style for days which have events.
if (FMonthView.EventDayStyle <> []) and (FMonthview.Datastore <> nil) and if (FMonthView.EventDayStyle <> []) and (FMonthview.Datastore <> nil) and
(FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource <> nil) and
(FMonthView.DataStore.Resource.Schedule.EventCountByDay(ADate) > 0) (FMonthView.DataStore.Resource.Schedule.EventCountByDay(ADate) > 0)
@ -201,7 +204,7 @@ begin
textHeight := RenderCanvas.TextHeight(str); textHeight := RenderCanvas.TextHeight(str);
RenderCanvas.Font.Style := FontStyle; RenderCanvas.Font.Style := FontStyle;
{ Calculate size of rect for the day number at the top of the TextRect. } // Calculate size of rect for the day number at the top of the TextRect.
if ACol = 6 then if ACol = 6 then
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.DaysMargin tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.DaysMargin
else else
@ -212,22 +215,19 @@ begin
tmpRect.Right := tmpRect.Left + textAdjust; tmpRect.Right := tmpRect.Left + textAdjust;
tmpRect.Bottom := tmpRect.Top + textHeight; tmpRect.Bottom := tmpRect.Top + textHeight;
{ Highlight today by a border } // Highlight today by a border
if ADate = todayDate then begin if ADate = todayDate then begin
OffsetRect(tmpRect, 2, 0); FTodayRect := tmpRect;
InflateRect(tmpRect, 3, 3); OffsetRect(FTodayRect, 2, 0);
RenderCanvas.Pen.Assign(FMonthView.TodayAttributes.BorderPen); InflateRect(FTodayRect, 3, 3);
RenderCanvas.Brush.Color := FMonthView.TodayAttributes.Color; FTodayStr := Str;
RenderCanvas.Brush.Style := bsSolid; // Will be painted after the events to avoid drawing events over the
RenderCanvas.Rectangle(tmpRect); // "today" rectangle
InflateRect(tmpRect, -3, -3); end else
RenderCanvas.Font.Color := FMonthView.TodayAttributes.Font.Color; // Write the day number at the top of the TextRect
end; TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Write the day number at the top of the TextRect. } // Update MonthDayArray
TPSTextOut(RenderCanvas, Angle, RenderIn, tmpRect.Left, tmpRect.Top, Str);
{ Update MonthDayArray }
with TVpMonthViewOpener(FMonthView) do begin with TVpMonthViewOpener(FMonthView) do begin
mvMonthDayArray[AIndex].Rec := ATextRect; mvMonthDayArray[AIndex].Rec := ATextRect;
mvMonthDayArray[AIndex].Date := ADate; mvMonthDayArray[AIndex].Date := ADate;
@ -238,11 +238,12 @@ begin
Inc(AIndex); Inc(AIndex);
if ACol = 6 then begin if ACol = 6 then begin
{ drop rect down one row and all the way to the left } // We just painted the last day in the row --> Drop rect down one row and
// then all the way to the left
ATextRect.TopLeft := Point(RealLeft + 1, ATextRect.Bottom + 1); ATextRect.TopLeft := Point(RealLeft + 1, ATextRect.Bottom + 1);
ATextRect.BottomRight := Point(ATextRect.Left + mvColWidth, ATextRect.Top + mvRowHeight); ATextRect.BottomRight := Point(ATextRect.Left + mvColWidth, ATextRect.Top + mvRowHeight);
end else begin end else begin
{ slide rect one column to the right } // Slide rect one column to the right
ATextRect.Left := ATextRect.Right + 1; ATextRect.Left := ATextRect.Right + 1;
ATextRect.Right := ATextRect.Right + mvColWidth; ATextRect.Right := ATextRect.Right + mvColWidth;
end; end;
@ -466,6 +467,7 @@ begin
end; end;
DrawEvents; DrawEvents;
DrawTodayRect;
end; end;
procedure TVpMonthViewPainter.DrawEvents; procedure TVpMonthViewPainter.DrawEvents;
@ -709,6 +711,20 @@ begin
); );
end; end;
procedure TVpMonthViewPainter.DrawTodayRect;
begin
// Highlight toay by a border defined by FTodayRect (it was measured in
// the DrawDayCell method).
RenderCanvas.Pen.Assign(FMonthView.TodayAttributes.BorderPen);
RenderCanvas.Brush.Color := FMonthView.TodayAttributes.Color;
RenderCanvas.Brush.Style := bsSolid;
RenderCanvas.Rectangle(FTodayRect);
// Write the day number into the TodayRect.
RenderCanvas.Font.Color := FMonthView.TodayAttributes.Font.Color;
TPSTextOut(RenderCanvas, Angle, RenderIn, FTodayRect.Left+3, FTodayRect.Top+3, FTodayStr);
end;
procedure TVpMonthViewPainter.FixFontHeights; procedure TVpMonthViewPainter.FixFontHeights;
begin begin
with FMonthView do begin with FMonthView do begin