tvplanit: Improving LCL scaling.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8438 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-02 17:38:26 +00:00
parent f60702ccb7
commit 30acf7208e
30 changed files with 448 additions and 163 deletions

View File

@ -309,6 +309,7 @@ var
OldTop: LongInt;
txtDist: Integer;
cat: TVpCategoryInfo;
txtMargin: Integer;
begin
// Initialize the rectangle to be used for all-day events
ADEventsRect := InitAllDayEventsRect;
@ -320,7 +321,9 @@ begin
// number of all day events for the range of days covered by the control.
NumADEvents := 0;
AllDayWidth := RealWidth - RealRowHeadWidth - TextMargin - ScrollBarOffset;
txtMargin := FDayView.TextMargin;
AllDayWidth := RealWidth - RealRowHeadWidth - txtMargin - ScrollBarOffset;
DayWidth := AllDayWidth div FDayView.NumDays;
ADEventsList := TList.Create;
@ -364,10 +367,10 @@ begin
{$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF}
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin;
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin;
// Distance between text and border
txtDist := TextMargin div 2;
txtDist := txtMargin div 2;
// Store the top of the event's rect
OldTop := ADEventsRect.Top;
@ -417,10 +420,10 @@ begin
);
EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description;
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 2*TextMargin);
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 2*txtMargin);
TPSTextOut(RenderCanvas,Angle, RenderIn,
AdEvRect.Left + TextMargin,
AdEvRect.Left + txtMargin,
AdEvRect.Top + txtDist, // AdEvRect.Bottom - ADTextHeight) div 2, //TextMargin,
EventStr
);
@ -428,7 +431,7 @@ begin
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect(
ADEvRect.Left,
ADEvRect.Top - 2,
ADEvRect.Right - TextMargin,
ADEvRect.Right - txtMargin,
ADEvRect.Bottom
);
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event;
@ -673,15 +676,15 @@ begin
{ center and write the resource name in the first column }
if (Col = 0) then begin
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - ResStrLen div 2;
Y := TextRect.Top + TextMargin;
Y := TextRect.Top + FDayView.TextMargin;
TPSTextOut(RenderCanvas, Angle, RenderIn, X, Y, FDayView.DataStore.Resource.Description);
end;
{ center the date string }
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2;
Y := TextRect.Top + (TextMargin * 2) + DateStrHt;
Y := TextRect.Top + (FDayView.TextMargin * 2) + DateStrHt;
end else begin
{ center the date string }
Y := TextRect.Top + TextMargin;
Y := TextRect.Top + FDayView.TextMargin;
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2;
end;
{ Write the date string }
@ -897,7 +900,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 - TextMargin;
maxW := EventRect.Right - IconRect.Right - FScaledGutterWidth - FDayView.TextMargin;
if RenderCanvas.TextWidth(EventString) > maxW then
EventString := GetDisplayString(RenderCanvas, EventString, 0, maxW);
end;
@ -1139,16 +1142,16 @@ begin
TPSTextOut(RenderCanvas, // wp: both cases are the same ?!
Angle,
RenderIn,
AIconRect.Right + FDayView.GutterWidth + TextMargin,
AEventRect.Top + TextMargin,
AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
AEventRect.Top + FDayView.TextMargin,
AText
)
else
TPSTextOut(RenderCanvas,
Angle,
RenderIn,
AIconRect.Right + FDayView.GutterWidth + TextMargin,
AEventRect.Top + TextMargin,
AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
AEventRect.Top + FDayView.TextMargin,
AText
);
end;
@ -1438,7 +1441,7 @@ begin
{$ENDIF}
timeStr := Format('%s:%s', [hourStr, minuteStr]);
x := lineRect.Left + FScaledTickDist;
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, timeStr);
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, timeStr);
end else
begin
// In all other cases, paint large hour and small minutes (or am/pm)
@ -1448,7 +1451,7 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF}
x := lineRect.Right - RenderCanvas.TextWidth(MinuteStr) - MINUTES_BORDER;
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, minuteStr);
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, minuteStr);
// Draw hours
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont);
@ -1456,7 +1459,7 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF}
dec(x, RenderCanvas.TextWidth(HourStr) + MINUTES_HOUR_DISTANCE);
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin{ - 2}, hourStr);
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin{ - 2}, hourStr);
end;
end;
@ -1575,11 +1578,19 @@ end;
procedure TVpDayViewPainter.FixFontHeights;
begin
with FDayView do begin
{$IF VP_LCL_SCALING = 0}
AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font);
Font.Height := GetRealFontHeight(Font);
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont);
RowHeadAttributes.MinuteFont.Height := GetRealFontHeight(RowHeadAttributes.MinuteFont);
{$ELSE}
AllDayEventAttributes.Font.Height := FixFontHeight(AllDayEventAttributes.Font);
Font.Height := FixFontHeight(Font);
HeadAttributes.Font.Height := FixFontHeight(HeadAttributes.Font);
RowHeadAttributes.HourFont.Height := FixFontHeight(RowHeadAttributes.HourFont);
RowHeadAttributes.MinuteFont.Height := FixFontHeight(RowHeadAttributes.MinuteFont);
{$IFEND}
end;
end;