home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / d3456 / KBMWABD.ZIP / WABD_TableStrEditor.pas < prev    next >
Pascal/Delphi Source File  |  2001-01-20  |  2KB  |  97 lines

  1. unit WABD_TableStrEditor;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   WABD_Objects, Grids, ComCtrls, StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TTableStrings_Editor = class(TForm)
  11.     ToolPanel: TPanel;
  12.     Edit1: TEdit;
  13.     Edit2: TEdit;
  14.     UpDown1: TUpDown;
  15.     UpDown2: TUpDown;
  16.     StringGrid1: TStringGrid;
  17.     Label1: TLabel;
  18.     Label2: TLabel;
  19.     btnSetSize: TButton;
  20.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  21.     procedure btnSetSizeClick(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.     TabStrings : TWABD_Table_Strings;
  27.     DetectChanges : boolean;
  28.     procedure  EditStrings(Strings: TWABD_Table_Strings);
  29.     procedure  StringsToGrid;
  30.     procedure  GridToStrings;
  31.   end;
  32.  
  33. var
  34.   TableStrings_Editor: TTableStrings_Editor;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TTableStrings_Editor.EditStrings(Strings: TWABD_Table_Strings);
  41. begin
  42.    TabStrings := Strings;
  43.  
  44.    DetectChanges := False;
  45.    UpDown1.Position := TabStrings.Cols;
  46.    UpDown2.Position := TabStrings.Rows;
  47.    DetectChanges := True;
  48.  
  49.    StringsToGrid;
  50.    ShowModal;
  51. end;
  52.  
  53. procedure  TTableStrings_Editor.StringsToGrid;
  54. var
  55.    x, y : integer;
  56. begin
  57.    StringGrid1.ColCount := TabStrings.Cols;
  58.    StringGrid1.RowCount := TabStrings.Rows;
  59.    for x := 0 to TabStrings.Cols-1 do
  60.       for y := 0 to TabStrings.Rows-1 do 
  61.          StringGrid1.Cells[x,y] := TabStrings[x,y];
  62. end;
  63.  
  64. procedure  TTableStrings_Editor.GridToStrings;
  65. var
  66.    x, y: integer;
  67. begin
  68.    for x := 0 to TabStrings.Cols-1 do
  69.       for y := 0 to TabStrings.Rows-1 do
  70.          TabStrings[x,y] := StringGrid1.Cells[x,y];
  71. end;
  72.  
  73.  
  74. procedure TTableStrings_Editor.FormClose(Sender: TObject;
  75.   var Action: TCloseAction);
  76. begin
  77.    GridToStrings;
  78. end;
  79.  
  80. procedure TTableStrings_Editor.btnSetSizeClick(Sender: TObject);
  81. var
  82.    x,y : integer;
  83. begin
  84.      x:=UpDown1.Position;
  85.      y:=UpDown2.Position;
  86.      if x<1 then UpDown1.Position:=1;
  87.      if y<1 then UpDown2.Position:=1;
  88.      if x>100 then UpDown1.Position:=100;
  89.      if y>100 then UpDown2.Position:=100;
  90.      Edit1.Text:=inttostr(UpDown1.position);
  91.      Edit2.Text:=inttostr(UpDown2.position);
  92.      TabStrings.SafeSetSize(x,y);
  93.      StringsToGrid;
  94. end;
  95.  
  96. end.
  97.