You've already forked lazarus-ccr
tvplanit: Fix layout issues in printing/preview of TVpMonthView (due to navigation buttons missing in print mode).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8536 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -12,6 +12,8 @@ type
|
||||
TVpMonthViewPainter = class(TVpBasePainter)
|
||||
private
|
||||
FMonthView: TVpMonthView;
|
||||
FScaledMonthMargin: Integer;
|
||||
FScaledDaysMargin: Integer;
|
||||
|
||||
// local parameters of the old TVpMonthView method
|
||||
DisplayDate: TDateTime;
|
||||
@ -206,12 +208,12 @@ begin
|
||||
|
||||
// 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
|
||||
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FScaledDaysMargin
|
||||
else
|
||||
tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.DaysMargin;
|
||||
tmpRect.Left := ATextRect.Right - TextAdjust - FScaledDaysMargin;
|
||||
if fsItalic in RenderCanvas.Font.Style then
|
||||
dec(tmpRect.Left, 2);
|
||||
tmpRect.Top := ATextRect.Top + FMonthView.DaysMargin;
|
||||
tmpRect.Top := ATextRect.Top + FScaledDaysMargin;
|
||||
tmpRect.Right := tmpRect.Left + textAdjust;
|
||||
tmpRect.Bottom := tmpRect.Top + textHeight;
|
||||
|
||||
@ -356,8 +358,8 @@ begin
|
||||
|
||||
{ Fix header string }
|
||||
strLen := RenderCanvas.TextWidth(str);
|
||||
if (strLen > mvColWidth - FMonthView.DaysMargin * 2) then
|
||||
str := GetDisplayString(RenderCanvas, str, 0, mvColWidth - FMonthView.DaysMargin * 2);
|
||||
if (strLen > mvColWidth - FScaledDaysMargin * 2) then
|
||||
str := GetDisplayString(RenderCanvas, str, 0, mvColWidth - FScaledDaysMargin * 2);
|
||||
strLen := RenderCanvas.TextWidth(str);
|
||||
|
||||
{ Draw header text }
|
||||
@ -490,7 +492,7 @@ begin
|
||||
RenderCanvas.Pen.Style := psSolid;
|
||||
RenderCanvas.Brush.Color := RealColor;
|
||||
|
||||
txtMargin := FMonthView.DaysMargin;
|
||||
txtMargin := FScaledDaysMargin;
|
||||
|
||||
{ write the events }
|
||||
if (FMonthView.DataStore <> nil) and FMonthView.ShowEvents and
|
||||
@ -641,8 +643,15 @@ begin
|
||||
|
||||
// Position the spinner buttons
|
||||
with TVpMonthViewOpener(FMonthView) do begin
|
||||
FPrevYearBtn.Visible := not DisplayOnly;
|
||||
FPrevMonthBtn.Visible := not DisplayOnly;
|
||||
FNextMonthBtn.Visible := not DisplayOnly;
|
||||
FNextYearBtn.Visible := not DisplayOnly;
|
||||
|
||||
if not DisplayOnly then
|
||||
begin
|
||||
FPrevYearBtn.Width := FPrevYearBtn.Height;
|
||||
FPrevYearBtn.Left := MonthMargin;
|
||||
FPrevYearBtn.Left := FScaledMonthMargin;
|
||||
FPrevYearBtn.Top := (HeadRect.Top + HeadRect.Bottom - FPrevYearBtn.Height) div 2 + 1;
|
||||
|
||||
FPrevMonthBtn.Height := FPrevYearBtn.Height;
|
||||
@ -660,7 +669,9 @@ begin
|
||||
FNextYearBtn.Left := FNextMonthBtn.Left + FNextMonthBtn.Width;
|
||||
FNextYearBtn.Top := FPrevYearBtn.Top;
|
||||
|
||||
txtStart := FNextYearBtn.Left + FNextYearBtn.Width + 2*MonthMargin;
|
||||
txtStart := FNextYearBtn.Left + FNextYearBtn.Width + 2*FScaledMonthMargin;
|
||||
end else
|
||||
txtStart := RealLeft + FScaledMonthMargin;
|
||||
end;
|
||||
|
||||
{ Acquire startdate and end date }
|
||||
@ -675,12 +686,12 @@ begin
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then
|
||||
HeadTextRect.Left := RealLeft + FMonthView.MonthMargin * 2
|
||||
HeadTextRect.Left := RealLeft + FScaledMonthMargin * 2
|
||||
else
|
||||
if DisplayOnly then
|
||||
HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2
|
||||
else
|
||||
HeadTextRect.Left := RealLeft + 30 + FMonthView.MonthMargin * 2;
|
||||
HeadTextRect.Left := RealLeft + 30 + FScaledMonthMargin * 2;
|
||||
HeadTextRect.Top := (HeadRect.Top + HeadRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2;
|
||||
HeadTextRect.BottomRight := HeadRect.BottomRight;
|
||||
|
||||
@ -692,7 +703,7 @@ begin
|
||||
RenderCanvas,
|
||||
HeadStr,
|
||||
0,
|
||||
HeadTextRect.Right - HeadTextRect.Left - FMonthView.MonthMargin
|
||||
HeadTextRect.Right - HeadTextRect.Left - FScaledMonthMargin
|
||||
);
|
||||
end;
|
||||
|
||||
@ -821,7 +832,7 @@ end;
|
||||
|
||||
procedure TVpMonthViewPainter.SetMeasurements;
|
||||
var
|
||||
h: Integer;
|
||||
h, scaledMargin: Integer;
|
||||
txt: String = VpProductName;
|
||||
// We use the VpProductName since it is a good representation of some generic text
|
||||
begin
|
||||
@ -831,18 +842,21 @@ begin
|
||||
|
||||
with TVpMonthViewOpener(FMonthView) do
|
||||
begin
|
||||
FScaledMonthMargin := round(Scale * MonthMargin);
|
||||
FScaledDaysMargin := round(Scale * DaysMargin);
|
||||
|
||||
h := GetCanvasTextHeight(RenderCanvas, HeadAttributes.Font, txt);
|
||||
mvMonthHeadHeight := Max(h, FPrevYearBtn.Height) + MonthMargin;
|
||||
mvMonthHeadHeight := Max(h, FPrevYearBtn.Height) + FScaledMonthMargin;
|
||||
|
||||
h := GetCanvasTextHeight(RenderCanvas, DayHeadAttributes.Font, txt);
|
||||
mvDayHeadHeight := Max(h, FPrevYearBtn.Height) + DaysMargin;
|
||||
mvDayHeadHeight := Max(h, FPrevYearBtn.Height) + FScaledDaysMargin;
|
||||
|
||||
mvHeaderHeight := mvMonthHeadHeight + mvDayHeadHeight;
|
||||
|
||||
mvDayNumberHeight := GetCanvasTextHeight(RenderCanvas, DayNumberFont, '00');
|
||||
mvEventTextHeight := GetCanvasTextHeight(RenderCanvas, EventFont, txt);
|
||||
mvLineHeight := GetCanvasTextHeight(RenderCanvas, Font, txt) + 2;
|
||||
mvColWidth := (RealWidth - 4) div 7;
|
||||
mvColWidth := (RealWidth - 2) div 7;
|
||||
|
||||
FMonthHeadHeight := mvMonthHeadHeight;
|
||||
FDayHeadHeight := mvDayHeadHeight;
|
||||
|
Reference in New Issue
Block a user