home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progpas / tegl6b.arj / INTROPAK.EXE / lha / SLIDER.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-04  |  3KB  |  79 lines

  1. {---------------------------------------------------------}
  2. { Demonstrates how to place a slider in a frame.          }
  3. {---------------------------------------------------------}
  4.  
  5. {$F+}
  6. USES   fastgrph,tgraph,moreicon,teglunit,teglspec,teglmain;
  7. function itos(i: longint): String;
  8.   var s : string;
  9.   begin
  10.     str(i,s); itos := s;
  11.   end;
  12.  
  13. VAR ifs : ImageStkPtr;
  14.     sldptr : SliderPtr;
  15.  
  16. {-- slideaction is called whenever the slider is moved }
  17.  
  18. Function SlideAction(ifs : ImageStkPtr; ms : MsClickPtr): Word;
  19.   VAR dx,dy: LongInt;   {-- delta }
  20.   BEGIN
  21.     GetSliderRelative(sldptr,100,dx,0,dy); {-- ignore y }
  22.     setviewport(ifs^.x+1,ifs^.y+60,ifs^.x1-1,ifs^.y1-1,clipon);
  23.  
  24.     {-- clear lower part of frame }
  25.     prepareforupdate(ifs);
  26.     setfillstyle(solidfill,white);
  27.     bar(0,0,1000,1000);  {-- let clip do the work }
  28.     OutTextXy(10,10,itos(dx));
  29.     setviewport(0,0,getmaxx,getmaxy,clipoff); {-- restore to full screen }
  30.     commitupdate;
  31.   END;
  32.  
  33. Procedure FrameWithSlider;
  34.   BEGIN
  35.     {-- push an image an save the frame pointer, then clear it}
  36.     pushimage(10,10,310,190);
  37.     ifs := stackptr;
  38.  
  39.     {-- set the viewport over the frame so bar and rectangle will }
  40.     {-- be relative to the frame }
  41.     setviewport(10,10,310,190,clipoff);
  42.     setfillstyle(solidfill,white);
  43.     bar(0,0,300,180);
  44.     setcolor(black);
  45.     rectangle(0,0,300,180);
  46.     setfillstyle(solidfill,lightgray);
  47.     bar(50,0,200,20);
  48.     setcolor(black);
  49.     rectangle(50,0,200,20);
  50.  
  51.     {-- DefineSliderArea is FRAME RELATIVE, the first 4 coordinates define }
  52.     {-- the slider thumb (the moveable part) and the second 4 coordinates }
  53.     {-- define the entire slider area (its scope) }
  54.     definesliderarea(ifs,50,0,100,20,   {-- slider thumb }
  55.                          50,0,200,20,   {-- slider bar }
  56.                          slideaction);  {-- event to calll when moved }
  57.  
  58.     {-- save the slider pointer }
  59.     SldPtr := GetLastSliderDef(ifs);
  60.  
  61.     {-- only AFTER drawing the slider then defining it do we draw the }
  62.     {-- thumb. During define is when the slider captures the screen image}
  63.     {-- of the slider area. }
  64.  
  65.     setfillstyle(solidfill,red);
  66.     bar(50,0,100,20);  {-- note same coordiantes as slider thumb above. }
  67.     setcolor(black);
  68.     rectangle(50,0,100,20);
  69.     putpict(ifs^.x+65,ifs^.y+5,@imageslider2,black);
  70.     setviewport(0,0,getmaxx,getmaxy,clipoff);  {--restore viewport }
  71.   END;
  72.  
  73. BEGIN
  74.   easytegl;
  75.   easyout;
  76.   framewithslider;
  77.   teglsupervisor;
  78. END.
  79.