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

  1. /*
  2.  * File......: GT_BLOCK.PRG
  3.  * Author....: Simon Coates
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Simon Coates
  7.  * Date......: 21/07/1993
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Simon Coates and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  *
  19.  */
  20.  
  21.  
  22. /*  $DOC$
  23.  *  $FUNCNAME$
  24.  *      GT_BLOCK()
  25.  *  $CATEGORY$
  26.  *      Video
  27.  *  $ONELINER$
  28.  *     Draws a '3d(ish)' box, and opptionally labels it
  29.  *  $SYNTAX$
  30.  *      GT_Block( nTop, nLeft, nBottom, nRight, ;
  31.  *                <cLabel>, <lShadow>, <cDull>, <cBright>, <cBoxChars>)
  32.  *  $ARGUMENTS$
  33.  *      nTop,nLeft,nBottom & nRight are the coordinates
  34.  *      cLabel    -   text string to be displayed *ABOVE* the box
  35.  *      lShadow   -   .T./.F. for shadowing the box
  36.  *      cDull     -   Darker colour pair
  37.  *      cBright   -   Brighter colour pair
  38.  *      cBoxChars -   Box Characters
  39.  *  $RETURNS$
  40.  *      NIL
  41.  *  $DESCRIPTION$
  42.  *      This routine was written to smarten up the screen display a bit.
  43.  *      The idea is to try and emulate "Windows" type boxes, i.e. to draw
  44.  *      them in two colours, one brighter than the other.
  45.  *  $EXAMPLES$
  46.  *
  47.  *  $SEEALSO$
  48.  *
  49.  *  $INCLUDE$
  50.  *
  51.  *  $END$
  52.  */
  53.  
  54. #include 'gt_lib.ch'
  55.  
  56. /****************************************************************************
  57.  Purpose -
  58.  Returns - None
  59.  Author  - Simon Coates
  60.  Created - 08 June 1993
  61. ******************************************************************************
  62. Parameters  - nTop       - Top of box
  63.               nLeft      - Left hand column of box
  64.               nBottom    - Bottom of box
  65.               nRight     - Right hand column (suprise, suprise)
  66.               cLabel    -  text string to be displayed *ABOVE* the box
  67.               lShadow   -  .T./.F. for shadowing the box
  68.               cDull     -  Darker colour pair
  69.               cBright   -  Brighter colour pair
  70.               cBoxChars -  Box Characters
  71. Locals      - cOldColours- Holds existing screen colours
  72.             - cTopLeft   - BoxChar
  73.             - cTopCent   -   "
  74.             - cTopRight  -   "
  75.             - cVertRight -   "
  76.             - cBotLeft   -   "
  77.             - cBotCent   -   "
  78.             - cBotRight  -   "
  79.             - cVertLeft  -   "
  80. ****************************************************************************/
  81.  
  82. FUNCTION GT_Block(nTop, nLeft, nBottom, nRight, cLabel, lShadow, cDull, cBright, cBoxChars)
  83.  
  84. Local cOldColours := SETCOLOR()
  85. Local cTopLeft    := "┌"
  86. Local cTopCent    := "─"
  87. Local cTopRight   := "┐"
  88. Local cVertRight  := "│"
  89. Local cBotLeft    := "┘"
  90. Local cBotCent    := "─"
  91. Local cBotRight   := "└"
  92. Local cVertLeft   := "│"
  93. LOCAL l           := 0
  94.  
  95. If Pcount() < 9
  96.     cBoxChars := BOX_SS     // Defined in GT_LIB.CH
  97. End If
  98.  
  99. If Pcount() < 8
  100.     cBright := "W+/W"
  101. End If
  102.  
  103. If Pcount() < 7
  104.     cDull := "N/W"
  105. End If
  106.  
  107. If Pcount() < 6
  108.     lShadow := FALSE
  109. End If
  110.  
  111. If Pcount() < 5
  112.     cLabel := ""
  113. End If
  114.  
  115. // Ok, everything's been defined (I hope), so lets get started
  116.  
  117. // Split up the character string
  118. cTopLeft    := SubStr(cBoxChars, 1, 1)
  119. cTopCent    := SubStr(cBoxChars, 2, 1)
  120. cTopRight   := SubStr(cBoxChars, 3, 1)
  121. cVertRight  := SubStr(cBoxChars, 4, 1)
  122. cBotRight   := SubStr(cBoxChars, 5, 1)
  123. cBotCent    := SubStr(cBoxChars, 6, 1)
  124. cBotLeft    := SubStr(cBoxChars, 7, 1)
  125. cVertLeft   := SubStr(cBoxChars, 8, 1)
  126.  
  127. // Draw the first bit of the box
  128. SetColor(cBright)
  129. @ nTop, nLeft CLEAR TO nBottom, nRight
  130. @ nTop, nLeft SAY cTopLeft + REPLICATE(cTopCent, nRight-nLeft)
  131.  
  132. // Draw the sides of the box
  133.  
  134. FOR l:= nTop+1 TO nBottom-1
  135.     SETCOLOR(cBright)
  136.     @ l, nLeft SAY cVertLeft
  137.     SETCOLOR(cDull)
  138.     @ l, nRight SAY cVertRight
  139. NEXT
  140.  
  141. // And draw the bottom bit as well
  142.  
  143. SETCOLOR(cBright)
  144. @ nBottom, nLeft SAY cBotLeft
  145. SETCOLOR(cDull)
  146. @ nBottom, nLeft+1 SAY REPLICATE(cBotCent, (nRight-1)-nLeft)+cBotRight
  147. @ nTop, nRight SAY cTopRight
  148.  
  149.  
  150. // If a label was passed, then display it
  151. IF Len(cLabel) > 0   // Label was passed
  152.     @ nTop-1, nLeft+1 SAY cLabel
  153. ENDIF
  154.  
  155. // Finally, draw a shadow (if required)
  156.  
  157. If lShadow
  158.     Shadow(nTop, nLeft, nBottom, nRight)
  159. End If
  160.  
  161. SETCOLOR(cOldColours)
  162.  
  163. RETURN(NIL)
  164.