home *** CD-ROM | disk | FTP | other *** search
- unit WABD_TableStrEditor;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- WABD_Objects, Grids, ComCtrls, StdCtrls, ExtCtrls;
-
- type
- TTableStrings_Editor = class(TForm)
- ToolPanel: TPanel;
- Edit1: TEdit;
- Edit2: TEdit;
- UpDown1: TUpDown;
- UpDown2: TUpDown;
- StringGrid1: TStringGrid;
- Label1: TLabel;
- Label2: TLabel;
- btnSetSize: TButton;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure btnSetSizeClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- TabStrings : TWABD_Table_Strings;
- DetectChanges : boolean;
- procedure EditStrings(Strings: TWABD_Table_Strings);
- procedure StringsToGrid;
- procedure GridToStrings;
- end;
-
- var
- TableStrings_Editor: TTableStrings_Editor;
-
- implementation
-
- {$R *.DFM}
-
- procedure TTableStrings_Editor.EditStrings(Strings: TWABD_Table_Strings);
- begin
- TabStrings := Strings;
-
- DetectChanges := False;
- UpDown1.Position := TabStrings.Cols;
- UpDown2.Position := TabStrings.Rows;
- DetectChanges := True;
-
- StringsToGrid;
- ShowModal;
- end;
-
- procedure TTableStrings_Editor.StringsToGrid;
- var
- x, y : integer;
- begin
- StringGrid1.ColCount := TabStrings.Cols;
- StringGrid1.RowCount := TabStrings.Rows;
- for x := 0 to TabStrings.Cols-1 do
- for y := 0 to TabStrings.Rows-1 do
- StringGrid1.Cells[x,y] := TabStrings[x,y];
- end;
-
- procedure TTableStrings_Editor.GridToStrings;
- var
- x, y: integer;
- begin
- for x := 0 to TabStrings.Cols-1 do
- for y := 0 to TabStrings.Rows-1 do
- TabStrings[x,y] := StringGrid1.Cells[x,y];
- end;
-
-
- procedure TTableStrings_Editor.FormClose(Sender: TObject;
- var Action: TCloseAction);
- begin
- GridToStrings;
- end;
-
- procedure TTableStrings_Editor.btnSetSizeClick(Sender: TObject);
- var
- x,y : integer;
- begin
- x:=UpDown1.Position;
- y:=UpDown2.Position;
- if x<1 then UpDown1.Position:=1;
- if y<1 then UpDown2.Position:=1;
- if x>100 then UpDown1.Position:=100;
- if y>100 then UpDown2.Position:=100;
- Edit1.Text:=inttostr(UpDown1.position);
- Edit2.Text:=inttostr(UpDown2.position);
- TabStrings.SafeSetSize(x,y);
- StringsToGrid;
- end;
-
- end.
-