home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PSGUI130.ZIP / PGUI.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-01-01  |  16.6 KB  |  436 lines

  1. {
  2.  
  3.                                                       ╔══════════════════╗
  4.                                                       ║    Pure Power    ║
  5.                                                       ║   VGA Graphical  ║
  6.                                                       ║   User Interface ║
  7.                                                       ║    Rev. 1.30     ║
  8.                                                       ╚══════════════════╝
  9.  
  10. }
  11.  
  12. {$F+} {$O-} {$A+} {$G+}
  13. {$V-} {$B-} {$X-} {$N+} {$E+}
  14.  
  15. {$I FINAL.PAS}
  16.  
  17. {$IFDEF FINAL}
  18.   {$I-} {$R-}
  19.   {$D-} {$L-} {$S-}
  20. {$ENDIF}
  21.  
  22. Unit PGUI;
  23.  
  24. { ╔════════════════════════════════════════════════════════════════════════╗}
  25. { ║                                                                        ║}
  26. { ║  Pure Power VGA Object Orientated Graphical User Interface             ║}
  27. { ║                                                                        ║}
  28. { ║  This unit controls Super VGA modes and mouse.  The unit requires      ║}
  29. { ║  Turbo Pascal Version 6 and Genius Mouse Driver Version 9.06 or later. ║}
  30. { ║                                                                        ║}
  31. { ║   Written by      : Michael Gallias                                    ║}
  32. { ║   Last Update     : 16 December 1992                                   ║}
  33. { ║                                                                        ║}
  34. { ╚════════════════════════════════════════════════════════════════════════╝}
  35.  
  36. Interface
  37.  
  38. Uses Graph,CRT,DOS,Dirs,Strings,KeyDef,Icons,PGUIMDef,PGUIMSE,PGUIBMSE;
  39.  
  40. Type {From MouseDef}
  41.  
  42.   BGIMouseShapePtr         = ^BGIMouseShape;
  43.  
  44.   BGIMouseShape            = Record
  45.                                Picture   :Pointer;
  46.                                Mask      :Pointer;
  47.                                XHot      :Integer;
  48.                                YHot      :Integer;
  49.                              End;
  50.  
  51.   STDMouseShapePtr         = ^STDMouseShape;
  52.  
  53.   STDMouseShape            = Record
  54.                                Picture   :Array[1..32] of Byte;
  55.                                Mask      :Array[1..32] of Byte;
  56.                                XHot      :Integer;
  57.                                YHot      :Integer;
  58.                              End;
  59.  
  60.  
  61. Type
  62.  
  63.   HideOrShow      = (Hidden,Visible);
  64.  
  65.   OutLineSave     = Record                            {Screen Save when dragging}
  66.                       Size1,                          {graphics box}
  67.                       Size2 :Word;
  68.                       Data  :Array[1..4] Of Pointer;
  69.                     End;
  70.  
  71.   ButtonListPtr = ^ButtonList;                   {Buttons to click on}
  72.  
  73.   ButtonList = Record
  74.                  X1,Y1,X2,Y2:Word;               {Screen Co-ordinate}
  75.                  Thickness  :Word;               {How thick it is}
  76.                  Background :Word;               {Background it lies on}
  77.                  Special    :Boolean;            {Keyboard Keys}
  78.                  Key        :Char;               {Keyboard Character}
  79.                  Picture    :Pointer;            {If it has a Picture}
  80.                  Name       :String[11];         {If it has a Name}
  81.                  Number     :Word;               {It's own Unique Number}
  82.                  Next       :ButtonListPtr;      {Next Button in Linked List}
  83.                End;
  84.  
  85.   ButtonChain     = Object
  86.                       Total          :Word;
  87.  
  88.                       Procedure Init;
  89.                       Function  Position     :Word;
  90.                       Function  Number       :Word;
  91.                       Procedure GotoPosition (Here:Word);
  92.                       Procedure GotoNumber   (ButtonNumber:Word);
  93.  
  94.                       Procedure DrawUp       (ButtonNumber:Word);
  95.                       Procedure DrawDown     (ButtonNumber:Word);
  96.  
  97.                       Procedure Add          (X1, Y1, X2, Y2:Word;
  98.                                               Thickness, Background:Word;
  99.                                               Picture:Pointer; Name:String;
  100.                                               Special:Boolean; Key:Char);
  101.  
  102.  
  103.                       Procedure Move         (X, Y:Integer;
  104.                                               ButtonNumber:Word);
  105.  
  106.                       Procedure MoveAll      (X, Y:Integer);
  107.  
  108.                       Procedure Create       (X1, Y1, X2, Y2:Word;
  109.                                               Thickness, Background:Word;
  110.                                               Picture:Pointer; Name:String;
  111.                                               Special:Boolean; Key:Char);
  112.  
  113.                       Procedure WaitForClick (Var X, Y:Word;Var MouseButtons:Byte;
  114.                                               Var Held,Doubled,Special:Boolean;
  115.                                               Var Key:Char);
  116.  
  117.                       Procedure KillAll;
  118.                       Procedure KillFrom;
  119.                       Procedure KillOne;
  120.  
  121.                       Private
  122.  
  123.                       Root           :Pointer;
  124.                       Buttons        :ButtonListPtr;
  125.  
  126.                       Function NewButtonNumber:Word;
  127.  
  128.                     End;
  129.  
  130.   MouseFunctions  = Object
  131.                       Init       :MouseProc_Init;
  132.                       Show       :MouseProc_Show;
  133.                       Hide       :MouseProc_Hide;
  134.                       SetSpeed   :MouseProc_SetSpeed;
  135.                       SetXY      :MouseProc_SetXY;
  136.                       SetBounds  :MouseProc_SetBounds;
  137.                       SetShape   :MouseProc_SetShape;
  138.                       GetPresses :MouseProc_GetPresses;
  139.                       GetXY      :MouseProc_GetXY;
  140.                       GetStatus  :MouseProc_GetStatus;
  141.                       GetClick   :MouseProc_GetClick;
  142.  
  143.                       Function  ComputerSpeed:LongInt;
  144.                       Function  Active       :Boolean;
  145.  
  146.                     End;
  147.  
  148.   GraphicWindow   = Object
  149.                       HdrButtonNum,                   {Button Numbers}
  150.  
  151.                       VSlideButtonNum,                {The Little Button}
  152.                       VSlideBarButtonNum,             {The Bar as a Button}
  153.                       VSlideButtonUpNum,
  154.                       VSlideButtonDownNum,
  155.  
  156.                       HSlideButtonNum,
  157.                       HSlideBarButtonNum,
  158.                       HSlideButtonLeftNum,
  159.                       HSlideButtonRightNum,
  160.  
  161.                       CloseButtonNum :Word;
  162.                       Buttons        :ButtonChain;   {The window's buttons}
  163.                       VSlideBarCurPos:LongInt;
  164.                       HSlideBarCurPos:LongInt;
  165.  
  166.                       Status         :HideOrShow;    {Visible or Not}
  167.                       KeepBack       :Boolean;       {Background Saved or Not}
  168.                       Thickness      :Byte;          {Box Outline}
  169.                       Pattern,                       {Pascal Pattern Number}
  170.                       FillColor,                     {Pattern Colour}
  171.                       HdrPattern,                    {Heading Background Pattern}
  172.                       HdrFillColor,                  {Heading Pattern Colour}
  173.                       HdrFrg,                        {Header Text Forg}
  174.                       BoxFrg,                        {Box Colour}
  175.                       BoxBck,                        {Box Backgound OutLine}
  176.                       Size,                          {Memory Required for Save}
  177.                       X1,Y1,                         {Location on Screen}
  178.                       X2,Y2          :Word;
  179.                       Header         :String;        {Heading Text}
  180.                       HdrFmt         :TextFormats;   {Heading Format}
  181.                       VSlideBarPat,
  182.                       VSlideBarClr,
  183.                       VSlideButtonPos:Word;
  184.  
  185.                       VSlideBarMaxPos:LongInt;
  186.  
  187.                       HSlideBarPat,
  188.                       HSlideBarClr,
  189.                       HSlideButtonPos:Word;
  190.  
  191.                       HSlideBarMaxPos:LongInt;
  192.  
  193.  
  194.                       Procedure Open      (NX1,NY1,NX2,NY2,Forg,Back,
  195.                                            Thick,Patrn,PatClr:Word;
  196.                                            KeepBackground:Boolean);
  197.                       Procedure DisplayHeading;
  198.                       Procedure NewHeading(NewHead:String;NewMode:TextFormats;
  199.                                            Forg,Patrn,PatClr:Word);
  200.                       Procedure Hide;
  201.                       Procedure Show;
  202.                       Procedure NewPosition(NewX,NewY:Word);
  203.                       Procedure Drag;
  204.                       Procedure DragVertSlideButton;
  205.                       Procedure DragHorzSlideButton;
  206.                       Procedure NewSize    (NX1,NY1,NX2,NY2:Word);
  207.                       Procedure CloseIcon  (Active:Boolean);
  208.                       Procedure HeadingIcon(Active:Boolean);
  209.  
  210.                       Procedure VertSlideIcon         (Active:Boolean);
  211.                       Procedure DrawVertSlideBar;
  212.                       Procedure VertSlideBar          (CurPos,MaxPos:LongInt;
  213.                                                        Patrn,PatClr:Word);
  214.                       Procedure UpdateVertSlideBar    (CurPos:LongInt);
  215.  
  216.                       Procedure HorzSlideIcon         (Active:Boolean);
  217.                       Procedure DrawHorzSlideBar;
  218.                       Procedure HorzSlideBar          (CurPos,MaxPos:LongInt;
  219.                                                        Patrn,PatClr:Word);
  220.                       Procedure UpdateHorzSlideBar    (CurPos:LongInt);
  221.  
  222.                       Procedure CloseButtonPos         (Var BX1,BY1,BX2,BY2:Word);
  223.                       Procedure HeadingPos             (Var BX1,BY1,BX2,BY2:Word);
  224.                       Procedure VertSlideBarPos        (Var BX1,BY1,BX2,BY2:Word);
  225.                       Procedure VertSlideButtonPos     (Var BX1,BY1,BX2,BY2:Word);
  226.                       Procedure VertSlideButtonUpPos   (Var BX1,BY1,BX2,BY2:Word);
  227.                       Procedure VertSlideButtonDownPos (Var BX1,BY1,BX2,BY2:Word);
  228.                       Procedure HorzSlideBarPos        (Var BX1,BY1,BX2,BY2:Word);
  229.                       Procedure HorzSlideButtonPos     (Var BX1,BY1,BX2,BY2:Word);
  230.                       Procedure HorzSlideButtonLeftPos (Var BX1,BY1,BX2,BY2:Word);
  231.                       Procedure HorzSlideButtonRightPos(Var BX1,BY1,BX2,BY2:Word);
  232.  
  233.                       Procedure Lock;
  234.                       Procedure UnLock;
  235.                       Procedure Close;
  236.  
  237.                       Private
  238.  
  239.                       Save           :Pointer;       {Background Save}
  240.  
  241.                       Procedure SaveBackground;
  242.                       Procedure DrawWindow;
  243.                       Procedure DrawOutLine(NewX,NewY:Word;
  244.                                             Var OutLine:OutLineSave);
  245.                       Procedure NoOutLine  (Var OutLine:OutLineSave);
  246.                     End;
  247.  
  248.  
  249. Procedure DefaultError   (Num:Byte);
  250.  
  251. Procedure InstallBGIMouse(Shape:Pointer);
  252. Procedure UnInstallBGIMouse;
  253.  
  254. Procedure InitVGA        (VPath:String);
  255. Procedure StandardScreen (Title:String);
  256. Procedure Box            (X1,Y1,X2,Y2:Word;C1,C2,Thick:Byte);
  257. Procedure ShadeText      (X,Y:Word;T:String);
  258. Procedure GraphicSpace   (X,Y,Spot:Word);
  259. Procedure TwirlyCursor   (X,Y,Spot:Word;Frame:Byte);
  260. Procedure LineCursor     (X,Y,Spot:Word;OnOff:Boolean);
  261. Procedure CommentWindow  (X,Y:Word;Comment:String);
  262. Procedure EditString     (X,Y:Word;MaxLets:Byte;Upper:Boolean;Var MainStr:String);
  263.  
  264. Procedure ShowDirList    (Var Dir:DirList;ShowMore:Byte;
  265.                           X,Y,Current,Start,HowMany:Word;
  266.                           FileColor,DirColor,CurrentColor:Byte;
  267.                           Var PgUp,PgDn:Boolean);
  268.  
  269. Procedure DrawButtonUp   (X1,Y1,X2,Y2,Thickness,Background:Word;
  270.                           Picture:Pointer;Name:String);
  271. Procedure DrawButtonDown (X1,Y1,X2,Y2,Thickness:Word;
  272.                           Picture:Pointer;Name:String);
  273. Procedure DrwButtonDown  (X,Y,Len,Depth,Thickness:Word;
  274.                           Picture:Pointer;Name:String);
  275. Procedure DrwButtonUp    (X,Y,Len,Depth,Thickness,Background:Word;
  276.                           Picture:Pointer;Name:String);
  277.  
  278. Var
  279.   Mouse                 :MouseFunctions;
  280.   Error                 :Procedure(Num:Byte);
  281.  
  282.   IconCloseButton       :Pointer;
  283.   IconSlideButtonVert   :Pointer;
  284.   IconSlideButtonHorz   :Pointer;
  285.   IconSlideButtonUp     :Pointer;
  286.   IconSlideButtonDown   :Pointer;
  287.   IconSlideButtonLeft   :Pointer;
  288.   IconSlideButtonRight  :Pointer;
  289.  
  290.   IconMousePoint        :Pointer;
  291.   IconMouseClock        :Pointer;
  292.   IconMouseNote         :Pointer;
  293.  
  294.   IconBGIMouseCursorA   :Pointer;
  295.   IconBGIMouseCursorB   :Pointer;
  296.   IconBGIMouseCursorC   :Pointer;
  297.  
  298.   IconBGIMouseMaskA     :Pointer;
  299.   IconBGIMouseMaskB     :Pointer;
  300.   IconBGIMouseMaskC     :Pointer;
  301.  
  302. Implementation
  303.  
  304. Procedure DefaultError(Num:Byte);
  305. Begin
  306.   CloseGraph;
  307.   ClrScr;
  308.   WriteLn('Fatal Error Occurred');
  309.   Halt;
  310. End;
  311.  
  312. Function MouseFunctions.ComputerSpeed:LongInt;
  313. Begin
  314.   ComputerSpeed:=PGUIMDef.ComputerSpeed;
  315. End;
  316.  
  317. Function MouseFunctions.Active:Boolean;
  318. Begin
  319.   Active:=PGUIMDef.Active;
  320. End;
  321.  
  322. Procedure InstallBGIMouse(Shape:Pointer);
  323.  
  324. Var
  325.   P,Q   :Pointer;
  326.  
  327. Begin
  328.   If Not Mouse.Active Then Exit;
  329.  
  330.   MouseMaxX      :=GetMaxX;
  331.   MouseMaxY      :=GetMaxY;
  332.  
  333.   If (Shape=NIL) Or (BGIMouseShape(Shape^).Picture=NIL) Then
  334.     MousePicture :=MouseDefaultPicture
  335.   Else
  336.     MousePicture :=BGIMouseShape(Shape^).Picture;
  337.  
  338.   If (Shape=NIL) Or (BGIMouseShape(Shape^).Mask=NIL) Then
  339.     MouseMask    :=MouseDefaultMask
  340.   Else
  341.     MouseMask    :=BGIMouseShape(Shape^).Mask;
  342.  
  343.   P              :=Ptr(Seg(MousePicture^),Ofs(MousePicture^)+0);
  344.   Q              :=Ptr(Seg(MouseMask^),Ofs(MouseMask^)+0);
  345.   If Word(P^)<>Word(Q^) Then Halt;
  346.   MouseSizeX     :=Word(P^);
  347.   P              :=Ptr(Seg(MousePicture^),Ofs(MousePicture^)+2);
  348.   Q              :=Ptr(Seg(MouseMask^),Ofs(MouseMask^)+2);
  349.   If Word(P^)<>Word(Q^) Then Halt;
  350.   MouseSizeY     :=Word(P^);
  351.   MouseBackgroundSize:=ImageSize(0,0,MouseSizeX,MouseSizeY);
  352.   GetMem(MouseBackgroundSave,MouseBackgroundSize);
  353.   MouseX         :=MouseMaxX Div 2;
  354.   MouseY         :=MouseMaxY Div 2;
  355.   MouseHideCount :=254;
  356.   P              :=@PGUIBMSE.ControlMouse;
  357.   Asm
  358.     les    dx, P
  359.     mov    ax, 0Ch
  360.     mov    cx, 1
  361.     int    33h
  362.   End;
  363.   OldExitProc:=ExitProc;
  364.   ExitProc:=@UnInstallBGIMouse;
  365.  
  366.   Mouse.Show           :=PGUIBMSE.Show;
  367.   Mouse.Hide           :=PGUIBMSE.Hide;
  368.   Mouse.SetXY          :=PGUIBMSE.SetXY;
  369.   Mouse.SetShape       :=PGUIBMSE.SetShape;
  370.   Mouse.SetBounds      :=PGUIBMSE.SetBounds;
  371.   Mouse.SetBounds(0,0,MouseMaxX,MouseMaxY);
  372.   Mouse.SetXY(MouseX,MouseY);
  373. End;
  374.  
  375. Procedure UnInstallBGIMouse;
  376. Begin
  377.   If Not Mouse.Active Then Exit;
  378.   ExitProc:=OldExitProc;
  379.   Asm
  380.       mov    ax, 0Ch
  381.       mov    cx, 0
  382.       int    33h
  383.   End;
  384.   FreeMem(MouseBackgroundSave,MouseBackgroundSize);
  385.   Mouse.Show           :=PGUIMSE.Show;
  386.   Mouse.Hide           :=PGUIMSE.Hide;
  387.   Mouse.SetXY          :=PGUIMSE.SetXY;
  388.   Mouse.SetShape       :=PGUIMSE.SetShape;
  389.   Mouse.SetBounds      :=PGUIMSE.SetBounds;
  390. End;
  391.  
  392. {$I PGUIAPP}
  393.  
  394. {$I PGUIBUT}
  395.  
  396. {$I PGUIWIN}
  397.  
  398. Begin
  399.   Error                :=DefaultError;
  400.   Mouse.Init           :=PGUIMSE.Init;
  401.   Mouse.Show           :=PGUIMSE.Show;
  402.   Mouse.Hide           :=PGUIMSE.Hide;
  403.   Mouse.SetSpeed       :=PGUIMSE.SetSpeed;
  404.   Mouse.SetXY          :=PGUIMSE.SetXY;
  405.   Mouse.SetBounds      :=PGUIMSE.SetBounds;
  406.   Mouse.SetShape       :=PGUIMSE.SetShape;
  407.   Mouse.GetPresses     :=PGUIMSE.GetPresses;
  408.   Mouse.GetXY          :=PGUIMSE.GetXY;
  409.   Mouse.GetStatus      :=PGUIMSE.GetStatus;
  410.   Mouse.GetClick       :=PGUIMSE.GetClick;
  411.  
  412.   Mouse.Init(False);
  413.  
  414.   IconCloseButton      :=@Icons.IconCloseButton;
  415.   IconSlideButtonVert  :=@Icons.IconSlideButtonVert;
  416.   IconSlideButtonHorz  :=@Icons.IconSlideButtonHorz;
  417.   IconSlideButtonUp    :=@Icons.IconSlideButtonUp;
  418.   IconSlideButtonDown  :=@Icons.IconSlideButtonDown;
  419.   IconSlideButtonLeft  :=@Icons.IconSlideButtonLeft;
  420.   IconSlideButtonRight :=@Icons.IconSlideButtonRight;
  421.  
  422.   IconMousePoint       :=@Icons.IconMousePoint;
  423.   IconMouseClock       :=@Icons.IconMouseClock;
  424.   IconMouseNote        :=@Icons.IconMouseNote;
  425.  
  426.   IconBGIMouseCursorA  :=@Icons.IconBGIMouseCursorA;
  427.   IconBGIMouseCursorB  :=@Icons.IconBGIMouseCursorB;
  428.   IconBGIMouseCursorC  :=@Icons.IconBGIMouseCursorC;
  429.  
  430.   IconBGIMouseMaskA    :=@Icons.IconBGIMouseMaskA;
  431.   IconBGIMouseMaskB    :=@Icons.IconBGIMouseMaskB;
  432.   IconBGIMouseMaskC    :=@Icons.IconBGIMouseMaskC;
  433. End.
  434.  
  435. { Copyright 1993, Michael Gallias }
  436.