home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / RTFFILE.PRG < prev    next >
Text File  |  1994-06-01  |  3KB  |  120 lines

  1. // FiveWin - RTF (Rich Text format) Class
  2. // FiveWin Documentation tools
  3.  
  4. #include "FiveWin.ch"
  5.  
  6. //----------------------------------------------------------------------------//
  7.  
  8. CLASS TRtfFile
  9.  
  10.    DATA    hFile
  11.    DATA    aBitmaps
  12.    DATA    cFileName
  13.  
  14.    METHOD  New( cFileName ) CONSTRUCTOR
  15.  
  16.    METHOD  WriteShort( cShort, cJumpTo, lPopup, cBitmap )
  17.  
  18.    METHOD  WriteLong( cLong )
  19.  
  20.    METHOD  WriteId( cIdentifier ) INLINE ;
  21.                     FWrite( ::hFile, "#{\footnote " + cIdentifier + "}" + ;
  22.                             CRLF +  "\par\pard" + CRLF )
  23.  
  24.    METHOD  WriteSeeAlso( cSeeAlsoList ) INLINE ;
  25.                        FWrite( ::hFile, "!seealso:" + cSeeAlsoList + CRLF )
  26.  
  27.    METHOD  NewPage() INLINE FWrite( ::hFile, "\page" + CRLF )
  28.  
  29.    METHOD  End()
  30.  
  31. ENDCLASS
  32.  
  33. //----------------------------------------------------------------------------//
  34.  
  35. METHOD New( cFileName ) CLASS TRtf
  36.  
  37.    ::cFileName = cFileName
  38.    ::hFile     = FCreate( cFileName )
  39.    ::aBitmaps  = {}
  40.  
  41.    FWrite( ::hFile, "{\rtf1\ansi \deff0" + CRLF + ;
  42.                     "{\fonttbl" + CRLF + ;
  43.                     "{\f0\fmodern Courier New;}" + CRLF + ;
  44.                     "{\f1\fdecor  Courier New;}" + CRLF + ;
  45.                     "{\f2\fswiss  Arial;}}" + CRLF + ;
  46.                     "{\colortbl;" + CRLF + ;
  47.                     "\red0\green0\blue0;" + CRLF + ;
  48.                     "\red0\green0\blue255;" + CRLF + ;
  49.                     "\red0\green255\blue255;" + CRLF + ;
  50.                     "\red0\green255\blue0;" + CRLF + ;
  51.                     "\red255\green0\blue255;" + CRLF + ;
  52.                     "\red255\green0\blue0;" + CRLF + ;
  53.                     "\red255\green255\blue0;" + CRLF + ;
  54.                     "\red255\green255\blue255;}" + CRLF + ;
  55.                     "\f2\fs20" + CRLF )
  56.  
  57. return nil
  58.  
  59. //----------------------------------------------------------------------------//
  60.  
  61. METHOD WriteLong( cLong ) CLASS TRtfFile
  62.  
  63.    local nLines := MlCount( cLong )
  64.    local n
  65.  
  66.    for n = 1 to nLines
  67.       FWrite( ::hFile, MemoLine( cLong,, n ) + "\line" )
  68.    next
  69.    FWrite( ::hFile, CRLF )
  70.  
  71. return nil
  72.  
  73. //----------------------------------------------------------------------------//
  74.  
  75. METHOD WriteShort( cShort, cJumpTo, lPopup, cBitmap ) CLASS TRtfFile
  76.  
  77.    local cBuffer := "\b\tab"
  78.  
  79.    DEFAULT cJumpTo := "", lPopup := .f.
  80.  
  81.    if ! Empty( cBitmap )
  82.       cBuffer += If( lPopup, "{\ul", "{\uldb" ) + "\{bmc " + ;
  83.                  AllTrim( cNoPath( cBitmap ) ) + "\}}\b\tab"
  84.       AAdd( ::aBitmaps, cBitmap )
  85.    endif
  86.  
  87.    cBuffer += If( lPopup, "{\ul ", "{\uldb " ) + ;
  88.               AllTrim( cShort ) + "}{\v " + cJumpTo + ;
  89.               "}\par\pard" + CRLF
  90.  
  91.    FWrite( ::hFile, cBuffer )
  92.  
  93. return nil
  94.  
  95. //----------------------------------------------------------------------------//
  96.  
  97. METHOD End() CLASS TRtfFile
  98.  
  99.    local hHpj
  100.    local n
  101.  
  102.    FWrite( ::hFile, "}" )
  103.    FClose( ::hFile )
  104.  
  105.    hHpj = FCreate( cNoExt( ::cFileName ) + ".hpj" )
  106.  
  107.    FWrite( hHpj, "[files]" + CRLF )
  108.    FWrite( hHpj, ::cFileName + CRLF + CRLF )
  109.  
  110.    FWrite( hHpj, "[bitmaps]" + CRLF )
  111.  
  112.    for n = 1 to Len( ::aBitmaps )
  113.       FWrite( hHpj, ::aBitmaps[ n ] + CRLF )
  114.    next
  115.    FClose( hHpj )
  116.  
  117. return nil
  118.  
  119. //----------------------------------------------------------------------------//
  120.