Grids: fix result of TCustomGrid.MouseToGridZone and TCustomGrid.CellToGridZone for gzFixedCol and gxFixedRow. Issue #41681.

This commit is contained in:
Bart 2025-05-31 09:34:04 +02:00
parent 66df7abea0
commit d70fd7f280

View File

@ -6530,23 +6530,14 @@ var
aBorderWidth: Integer;
aCol, aRow: Longint;
begin
{$ifdef dbgGrid}
debugln(['TCustomGrid.MouseToGridZone: X=',X,', Y=',Y,', FGCache.FixedWidth=',FGCache.FixedWidth,', FGCache.FixedHeight=',FGCache.FixedHeight]);
{$endif}
aBorderWidth := GetBorderWidth;
if FlipX(X)<FGCache.FixedWidth+aBorderWidth then begin
// in fixedwidth zone
// in fixedwidth zone: either a fixedcol or a fixedcell
if Y<FGcache.FixedHeight+aBorderWidth then
Result:= gzFixedCells
else begin
OffsetToColRow(False, True, Y, aRow, aCol);
if (aRow<0) or (RowCount<=FixedRows) then
Result := gzInvalid
else
Result := gzFixedRows;
end;
end
else if Y<FGCache.FixedHeight+aBorderWidth then begin
// if fixedheight zone
if FlipX(X)<FGCache.FixedWidth+aBorderWidth then
Result:=gzFixedCells
else begin
OffsetToColRow(True, True, X, aCol, aRow);
if (aCol<0) or (ColCount<=FixedCols) then
@ -6555,6 +6546,18 @@ begin
Result := gzFixedCols;
end;
end
else if Y<FGCache.FixedHeight+aBorderWidth then begin
// if fixedheight zone: either a fixedrow or a fixedcell
if FlipX(X)<FGCache.FixedWidth+aBorderWidth then
Result:=gzFixedCells
else begin
OffsetToColRow(False, True, Y, aRow, aCol);
if (aRow<0) or (RowCount<=FixedRows) then
Result := gzInvalid
else
Result := gzFixedRows;
end;
end
else if not FixedGrid then begin
// in normal cell zone (though, might be outbounds)
MouseToCell(x, y, aCol, aRow);
@ -6565,6 +6568,9 @@ begin
end
else
result := gzInvalid;
{$ifdef dbgGrid}
debugln(['TCustomGrid.MouseToGridZone: Result=',Dbgs(Result)]);
{$endif}
end;
function TCustomGrid.CellToGridZone(aCol, aRow: Integer): TGridZone;
@ -6576,13 +6582,13 @@ begin
if aRow<FFixedRows then
Result:= gzFixedCells
else
Result:= gzFixedRows
Result:= gzFixedCols
else
if (aRow<FFixedRows) then
if aCol<FFixedCols then
Result:= gzFixedCells
else
Result:= gzFixedCols
Result:= gzFixedRows
else
Result := gzNormal;
end;