home *** CD-ROM | disk | FTP | other *** search
- {---------------------------------------------------------}
- { Demonstrates how to place a slider in a frame. }
- {---------------------------------------------------------}
-
- {$F+}
- USES fastgrph,tgraph,moreicon,teglunit,teglspec,teglmain;
- function itos(i: longint): String;
- var s : string;
- begin
- str(i,s); itos := s;
- end;
-
- VAR ifs : ImageStkPtr;
- sldptr : SliderPtr;
-
- {-- slideaction is called whenever the slider is moved }
-
- Function SlideAction(ifs : ImageStkPtr; ms : MsClickPtr): Word;
- VAR dx,dy: LongInt; {-- delta }
- BEGIN
- GetSliderRelative(sldptr,100,dx,0,dy); {-- ignore y }
- setviewport(ifs^.x+1,ifs^.y+60,ifs^.x1-1,ifs^.y1-1,clipon);
-
- {-- clear lower part of frame }
- prepareforupdate(ifs);
- setfillstyle(solidfill,white);
- bar(0,0,1000,1000); {-- let clip do the work }
- OutTextXy(10,10,itos(dx));
- setviewport(0,0,getmaxx,getmaxy,clipoff); {-- restore to full screen }
- commitupdate;
- END;
-
- Procedure FrameWithSlider;
- BEGIN
- {-- push an image an save the frame pointer, then clear it}
- pushimage(10,10,310,190);
- ifs := stackptr;
-
- {-- set the viewport over the frame so bar and rectangle will }
- {-- be relative to the frame }
- setviewport(10,10,310,190,clipoff);
- setfillstyle(solidfill,white);
- bar(0,0,300,180);
- setcolor(black);
- rectangle(0,0,300,180);
- setfillstyle(solidfill,lightgray);
- bar(50,0,200,20);
- setcolor(black);
- rectangle(50,0,200,20);
-
- {-- DefineSliderArea is FRAME RELATIVE, the first 4 coordinates define }
- {-- the slider thumb (the moveable part) and the second 4 coordinates }
- {-- define the entire slider area (its scope) }
- definesliderarea(ifs,50,0,100,20, {-- slider thumb }
- 50,0,200,20, {-- slider bar }
- slideaction); {-- event to calll when moved }
-
- {-- save the slider pointer }
- SldPtr := GetLastSliderDef(ifs);
-
- {-- only AFTER drawing the slider then defining it do we draw the }
- {-- thumb. During define is when the slider captures the screen image}
- {-- of the slider area. }
-
- setfillstyle(solidfill,red);
- bar(50,0,100,20); {-- note same coordiantes as slider thumb above. }
- setcolor(black);
- rectangle(50,0,100,20);
- putpict(ifs^.x+65,ifs^.y+5,@imageslider2,black);
- setviewport(0,0,getmaxx,getmaxy,clipoff); {--restore viewport }
- END;
-
- BEGIN
- easytegl;
- easyout;
- framewithslider;
- teglsupervisor;
- END.
-