home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / HSYS10 / HFTP.INT < prev    next >
Text File  |  1993-08-26  |  10KB  |  355 lines

  1. {*********************************************************}
  2. {                                                         }
  3. {   Turbo Vision Demo                                     }
  4. {   Portions Copyright (c) 1992 by Borland International  }
  5. {   Portions Coypright (c) 1993 by KAP Holger Lembke      }
  6. {                                                         }
  7. {*********************************************************}
  8.  
  9. {
  10. KAP - Ergänzungen
  11. 19.08.93
  12.   ■ Kontrolle der Streamregistrierung eingebaut. Wenn Hilfsstreams nicht
  13.     registriert, dann reagieren wichtige Objekte im Constructor mit FAIL.
  14. 10.08.93
  15.   ■ Kontrolle der Änderungen vom 8.-9.8.
  16.   ■ Topic link-Jumping eingebaut (MakefocusVisible)
  17. 09.08.93
  18.   ■ Markierung von Schaltflächen dramatisch beschleunigt (Handleevent)
  19.     (alles im Zuge des Deppen-Aufräumens)
  20. 08.08.93
  21.   ■ DRAW-Methode bei vielen Links dramatisch beschleunigt
  22.     (vorher muss ein Depp drangewesen sein...)
  23. 04.08.93
  24.   ■ compressor/decompressor optimiert
  25. 01.08.93
  26.   ■ compressor/decompressor
  27. 22.07.93
  28.   ■ modales Fenster ergänzt um "resizable dialog"
  29. 11.07.93
  30.   ■ Fehler in der thelpviewer.draw methode, wenn farbumschaltung
  31.     ausserhalb des sichtbereiches liegt. es wurde dann übersehen.
  32.     Folge: text war falsch befarbt...
  33.  
  34. 03.07.93
  35.   ■ Speichern der letzten Menüposition umgestellt
  36.  
  37. 02.06.93
  38.   ■ Verändertes Mono-Handling
  39.  
  40. 19.05.93
  41.   ■ Bugfix: Topic-Markierung und Farben in einer Zeile
  42.     Bugfix: Farbmarkierungen und horizontales Scrollen
  43.  
  44. 11.05.93
  45.   ■ Bugfix: thelpviewer.draw und mehrzeiliger Umbruch farbiger texte
  46.  
  47. 25.04.93
  48.   ■ Optimisierung bei "countcs" in THelpTopic.WrapText
  49.     (Die Darstellung bei vielen Topics ist immer noch recht träge.)
  50.  
  51. 21.04.93
  52.   ■ Bugfix: Zeilenumbruch bei langen Paragraphen
  53.  
  54. 20.04.93
  55.   ■ nicht-modale Hilfe merkt sich die Größe
  56.   ■ geänderte Farbe auch über Zeilenumbrüche hinweg
  57.  
  58. 19.04.93
  59.   ■ Umbau der THelpViewer.Draw-Methode
  60.     (incl. Änderungen in THelpTopic.WrapText)
  61.     - lock/unlock zur Darstellungsberuhigung
  62.     - zeichenweises Ablegen wg. Farbänderungen
  63.       methode: #n als Code, es ändert sich =nur= der Vordergrund
  64.                ## für #
  65.                #! für Rücksetzen auf Dialogfarbe
  66.  
  67. 16.04.93
  68.   ■ Alt-F1 focusiert letztes focusiertes topic
  69.  
  70. 15.04.93
  71.   ■ modales Fenster wird in anderem Farbset dargestellt als nicht-modales
  72.   ■ Alt-F1 für Help-History
  73.   ■ Shift-F1 für Hilfe über Hilfe
  74.  
  75. 14.04.93
  76.   ■ Unterscheidung zwischen modaler und nicht-modaler Hilfe
  77. }
  78.  
  79. unit HelpFile;
  80.  
  81. interface
  82.  
  83. uses Objects, Drivers, Views;
  84.  
  85. const
  86.   CHelpColor      = {8} #$37#$3F#$3A#$13#$13#$30#$3E#$1E;
  87.   CHelpBlackWhite = {8} #$07#$0F#$07#$70#$70#$07#$0F#$70;
  88.   CHelpMonochrome = {8} #$07#$0F#$07#$70#$70#$07#$0F#$70;
  89.   CHelpViewer     = {3} #6#7#8;
  90.   Chelpwindow     = {8} #16#17#18#19#20#57#21#13;
  91.   Cdialogwindow   = {8} #32#33#34#35#36#38#40#13; { die farbe der dialoge }
  92.  
  93. {KAP}
  94.   {
  95.   chelpwindow-felder
  96.    1 ????
  97.    2 rahmen
  98.    3 rahmensymbole [■]
  99.    4 scroller
  100.    5 background, scrollersymbole
  101.    6 textinhalt
  102.    7 nicht focusierter topic
  103.    8 linked topics/reaktionstopic für ENTER
  104.   }
  105.  
  106. (*
  107.   CHelpWindow     = #128#129#130#131#132#133#134#135;
  108. *)
  109.  
  110. {KAP}
  111.   maxhelpback           = 50;
  112.  
  113.   indexpagenumber       : word = 100;
  114.   helpabouthelp         : word = 99;
  115.  
  116.   cmhelplast            = 65001;
  117.   cmhelpindex           = 65002;
  118.  
  119.   lastpos               : trect = (a:(x:-1;y:0);b:(x:50;y:18));
  120.  
  121.   MagicHeader           = $46484246; {'FBHF'}
  122.  
  123. { wenn auch tp60-hf geöffnet werden können sollen ... }
  124.   openanyway            : boolean = false;
  125.  
  126. { erlaubt den Hilfsfenster (trotz Dialog-Aussehen) die Größe zu ändern }
  127.   resizeabledialog      : boolean = false;
  128.  
  129.   ct_store              = $01;
  130.   ct_nibble             = $02;
  131.   ct_lastnibble         = $03;
  132.  
  133.   nc_rawchar            = $0f;
  134.   nc_repchar            = $0e;
  135.  
  136.   comparraysize         = 13;
  137.  
  138.   createcompressedhelp  : boolean = false;
  139.  
  140.   helpversion           = $20;  { helpfile - version 2.0 }
  141.  
  142. Type string80 = string[80];
  143.  
  144. Const
  145.  
  146.   helpdialogtitle       : string80 = 'Help-Dialog';
  147.   helpwindowtitle       : string80 = 'Help';
  148.   nohelpInvalidStr      : string80 = #13' No help for this topic link.';
  149.   emptyhelpInvalidStr   : string80 = #13' This helppage is empty.';
  150.  
  151.  
  152. type
  153.  
  154. {$I chararray.pas }
  155.  
  156. { TParagraph }
  157.  
  158.   PPParagraph = ^pparagraph;
  159.   PParagraph = ^TParagraph;
  160.   TParagraph = record
  161.     Next: PParagraph;
  162.     Wrap: Boolean;
  163.     Size: Word;
  164.     Text: record end;
  165.   end;
  166.  
  167. { THelpTopic }
  168.  
  169.   TCrossRef = record
  170.     Ref: Word;
  171.     Offset: Integer;
  172.     Length: Byte;
  173.   end;
  174.  
  175.   tCompressinfo = record
  176.     comptype  : byte;                 {                           }
  177.     orgsize   : word;                 { orginalgroesse            }
  178.     chartable : array[0..comparraysize] of byte;
  179.                                       { die comparraysize+1 häufigsten codes   }
  180.   end;
  181.  
  182.   plocarray  = ^tlocarray;
  183.   tlocarray  = array[1..1000] of tpoint;
  184.  
  185.   PCrossRefs = ^TCrossRefs;
  186.   TCrossRefs = array[1..10000] of TCrossRef;
  187.   TCrossRefHandler = procedure (var S: TStream; XRefValue: Integer);
  188.  
  189.   PHelpTopic = ^THelpTopic;
  190.   THelpTopic = object(TObject)
  191. { private}
  192.     Paragraphs    : PParagraph;
  193.     NumRefs       : Integer;
  194.     CrossRefs     : PCrossRefs;
  195.     Width         : Integer;
  196.     LastOffset    : Integer;
  197.     LastLine      : Integer;
  198.     LastParagraph : PParagraph;
  199. { public }
  200.     constructor   Init;
  201.     constructor   Load(var S: TStream);
  202.     destructor    Done; virtual;
  203.  
  204.     procedure     initstatistic    (var compheader : tcompressinfo;     p : pParagraph);
  205.     function      Paragraphcompress(var compheader : tcompressinfo;     p : PPParagraph):word;
  206.     procedure     Paragraphexpand  (var compheader : tcompressinfo; var p : ppparagraph);
  207.  
  208.     procedure     AddCrossRef(Ref: TCrossRef);
  209.     procedure     AddParagraph(P: PParagraph);
  210.  
  211.     procedure     GetCrossRef(I: Integer; var Loc: TPoint; var Length: Byte; var Ref: Word);
  212.     procedure     GetallCrossRef(locarray : plocarray; maxline : integer);
  213.  
  214.     function      GetLine(Line: Integer): String;
  215.     function      GetNumCrossRefs: Integer;
  216.     function      NumLines: Integer;
  217.     procedure     SetCrossRef(I: Integer; var Ref: TCrossRef);
  218.     procedure     SetNumCrossRefs(I: Integer);
  219.     procedure     SetWidth(AWidth: Integer);
  220.     procedure     Store(var S: TStream);
  221. { private }
  222.     function WrapText(var Text; Size: Integer; var Offset: Integer;
  223.       Wrap: Boolean): String;
  224.   end;
  225.  
  226. { THelpIndex }
  227.  
  228.   PIndexArray = ^TIndexArray;
  229.   TIndexArray = array[0..16380] of LongInt;
  230.  
  231.   PContextArray = ^TContextArray;
  232.   TContextArray = array[0..16380] of Word;
  233.  
  234.   PHelpIndex = ^THelpIndex;
  235.   THelpIndex = object(TObject)
  236.     Contexts  : PContextArray;
  237.     Index     : PIndexArray;
  238. { private }
  239.     Size      : Word;
  240.     Used      : Word;
  241. { public }
  242.     constructor Init;
  243.     constructor Load(var S: TStream);
  244.     destructor  Done; virtual;
  245.     function    Position(I: Word): Longint;
  246.     procedure   Add(I: Word; Val: Longint);
  247.     procedure   Store(var S: TStream);
  248. { private }
  249.     function    Find(I: Word):longint;
  250.   end;
  251.  
  252. { THelpFile }
  253.  
  254.   PHelpFile = ^THelpFile;
  255.   THelpFile = object(TObject)
  256.     Stream     : PStream;
  257.     Modified   : Boolean;
  258. {KAP}
  259.     invaltopic : boolean;
  260. { private}
  261.     Index      : PHelpIndex;
  262.     IndexPos   : LongInt;
  263. { public }
  264.     constructor Init(S: PStream);
  265.     destructor  Done; virtual;
  266.     function    GetTopic(I: Word): PHelpTopic;
  267.     function    InvalidTopic: PHelpTopic;
  268.     function    emptyTopic: PHelpTopic;
  269.     procedure   RecordPositionInIndex(I: word);
  270.     procedure   PutTopic(Topic: PHelpTopic);
  271.   end;
  272.  
  273. {KAP}
  274.   stackrec = record
  275.     helpctx  : word;
  276.     selected : byte;
  277.   end;
  278.  
  279.   pstackarray = ^tstackarray;
  280.   tstackarray = array[1..maxhelpback] of stackrec;
  281.  
  282. { THelpViewer }
  283.   PHelpViewer = ^THelpViewer;
  284.   THelpViewer = object(TScroller)
  285.     HFile         : PHelpFile;
  286.     Topic         : PHelpTopic;
  287.     stack         : pstackarray;
  288.     Selected      : Integer;
  289.  
  290.     oldsize       : byte;
  291.     locarray      : plocarray;
  292.     locarraysize  : word;
  293.     keyfocus      : pstring;
  294.     constructor Init(var Bounds       : TRect;
  295.                          AHScrollBar,
  296.                          AVScrollBar  : PScrollBar;
  297.                          AHelpFile    : PHelpFile;
  298.                          Context      : Word);
  299.     destructor Done; virtual;
  300.     procedure  ChangeBounds(var Bounds: TRect); virtual;
  301.     procedure  Draw; virtual;
  302.     function   GetPalette: PPalette; virtual;
  303.     procedure  HandleEvent(var Event: TEvent); virtual;
  304.     procedure  SwitchToTopic(KeyRef: word);
  305.  
  306.     procedure  invalidatelocarray;
  307.  
  308.     procedure  Popstack(var keyword : word);
  309.     procedure  Pushstack(keyword : word);
  310.     procedure  SwitchTooldTopic(Var keyref : word);
  311.   end;
  312.  
  313. { THelpWindow }
  314.   PHelpWindow = ^THelpWindow;
  315.   THelpWindow = object(TWindow)
  316.     phv      : phelpviewer;
  317.     ismodal  : boolean;
  318.     constructor Init(HFile: PHelpFile; Context: Word; aismodal : boolean);
  319.     function GetPalette: PPalette; virtual;
  320.     destructor done; virtual;
  321.   end;
  322.  
  323. Var
  324.   originalsize, compresssize  : longint;
  325.  
  326.  
  327. const
  328.   RHelpTopic: TStreamRec = (
  329.      ObjType: 10000;
  330.      VmtLink: Ofs(TypeOf(THelpTopic)^);
  331.      Load:    @THelpTopic.Load;
  332.      Store:   @THelpTopic.Store
  333.   );
  334.  
  335. const
  336.   RHelpIndex: TStreamRec = (
  337.      ObjType: 10001;
  338.      VmtLink: Ofs(TypeOf(THelpIndex)^);
  339.      Load:    @THelpIndex.Load;
  340.      Store:   @THelpIndex.Store
  341.   );
  342.  
  343. procedure RegisterHelpFile;
  344.  
  345. procedure NotAssigned(var S: TStream; Value: Integer);
  346.  
  347. const     CrossRefHandler: TCrossRefHandler = NotAssigned;
  348.  
  349. implementation
  350.  
  351. {....}
  352.  
  353. end.
  354.  
  355.