home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / turbopas / pstui100.zip / DEMO2.PAS < prev    next >
Pascal/Delphi Source File  |  1993-02-16  |  11KB  |  312 lines

  1. {
  2.  
  3.                                                       ╔══════════════════╗
  4.                                                       ║   PTUI  Demo     ║
  5.                                                       ║                  ║
  6.                                                       ║    Rev. 1.00     ║
  7.                                                       ╚══════════════════╝
  8.  
  9. }
  10.  
  11. Program Demo;
  12.  
  13. {$F-} {$O-} {$A+} {$G-}
  14. {$V-} {$B-} {$X-} {$N+} {$E+}
  15.  
  16. {$I FINAL.PAS}
  17.  
  18. {$IFDEF FINAL}
  19.   {$I-} {$R-}
  20.   {$D-} {$L-} {$S-}
  21.   {$M 8192,262144,655360}
  22. {$ELSE}
  23.   {$M 8192,0,655360}
  24. {$ENDIF}
  25.  
  26. Uses CRT,Strings,PTUI,PTUIVCRT,KeyDef;
  27.  
  28. Var
  29.   Win       :Array [1..2] of TextWindow;
  30.   NewSlide  :SlideBarInfo;
  31.   ActiveWin :Byte;
  32.   St        :String;
  33.  
  34.   MX,MY     :Word;
  35.   MB        :Byte;
  36.   Held,
  37.   Doubled,
  38.   Special   :Boolean;
  39.   Key       :Char;
  40.  
  41.   Param     :String;
  42.  
  43. Begin
  44.   If ParamCount>0 Then
  45.     UpperCase(ParamStr(1),Param)
  46.   Else
  47.     Param:='';
  48.  
  49.   If Pos('?',Param)>0 Then
  50.   Begin
  51.     WriteLn('This demo is used on computers with both a EGA/VGA card and');
  52.     WriteLn('a mono card.  Use /E if you have an EGA, otherwise VGA is assumed.');
  53.     Halt;
  54.   End;
  55.  
  56.   If (Card=ColorCard) Then
  57.   Begin
  58.     If Pos('/E',Param)>0 Then
  59.       EnableVScreen(EGA)
  60.     Else
  61.       EnableVScreen(VGA);
  62.     SetVirtualScreen(160,70);
  63.   End;
  64.   GotoCard(ColorCard);
  65.   ClrScr;
  66.   PushCursorSize;
  67.   CursorSize($20,$20);
  68.   Cursor:=False;
  69.   Mouse.Init(True);
  70.   InstallVScreenMouse;
  71.   TextBackground(Blue);
  72.   TextColor(Yellow);
  73.   FillBlock(1,1,160,70,' ');
  74.   GotoXY(2,2);
  75.   WriteStr(#7+' Click here to exit or press [Esc] to exit.');
  76.   GotoXY(4,3);
  77.   WriteStr('Swap between windows with Right Mouse Button or [Tab].');
  78.   GotoXY(4,4);
  79.   WriteStr('Mouse users can drag the window by holding on to the heading and moving the mouse.');
  80.   GotoXY(4,5);
  81.   WriteStr('Keyboard users (no mouse) can use [F5] and the cursor keys, followed by [Return].');
  82.   GotoXY(4,6);
  83.   WriteStr('Use the mouse or [Ctrl][PgUp] [PgDn] [Left] [Right] to scroll across the VGA virtual screen.');
  84.   GotoCard(MonoCard);
  85.   FillBlock(1,1,80,25,'▒');
  86.  
  87.   Win[1].Card:=ColorCard;
  88.   GotoCard(Win[1].Card);
  89.   Win[1].Open(10,10,50,20,Yellow,Green,Blue,Magenta,NoLine,Solid);
  90.   Win[1].NewHeading('Window 1',CentreText,Yellow,Red);
  91.   Win[1].HeadingIcon(True);
  92.  
  93.   NewSlide.X1:=48;
  94.   NewSlide.Y1:=13;
  95.   NewSlide.X2:=48;
  96.   NewSlide.Y2:=19;
  97.   NewSlide.Forg:=Yellow;
  98.   NewSlide.Back:=Green;
  99.   NewSlide.MainChar:='░';
  100.   NewSlide.ButtonChar:='▓';
  101.   NewSlide.UpLeftChar:=#$18;
  102.   NewSlide.DownRightChar:=#$19;
  103.   NewSlide.CurPos:=0;
  104.   NewSlide.MaxPos:=99;
  105.  
  106.   Win[1].VertSlideBar(NewSlide);
  107.  
  108.   NewSlide.X1:=12;
  109.   NewSlide.Y1:=19;
  110.   NewSlide.X2:=47;
  111.   NewSlide.Y2:=19;
  112.   NewSlide.UpLeftChar:=#$1B;
  113.   NewSlide.DownRightChar:=#$1A;
  114.  
  115.   Win[1].HorzSlideBar(NewSlide);
  116.  
  117.   Win[1].VertSlideIcon(True);
  118.   Win[1].HorzSlideIcon(True);
  119.  
  120.   Win[1].Buttons.Add(2,2,2,2,False,#27);
  121.   Win[1].Buttons.Add(0,0,0,0,False,#9);
  122.   Win[1].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_Right),KeyCode(Key_Ctrl,Key_Right));
  123.   Win[1].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_Left) ,KeyCode(Key_Ctrl,Key_Left));
  124.   Win[1].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_PgUp) ,KeyCode(Key_Ctrl,Key_PgUp));
  125.   Win[1].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_PgDn) ,KeyCode(Key_Ctrl,Key_PgDn));
  126.  
  127.   Win[2].Card:=MonoCard;
  128.   GotoCard(Win[2].Card);
  129.   Win[2].Open(15,15,60,23,White,Black,LightGrey,Black,DoubleLine,LightHash);
  130.   Win[2].NewHeading('Window 2',CentreText,Black,LightGrey);
  131.   Win[2].HeadingIcon(True);
  132.  
  133.   Win[2].Buttons.Add(2,2,2,2,False,#27);
  134.   Win[2].Buttons.Add(0,0,0,0,False,#9);
  135.   Win[2].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_Right),KeyCode(Key_Ctrl,Key_Right));
  136.   Win[2].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_Left) ,KeyCode(Key_Ctrl,Key_Left));
  137.   Win[2].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_PgUp) ,KeyCode(Key_Ctrl,Key_PgUp));
  138.   Win[2].Buttons.Add(0,0,0,0,SpecialCode(Key_Ctrl,Key_PgDn) ,KeyCode(Key_Ctrl,Key_PgDn));
  139.  
  140.   Mouse.Show;
  141.   ActiveWin:=2;
  142.   GotoCard(Win[ActiveWin].Card);
  143.  
  144.   Repeat
  145.     Win[ActiveWin].Buttons.WaitForClick(MX,MY,MB,Held,Doubled,Special,Key);
  146.     If (MB=MouseRightButton) Or ((Key=#9) And (Not Special)) Then
  147.     Begin
  148.       If ActiveWin=1 Then
  149.         ActiveWin:=2
  150.       Else
  151.         ActiveWin:=1;
  152.       GotoCard(Win[ActiveWin].Card);
  153.     End;
  154.  
  155.     If (Special=SpecialCode(Key_Ctrl,Key_Right)) And
  156.        (Key=KeyCode(Key_Ctrl,Key_Right)) And
  157.        (VideoCard[Card].SX2<VideoCard[Card].XSize) Then
  158.     Begin
  159.       If Not KeyPressed Then
  160.       Begin
  161.  
  162.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 1,
  163.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  164.  
  165.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 4,
  166.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  167.  
  168.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 6,
  169.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  170.  
  171.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 7,
  172.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  173.       End;
  174.  
  175.       ScreenOrigin((VideoCard[Card].SX1) * VideoCard[Card].CharacterLength,
  176.                    (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  177.     End;
  178.  
  179.     If (Special=SpecialCode(Key_Ctrl,Key_Left)) And
  180.        (Key=KeyCode(Key_Ctrl,Key_Left)) And
  181.        (VideoCard[Card].SX1>1) Then
  182.     Begin
  183.       ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength - 1,
  184.                    (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  185.  
  186.       If Not KeyPressed Then
  187.       Begin
  188.  
  189.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 6,
  190.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  191.  
  192.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 4,
  193.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  194.  
  195.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength + 1,
  196.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  197.  
  198.       End;
  199.  
  200.       ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  201.                    (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  202.     End;
  203.  
  204.     If (Special=SpecialCode(Key_Ctrl,Key_PgDn)) And
  205.        (Key=KeyCode(Key_Ctrl,Key_PgDn)) And
  206.        (VideoCard[Card].SY2<VideoCard[Card].YSize) Then
  207.     Begin
  208.       If Not KeyPressed Then
  209.       Begin
  210.  
  211.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  212.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 2);
  213.  
  214.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  215.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 7);
  216.  
  217.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  218.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 11);
  219.  
  220.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  221.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 14);
  222.       End;
  223.  
  224.       ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  225.                    (VideoCard[Card].SY1) * VideoCard[Card].CharacterHeight);
  226.     End;
  227.  
  228.     If (Special=SpecialCode(Key_Ctrl,Key_PgUp)) And
  229.        (Key=KeyCode(Key_Ctrl,Key_PgUp)) And
  230.        (VideoCard[Card].SY1>1) Then
  231.     Begin
  232.       ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  233.                    (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight - 2);
  234.  
  235.       If Not KeyPressed Then
  236.       Begin
  237.  
  238.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  239.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 11);
  240.  
  241.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  242.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 7);
  243.  
  244.         ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  245.                      (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight + 2);
  246.  
  247.       End;
  248.  
  249.       ScreenOrigin((VideoCard[Card].SX1 - 1) * VideoCard[Card].CharacterLength,
  250.                    (VideoCard[Card].SY1 - 1) * VideoCard[Card].CharacterHeight);
  251.     End;
  252.  
  253.  
  254.     If (Special=SpecialCode(Key_Ctrl, Key_F5)) And
  255.        (Key=KeyCode(Key_Ctrl, Key_F5)) Then Win[ActiveWin].Drag;
  256.  
  257.     If ActiveWin=1 Then
  258.     Begin
  259.  
  260.       If Held And (Special=SpecialCode(Mouse_Only, Mouse_SlideButtonVert)) And
  261.                   (Key=KeyCode(Mouse_Only, Mouse_SlideButtonVert)) Then Win[ActiveWin].DragVertSlideButton;
  262.  
  263.       If Held And (Special=SpecialCode(Mouse_Only, Mouse_SlideButtonHorz)) And
  264.                   (Key=KeyCode(Mouse_Only, Mouse_SlideButtonHorz)) Then Win[ActiveWin].DragHorzSlideButton;
  265.  
  266.       If (Special=SpecialCode(Mouse_Only, Mouse_SlideBarVert)) And
  267.          (Key=KeyCode(Mouse_Only, Mouse_SlideBarVert)) Then Win[ActiveWin].DragVertSlideButton;
  268.  
  269.       If (Special=SpecialCode(Mouse_Only, Mouse_SlideBarHorz)) And
  270.          (Key=KeyCode(Mouse_Only, Mouse_SlideBarHorz)) Then Win[ActiveWin].DragHorzSlideButton;
  271.  
  272.       If (Special=SpecialCode(Key_None, Key_Up)) And
  273.          (Key=KeyCode(Key_None, Key_Up)) And (Win[ActiveWin].VSlide.CurPos>0)
  274.       Then
  275.         Win[ActiveWin].UpdateVertSlideBar(Win[ActiveWin].VSlide.CurPos-1);
  276.  
  277.       If (Special=SpecialCode(Key_None, Key_Down)) And
  278.          (Key=KeyCode(Key_None, Key_Down)) And (Win[ActiveWin].VSlide.CurPos<99)
  279.       Then
  280.         Win[ActiveWin].UpdateVertSlideBar(Win[ActiveWin].VSlide.CurPos+1);
  281.  
  282.       If (Special=SpecialCode(Key_None, Key_Right)) And
  283.          (Key=KeyCode(Key_None, Key_Right)) And (Win[ActiveWin].HSlide.CurPos<99)
  284.       Then
  285.         Win[ActiveWin].UpdateHorzSlideBar(Win[ActiveWin].HSlide.CurPos+1);
  286.  
  287.       If (Special=SpecialCode(Key_None, Key_Left)) And
  288.          (Key=KeyCode(Key_None, Key_Left)) And (Win[ActiveWin].HSlide.CurPos>0)
  289.       Then
  290.         Win[ActiveWin].UpdateHorzSlideBar(Win[ActiveWin].HSlide.CurPos-1);
  291.  
  292.     End;
  293.  
  294.     If ActiveWin=1 Then
  295.     Begin
  296.       Mouse.Hide;
  297.       Win[1].Lock;
  298.       VideoColor(Blue,Green);
  299.       GotoXY(5,5);
  300.       Str(Win[1].VSlide.CurPos+1,St);
  301.       WriteStr('Line  : '+St+'  ');
  302.       GotoXY(5,7);
  303.       Str(Win[1].HSlide.CurPos+1,St);
  304.       WriteStr('Column: '+St+'  ');
  305.       Win[1].UnLock;
  306.       Mouse.Show;
  307.     End;
  308.  
  309.   Until ((MX=2) And (MY=2)) Or (Key=#27);
  310.   PopCursorSize;
  311. End.
  312.