home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DELPHI / ORPHTR / AEUNIT.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-17  |  3KB  |  121 lines

  1. unit AEUnit;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, OvcBase, OvcData, OvcAe, OvcMisc, StdCtrls, CalUnit,
  8.   Buttons;
  9.  
  10. type
  11.   TAEForm = class(TForm)
  12.     OvcSimpleArrayEditor1: TOvcSimpleArrayEditor;
  13.     Label1: TLabel;
  14.     OvcPictureArrayEditor1: TOvcPictureArrayEditor;
  15.     BitBtn1: TBitBtn;
  16.     Label2: TLabel;
  17.     OvcController1: TOvcController;
  18.     procedure OvcSimpleArrayEditor1GetItem(Sender : TObject; Index: Longint;
  19.       var Value: Pointer);
  20.     procedure btnExitClick(Sender: TObject);
  21.     procedure OvcSimpleArrayEditor1GetItemColor(Sender: TObject;
  22.       Index: Longint; var FG, BG: TColor);
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure OvcSimpleArrayEditor1DblClick(Sender: TObject);
  25.     procedure OvcPictureArrayEditor1GetItem(Sender : TObject; Index: Longint;
  26.       var Value: Pointer);
  27.     procedure OvcPictureArrayEditor1DblClick(Sender: TObject);
  28.   private
  29.     { Private declarations }
  30.   public
  31.     { Public declarations }
  32.   end;
  33.  
  34. var
  35.   AEForm: TAEForm;
  36.  
  37. implementation
  38.  
  39. {$R *.DFM}
  40.  
  41. const
  42.   MaxItems = 50;
  43.  
  44. var
  45.   {Data for the array. Data type must match the array data type}
  46.   Data : array[0..MaxItems-1] of LongInt;
  47.   Colors : array[0..MaxItems-1] of TColor;
  48.   Dates : array[0..MaxItems-1] of TOvcDate;
  49.  
  50. procedure TAEForm.OvcSimpleArrayEditor1GetItem(Sender : TObject; Index: Longint;
  51.   var Value: Pointer);
  52. begin
  53.   if (Index > -1) and (Index < MaxItems) then
  54.     Value := @Data[Index]
  55.   else
  56.     raise Exception.Create('Invalid index value');
  57. end;
  58.  
  59. procedure TAEForm.btnExitClick(Sender: TObject);
  60. begin
  61.   Close;
  62. end;
  63.  
  64. procedure TAEForm.OvcSimpleArrayEditor1GetItemColor(Sender: TObject;
  65.   Index: Longint; var FG, BG: TColor);
  66. begin
  67.   if (Index > -1) and (Index < MaxItems) then
  68.     {just the text color--set BG for the background color}
  69.     FG := Colors[Index]
  70.   else
  71.     raise Exception.Create('Invalid index value');
  72. end;
  73.  
  74. procedure TAEForm.FormCreate(Sender: TObject);
  75. var
  76.   I : Integer;
  77. begin
  78.   for I := 0 to MaxItems-1 do begin
  79.     Data[I] := I;
  80.     Colors[I] := clBlack;
  81.  
  82.     Dates[I] := CurrentDate + I;
  83.   end;
  84. end;
  85.  
  86. procedure TAEForm.OvcSimpleArrayEditor1DblClick(Sender: TObject);
  87. var
  88.   I : LongInt;
  89. begin
  90.   {requires one click to make the cell active before a}
  91.   {double click is registered}
  92.   I := OvcSimpleArrayEditor1.ItemIndex;
  93.   Label1.Caption := Format('Index: %d', [I]);
  94. end;
  95.  
  96. procedure TAEForm.OvcPictureArrayEditor1GetItem(Sender : TObject; Index: Longint;
  97.   var Value: Pointer);
  98. begin
  99.   if (Index > -1) and (Index < MaxItems) then
  100.     Value := @Dates[Index]
  101.   else
  102.     raise Exception.Create('Invalid index value');
  103. end;
  104.  
  105. procedure TAEForm.OvcPictureArrayEditor1DblClick(Sender: TObject);
  106. begin
  107.   CalForm := TCalForm.Create(Application);
  108.   try
  109.     CalForm.OvcCalendar1.CalendarDate := Dates[OvcPictureArrayEditor1.ItemIndex];
  110.     CalForm.ShowModal;
  111.     if CalForm.ModalResult = idOK then begin
  112.       Dates[OvcPictureArrayEditor1.ItemIndex] := CalForm.OvcCalendar1.CalendarDate;
  113.       OvcPictureArrayEditor1.Refresh;
  114.     end;
  115.   finally
  116.     CalForm.Free;
  117.   end;
  118. end;
  119.  
  120. end.
  121.