fpspreadsheet: Fix painting artefacts of TsWorksheetGrid when resizing col widths or row heights by dragging with mouse.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4443 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-01-19 19:34:28 +00:00
parent 2ee3d18801
commit 0b6a62b46c

View File

@ -193,6 +193,7 @@ type
function GetEditText(ACol, ARow: Integer): String; override;
function GetDefaultHeaderColWidth: Integer;
function HasBorder(ACell: PCell; ABorder: TsCellBorder): Boolean;
procedure HeaderSizing(const IsColumn:boolean; const AIndex,ASize:Integer); override;
procedure HeaderSized(IsColumn: Boolean; AIndex: Integer); override;
procedure InternalDrawTextInCell(AText: String; ARect: TRect;
ACellHorAlign: TsHorAlignment; ACellVertAlign: TsVertAlignment;
@ -611,6 +612,8 @@ type
{@@ inherited from ancestors}
property OnHeaderSized;
{@@ inherited from ancestors}
property OnHeaderSizing;
{@@ inherited from ancestors}
property OnKeyDown;
{@@ inherited from ancestors}
property OnKeyPress;
@ -3224,6 +3227,46 @@ begin
Result := ABorder in Worksheet.ReadCellBorders(ACell);
end;
{@@ ----------------------------------------------------------------------------
HeaderSizing is called while a column width or row height is resized by the
mouse. Is overridden here to enforce a grid repaint if merged cells are
affected by the resizing column/row. Otherwise parts of the merged cells would
not be updated if the cell text moves during the resizing action.
-------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.HeaderSizing(const IsColumn:boolean;
const AIndex,ASize:Integer);
var
gc, gr: Integer;
sc, sr, sr1, sr2, sc1, sc2, si: Cardinal;
cell: PCell;
begin
inherited;
if Worksheet = nil then
exit;
// replaint the grid if merged cells are affected by the resizing col/row.
si := IfThen(IsColumn, GetWorksheetCol(AIndex), GetWorksheetRow(AIndex));
for gc := GetFirstVisibleColumn to GetLastVisibleColumn do
begin
sc := GetWorksheetCol(gc);
for gr := GetFirstVisibleRow to GetLastVisibleRow do
begin
sr := GetWorksheetRow(gr);
cell := Worksheet.FindCell(gr, gc);
if Worksheet.IsMerged(cell) then begin
Worksheet.FindMergedRange(cell, sr1, sc1, sr2, sc2);
if IsColumn and InRange(si, sc1, sc2) or
(not IsColumn) and InRange(si, sr1, sr2) then
begin
InvalidateGrid;
exit;
end;
end;
end;
end;
end;
{@@ ----------------------------------------------------------------------------
Inherited from TCustomGrid. Is called when column widths or row heights
have changed. Stores the new column width or row height in the worksheet.