home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / blatbox.prg < prev    next >
Text File  |  1993-10-14  |  4KB  |  125 lines

  1. /*
  2.  * File......: BLATBOX.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_BLATBOX()
  24.  *  $CATEGORY$
  25.  *      Video
  26.  *  $ONELINER$
  27.  *      Draw a double lined box with a shadow around a text string
  28.  *  $SYNTAX$
  29.  *      GT_BlatBox( aString , nRow , nCol , cColour )
  30.  *  $ARGUMENTS$
  31.  *      aString - Array containg string to be output - each element will
  32.  *                appear on a separate line
  33.  *      nRow    - Top row of box
  34.  *      nCol    - Left column of box ( -1 to centre )
  35.  *      cColour - Colour string
  36.  *  $RETURNS$
  37.  *      NIL
  38.  *  $DESCRIPTION$
  39.  *      Draws a double lined box on screen, with a shadow around the box.
  40.  *      The text in aString will appear in the box, with each element
  41.  *      appearing on a new line.
  42.  *  $EXAMPLES$
  43.  *      Show the two text lines "Line1" and "Line2" in a box horizontally
  44.  *      centred from line 10, in White on Blue :
  45.  *
  46.  *          GT_BlatBox( { "Line 1" , "Line 2" } , 10 , -1 , "W+/B" )
  47.  *  $SEEALSO$
  48.  *
  49.  *  $INCLUDE$
  50.  *      GT_LIB.CH
  51.  *  $END$
  52.  */
  53.  
  54. *
  55. #include "GT_LIB.ch"
  56.  
  57. FUNCTION GT_BlatBox( aString , nRow , nCol , nColour )
  58.  
  59. /****************************************************************************
  60.  Purpose - Output a box around a string
  61.  Returns - Length of longest line
  62.  Author  - Martin Colloby
  63.  Created - 12/9/90
  64.  Edited  - 29/5/91 by Martin Colloby - Added nRow parameter
  65.            26/6/91 by Martin Colloby - Added return value
  66. ******************************************************************************
  67.  Parameters - aString   - Array containing string
  68.               nRow      - Row at which to start box
  69.  Private    - cOldColor - Temporary storage for colour setup
  70.               nCount    - Counting variable
  71.               nLCol     - Screen column for output
  72.               nLength   - Length of longest line in aString
  73.               nLines    - Number of lines in aString
  74.               nLRow     - Screen row to output next line to
  75.  Externals  - None
  76.  
  77.  N.B. Tilde (~) character can be used to split string onto > 1 line
  78. ****************************************************************************/
  79.  
  80. LOCAL cOldColor := ""
  81. LOCAL nCount   := 0
  82. LOCAL nCursor  := SETCURSOR( 0 )
  83. LOCAL nLCol    := 0
  84. LOCAL nLength  := 0
  85. LOCAL nLines   := LEN( aString )
  86. LOCAL nLRow    := 0
  87.  
  88. * Find the length of the longest line in the string
  89. FOR nCount := 1 TO nLines
  90.     nLength := MAX( nLength , LEN( aString[nCount] ) + 1 )
  91. NEXT nCount
  92.  
  93. * Starting column is such that box is centred on screen
  94. nLCol := INT( ( MAXCOL() + 1 - nLength + 2 ) / 2 ) - 1
  95.  
  96. * If nRow is -1 the box is to be placed such that the last line is at row 22
  97. IF nRow == -1
  98.     nLRow := MAXROW() - 2 - nLines - 2
  99. ELSE
  100.     * If nRow is such that the bottom of the box would go off the edge of the
  101.     * screen, flag a warning
  102.     IF nRow > MAXROW() - 2 - nLines - 2
  103.         GT_Warning( { "GT_BlatBox Error - nRow is too close to bottom of screen !" } )
  104.     ELSE
  105.         NLRow := nRow
  106.     ENDIF
  107. ENDIF
  108.  
  109. * Draw a shadow
  110. GT_Shadow( nLRow , nLcol , nLRow + nLines + 1 , nLcol + nLength + 2 )
  111.  
  112. GT_ColorSet( nColour )
  113. @ nLRow , nLCol , nLRow + nLines + 1 , nLCol + nLength + 2 BOX B_DOUBLE
  114.  
  115. FOR nCount := 1 TO nLines
  116.     nLRow ++
  117.     * Draw the middle lines of the box, with the string in it
  118.     @ nLRow, nLCol + 1 SAY PADR( " " + aString[nCount] , nLength + 1 )
  119. NEXT cCount
  120.  
  121. SETCURSOR( nCursor )
  122.  
  123. RETURN( nLength )
  124. *
  125.