source: trunk/Packages/Common/StringTable.pas

Last change on this file was 2, checked in by chronos, 16 months ago
  • Added: Initial development version.
File size: 1.5 KB
Line 
1unit StringTable;
2
3interface
4
5uses
6 Classes, SysUtils;
7
8type
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
30implementation
31
32{ TStringTable }
33
34function TStringTable.GetCell(X, Y: Integer): string;
35begin
36 Result := FCells[Y, X];
37end;
38
39function TStringTable.GetColCount: Integer;
40begin
41 Result := Size.x;
42end;
43
44function TStringTable.GetRowCount: Integer;
45begin
46 Result := Size.Y;
47end;
48
49procedure TStringTable.SetCell(X, Y: Integer; AValue: string);
50begin
51 FCells[Y, X] := AValue;
52end;
53
54procedure TStringTable.SetColCount(AValue: Integer);
55begin
56 Size := Point(AValue, RowCount);
57end;
58
59procedure TStringTable.SetRowCount(AValue: Integer);
60begin
61 Size := Point(ColCount, AValue);
62end;
63
64procedure TStringTable.SetSize(AValue: TPoint);
65begin
66 if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit;
67 FSize := AValue;
68 SetLength(FCells, FSize.Y, FSize.X);
69end;
70
71end.
Note: See TracBrowser for help on using the repository browser.