LCL, implemented grid's assign method, issue #17052

git-svn-id: trunk@26888 -
This commit is contained in:
jesus 2010-07-29 05:24:37 +00:00
parent e0a8591ef0
commit cc2754ad38
2 changed files with 73 additions and 0 deletions

View File

@ -360,6 +360,7 @@ type
procedure RenewColWidths;
protected
procedure AddAutomaticColumns;
procedure AssignTo(Dest: TPersistent); override;
procedure BeforeMoveSelection(const DCol,DRow: Integer); override;
procedure BeginLayout;
procedure CellClick(const aCol,aRow: Integer; const Button:TMouseButton); override;
@ -1498,6 +1499,14 @@ begin
end;
procedure TCustomDBGrid.AssignTo(Dest: TPersistent);
begin
if Dest is TCustomDbGrid then begin
// TODO
end else
inherited AssignTo(Dest);
end;
procedure TCustomDBGrid.UpdateAutoSizeColumns;
var
ACol,ARow,w: Integer;

View File

@ -796,6 +796,7 @@ type
fGridState: TGridState;
class procedure WSRegisterClass; override;
procedure AdjustEditorBounds(NewCol,NewRow:Integer); virtual;
procedure AssignTo(Dest: TPersistent); override;
procedure AutoAdjustColumn(aCol: Integer); virtual;
procedure BeforeMoveSelection(const DCol,DRow: Integer); virtual;
function BoxRect(ALeft,ATop,ARight,ABottom: Longint): TRect;
@ -1425,6 +1426,7 @@ type
procedure WriteCells(Writer: TWriter);
procedure CopyCellRectToClipboard(const R:TRect);
protected
procedure AssignTo(Dest: TPersistent); override;
procedure AutoAdjustColumn(aCol: Integer); override;
procedure CalcCellExtent(acol, aRow: Integer; var aRect: TRect); override;
procedure DefineProperties(Filer: TFiler); override;
@ -2549,6 +2551,53 @@ begin
EditorPos;
end;
procedure TCustomGrid.AssignTo(Dest: TPersistent);
var
Target: TCustomGrid;
begin
if Dest is TCustomGrid then begin
Target := TCustomGrid(Dest);
Target.BeginUpdate;
// structure
Target.FixedCols := 0;
Target.FixedRows := 0;
if Columns.Enabled then
Target.Columns.Assign(Columns)
else begin
Target.ColCount :=ColCount;
end;
Target.RowCount := RowCount;
Target.FixedCols := FixedCols;
Target.FixedRows := FixedRows;
Target.DefaultRowHeight := DefaultRowHeight;
Target.DefaultColWidth := DefaultColWidth;
if not Columns.Enabled then
Target.FCols.Assign(FCols);
Target.FRows.Assign(FRows);
// Options
Target.Options := Options;
Target.Color := Color;
Target.FixedColor := FixedColor;
Target.AlternateColor := AlternateColor;
Target.Font := Font;
Target.TitleFont := TitleFont;
// position
Target.TopRow := TopRow;
Target.LeftCol := LeftCol;
Target.Col := Col;
Target.Row := Row;
Target.FRange := FRange;
Target.EndUpdate;
end else
inherited AssignTo(Dest);
end;
procedure TCustomGrid.SetColCount(AValue: Integer);
begin
if Columns.Enabled then
@ -9105,6 +9154,21 @@ begin
Clipboard.AsText := SelStr;
end;
procedure TCustomStringGrid.AssignTo(Dest: TPersistent);
var
i, j: Integer;
begin
if Dest is TCustomStringGrid then begin
BeginUpdate;
inherited AssignTo(Dest);
for i:=0 to ColCount-1 do
for j:=0 to RowCount-1 do
TCustomStringGrid(Dest).Cells[i,j] := Cells[i,j];
EndUpdate;
end else
inherited AssignTo(Dest);
end;
procedure TCustomStringGrid.AutoAdjustColumn(aCol: Integer);
var
i,W: Integer;