You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
3.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * helpbase.h
  3. *
  4. * Turbo Vision - Version 2.0
  5. *
  6. * Copyright (c) 1994 by Borland International
  7. * All Rights Reserved.
  8. *
  9. * Modified by Sergio Sigala <ssigala@globalnet.it>
  10. * Modified by Salvador E. Tropea <set@ieee.org>, <set@users.sourceforge.net>
  11. */
  12. #if defined(Uses_THelpFile) && !defined(THelpFile_Included)
  13. #define THelpFile_Included
  14. const long magicHeader = 0x46484246L; //"FBHF"
  15. #define cHelpViewer "\x06\x07\x08"
  16. #define cHelpWindow "\x80\x81\x82\x83\x84\x85\x86\x87"
  17. // TParagraph
  18. class TParagraph
  19. {
  20. public:
  21. TParagraph() {}
  22. TParagraph *next;
  23. Boolean wrap;
  24. ushort size;
  25. char *text;
  26. };
  27. // TCrossRef
  28. class TCrossRef
  29. {
  30. public:
  31. TCrossRef() {}
  32. int ref;
  33. int offset;
  34. uchar length;
  35. };
  36. typedef void (*TCrossRefHandler) ( opstream&, int );
  37. class THelpTopic: public TObject, public TStreamable
  38. {
  39. public:
  40. THelpTopic();
  41. THelpTopic( StreamableInit ) {};
  42. virtual ~THelpTopic();
  43. void addCrossRef( TCrossRef ref );
  44. void addParagraph( TParagraph *p );
  45. void getCrossRef( int i, TPoint& loc, uchar& length, int& ref );
  46. char *getLine( int line, char *buffer, int buflen );
  47. int getNumCrossRefs();
  48. int numLines();
  49. void setCrossRef( int i, TCrossRef& ref );
  50. void setNumCrossRefs( int i );
  51. void setWidth( int aWidth );
  52. TParagraph *paragraphs;
  53. int numRefs;
  54. TCrossRef *crossRefs;
  55. private:
  56. char *wrapText( char *text, int size, int& offset, Boolean wrap, char *lineBuf, int lineBufLen );
  57. void readParagraphs( ipstream& s );
  58. void readCrossRefs( ipstream& s );
  59. void writeParagraphs( opstream& s );
  60. void writeCrossRefs( opstream& s );
  61. void disposeParagraphs();
  62. const char *streamableName() const
  63. { return name; }
  64. int width;
  65. int lastOffset;
  66. int lastLine;
  67. TParagraph *lastParagraph;
  68. protected:
  69. virtual void write( opstream& );
  70. virtual void *read( ipstream& );
  71. public:
  72. static const char * const name;
  73. static TStreamable *build();
  74. };
  75. inline ipstream& operator >> ( ipstream& is, THelpTopic& cl )
  76. { return is >> (TStreamable&)cl; }
  77. inline ipstream& operator >> ( ipstream& is, THelpTopic*& cl )
  78. { return is >> (void *&)cl; }
  79. inline opstream& operator << ( opstream& os, THelpTopic& cl )
  80. { return os << (TStreamable&)cl; }
  81. inline opstream& operator << ( opstream& os, THelpTopic* cl )
  82. { return os << (TStreamable *)cl; }
  83. // THelpIndex
  84. class THelpIndex : public TObject, public TStreamable
  85. {
  86. public:
  87. THelpIndex();
  88. THelpIndex( StreamableInit ) {};
  89. virtual ~THelpIndex();
  90. long position( int );
  91. void add( int, long );
  92. ushort size;
  93. long *index;
  94. private:
  95. const char *streamableName() const
  96. { return name; }
  97. protected:
  98. virtual void write( opstream& );
  99. virtual void *read( ipstream& );
  100. public:
  101. static const char * const name;
  102. static TStreamable *build();
  103. };
  104. inline ipstream& operator >> ( ipstream& is, THelpIndex& cl )
  105. { return is >> (TStreamable&)cl; }
  106. inline ipstream& operator >> ( ipstream& is, THelpIndex*& cl )
  107. { return is >> (void *&)cl; }
  108. inline opstream& operator << ( opstream& os, THelpIndex& cl )
  109. { return os << (TStreamable&)cl; }
  110. inline opstream& operator << ( opstream& os, THelpIndex* cl )
  111. { return os << (TStreamable *)cl; }
  112. // THelpFile
  113. class THelpFile : public TObject
  114. {
  115. static const char * invalidContext;
  116. public:
  117. THelpFile( fpstream& s );
  118. virtual ~THelpFile();
  119. virtual THelpTopic *getTopic( int );
  120. THelpTopic *invalidTopic();
  121. void recordPositionInIndex( int );
  122. void putTopic( THelpTopic* );
  123. fpstream *stream;
  124. Boolean modified;
  125. THelpIndex *index;
  126. long indexPos;
  127. };
  128. extern void notAssigned( opstream& s, int value );
  129. extern TCrossRefHandler crossRefHandler;
  130. #endif // Uses_THelpFile && !THelpFile_Included