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