summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-19 14:02:24 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-09-19 14:02:24 +0000
commitc4c280141a787c832c5c9ad3a0f5e0efeb57e5a4 (patch)
tree5b6321ce2c70ba55a9dc8c258427f528672a4561 /src/gui
parente879ec3c3c1e91e6d99582cf26a7f2f0ebe45bfd (diff)
downloadfpGUI-c4c280141a787c832c5c9ad3a0f5e0efeb57e5a4.tar.xz
* GUI: All CustomGrid and StringGrid properties using a Column Index is now
1-based. So to access the first column the Index will be 1. * GUI Designer: Added a StringGrid Columns property editor. * GUI Designer: When saving files that are now also added to the MRU menu.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui_customgrid.pas38
-rw-r--r--src/gui/gui_grid.pas20
2 files changed, 49 insertions, 9 deletions
diff --git a/src/gui/gui_customgrid.pas b/src/gui/gui_customgrid.pas
index 47cd2e9f..be589e7c 100644
--- a/src/gui/gui_customgrid.pas
+++ b/src/gui/gui_customgrid.pas
@@ -15,7 +15,6 @@ interface
uses
Classes,
SysUtils,
- gfxbase,
fpgfx,
gui_basegrid;
@@ -52,12 +51,16 @@ type
function GetHeaderText(ACol: integer): string; override;
property RowCount: integer read GetRowCount write SetRowCount;
property ColumnCount: integer read GetColumnCount write SetColumnCount;
+ { Columns AIndex is 1-based. }
property Columns[AIndex: integer]: TfpgGridColumn read GetColumns;
// property AlternateColor: TColor read FAlternateColor write SetAlternateColor stored IsAltColorStored;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AddColumn(ATitle: string; AWidth: integer): TfpgGridColumn; virtual;
+ { AIndex is 1-based. }
+ procedure DeleteColumn(AIndex: integer); virtual;
+ procedure MoveColumn(oldindex, newindex: integer); virtual;
end;
@@ -67,9 +70,9 @@ implementation
constructor TfpgGridColumn.Create;
begin
- Width := 64;
+ Width := 65;
Title := '';
- Alignment := taCenter;
+ Alignment := taLeftJustify;
end;
{ TfpgCustomGrid }
@@ -81,10 +84,10 @@ end;
function TfpgCustomGrid.GetColumns(AIndex: integer): TfpgGridColumn;
begin
- if (AIndex < 0) or (AIndex > FColumns.Count-1) then
+ if (AIndex < 1) or (AIndex > FColumns.Count) then
Result := nil
else
- Result := TfpgGridColumn(FColumns[AIndex]);
+ Result := TfpgGridColumn(FColumns[AIndex-1]);
end;
procedure TfpgCustomGrid.DoDeleteColumn(ACol: integer);
@@ -182,8 +185,8 @@ end;
constructor TfpgCustomGrid.Create(AOwner: TComponent);
begin
- inherited Create(AOwner);
FColumns := TList.Create;
+ inherited Create(AOwner);
ColumnCount := 5;
RowCount := 5;
end;
@@ -207,9 +210,32 @@ begin
Result.Width := AWidth;
FColumns.Add(Result);
+ if csUpdating in ComponentState then
+ Exit; //==>
+
UpdateScrollBars;
RePaint;
end;
+procedure TfpgCustomGrid.DeleteColumn(AIndex: integer);
+var
+ c: TfpgGridColumn;
+begin
+ c := Columns[AIndex];
+ if c <> nil then
+ begin
+ DoDeleteColumn(AIndex);
+ if HasHandle then
+ Update;
+ end;
+end;
+
+procedure TfpgCustomGrid.MoveColumn(oldindex, newindex: integer);
+begin
+ FColumns.Move(oldindex, newindex);
+ if HasHandle then
+ Update;
+end;
+
end.
diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas
index c57b3c38..be619194 100644
--- a/src/gui/gui_grid.pas
+++ b/src/gui/gui_grid.pas
@@ -151,9 +151,12 @@ type
procedure DoSetRowCount(AValue: integer); override;
function DoCreateColumnClass: TfpgStringColumn; reintroduce; override;
procedure DrawCell(ARow, ACol: integer; ARect: TfpgRect; AFlags: integer); override;
+ { AIndex is 1-based. }
property Columns[AIndex: integer]: TfpgStringColumn read GetColumns;
public
- function AddColumn(ATitle: string; AWidth: integer): TfpgStringColumn; reintroduce; override;
+ constructor Create(AOwner: TComponent); override;
+ function AddColumn(ATitle: string; AWidth: integer; AAlignment: TAlignment = taLeftJustify): TfpgStringColumn; overload;
+ { ACol and ARow is 1-based. }
property Cells[ACol, ARow: LongWord]: string read GetCell write SetCell;
// property Objects[ACol, ARow: Integer]: TObject read GetObjects write SetObjects;
property ColumnTitle[ACol: integer]: string read GetColumnTitle write SetColumnTitle;
@@ -592,7 +595,7 @@ begin
RowCount := 0;
FFixedFont := fpgGetFont('Courier New-9');
- {$Note Abstract this! No IFDEF's allowed!!! }
+ {$Note No IFDEF's allowed!!! But how the hell to we get around this? }
{$ifdef MSWINDOWS}
AddColumn('Name', 320);
{$else}
@@ -745,13 +748,24 @@ begin
end;
end;
-function TfpgCustomStringGrid.AddColumn(ATitle: string; AWidth: integer): TfpgStringColumn;
+constructor TfpgCustomStringGrid.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ ColumnCount := 0;
+ RowCount := 0;
+end;
+
+function TfpgCustomStringGrid.AddColumn(ATitle: string; AWidth: integer;
+ AAlignment: TAlignment): TfpgStringColumn;
var
r: integer;
begin
+ Include(ComponentState, csUpdating);
Result := TfpgStringColumn(inherited AddColumn(ATitle, AWidth));
+ Result.Alignment := AAlignment;
for r := 1 to RowCount do
Result.Cells.Append('');
+ Exclude(ComponentState, csUpdating);
end;
end.