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