home *** CD-ROM | disk | FTP | other *** search
/ Deathday Collection / dday.bin / edit / dfe / doomgui.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-26  |  8KB  |  359 lines

  1. {****************************************************************************
  2. *                      The DOOM Hacker's Tool Kit                           *
  3. *****************************************************************************
  4. * Unit:    DOOMGUI                                                          *
  5. * Purpose: Graphical User Interface Routines                                *
  6. * Date:    4/28/94                                                          *
  7. * Author:  Joshua Jackson        Internet: joshjackson@delphi.com           *
  8. ****************************************************************************}
  9.  
  10. unit DOOMGUI;
  11.  
  12. interface
  13.  
  14. uses Graph,GUIEvent,GUIObj;
  15.  
  16. const    wcWhite        = 5;
  17.         wcLtGrey        = 86;
  18.         wcGrey        = 95;
  19.         wcDkGrey        = 99;
  20.         wcBlack        = 0;
  21.         wcLtBlue        = 198;
  22.         wcBlue        = 204;
  23.         wcDkBlue        = 207;
  24.         wcLtGreen    = 124;
  25.         wcGreen        = 120;
  26.         wcDkGreen    = 124;
  27.         wcLtPink        = 171;
  28.         wcPink        = 174;
  29.         wcRed            = 177;
  30.         wcDkRed        = 185;
  31.         wcLtPurple    = 252;
  32.         wcPurple        = 253;
  33.         wcDkPurple    = 254;
  34.         wcLtYellow    = 228;
  35.         wcYellow        = 231;
  36.  
  37. type    PGraphView=^TGraphView;
  38.         PGraphGroup=^TGraphGroup;
  39.         TGraphView=object
  40.             Owner:PGraphGroup;
  41.             Next:PGraphView;
  42.             Prev:PGraphView;
  43.             Bounds:TGraphRect;
  44.             Constructor Init(R:TGraphRect);
  45.             Function EventAvail:Boolean; virtual;
  46.             Procedure GetEvent(var Event:TGraphEvent); virtual;
  47.             Procedure PutEvent(var Event:TGraphEvent); virtual;
  48.             Procedure Draw; virtual;
  49.             Destructor Done; virtual;
  50.         end;
  51.         TGraphGroup=object(TGraphView)
  52.             Current:PGraphView;
  53.             GroupList:PGraphView;
  54.             xs,ys,xe,ye:word;
  55.             Constructor Init(R:TGraphRect);
  56.             Procedure Insert(SubView:PGraphView); virtual;
  57.             Procedure Draw; virtual;
  58.             Procedure Delete(SubView:PGraphView); virtual;
  59.             Destructor Done; virtual;
  60.         end;
  61.         PGraphWindow=^TGraphWindow;
  62.         TGraphWindow=object(TGraphGroup)
  63.             Constructor Init(R:TGraphRect);
  64.             Function InWindow(x,y:word):boolean;
  65.             Procedure Draw; virtual;
  66.         end;
  67.         PGraphButton=^TGraphButton;
  68.         TGraphButton=object(TGraphView)
  69.             IsPressed:byte;
  70.             Xs,Ys,Xe,Ye:word;
  71.             XOfs,YOfs:word;
  72.             TitleStr:string;
  73.             TitleColor:word;
  74.             Constructor Init(R:TGraphRect;TColor:word;Title:string);
  75.             Function InButton(x,y:word):boolean; virtual;
  76.             Procedure Press; virtual;
  77.             Procedure Release; virtual;
  78.             Procedure Toggle; virtual;
  79.             Procedure Draw; virtual;
  80.         end;
  81.         PGraphText=^TGraphText;
  82.         TGraphText=object(TGraphView)
  83.             DataStr:string;
  84.             Constructor Init(R:TGraphRect;TextStr:String);
  85.             Procedure Draw; virtual;
  86.         end;
  87.  
  88. implementation
  89.  
  90. Constructor TGraphView.Init(R:TGraphRect);
  91.  
  92.     begin
  93.         Owner:=Nil;
  94.     end;
  95.  
  96. Function TGraphView.EventAvail:Boolean;
  97.  
  98.     begin
  99.     end;
  100.  
  101. Procedure TGraphView.GetEvent(var Event:TGraphEvent);
  102.  
  103.     begin
  104.     end;
  105.  
  106. Procedure TGraphView.PutEvent(var Event:TGraphEvent);
  107.  
  108.     begin
  109.     end;
  110.  
  111. Procedure TGraphView.Draw;
  112.  
  113.     begin
  114.     end;
  115.  
  116. Destructor TGraphView.Done;
  117.  
  118.     begin
  119.     end;
  120.  
  121. Constructor TGraphGroup.Init(R:TGraphRect);
  122.  
  123.     begin
  124.         Bounds:=r;
  125.         GroupList:=Nil;
  126.         Owner:=Nil;
  127.         Next:=Nil;
  128.     end;
  129.  
  130. Procedure TGraphGroup.Insert(SubView:PGraphView);
  131.  
  132.     begin
  133.         if GroupList=Nil then begin
  134.             GroupList:=SubView;
  135.             SubView^.Prev:=Nil;
  136.             Current:=SubView;
  137.          end
  138.         else
  139.             SubView^.Prev:=Current;
  140.         SubView^.Owner:=@Self;
  141.         Current^.Next:=SubView;
  142.         SubView^.Next:=Nil;
  143.         Current:=SubView;
  144.     end;
  145.  
  146. Procedure TGraphGroup.Draw;
  147.  
  148.     var SubView:PGraphView;
  149.  
  150.     begin
  151.         SubView:=GroupList;
  152.         while SubView <> Nil do begin
  153.             SubView^.Draw;
  154.             SubView:=SubView^.Next;
  155.         end;
  156.     end;
  157.  
  158. Procedure TGraphGroup.Delete(SubView:PGraphView);
  159.  
  160.     begin
  161.     end;
  162.  
  163. Destructor TGraphGroup.Done;
  164.  
  165.     var SubView,TempView:PGraphView;
  166.  
  167.     begin
  168.         SubView:=GroupList;
  169.         while SubView <> Nil do begin
  170.             TempView:=SubView^.Next;
  171.             Dispose(SubView, Done);
  172.             SubView:=TempView;
  173.         end;
  174.     end;
  175.  
  176. Constructor TGraphWindow.Init(R:TGraphRect);
  177.  
  178.     begin
  179.         Bounds:=R;
  180.         GroupList:=Nil;
  181.         Owner:=Nil;
  182.     end;
  183.  
  184. Function TGraphWindow.InWindow(x,y:word):boolean;
  185.  
  186.     begin
  187.         if (x>=xs) and (x<=xe) and (y>=ys) and (y<=ye) then
  188.             InWindow:=True
  189.         else
  190.             InWindow:=False;
  191.     end;
  192.  
  193. Procedure TGraphWindow.Draw;
  194.  
  195.     var SubView:PGraphView;
  196.  
  197.     begin
  198.         if Owner=Nil then begin
  199.             xs:=Bounds.a.x;
  200.             xe:=Bounds.b.x;
  201.             ys:=Bounds.a.y;
  202.             ye:=Bounds.b.y;
  203.          end
  204.         else begin
  205.             xs:=Bounds.a.x+Owner^.Bounds.a.x;
  206.             xe:=Bounds.b.x+Owner^.Bounds.a.x;
  207.             ys:=Bounds.a.y+Owner^.Bounds.a.y;
  208.             ye:=Bounds.b.y+Owner^.Bounds.a.y;
  209.         end;
  210.         Setcolor(wcLtGrey);
  211.         line(xs,ys,xe,ys);
  212.         line(xs+1,ys+1,xe-1,ys+1);
  213.         line(xs,ys,xs,ye);
  214.         line(xs+1,ys+1,xs+1,ye-1);
  215.         Setcolor(wcDkGrey);
  216.         line(xs,ye,xe,ye);
  217.         line(xs+1,ye-1,xe-1,ye-1);
  218.         line(xe,ye,xe,ys);
  219.         line(xe-1,ye-1,xe-1,ys+1);
  220.         SetFillStyle(SolidFill,wcGrey);
  221.         bar(xs+2,ys+2,xe-2,ye-2);
  222.         SubView:=GroupList;
  223.         while SubView <> Nil do begin
  224.             SubView^.Draw;
  225.             SubView:=SubView^.Next;
  226.         end;
  227.     end;
  228.  
  229.  
  230. Constructor TGraphButton.Init(R:TGraphRect;TColor:word;Title:string);
  231.  
  232.     var    BuffSize:word;
  233.  
  234.     begin
  235.         Bounds:=r;
  236.         TitleStr:=Title;
  237.         TitleColor:=TColor;
  238.         IsPressed:=0;
  239.         Owner:=Nil;
  240.         Next:=Nil;
  241.     end;
  242.  
  243. Function TGraphButton.InButton(x,y:word):boolean;
  244.  
  245.     begin
  246.         if (x>=xs) and (x<=xe) and (y>=ys) and (y<=ye) then
  247.             InButton:=True
  248.         else
  249.             InButton:=False;
  250.     end;
  251.  
  252. Procedure TGraphButton.Press;
  253.  
  254.     begin
  255.         if Owner=Nil then begin
  256.             xs:=Bounds.a.x;
  257.             xe:=Bounds.b.x;
  258.             ys:=Bounds.a.y;
  259.             ye:=Bounds.b.y;
  260.          end
  261.         else begin
  262.             xs:=Bounds.a.x+Owner^.Bounds.a.x;
  263.             xe:=Bounds.b.x+Owner^.Bounds.a.x;
  264.             ys:=Bounds.a.y+Owner^.Bounds.a.y;
  265.             ye:=Bounds.b.y+Owner^.Bounds.a.y;
  266.         end;
  267.         XOfs:=((Xe - Xs) - TextWidth(TitleStr)) div 2;
  268.         YOfs:=((Ye - Ys) - TextHeight(TitleStr)) div 2;
  269.         Setcolor(wcDkGrey);
  270.         line(xs,ys,xe,ys);
  271.         line(xs+1,ys+1,xe-1,ys+1);
  272.         line(xs,ys,xs,ye);
  273.         line(xs+1,ys+1,xs+1,ye-1);
  274.         Setcolor(wcLtGrey);
  275.         line(xs,ye,xe,ye);
  276.         line(xs+1,ye-1,xe-1,ye-1);
  277.         line(xe,ye,xe,ys);
  278.         line(xe-1,ye-1,xe-1,ys+1);
  279.         SetFillStyle(SolidFill,wcGrey);
  280.         bar(xs+2,ys+2,xe-2,ye-2);
  281.         SetColor(TitleColor);
  282.         SetTextStyle(0,0,1);
  283.         OutTextXY(xs+XOfs,ys+YOfs,TitleStr);
  284.         IsPressed:=1;
  285.     end;
  286.  
  287. Procedure TGraphButton.Release;
  288.  
  289.  
  290.     begin
  291.         if Owner=Nil then begin
  292.             xs:=Bounds.a.x;
  293.             xe:=Bounds.b.x;
  294.             ys:=Bounds.a.y;
  295.             ye:=Bounds.b.y;
  296.          end
  297.         else begin
  298.             xs:=Bounds.a.x+Owner^.Bounds.a.x;
  299.             xe:=Bounds.b.x+Owner^.Bounds.a.x;
  300.             ys:=Bounds.a.y+Owner^.Bounds.a.y;
  301.             ye:=Bounds.b.y+Owner^.Bounds.a.y;
  302.         end;
  303.         XOfs:=((Xe - Xs) - TextWidth(TitleStr)) div 2;
  304.         YOfs:=((Ye - Ys) - TextHeight(TitleStr)) div 2;
  305.         Setcolor(wcLtGrey);
  306.         line(xs,ys,xe,ys);
  307.         line(xs+1,ys+1,xe-1,ys+1);
  308.         line(xs,ys,xs,ye);
  309.         line(xs+1,ys+1,xs+1,ye-1);
  310.         Setcolor(wcDkGrey);
  311.         line(xs,ye,xe,ye);
  312.         line(xs+1,ye-1,xe-1,ye-1);
  313.         line(xe,ye,xe,ys);
  314.         line(xe-1,ye-1,xe-1,ys+1);
  315.         SetFillStyle(SolidFill,wcGrey);
  316.         bar(xs+2,ys+2,xe-2,ye-2);
  317.         SetTextStyle(0,0,1);
  318.         SetColor(TitleColor);
  319.         OutTextXY(xs+XOfs,ys+YOfs,TitleStr);
  320.         IsPressed:=0;
  321.     end;
  322.  
  323. Procedure TGraphButton.Toggle;
  324.  
  325.     begin
  326.         IsPressed:=IsPressed xor 1;
  327.         Draw;
  328.     end;
  329.  
  330. Procedure TGraphButton.Draw;
  331.  
  332.     begin
  333.         if IsPressed=1 then
  334.             Press
  335.         else
  336.             Release;
  337.     end;
  338.  
  339. Constructor TGraphText.Init(R:TGraphRect;TextStr:string);
  340.  
  341.     begin
  342.         Bounds:=r;
  343.         DataStr:=TextStr;
  344.         Owner:=Nil;
  345.         Next:=Nil;
  346.     end;
  347.  
  348. Procedure TGraphText.Draw;
  349.  
  350.     begin
  351.         SetColor(wcBlack);
  352.         if Owner<>Nil then
  353.             OutTextXY(Owner^.Bounds.a.x+Bounds.a.x,Owner^.Bounds.a.y+Bounds.a.y,DataStr)
  354.         else
  355.             OutTextXY(Bounds.a.x,Bounds.a.y,DataStr);
  356.     end;
  357.  
  358. end.
  359.