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

  1. unit Nbunit;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, OvcNbk, OvcBase, OvcEf, OvcSf,
  8.   OvcCal, OvcPb, OvcPf, OvcNf, OvcMisc, OvcSc, OvcData, ExtCtrls, Buttons,
  9.   OvcTimer;
  10.  
  11. type
  12.   TForm1 = class(TForm)
  13.     btnTabPos: TButton;
  14.     btnShadowText: TButton;
  15.     Label1: TLabel;
  16.     btnChangeTab: TButton;
  17.     btnFontColor: TButton;
  18.     ColorDialog1: TColorDialog;
  19.     FontDialog1: TFontDialog;
  20.     btnFontSel: TButton;
  21.     NB1: TOvcNotebook;
  22.     OvcFourWaySpinner1: TOvcFourWaySpinner;
  23.     Label2: TLabel;
  24.     OvcSimpleField1: TOvcSimpleField;
  25.     OvcNotebook2: TOvcNotebook;
  26.     OvcCalendar1: TOvcCalendar;
  27.     Label3: TLabel;
  28.     OvcPictureField1: TOvcPictureField;
  29.     btnCalDate: TButton;
  30.     OvcSimpleField2: TOvcSimpleField;
  31.     OvcPictureField2: TOvcPictureField;
  32.     OvcNumericField1: TOvcNumericField;
  33.     Label4: TLabel;
  34.     Label5: TLabel;
  35.     btnTabDisable: TButton;
  36.     OvcSimpleField3: TOvcSimpleField;
  37.     CheckBox1: TCheckBox;
  38.     Memo1: TMemo;
  39.     Edit1: TEdit;
  40.     Edit2: TEdit;
  41.     Label6: TLabel;
  42.     Label7: TLabel;
  43.     OvcFourWaySpinner2: TOvcFourWaySpinner;
  44.     Panel1: TPanel;
  45.     BitBtn1: TBitBtn;
  46.     TP: TOvcTimerPool;
  47.     btnAuto: TBitBtn;
  48.     OvcController1: TOvcController;
  49.     procedure btnTabPosClick(Sender: TObject);
  50.     procedure btnShadowTextClick(Sender: TObject);
  51.     procedure btnChangeTabClick(Sender: TObject);
  52.     procedure NB1TabChange(Sender: TObject; Index: Integer;
  53.       var AllowChange: Boolean);
  54.     procedure btnFontColorClick(Sender: TObject);
  55.     procedure btnFontSelClick(Sender: TObject);
  56.     procedure OvcFourWaySpinner1Click(Sender: TObject; State: TSpinState;
  57.       Delta: Longint; Wrap: Boolean);
  58.     procedure btnCalDateClick(Sender: TObject);
  59.     procedure OvcCalendar1Change(Sender: TObject);
  60.     procedure btnTabDisableClick(Sender: TObject);
  61.     procedure TPAllTriggers(Sender: TObject;
  62.       TriggerHandle: Integer; Interval: Word; ElapsedTime: Longint);
  63.     procedure FormCreate(Sender: TObject);
  64.     procedure btnAutoClick(Sender: TObject);
  65.   private
  66.     { Private declarations }
  67.     T1,
  68.     T2,
  69.     T3 : Integer;  {trigger handles}
  70.   public
  71.     { Public declarations }
  72.   end;
  73.  
  74. var
  75.   Form1: TForm1;
  76.  
  77. implementation
  78.  
  79. {$R *.DFM}
  80.  
  81.  
  82. procedure TForm1.btnTabPosClick(Sender: TObject);
  83. begin
  84.   with NB1 do
  85.     if TabOrientation = toRight then
  86.       TabOrientation := toTop
  87.     else
  88.       TabOrientation := toRight;
  89. end;
  90.  
  91. procedure TForm1.btnShadowTextClick(Sender: TObject);
  92. begin
  93.   with NB1 do
  94.     ShadowedText := not ShadowedText;
  95. end;
  96.  
  97. procedure TForm1.btnChangeTabClick(Sender: TObject);
  98. begin
  99.   NB1.PageIndex := OvcSimpleField1.AsInteger;
  100. end;
  101.  
  102. procedure TForm1.NB1TabChange(Sender: TObject; Index: Integer;
  103.   var AllowChange: Boolean);
  104. begin
  105.   OvcSimpleField1.AsInteger := Index;
  106. end;
  107.  
  108. procedure TForm1.btnFontColorClick(Sender: TObject);
  109. begin
  110.   ColorDialog1.Color := NB1.Font.Color;
  111.   ColorDialog1.Execute;
  112.   NB1.Font.Color := ColorDialog1.Color;
  113. end;
  114.  
  115. procedure TForm1.btnFontSelClick(Sender: TObject);
  116. begin
  117.   FontDialog1.Font := NB1.Font;
  118.   FontDialog1.Execute;
  119.   NB1.Font := FontDialog1.Font;
  120. end;
  121.  
  122. procedure TForm1.OvcFourWaySpinner1Click(Sender: TObject;
  123.   State: TSpinState; Delta: Longint; Wrap: Boolean);
  124. begin
  125.   with NB1 do begin
  126.     if TabOrientation = toTop then begin
  127.       case State of
  128.         ssUpBtn : TabHeight := TabHeight + 1;
  129.         ssDownBtn : TabHeight := TabHeight - 1;
  130.         ssRightBtn : TabWidth := TabWidth + 5;
  131.         ssLeftBtn : TabWidth := TabWidth - 5;
  132.       end;
  133.      end else begin
  134.       case State of
  135.         ssRightBtn : TabHeight := TabHeight + 1;
  136.         ssLeftBtn : TabHeight := TabHeight - 1;
  137.         ssUpBtn : TabWidth := TabWidth + 5;
  138.         ssDownBtn : TabWidth := TabWidth - 5;
  139.       end;
  140.      end;
  141.   end;
  142. end;
  143.  
  144. procedure TForm1.btnCalDateClick(Sender: TObject);
  145. begin
  146.   {second page (index 1) contains the calendar}
  147.   NB1.PageIndex := 1;
  148.   {change the calendar date}
  149.   OvcCalendar1.CalendarDate := OvcPictureField1.AsOvcDate;
  150. end;
  151.  
  152. procedure TForm1.OvcCalendar1Change(Sender: TObject);
  153. var
  154.   S : string[25];
  155.   Y : Word;
  156. begin
  157.   Y := OvcCalendar1.Year;
  158.   S := Format('%d', [Y]);
  159.   Label7.Caption := OvcCalendar1.MonthString + ' ' + S;
  160.   Panel1.Caption := OvcCalendar1.DateString('www, dd nnn yyyy');
  161. end;
  162.  
  163. procedure TForm1.btnTabDisableClick(Sender: TObject);
  164. begin
  165.   with NB1 do
  166.     PageStatus[3] := not PageStatus[3];
  167. end;
  168.  
  169. procedure TForm1.TPAllTriggers(Sender: TObject;
  170.   TriggerHandle: Integer; Interval: Word; ElapsedTime: Longint);
  171.   {respond to all trigger events here}
  172. const
  173.   C : Integer = 0;
  174. begin
  175.   if TriggerHandle = T1 then begin
  176.     Inc(C);
  177.     if C > NB1.Pages.Count-1 then
  178.       C := 0;
  179.     if NB1.IsValid(C) then
  180.       NB1.PageIndex := C;
  181.   end;
  182.  
  183.   if TriggerHandle = T2 then begin
  184.     btnTabPosClick(Sender);
  185.   end;
  186.  
  187.   if TriggerHandle = T3 then begin
  188.     btnTabDisableClick(Sender);
  189.   end;
  190.  
  191. end;
  192.  
  193. procedure TForm1.FormCreate(Sender: TObject);
  194. var
  195.   Buf : array[0..255] of Char;
  196. begin
  197.   OvcSimpleField1.AsInteger := Form1.NB1.PageIndex;
  198.   OvcCalendar1.CalendarDate := CurrentDate;
  199.   {set picture mask to correspond with the control panel settings}
  200.   OvcPictureField1.PictureMask :=
  201.     StrPas(OvcCalendar1.IntlSupport.InternationalDateP(Buf, True));
  202.   OvcPictureField1.AsOvcDate := CurrentDate;
  203.   OvcSimpleField2.AsString := 'Simple Field Editor';
  204.   OvcPictureField2.AsString := 'Picture Field Editor';
  205.   OvcNumericField1.AsInteger := 32768;
  206. end;
  207.  
  208. procedure TForm1.btnAutoClick(Sender: TObject);
  209. const
  210.   Started : Boolean = False;
  211. begin
  212.   Started := not Started;
  213.   if Started then begin
  214.     T1 := TP.AddTrigger(nil, 1000);
  215.     T2 := TP.AddTrigger(nil, 7000);
  216.     T3 := TP.AddTrigger(nil, 5000);
  217.     btnAuto.Caption := 'Stop Auto Demo';
  218.   end else begin
  219.     TP.RemoveAllTriggers;
  220.     btnAuto.Caption := 'Start Auto Demo';
  221.   end;
  222. end;
  223.  
  224. end.
  225.