home *** CD-ROM | disk | FTP | other *** search
/ TopWare 18: Liquid / Image.iso / liquid / top1143 / gepackt.exe / BSPQTSW.EXE / DEMOLST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-07-09  |  7.1 KB  |  285 lines

  1. (***************************************
  2. * WG-VISION 1.0      DEMONSTRATION     *
  3. ****************************************
  4. *                                      *
  5. * Unit für das Demonstrationsprogramm  *
  6. *                                      *
  7. *--------------------------------------*
  8. * Achtung: Nur VGA !                   *
  9. ****************************************
  10. * (c) 1993 Dipl.Phys. Mathias Scholz   *
  11. ***************************************)
  12.  
  13. {$I COMPILER.INC}
  14. {$F+,O+}
  15.  
  16. UNIT DEMOLST;
  17.  
  18. INTERFACE
  19.  
  20. USES WDecl,
  21.      WViews,
  22.      WDlg,
  23.      WDriver,
  24.      WText,
  25.      WEvent,
  26.      WUtils,
  27.      dos,
  28.      graph;
  29.  
  30. type PNewScroller=^TNewScroller;
  31.  
  32.      PScrollWindow=^TScrollWindow;
  33.      TScrollWindow=object(TWindow)
  34.        Scroller:PNewScroller;
  35.        Nr:byte;
  36.        constructor Init(Nummer:byte);
  37.        procedure InitWindowScroller; virtual;
  38.        destructor Done; virtual;
  39.      end;
  40.  
  41.      TNewScroller=object(TScroller)
  42.        procedure CreateData(DateiName:string);
  43.        procedure ScrollDraw; virtual;
  44.      end;
  45.  
  46.      PMemoryInfo=^TMemoryInfo;
  47.      TMemoryInfo=object(TWindow)
  48.       constructor Init;
  49.       procedure InitBackground; virtual;
  50.      end;
  51.  
  52.      PMemoryInfoBgrd=^TMemoryInfoBgrd;
  53.      TMemoryInfoBgrd=object(TBackground)
  54.       procedure Draw; virtual;
  55.      end;
  56.  
  57.      PDateWindow=^TDateWindow;
  58.      TDateWindow=object(TDlgWindow)
  59.       constructor Init;
  60.       procedure HandleEvent; virtual;
  61.       procedure SetHelp;
  62.      end;
  63.  
  64.      PHilfe=^THilfe;
  65.      THilfe=object(TDlgWindow)
  66.       constructor Init;
  67.      end;
  68.  
  69.      tSetDateTime=record
  70.                     Schalter:string[5];
  71.                     Datum:string[10];
  72.                     Zeit:string[8]
  73.                   end;
  74.  
  75. var DT    : tSetDateTime;
  76.  
  77. IMPLEMENTATION
  78.  
  79. {Implementation TScrollWindow}
  80.  
  81. constructor TScrollWindow.Init(Nummer:byte);
  82. var R:TRect;
  83. begin
  84.   Nr:=Nummer;
  85.   R.Assign(60,80,580,380);
  86.   TWindow.Init(R,'Quelltext-Lister',winDouble+winPanel+winMenu+winKey);
  87. end;
  88.  
  89. procedure TScrollWindow.InitWindowScroller;
  90. var R:TRect;
  91.     i:byte;
  92.     SBH1,SBV1:PScrollBar;
  93. begin
  94.   R:=Frame^.Area;
  95.   SBH1:=new(PScrollBar, Init(R,HorizDir));
  96.   SBV1:=new(PScrollBar, Init(R,VertDir));
  97.   Scroller:=new(PNewScroller, Init(R,SBH1,SBV1));
  98.   if Nr=1 then Scroller^.CreateData(Event.InfoString);
  99.   if Nr=2 then Scroller^.CreateData('DEMO.TXT');
  100.   List^.InsertItem(Scroller);
  101. end;
  102.  
  103. destructor TScrollWindow.Done;
  104. begin
  105.   TWindow.Done;
  106.   dispose(Scroller, Done);
  107. end;
  108.  
  109. {Implementation TNewScroller}
  110.  
  111. procedure TNewScroller.CreateData(DateiName:string);
  112. var f:text;
  113.     LfdPtr:PLine;
  114. begin
  115.   assign(f,DateiName);
  116.   reset(f);
  117.   while not EOF(f) do
  118.    begin
  119.      LfdPtr:=new(PLine, Init);
  120.      readln(f,LfdPtr^.Eintrag);
  121.      Liste^.InsertItem(LfdPtr);
  122.    end;
  123.   SetLimit(25,Liste^.AnzElem,8,19);
  124. end;
  125.  
  126. procedure TNewScroller.ScrollDraw;
  127. var i:integer;
  128.     LfdPtr:PGroup;
  129.  
  130. function clip(p,n:byte;z:string):string;
  131. begin
  132.   clip:=copy(z,p,n);
  133. end;
  134.  
  135. begin
  136.   SetFont(Sans19);
  137.   Mouse.HideMouse;
  138.   with Border do
  139.    begin
  140.      SetFillStyle(SolidFill,GetPalColor(1));
  141.      SetColor(GetPalColor(2));
  142.      for i:=Delta.y to WDelta.y do
  143.       begin
  144.         LfdPtr:=Liste^.GetItems(i);
  145.         Bar(A.x,A.y+(i-Delta.y)*Py+10,B.x,A.y+(i-Delta.y)*Py+10+Py);
  146.         WriteText(A.x+20,A.y+(i-Delta.y)*Py+10,clip(Delta.x,Spalten*8 div 8-5,PLine(LfdPtr)^.Eintrag));
  147.       end;
  148.      if VertiScrollBar<>nil then
  149.       for i:=(WDelta.y-Delta.y)+1 to Zeilen do
  150.        Bar(A.x,A.y+i*Py+10,B.x,A.y+i*Py+10+Py);
  151.    end;
  152.   Mouse.ShowMouse;
  153. end;
  154.  
  155. {Implementation TMemoryInfo}
  156.  
  157. constructor TMemoryInfo.Init;
  158. var R:TRect;
  159. begin
  160.   R.Assign(60,80,450,320);
  161.   TWindow.Init(R,'Speicher-Ressourcen',winDouble+winPanel+winMenu);
  162.   SetWindowAttrib(false);
  163. end;
  164.  
  165. procedure TMemoryInfo.InitBackground;
  166. var R:TRect;
  167. begin
  168.   R:=Frame^.Area;
  169.   Bgrd:=new(PMemoryInfoBgrd, Init(R));
  170.   List^.InsertItem(Bgrd);
  171. end;
  172.  
  173. {Implementation TMemoryInfoBgrd}
  174.  
  175. procedure TMemoryInfoBgrd.Draw;
  176. var z:string;
  177.     EMS:PEMS;
  178.     HD:PHardDisk;
  179. begin
  180.   with Border do
  181.    begin
  182.      FillBar(A.x,A.y,B.x,B.y,Yellow,White,SolidFill);
  183.      str(MemAvail:8,z);
  184.      SetColor(Red);
  185.      OutTextXY(A.x+10,A.y+25,'Hauptspeicher');
  186.      OutTextXY(A.x+10,A.y+100,'Expanded Memory');
  187.      OutTextXY(A.x+10,A.y+160,'Festplatte C');
  188.      SetColor(Blue);
  189.      OutTextXY(A.x+10,A.y+45,'freier RAM (Heap)           :   '+z+' Byte');
  190.      str(MaxAvail:8,z);
  191.      OutTextXY(A.x+10,A.y+65,'größter zusammenhängender');
  192.      OutTextXY(A.x+10,A.y+75,'freier Speicherblock        :   '+z+' Byte');
  193.      EMS:=new(PEMS, Init(Border));
  194.      str(EMS^.FreeMemory:8,z);
  195.      OutTextXY(A.x+10,A.y+120,'verfügbarer Speicher        :   '+z+' Byte');
  196.      str(EMS^.FreeMemory div 16384:8,z);
  197.      OutTextXY(A.x+10,A.y+140,'verfügbare Seiten           :   '+z+' Pages');
  198.      dispose(EMS, Done);
  199.      HD:=new(PHardDisk, Init(Border));
  200.      str(HD^.FreeMemory:8,z);
  201.      OutTextXY(A.x+10,A.y+180,'verfügbare Plattenkapazität :   '+z+' Byte');
  202.      dispose(HD, Done);
  203.    end;
  204. end;
  205.  
  206. {Implementation TDateWindow}
  207.  
  208. constructor TDateWindow.Init;
  209. var RR:TRect; z:string;
  210.     Jahr,Monat,Tag,Wochentag:word;
  211.     Stunde,Minute,Sekunde,Sek100:word;
  212. begin
  213.   RR.Assign((GetMaxX div 2)-150,140,(GetMaxX div 2)+150,300);
  214.   TDlgWindow.Init(RR,'Datum & Uhrzeit',winDouble+winPanel+winMenu);
  215.   SetInputLine(95,70,10,'~D~atum  ',10,Ziffern-['-']);
  216.   SetInputLine(95,105,8,'~U~hrzeit',8,Ziffern+[':']-['.','-']);
  217.   SetPushButton(200,40,80,22,'OK',cmOK);
  218.   SetPushButton(200,70,80,22,'~A~bbrechen',cmCloseWindow);
  219.   SetPushButton(200,115,80,22,'~H~ilfe',90);
  220.   with DT do
  221.    begin
  222.      Schalter:='LLTTT';
  223.      Datum:=''; Zeit:='';
  224.      GetDate(Jahr,Monat,Tag,Wochentag);
  225.      str(Tag:2,z);
  226.      Datum:=Datum+z+'.';
  227.      str(Monat:2,z);
  228.      Datum:=Datum+z+'.';
  229.      str(Jahr:4,z);
  230.      Datum:=Datum+z;
  231.      GetTime(Stunde,Minute,Sekunde,Sek100);
  232.      str(Stunde:2,z);
  233.      Zeit:=Zeit+z+':';
  234.      str(Minute:2,z);
  235.      Zeit:=Zeit+z+':';
  236.      str(Sekunde:2,z);
  237.      Zeit:=Zeit+z;
  238.    end;
  239.   SetData(DT);
  240. end;
  241.  
  242. procedure TDateWindow.HandleEvent;
  243. begin
  244.   TDlgWindow.HandleEvent;
  245.   if Event.Command=90 then SetHelp;
  246.   if Event.Command=cmOK then
  247.    begin
  248.      with DT do
  249.       begin
  250.  
  251.         {und hier kommen die Routinen zum Setzen des neuen
  252.         Datums und der neuen Uhrzeit hinein. Dazu müssen Sie
  253.         die Strings Datum und Uhrzeit zerpflücken und die
  254.         in das word-Format umgewandelten Teilstrings den
  255.         Routinen SetDate und SetTime übergeben}
  256.  
  257.       end;
  258.      Event.Command:=cmCloseWindow;
  259.    end;
  260. end;
  261.  
  262. procedure TDateWindow.SetHelp;
  263. var HelpWindow:PHilfe;
  264. begin
  265.   HelpWindow:=new(PHilfe, Init);
  266.   FrameDeaktivated:=true;
  267.   DrawNewFrame;
  268.   HelpWindow^.Draw;
  269.   InsertChildWindow(HelpWindow);
  270. end;
  271.  
  272. {Implementation THilfe}
  273.  
  274. constructor THilfe.Init;
  275. var RR:TRect;
  276. begin
  277.   RR.Assign((GetMaxX div 2)-100,180,(GetMaxX div 2)+200,340);
  278.   TDlgWindow.Init(RR,'Hilfe',winDouble+winPanel);
  279.   SetStaticText(150,45,'Einstellen von',CenterText);
  280.   SetStaticText(150,75,'Datum und Uhrzeit',CenterText);
  281.   SetPushButton(110,130,80,22,'OK',cmCloseWindow);
  282. end;
  283.  
  284.  
  285. END.