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

  1. /*
  2.  * File......: ELEVBAR.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_ELEVBAR()
  24.  *  $CATEGORY$
  25.  *      Video
  26.  *  $ONELINER$
  27.  *      Output an elevator bar on screen
  28.  *  $SYNTAX$
  29.  *      GT_ElevBar( nTop , nBottom , nCol , cNorm , cCurrent , ;
  30.  *                  cColor , nCurrent , nTotal )
  31.  *  $ARGUMENTS$
  32.  *      nTop     - Top row of elevator bar
  33.  *      nBottom  - Bottom row of elevator bar
  34.  *      nCol     - Column for elevator bar
  35.  *      cNorm    - Normal bar character
  36.  *      cCurrent - Highlighted bar character
  37.  *      cColor   - Colour of elevator bar
  38.  *      nCurrent - Current value of bar position
  39.  *      nTotal   - Maximum value of bar position
  40.  *  $RETURNS$
  41.  *      NIL
  42.  *  $DESCRIPTION$
  43.  *      Draws a bar from nCol , nTop to nCol , nBottom using the character
  44.  *      cNorm, in the colour cColor.  Then draws character cCurrent at a
  45.  *      position calculated as follows :
  46.  *
  47.  *             ( ( nCurrent  )                                    )
  48.  *      nTop + ( ( --------  ) * ( ( nBottom - 1 ) - ( nTop + 1 ) )
  49.  *             ( ( nElements )                                    )
  50.  *  $EXAMPLES$
  51.  *
  52.  *  $SEEALSO$
  53.  *
  54.  *  $INCLUDE$
  55.  *      GT_LIB.CH
  56.  *  $END$
  57.  */
  58.  
  59. *
  60. #include "GT_lib.ch"
  61.  
  62. FUNCTION GT_ElevBar( nTop , nBottom , nCol , cNorm , cCurrent , nColor , nCurrent , nTotal )
  63.  
  64. /*****************************************************************************
  65.  Purpose - Draw an elevator bar at the side of a lookup/achoice/tbrowse
  66.  Returns - None
  67.  Author  - Martin Colloby
  68.  Created - 20/10/92
  69. ******************************************************************************
  70.  Parameters - nTop     - Top line of menu box
  71.               nBottom  - Bottom line of menu box
  72.               nCol     - Column for bar
  73.               cNorm    - Normal bar character ( CHR(177) )
  74.               cCurrent - Position within bar character ( CHR(219) )
  75.               nColor   - Standard color
  76.               nCurrent - Index of current element
  77.               nTotal   - Total number of elements available
  78.  Privates   - None
  79.  Locals     - None
  80.  Externals  - None
  81. *****************************************************************************/
  82.  
  83. LOCAL nCursor := SET( _SET_CURSOR , SC_NONE )
  84. LOCAL nRow    := 0
  85.  
  86. * The position of the bar pointer is calculated as follows :
  87. *        ( ( nCurrent  )                                    )
  88. * nTop + ( ( --------  ) * ( ( nBottom - 1 ) - ( nTop + 1 ) )
  89. *        ( ( nElements )                                    )
  90.  
  91. GT_ColorSet( nColor )
  92. AEVAL( Array( nBottom - nTop - 1 ) , { |e , n| SETPOS( nTop + 1 + nRow , nCol ) , ;
  93.                                                DISPOUT( cNorm ) , ;
  94.                                                nRow++ } )
  95.  
  96. * Calculate the current position of the pointer, and draw it
  97. SETPOS( nTop + 1 + ( ( nCurrent / nTotal ) * ( nBottom - nTop - 2 ) ) , nCol )
  98. DISPOUT( cCurrent )
  99.  
  100. * Reset the cursor
  101. SET( _SET_CURSOR , nCursor )
  102.  
  103. GT_ColorSet( C_NORMAL )
  104.  
  105. RETURN NIL
  106. *
  107.