summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui_customgrid.pas16
-rw-r--r--src/gui/gui_grid.pas20
2 files changed, 26 insertions, 10 deletions
diff --git a/src/gui/gui_customgrid.pas b/src/gui/gui_customgrid.pas
index dc2c0631..b18631e1 100644
--- a/src/gui/gui_customgrid.pas
+++ b/src/gui/gui_customgrid.pas
@@ -64,6 +64,7 @@ type
function GetColumns(AIndex: integer): TfpgGridColumn; virtual;
procedure DoDeleteColumn(ACol: integer); virtual;
procedure DoSetRowCount(AValue: integer); virtual;
+ procedure DoAfterAddColumn(ACol: integer); virtual;
function DoCreateColumnClass: TfpgGridColumn; virtual;
function GetColumnCount: Integer; override;
procedure SetColumnCount(const AValue: Integer); virtual;
@@ -135,7 +136,13 @@ end;
procedure TfpgCustomGrid.DoSetRowCount(AValue: integer);
begin
- // do nothing
+ // do nothing yet
+end;
+
+procedure TfpgCustomGrid.DoAfterAddColumn(ACol: integer);
+begin
+ // do nothing yet
+ // update empty cells in descendants
end;
function TfpgCustomGrid.DoCreateColumnClass: TfpgGridColumn;
@@ -291,14 +298,17 @@ begin
end;
function TfpgCustomGrid.AddColumn(ATitle: string; AWidth: integer): TfpgGridColumn;
+var
+ i: integer;
begin
Result := DoCreateColumnClass;
Result.Title := ATitle;
Result.Width := AWidth;
Result.Backgroundcolor := clBoxcolor;
Result.TextColor := TextColor;
- FColumns.Add(Result);
-
+ i := FColumns.Add(Result);
+ DoAfterAddColumn(i); // update empty cells in descendants
+
if csUpdating in ComponentState then
Exit; //==>
diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas
index 2284bec1..f694f23a 100644
--- a/src/gui/gui_grid.pas
+++ b/src/gui/gui_grid.pas
@@ -94,6 +94,7 @@ type
function GetColumns(AIndex: Integer): TfpgStringColumn; reintroduce;
procedure DoDeleteColumn(ACol: integer); override;
procedure DoSetRowCount(AValue: integer); override;
+ procedure DoAfterAddColumn(ACol: integer); override;
function DoCreateColumnClass: TfpgStringColumn; reintroduce; override;
procedure DrawCell(ARow, ACol: Integer; ARect: TfpgRect; AFlags: TfpgGridDrawState); override;
property Columns[AIndex: Integer]: TfpgStringColumn read GetColumns;
@@ -105,8 +106,8 @@ type
property Objects[ACol, ARow: Integer]: TObject read GetObjects write SetObjects;
property ColumnTitle[ACol: Integer]: string read GetColumnTitle write SetColumnTitle;
property ColumnWidth[ACol: Integer]: integer read GetColumnWidth write SetColumnWidth;
- property ColumnBackgroundColor[ACol: Integer]: TfpgColor read GetColumnBackgroundColor write SetColumnBackgroundColor;
- property ColumnTextColor[ACol: Integer]: TfpgColor read GetColumnTextColor write SetColumnTextColor;
+ property ColumnBackgroundColor;
+ property ColumnTextColor;
// property Cols[index: Integer]: TStrings read GetCols write SetCols;
// property Rows[index: Integer]: TStrings read GetRows write SetRows;
end;
@@ -404,6 +405,16 @@ begin
end;
end;
+procedure TfpgCustomStringGrid.DoAfterAddColumn(ACol: integer);
+var
+ r: integer;
+begin
+ inherited DoAfterAddColumn(ACol);
+ // initialize cells for existing rows
+ for r := 0 to RowCount-1 do
+ TfpgStringColumn(FColumns.Items[ACol]).Cells.Append('');
+end;
+
function TfpgCustomStringGrid.DoCreateColumnClass: TfpgStringColumn;
begin
Result := TfpgStringColumn.Create;
@@ -450,8 +461,6 @@ end;
function TfpgCustomStringGrid.AddColumn(ATitle: string; AWidth: integer;
AAlignment: TAlignment; ABackgroundColor: TfpgColor; ATextColor: TfpgColor): TfpgStringColumn;
-var
- r: integer;
begin
Updating;
Result := TfpgStringColumn(inherited AddColumn(ATitle, AWidth));
@@ -467,9 +476,6 @@ begin
else
Result.TextColor:= ATextColor;
- for r := 0 to RowCount-1 do
- Result.Cells.Append('');
-
if UpdateCount = 0 then
Updated; // if we called .BeginUpdate then don't clear csUpdating here
end;