You've already forked lazarus-ccr
tvplanit: Fix scaling issues in printing of TVpDayView
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8459 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -25,9 +25,12 @@ type
|
||||
TVpDayViewPainter = class(TVpBasePainter)
|
||||
private
|
||||
FDayView: TVpDayView;
|
||||
FScaledMinutesBorder: Integer;
|
||||
FScaledMinutesHourDistance: Integer;
|
||||
FScaledGutterWidth: Integer;
|
||||
FScaledIconMargin: Integer;
|
||||
FScaledTickDist: Integer;
|
||||
FScaledTextMargin: Integer;
|
||||
// local parameters of the old render procedure
|
||||
ColHeadRect: TRect;
|
||||
CellsRect: TRect;
|
||||
@ -321,7 +324,7 @@ begin
|
||||
// number of all day events for the range of days covered by the control.
|
||||
NumADEvents := 0;
|
||||
|
||||
txtMargin := FDayView.TextMargin;
|
||||
txtMargin := FScaledTextMargin;
|
||||
|
||||
AllDayWidth := RealWidth - RealRowHeadWidth - txtMargin - ScrollBarOffset;
|
||||
DayWidth := AllDayWidth div FDayView.NumDays;
|
||||
@ -424,7 +427,7 @@ begin
|
||||
|
||||
TPSTextOut(RenderCanvas,Angle, RenderIn,
|
||||
AdEvRect.Left + txtMargin,
|
||||
AdEvRect.Top + txtDist, // AdEvRect.Bottom - ADTextHeight) div 2, //TextMargin,
|
||||
AdEvRect.Top + txtDist,
|
||||
EventStr
|
||||
);
|
||||
|
||||
@ -667,15 +670,15 @@ begin
|
||||
{ center and write the resource name in the first column }
|
||||
if (Col = 0) then begin
|
||||
X := TextRect.Left + wText div 2 - ResStrLen div 2;
|
||||
Y := TextRect.Top + FDayView.TextMargin;
|
||||
Y := TextRect.Top + FScaledTextMargin;
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, X, Y, FDayView.DataStore.Resource.Description);
|
||||
end;
|
||||
{ center the date string }
|
||||
X := TextRect.Left + wText div 2 - DateStrLen div 2;
|
||||
Y := TextRect.Top + (FDayView.TextMargin * 2) + DateStrHt;
|
||||
Y := TextRect.Top + FScaledTextMargin * 2 + DateStrHt;
|
||||
end else begin
|
||||
{ center the date string }
|
||||
Y := TextRect.Top + FDayView.TextMargin;
|
||||
Y := TextRect.Top + FScaledTextMargin;
|
||||
X := TextRect.Left + wText div 2 - DateStrLen div 2;
|
||||
end;
|
||||
{ Write the date string }
|
||||
@ -841,7 +844,7 @@ begin
|
||||
|
||||
{ Paint the gutter inside the EventRect of all events }
|
||||
if (AEventRec.Level = 0) then
|
||||
GutterRect.Left := EventRect.Left - Trunc(FDayView.GutterWidth * Scale) // wp: use FGutterWidth? It uses round, though...
|
||||
GutterRect.Left := EventRect.Left - FScaledGutterWidth
|
||||
else
|
||||
GutterRect.Left := EventRect.Left;
|
||||
GutterRect.Right := GutterRect.Left + FScaledGutterWidth;
|
||||
@ -862,7 +865,7 @@ begin
|
||||
IconRect := DetermineIconRect(EventRect);
|
||||
end else begin
|
||||
tmpRect := EventRect;
|
||||
inc(tmpRect.Left, FDayView.GutterWidth);
|
||||
inc(tmpRect.Left, FScaledGutterWidth);
|
||||
ScaleIcons(tmpRect);
|
||||
IconRect := DetermineIconRect(tmpRect);
|
||||
end;
|
||||
@ -875,7 +878,7 @@ begin
|
||||
if Assigned(FDayView.OnBeforeDrawEvent) then begin
|
||||
tmpRect := EventRect;
|
||||
if (AEventRec.Level <> 0) then
|
||||
inc(tmpRect.Left, FDayView.GutterWidth);
|
||||
inc(tmpRect.Left, FScaledGutterWidth);
|
||||
FDayView.OnBeforeDrawEvent(Self, AEvent, FDayView.ActiveEvent = AEvent,
|
||||
RenderCanvas, GutterRect, tmpRect, IconRect);
|
||||
end;
|
||||
@ -889,7 +892,7 @@ begin
|
||||
{ If the string is longer than the availble space then chop off the end
|
||||
and place those little '...'s at the end }
|
||||
if FDayView.WrapStyle = wsNone then begin
|
||||
maxW := EventRect.Right - IconRect.Right - FScaledGutterWidth - FDayView.TextMargin;
|
||||
maxW := EventRect.Right - IconRect.Right - FScaledGutterWidth - FScaledTextMargin;
|
||||
if RenderCanvas.TextWidth(EventString) > maxW then
|
||||
EventString := GetDisplayString(RenderCanvas, EventString, 0, maxW);
|
||||
end;
|
||||
@ -915,7 +918,7 @@ begin
|
||||
if Assigned(FDayView.OnAfterDrawEvent) then begin
|
||||
tmpRect := EventRect;
|
||||
if (AEventRec.Level <> 0) then
|
||||
inc(tmpRect.Left, FDayView.GutterWidth);
|
||||
inc(tmpRect.Left, FScaledGutterWidth);
|
||||
FDayView.OnAfterDrawEvent(Self, AEvent, FDayView.ActiveEvent = AEvent,
|
||||
RenderCanvas, GutterRect, tmpRect, IconRect);
|
||||
end;
|
||||
@ -1097,13 +1100,13 @@ begin
|
||||
if FDayView.WrapStyle = wsIconFlow then
|
||||
begin
|
||||
WorkRegion1 := CreateRectRgn(AIconRect.Right, AEventRect.Top, AEventRect.Right, AIconRect.Bottom);
|
||||
WorkRegion2 := CreateRectRgn(AEventRect.Left + FDayView.GutterWidth, AIconRect.Bottom, AEventRect.Right, AEventRect.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);
|
||||
end else
|
||||
TextRegion := CreateRectRgn(AIconRect.Right, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
|
||||
end else
|
||||
TextRegion := CreateRectRgn(AIconRect.Right + FDayView.GutterWidth, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
|
||||
TextRegion := CreateRectRgn(AIconRect.Right + FScaledGutterWidth, AEventRect.Top, AEventRect.Right, AEventRect.Bottom);
|
||||
|
||||
try
|
||||
CW := RenderTextToRegion(RenderCanvas, Angle, RenderIn, TextRegion, AText);
|
||||
@ -1131,16 +1134,16 @@ begin
|
||||
TPSTextOut(RenderCanvas, // wp: both cases are the same ?!
|
||||
Angle,
|
||||
RenderIn,
|
||||
AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
|
||||
AEventRect.Top + FDayView.TextMargin,
|
||||
AIconRect.Right + FScaledGutterWidth + FScaledTextMargin,
|
||||
AEventRect.Top + FScaledTextMargin,
|
||||
AText
|
||||
)
|
||||
else
|
||||
TPSTextOut(RenderCanvas,
|
||||
Angle,
|
||||
RenderIn,
|
||||
AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
|
||||
AEventRect.Top + FDayView.TextMargin,
|
||||
AIconRect.Right + FScaledGutterWidth + FScaledTextMargin,
|
||||
AEventRect.Top + FScaledTextMargin,
|
||||
AText
|
||||
);
|
||||
end;
|
||||
@ -1413,7 +1416,7 @@ begin
|
||||
{$ENDIF}
|
||||
timeStr := Format('%s:%s', [hourStr, minuteStr]);
|
||||
x := lineRect.Left + FScaledTickDist;
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, timeStr);
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FScaledTextMargin, timeStr);
|
||||
end else
|
||||
begin
|
||||
// In all other cases, paint large hour and small minutes (or am/pm)
|
||||
@ -1422,16 +1425,16 @@ begin
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
x := lineRect.Right - RenderCanvas.TextWidth(MinuteStr) - MINUTES_BORDER;
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, minuteStr);
|
||||
x := lineRect.Right - RenderCanvas.TextWidth(MinuteStr) - FScaledMinutesBorder;
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FScaledTextMargin, minuteStr);
|
||||
|
||||
// Draw hours
|
||||
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
dec(x, RenderCanvas.TextWidth(HourStr) + MINUTES_HOUR_DISTANCE);
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin{ - 2}, hourStr);
|
||||
dec(x, RenderCanvas.TextWidth(HourStr) + FScaledMinutesHourDistance);
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FScaledTextMargin, hourStr);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1464,7 +1467,7 @@ begin
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
minutesLen := RenderCanvas.TextWidth('00') + MINUTES_BORDER + MINUTES_HOUR_DISTANCE div 2;
|
||||
minutesLen := RenderCanvas.TextWidth('00') + FScaledMinutesBorder + FScaledMinutesHourDistance div 2;
|
||||
|
||||
// Prepare pen
|
||||
RenderCanvas.Pen.Style := psSolid;
|
||||
@ -1531,7 +1534,7 @@ end;
|
||||
|
||||
function TVpDayViewPainter.CalcRowHeadWidth: integer;
|
||||
begin
|
||||
Result := 2 * MINUTES_BORDER + MINUTES_HOUR_DISTANCE;
|
||||
Result := 2 * (FScaledMinutesBorder + FScaledMinutesHourDistance);
|
||||
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.MinuteFont);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
@ -2077,6 +2080,9 @@ begin
|
||||
FScaledGutterWidth := Round(FDayView.GutterWidth * Scale);
|
||||
FScaledIconMargin := Round(ICON_MARGIN * Scale);
|
||||
FScaledTickdist := Round(TICK_Dist * Scale);
|
||||
FScaledMinutesBorder := Round(MINUTES_BORDER * Scale);
|
||||
FScaledMinutesHourDistance := Round(MINUTES_HOUR_DISTANCE * Scale);
|
||||
FScaledTextMargin := Round(FDayView.TextMargin * Scale);
|
||||
end;
|
||||
|
||||
procedure TVpDayViewPainter.VerifyMaxWidthDevisors;
|
||||
|
@ -895,14 +895,6 @@ begin
|
||||
Result := m2 - m1 + 1
|
||||
else
|
||||
Result := 13 - m1 + m2 + (y2 - y1 - 1)*12;
|
||||
{
|
||||
else
|
||||
Result := (y2 - y1 - 1) * 12;
|
||||
dm1 := trunc(StartOfTheMonth(FStartDate));
|
||||
dm2 := trunc(StartOfTheMonth(FEndDate)) + 1;
|
||||
writeln(datetostr(dm1), ' ', datetostr(dm2));
|
||||
Result := MonthsBetween(dm1, dm2) + 1;
|
||||
}
|
||||
end else
|
||||
Result := 0;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user