source: trunk/Packages/Common/UStringTable.pas

Last change on this file was 41, checked in by chronos, 6 years ago
  • Modified: Build under Lazarus 2.0.
  • Modified: Used .lrj files instead of .lrt files.
  • Modified: Removed TemplateGenerics package.
File size: 1.6 KB
Line 
1unit UStringTable;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils;
9
10type
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
32implementation
33
34{ TStringTable }
35
36function TStringTable.GetCell(X, Y: Integer): string;
37begin
38 Result := FCells[Y, X];
39end;
40
41function TStringTable.GetColCount: Integer;
42begin
43 Result := Size.x;
44end;
45
46function TStringTable.GetRowCount: Integer;
47begin
48 Result := Size.Y;
49end;
50
51procedure TStringTable.SetCell(X, Y: Integer; AValue: string);
52begin
53 FCells[Y, X] := AValue;
54end;
55
56procedure TStringTable.SetColCount(AValue: Integer);
57begin
58 Size := Point(AValue, RowCount);
59end;
60
61procedure TStringTable.SetRowCount(AValue: Integer);
62begin
63 Size := Point(ColCount, AValue);
64end;
65
66procedure TStringTable.SetSize(AValue: TPoint);
67begin
68 if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit;
69 FSize := AValue;
70 SetLength(FCells, FSize.Y, FSize.X);
71end;
72
73
74end.
75
Note: See TracBrowser for help on using the repository browser.