home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1998 July / pcx23_9807.iso / PC-XUSER / PC-XUSER.16 / XVISION / XV2DEMO2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-03-08  |  1.3 KB  |  65 lines

  1. Uses Graph, Crt, XV2App;
  2.  
  3. Type
  4.   PButton=^TButton;
  5.   TButton=Object(TView)
  6.     Procedure Draw; Virtual;
  7.     Procedure HandleEvent(var Event: TEvent); Virtual;
  8.   End;
  9.  
  10.   PWindow=^TWindow;
  11.   TWindow=Object(TView)
  12.     color: Byte;
  13.     Constructor Init(ax,ay,aw,ah: Integer);
  14.     Procedure Draw; Virtual;
  15.   End;
  16.  
  17. Procedure TButton.HandleEvent;
  18. Begin
  19.   Case Event.What of
  20.   EvMouseDown: Begin;Sound(800);delay(100);nosound;End;
  21.   EvMouseUp  : Begin;Sound(1200);delay(100);nosound;End;
  22.   End;
  23. End;
  24.  
  25. Procedure TButton.Draw;
  26. Begin
  27.   SetFillStyle(1,1);
  28.   Bar(0,0,w,h);
  29.   SetColor(15);
  30.   Rectangle(0,0,w,h);
  31. End;
  32.  
  33. Constructor TWindow.Init;
  34. Begin
  35.   Inherited Init(ax,ay,aw,ah);
  36.   Color:=random(15);
  37.   Insert(New(PButton, Init(1,1,12,12)));
  38.   Insert(New(PButton, Init(20,30,50,20)));
  39.   Insert(New(PButton, Init(30,40,50,20)));
  40.   Insert(New(PButton, Init(30,70,50,20)));
  41. End;
  42.  
  43. Procedure TWindow.Draw;
  44. Begin
  45.   Sound(300);delay(100);nosound;
  46.   SetFillStyle(1,1);
  47.   Bar(0,0,w,15);
  48.   SetFillStyle(1,color);
  49.   Bar(0,16,w,h);
  50.   SetColor(0);
  51.   Rectangle(0,0,w,h);
  52.   Line(0,15,w,15);
  53. End;
  54.  
  55. Var
  56.   MyApp: TApplication;
  57.  
  58. Begin
  59.   Randomize;
  60.   MyApp.Init;
  61.   MyApp.Insert(New(PWindow, Init(10,10,300,100)));
  62.   MyApp.Insert(New(PWindow, Init(30,30,350,150)));
  63.   MyApp.Insert(New(PWindow, Init(50,50,400,200)));
  64.   MyApp.Run;
  65. End.