fpspreadsheet: Fix painting glitches of frozen pane border lines in WorksheetGrid

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5810 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-03-18 22:28:06 +00:00
parent 932290dee9
commit 59a38caa22

View File

@ -225,7 +225,7 @@ type
procedure DrawCellGrid(ACol,ARow: Integer; ARect: TRect; AState: TGridDrawState); override; procedure DrawCellGrid(ACol,ARow: Integer; ARect: TRect; AState: TGridDrawState); override;
procedure DrawCommentMarker(ARect: TRect); procedure DrawCommentMarker(ARect: TRect);
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override; procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
procedure DrawFrozenPaneBorders(ARect: TRect); procedure DrawFrozenPaneBorder(AStart, AEnd, ACoord: Integer; IsHor: Boolean);
procedure DrawFrozenPanes; procedure DrawFrozenPanes;
procedure DrawImages(AGridPart: Integer = 0); procedure DrawImages(AGridPart: Integer = 0);
procedure DrawRow(aRow: Integer); override; procedure DrawRow(aRow: Integer); override;
@ -1910,33 +1910,29 @@ begin
FTopLeft := CalcTopLeft(false); FTopLeft := CalcTopLeft(false);
Canvas.SaveHandleState; if (FrozenRows > 0) or (FrozenCols > 0) then
DrawFrozenPanes;
// Set cliprect for scrollable grid area
cliprect := ClientRect;
TL := CalcTopLeft(false);
if IsRightToLeft then
cliprect.Right := TL.X
else
cliprect.Left := TL.X;
cliprect.Top := TL.Y;
// Paint cell borders, selection rectangle, images and frozen-pane-borders
// into this clipped area
rgn := CreateRectRgn(cliprect.Left, cliprect.top, cliprect.Right, cliprect.Bottom);
try try
if (FrozenRows > 0) or (FrozenCols > 0) then
DrawFrozenPanes;
// Set cliprect for scrollable grid area
cliprect := ClientRect;
TL := CalcTopLeft(false);
if IsRightToLeft then
cliprect.Right := TL.X
else
cliprect.Left := TL.X;
cliprect.Top := TL.Y;
DrawFrozenPaneBorders(clipRect);
rgn := CreateRectRgn(cliprect.Left, cliprect.top, cliprect.Right, cliprect.Bottom);
SelectClipRgn(Canvas.Handle, Rgn); SelectClipRgn(Canvas.Handle, Rgn);
DrawCellBorders; DrawCellBorders;
DrawSelection; DrawSelection;
DrawImages(DRAW_NON_FROZEN); DrawImages(DRAW_NON_FROZEN);
//DrawFrozenPaneBorders(clipRect); // DrawFrozenPaneBorders(clipRect);
DeleteObject(rgn);
finally finally
Canvas.RestoreHandleState; DeleteObject(rgn);
end; end;
end; end;
@ -1976,6 +1972,7 @@ begin
SelectClipRgn(Canvas.Handle, rgn); SelectClipRgn(Canvas.Handle, rgn);
DrawCellBorders(DRAW_FROZEN_ROWS); DrawCellBorders(DRAW_FROZEN_ROWS);
DrawImages(DRAW_FROZEN_ROWS); DrawImages(DRAW_FROZEN_ROWS);
DrawFrozenPaneBorder(cliprect.Left, clipRect.Right, cliprect.Bottom-1, true);
finally finally
DeleteObject(rgn); DeleteObject(rgn);
end; end;
@ -1992,6 +1989,10 @@ begin
SelectClipRgn(Canvas.Handle, rgn); SelectClipRgn(Canvas.Handle, rgn);
DrawCellBorders(DRAW_FROZEN_COLS); DrawCellBorders(DRAW_FROZEN_COLS);
DrawImages(DRAW_FROZEN_COLS); DrawImages(DRAW_FROZEN_COLS);
if IsRightToLeft then
DrawFrozenPaneBorder(cliprect.Top, cliprect.Bottom, cliprect.Left+1, false)
else
DrawFrozenPaneBorder(cliprect.Top, cliprect.Bottom, cliprect.Right-1, false);
finally finally
DeleteObject(rgn); DeleteObject(rgn);
end; end;
@ -2308,29 +2309,26 @@ end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Draws a solid line along the borders of frozen panes. Draws a solid line along the borders of frozen panes.
@param ARect This rectangle indicates the area containing scrollable cells. @param AStart Start coordinate of the pane border line
If the grid has frozen panes, a black line is drawn along the @param AEnd End coordinate of the pane border line
upper and/or left edge of this rectangle (depending on the @param ACoord other coordinate of the border line
value of FrozenRows and FrozenCols). (y if horizontal, x if vertical)
@param IsHor Determines whether a horizontal or vertical line is drawn and,
thus, how AStart, AEnd and ACoord are interpreted.
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCustomWorksheetGrid.DrawFrozenPaneBorders(ARect: TRect); procedure TsCustomWorksheetGrid.DrawFrozenPaneBorder(AStart, AEnd, ACoord: Integer;
IsHor: Boolean);
begin begin
if WorkSheet = nil then if (IsHor and (FFrozenRows = 0)) or (not IsHor and (FFrozenCols = 0)) then
exit; exit;
if (soHasFrozenPanes in Worksheet.Options) then begin Canvas.Pen.Style := psSolid;
Canvas.Pen.Style := psSolid; Canvas.Pen.Color := clBlack;
Canvas.Pen.Color := clBlack; Canvas.Pen.Width := 1;
Canvas.Pen.Width := 1; if IsHor then
if FFrozenRows > 0 then Canvas.Line(AStart, ACoord, AEnd, ACoord)
Canvas.Line(ARect.Left, ARect.Top, ARect.Right, ARect.Top); else
if FFrozenCols > 0 then Canvas.Line(ACoord, AStart, ACoord, AEnd);
begin
if IsRightToLeft then
Canvas.Line(ARect.Right, ARect.Top, ARect.Right, ARect.Bottom) else
Canvas.Line(ARect.Left, ARect.Top, ARect.Left, ARect.Bottom);
end;
end;
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------