home *** CD-ROM | disk | FTP | other *** search
/ TopWare 18: Liquid / Image.iso / liquid / top1143 / gepackt.exe / BSPQTSW.EXE / LISTER.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-06-28  |  6.4 KB  |  272 lines

  1. (***************************************
  2. * WG-VISION 1.0   BEISPIELPROGRAMM     *
  3. ****************************************
  4. *                                      *
  5. * Programmlister mit Druckerdialog     *
  6. *                                      *
  7. *                                      *
  8. ****************************************
  9. * (c) 1993 Dipl.Phys. Mathias Scholz   *
  10. ***************************************)
  11.  
  12. {$I COMPILER.INC}
  13.  
  14. program Lister;
  15.  
  16. {Programmlister mit WGraph}
  17.  
  18. uses  WDecl,
  19.       WApp,
  20.       WFileDlg,
  21.       WEvent,
  22.       WDlg,
  23.       WViews,
  24.       WUtils,
  25.       WPrint,
  26.       WDriver,
  27.       Printer,
  28.       Graph;
  29.  
  30. const cmLoad         = 101;
  31.       cmDruckOptionen= 102;
  32.       cmDruck        = 103;
  33.       msgPrint       = 20;
  34.       msgPrintError  = 21;
  35.  
  36. type  TApplication=object(TApp)
  37.         procedure InitVideoDevice; virtual;
  38.         procedure InitMenuBar; virtual;
  39.         procedure HandleEvent; virtual;
  40.         procedure CM_Load;
  41.         procedure CM_DruckOptionen;
  42.         procedure CM_Druck;
  43.       end;
  44.  
  45.       PNewScroller=^TNewScroller;
  46.  
  47.       PListWindow=^TListWindow;
  48.       TListWindow=object(TWindow)
  49.        Scroller:PNewScroller;
  50.        procedure InitWindowScroller; virtual;
  51.        destructor Done; virtual;
  52.        procedure HandleEvent; virtual;
  53.       end;
  54.  
  55.       TPrintLine=object(TLinePrint)
  56.        procedure SetParameters; virtual;
  57.       end;
  58.  
  59.       TNewScroller=object(TScroller)
  60.        PR:TPrintLine;
  61.        constructor Init(R:TRect;HScroller,VScroller:PScrollBar);
  62.        procedure CreateData;
  63.        procedure ScrollDraw;virtual;
  64.        procedure Print;
  65.       end;
  66.  
  67.  
  68. var   MyApp : TApplication;
  69.  
  70. {Implementation TApplication}
  71.  
  72. procedure TApplication.InitVideoDevice;
  73. begin
  74.   Video.Init(VESA,M640x480);
  75. end;
  76.  
  77. procedure TApplication.InitMenuBar;
  78. begin
  79.   Palette[1]:=#14;
  80.   Palette[5]:=#14;
  81.   Palette[4]:=#4;
  82.   Palette[12]:=#4;
  83.   MainMenu('~D~atei',0);
  84.    SubMenu('~L~aden         F3',cmLoad,0,kbF3,false,false);
  85.    SubMenu('~D~ruckoptionen   ',cmDruckOptionen,0,0,false,false);
  86.    SubMenu('~D~rucken       F5',cmDruck,0,kbF4,false,false);
  87.    NewLine;
  88.    SubMenu('E~x~it    <ALT><X>',cmCloseApplication,0,altX,false,false);
  89. end;
  90.  
  91. procedure TApplication.HandleEvent;
  92. begin
  93.   Heap^.ShowHeapStatus(523,8,White);
  94.   EMS^.ShowEMSStatus(50,8,White);
  95.   TProgram.HandleEvent;
  96.   case Event.Command of
  97.    cmLoad         : CM_Load;
  98.    cmDruck        : Event.Message:=msgPrint;
  99.    cmDruckOptionen: CM_DruckOptionen;
  100.   end; {case}
  101.   if Event.Message=msgLoadFile then    {übergeben aus Fileauswahlfenster}
  102.    begin
  103.      CM_Druck;
  104.      Event.Message:=msgNothing;
  105.    end;
  106. end;
  107.  
  108. procedure TApplication.CM_Load;
  109. var Window:PInputDialog;
  110. begin
  111.   Window:=New(PInputDialog, Init('Textdateien','*.pas'));
  112.   InsertDesktop(Window);
  113. end;
  114.  
  115. procedure TApplication.CM_DruckOptionen;
  116. var Window:PDruckOptionen;
  117. begin
  118.   Window:=New(PDruckOptionen, Init);
  119.   InsertDesktop(Window);
  120. end;
  121.  
  122. procedure TApplication.CM_Druck;
  123. var Window:PListWindow;
  124.     R:TRect;
  125.     X,Y:integer;
  126. begin
  127.   R.Assign(20,60,620,460);
  128.   Window:=New(PListWindow, Init(R,'Anzeigefenster',winDouble+winPanel+winMenu+winKey));
  129.   InsertDesktop(Window);
  130. end;
  131.  
  132. {Implementation TListWindow}
  133.  
  134. procedure  TListWindow.InitWindowScroller;
  135. var R:TRect;
  136.     I:byte;
  137.     SBH1,SBV1 :PScrollBar;
  138. begin
  139.   R:=Frame^.Area;
  140.   SBH1:=New(PScrollBar,Init(R,HorizDir));
  141.   SBV1:=New(PScrollBar,Init(R,VertDir));
  142.   Scroller:=New(PNewScroller,Init(R,SBH1,SBV1));
  143.   Scroller^.CreateData;
  144.   List^.InsertItem(Scroller);
  145. end;
  146.  
  147. procedure TListWindow.HandleEvent;
  148. begin
  149.   TWindow.HandleEvent;
  150.   if Event.Message=msgPrint then
  151.    begin
  152.      Scroller^.Print;
  153.      if Event.Message=msgPrint then Event.Message:=msgNothing;
  154.    end;
  155. end;
  156.  
  157. destructor TListWindow.Done;
  158. begin
  159.  TWindow.Done;
  160.  Dispose(Scroller,Done);
  161. end;
  162.  
  163. {Implementation TPrintLine}
  164.  
  165. procedure TPrintLine.SetParameters;
  166. var  Err:integer;
  167. begin
  168.   KopfZeile:=OptData.Header;
  169.   Val(OptData.LRand,RLinks,Err);
  170.   Val(OptData.RRand,RRechts,Err);
  171.   Val(OptData.ORand,ORand,Err);
  172.   if OptData.Schalter[7]='R' then SetLine:=true else SetLine:=false;
  173.   if OptData.Schalter[11]='C' then WNumber:=true else WNumber:=false;
  174.   if OptData.Schalter[12]='C' then SetDate:=true else SetDate:=false;
  175.   if DruckData.Schalter[8]='R' then Breite:=132 else Breite:=80;
  176.   if Breite=132 then Write(Lst,#15) else Write(Lst,#18);
  177.   if DruckData.Schalter[4]='R' then
  178.    begin
  179.      Val(Trim(DruckData.VonSeite),FromPage,Err);
  180.      Val(Trim(DruckData.BisSeite),ToPage,Err);
  181.    end;
  182.   if DruckData.Schalter[3]='R' then
  183.    begin
  184.      FromPage:=1;
  185.      ToPage:=999;
  186.    end;
  187. end;
  188.  
  189. {Implementation TNewScroller}
  190.  
  191. constructor TNewScroller.Init(R:TRect;HScroller,VScroller:PScrollBar);
  192. begin
  193.   TScroller.Init(R,HScroller,VScroller);
  194.   PR.Init('Programmausdruckprogramm V 1.0' );
  195. end;
  196.  
  197. procedure TNewScroller.CreateData;
  198. var F:text;
  199.     LfdPtr:PLine;
  200. begin
  201.   Assign(F,Event.InfoString);
  202.   Reset(F);
  203.   while not Eof(F) do
  204.     begin
  205.       LfdPtr:=New(PLine,Init);
  206.       ReadLn(F,LfdPtr^.Eintrag);
  207.       Liste^.InsertItem(LfdPtr);
  208.     end;
  209.   SetLimit(25,Liste^.AnzElem-1,8,16);
  210. end;
  211.  
  212. procedure TNewScroller.ScrollDraw;
  213. var I:integer;
  214.     LfdPtr:PGroup;
  215.  
  216. function Clip(P,N:byte;z:string):string;
  217. begin
  218.   Clip:=Copy(z,P,N)
  219. end;
  220.  
  221. {-------}
  222.  
  223. begin
  224.   Mouse.HideMouse;
  225.   with Border do
  226.    begin
  227.      SetFillStyle(SolidFill,GetPalColor(1));
  228.      SetColor(GetPalColor(2));
  229.      for I:=Delta.Y to WDelta.Y do
  230.       begin
  231.         LfdPtr:=Liste^.GetItems(I);
  232.         Bar(A.X,A.Y+(I-Delta.Y)*Py+10,B.X,A.Y+(I-Delta.Y)*Py+10+Py);
  233.         OutTextXY(A.X+20,A.Y+(I-Delta.Y)*Py+10,Clip(Delta.X,
  234.                   Spalten*8 div 8-5,PLine(LfdPtr)^.Eintrag));
  235.       end;
  236.      if VertiScrollbar<>nil then
  237.       for I:=(WDelta.Y-Delta.Y)+1 to Zeilen do
  238.        Bar(A.X,A.Y+I*Py+10,B.X,A.Y+I*Py+10+Py);
  239.    end;
  240.   Mouse.ShowMouse;
  241. end;
  242.  
  243. procedure TNewScroller.Print;
  244. var LfdPtr:PGroup;
  245.     I:integer;
  246. begin
  247.   with Liste^ do
  248.    begin
  249.      for I:=1 to AnzElem do
  250.       begin
  251.         LfdPtr:=GetItems(I);
  252.         if PR.PrinterOK then PR.Print(PLine(LfdPtr)^.Eintrag)
  253.         else
  254.         begin
  255.           Event.Message:=msgPrintError;
  256.           PR.Done;
  257.           Exit;
  258.         end;
  259.       end;
  260.      PR.Eject;
  261.      PR.Done;
  262.    end;
  263. end;
  264.  
  265. {Hauptprogramm}
  266.  
  267. begin
  268.   MyApp.Init('Datei Lister');
  269.   MyApp.Run;
  270.   MyApp.Done;
  271. end.
  272.