diff --git a/lcl/grids.pas b/lcl/grids.pas index 0244ec4747..82aa863e0e 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -180,14 +180,20 @@ type const soAll: TSaveOptions = [soDesign, soAttributes, soContent, soPosition]; - constRubberSpace: byte = 2; - constCellPadding: byte = 3; - constColRowBorderTolerance: byte = 3; DefaultGridOptions = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goSmoothScroll ]; DefaultGridOptions2 = []; + constRubberSpace: byte = 2; + constCellPadding: byte = 3; + constColRowBorderTolerance: byte = 3; + +var + // Values to be used after HighDPI scaling + varRubberSpace: byte; + varCellpadding: byte; + varColRowBorderTolerance: byte; type @@ -2028,12 +2034,12 @@ procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor; if Y2nil then begin case bmpAlign of taCenter: XPos := Trunc((aRect.Left+aRect.Right-ChkBitmap.Width)/2); - taLeftJustify: XPos := ARect.Left + constCellPadding; - taRightJustify: XPos := ARect.Right - ChkBitmap.Width - constCellPadding - 1; + taLeftJustify: XPos := ARect.Left + varCellPadding; + taRightJustify: XPos := ARect.Right - ChkBitmap.Width - varCellPadding - 1; end; YPos := Trunc((aRect.Top+aRect.Bottom-ChkBitmap.Height)/2); Canvas.Draw(XPos, YPos, ChkBitmap); @@ -5704,7 +5710,7 @@ begin end; // check if cursor is near boundary and it's a valid column - if (Abs(Offset-x)<=constColRowBorderTolerance) then begin + if (Abs(Offset-x)<=varColRowBorderTolerance) then begin if goFixedColSizing in Options then Offset := 0 else @@ -5776,7 +5782,7 @@ begin // check if it's not fixed row and if cursor is close enough to // selected boundary - if (Index>=FFixedRows)and(Abs(Offset-Y)<=constColRowBorderTolerance) then begin + if (Index>=FFixedRows)and(Abs(Offset-Y)<=varColRowBorderTolerance) then begin // start resizing if Cursor<>crVSplit then begin ChangeCursor(crVSplit); @@ -9435,6 +9441,10 @@ begin FUnCheckedBitmap := LoadResBitmapImage('dbgriduncheckedcb'); FCheckedBitmap := LoadResBitmapImage('dbgridcheckedcb'); FGrayedBitmap := LoadResBitmapImage('dbgridgrayedcb'); + + varRubberSpace := MulDiv(constRubberSpace, Screen.PixelsPerInch, 96); + varCellPadding := MulDiv(constCellPadding, Screen.PixelsPerInch, 96); + varColRowBorderTolerance := MulDiv(constColRowBorderTolerance, Screen.PixelsPerInch, 96); end; destructor TCustomGrid.Destroy;