| 1 | unit StringTable;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | { TStringTable }
|
|---|
| 10 |
|
|---|
| 11 | TStringTable = class
|
|---|
| 12 | private
|
|---|
| 13 | FCells: array of array of string;
|
|---|
| 14 | FSize: TPoint;
|
|---|
| 15 | function GetCell(X, Y: Integer): string;
|
|---|
| 16 | function GetColCount: Integer;
|
|---|
| 17 | function GetRowCount: Integer;
|
|---|
| 18 | procedure SetCell(X, Y: Integer; AValue: string);
|
|---|
| 19 | procedure SetColCount(AValue: Integer);
|
|---|
| 20 | procedure SetRowCount(AValue: Integer);
|
|---|
| 21 | procedure SetSize(AValue: TPoint);
|
|---|
| 22 | public
|
|---|
| 23 | property Cells[X, Y: Integer]: string read GetCell write SetCell;
|
|---|
| 24 | property ColCount: Integer read GetColCount write SetColCount;
|
|---|
| 25 | property RowCount: Integer read GetRowCount write SetRowCount;
|
|---|
| 26 | property Size: TPoint read FSize write SetSize;
|
|---|
| 27 | end;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | implementation
|
|---|
| 31 |
|
|---|
| 32 | { TStringTable }
|
|---|
| 33 |
|
|---|
| 34 | function TStringTable.GetCell(X, Y: Integer): string;
|
|---|
| 35 | begin
|
|---|
| 36 | Result := FCells[Y, X];
|
|---|
| 37 | end;
|
|---|
| 38 |
|
|---|
| 39 | function TStringTable.GetColCount: Integer;
|
|---|
| 40 | begin
|
|---|
| 41 | Result := Size.x;
|
|---|
| 42 | end;
|
|---|
| 43 |
|
|---|
| 44 | function TStringTable.GetRowCount: Integer;
|
|---|
| 45 | begin
|
|---|
| 46 | Result := Size.Y;
|
|---|
| 47 | end;
|
|---|
| 48 |
|
|---|
| 49 | procedure TStringTable.SetCell(X, Y: Integer; AValue: string);
|
|---|
| 50 | begin
|
|---|
| 51 | FCells[Y, X] := AValue;
|
|---|
| 52 | end;
|
|---|
| 53 |
|
|---|
| 54 | procedure TStringTable.SetColCount(AValue: Integer);
|
|---|
| 55 | begin
|
|---|
| 56 | Size := Point(AValue, RowCount);
|
|---|
| 57 | end;
|
|---|
| 58 |
|
|---|
| 59 | procedure TStringTable.SetRowCount(AValue: Integer);
|
|---|
| 60 | begin
|
|---|
| 61 | Size := Point(ColCount, AValue);
|
|---|
| 62 | end;
|
|---|
| 63 |
|
|---|
| 64 | procedure TStringTable.SetSize(AValue: TPoint);
|
|---|
| 65 | begin
|
|---|
| 66 | if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit;
|
|---|
| 67 | FSize := AValue;
|
|---|
| 68 | SetLength(FCells, FSize.Y, FSize.X);
|
|---|
| 69 | end;
|
|---|
| 70 |
|
|---|
| 71 | end.
|
|---|