home *** CD-ROM | disk | FTP | other *** search
/ Best of German Only 1 / romside_best_of_german_only_1.iso / wissen / dos / wgraph / entpack.exe / WGDEMOQ!.EXE / GHELP.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-01  |  3KB  |  130 lines

  1. (*****************************************************
  2. *                                                    *
  3. * WGRAPH V. 1.0    Kontextsensitives Hilfesystem     *
  4. *                                                    *
  5. ******************************************************
  6. *                                                    *
  7. *                                                    *
  8. * (c) 1992 Dipl.Phys. Mathias Scholz                 *
  9. *                                                    *
  10. *****************************************************)
  11.  
  12. {$A+,B-,D-,E-,F+,I-,L-,N-,O+,R-,S-,V-}
  13.  
  14. UNIT GHelp;
  15.  
  16. INTERFACE
  17.  
  18. uses GDecl,
  19.      GDrivers,
  20.      GViews,
  21.      GDlg,
  22.      GText,
  23.      Graph;
  24.  
  25. type PHelpScroller=^THelpScroller;
  26.      THelpScroller=object(TScroller)
  27.        procedure CreateData(HelpDatei:string;HelpCtx:word);
  28.        procedure ScrollDraw; virtual;
  29.      end;
  30.  
  31.      PHelpWindow=^THelpWindow;
  32.      THelpWindow=object(TWindow)
  33.        HelpIndex:word;
  34.        HelpDatei:string;
  35.        Scroller:PHelpScroller;
  36.        constructor Init(Datei:string;HI:word;var Bounds:TRect;ATitle:str80;AType:byte);
  37.        procedure InitWindowScroller; virtual;
  38.        destructor Done; virtual;
  39.      end;
  40.  
  41.  
  42. IMPLEMENTATION
  43.  
  44.  
  45. {Implementation THelpScroller}
  46.  
  47. procedure THelpScroller.CreateData(HelpDatei:string;HelpCTX:word);
  48. var f:text;
  49.     KZ,zz:string;
  50.     LfdPtr:PLine;
  51. begin
  52.   str(HelpCTX,KZ);
  53.   KZ:='##'+KZ;
  54.   assign(f,HelpDatei);
  55.   reset(f);
  56.   while not EOF(f) do
  57.    begin
  58.      readln(f,zz);
  59.      if zz=KZ then
  60.       while zz<>'END' do
  61.        begin
  62.          readln(f,zz);
  63.          LfdPtr:=new(PLine, Init);
  64.          LfdPtr^.Eintrag:=zz;
  65.          Liste^.InsertItem(LfdPtr);
  66.        end;
  67.    end;
  68.   SetLimit(75,Liste^.AnzElem-1,CharLength,CharHeight);
  69. end;
  70.  
  71. procedure THelpScroller.ScrollDraw; 
  72. var i:integer;
  73.     LfdPtr:PGroup;
  74.  
  75. function clip(p,n:byte;z:string):string;
  76. begin
  77.   clip:=copy(z,p,n);
  78. end;
  79.  
  80. begin
  81.   Mouse.HideMouse;
  82.   with Border do
  83.    begin
  84.      SetFillStyle(SolidFill,GetPalColor(1));
  85.      SetColor(GetPalColor(2));
  86.      for i:=Delta.y to WDelta.y do
  87.       begin
  88.         LfdPtr:=Liste^.GetItems(i);
  89.         Bar(A.x,A.y+(i-Delta.y)*Py+10,B.x,A.y+(i-Delta.y)*Py+10+Py);
  90.         if Font<>VGAF then WriteText(A.x+20,A.y+(i-Delta.y)*Py+10,clip(Delta.x,Spalten*8 div 8-5,PLine(LfdPtr)^.Eintrag))
  91.          else OutTextXY(A.x+20,A.y+(i-Delta.y)*Py+10,clip(Delta.x,Spalten*8 div 8-5,PLine(LfdPtr)^.Eintrag));
  92.       end;
  93.      if VertiScrollBar<>nil then
  94.       for i:=(WDelta.y-Delta.y)+1 to Zeilen do
  95.        Bar(A.x,A.y+i*Py+10,B.x,A.y+i*Py+10+Py);
  96.    end;
  97.   Mouse.ShowMouse;
  98. end;
  99.  
  100. {Implementation THelpWindow}
  101.  
  102. constructor THelpWindow.Init(Datei:string;HI:word;var Bounds:TRect;ATitle:str80;AType:byte);
  103. begin
  104.   HelpIndex:=HI;
  105.   HelpDatei:=Datei;
  106.   TWindow.Init(Bounds,ATitle,AType);
  107. end;
  108.  
  109.  
  110. procedure THelpWindow.InitWindowScroller; 
  111. var R:TRect;
  112.     SBH1,SBV1:PScrollBar;
  113. begin
  114.   R:=Frame^.Area;
  115.   SBH1:=new(PScrollBar, Init(R,HorizDir));
  116.   SBV1:=new(PScrollBar, Init(R,VertDir));
  117.   Scroller:=new(PHelpScroller, Init(R,SBH1,SBV1));
  118.  
  119.   Scroller^.CreateData(HelpDatei,HelpIndex);
  120.   List^.InsertItem(Scroller);
  121. end;
  122.  
  123. destructor THelpWindow.Done;
  124. begin
  125.   TWindow.Done;
  126.   dispose(Scroller, Done);
  127. end;
  128.  
  129.  
  130. END.