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

  1. /*
  2.  * File......: GTCURS.PRG
  3.  * Author....: Philip Ide
  4.  * BBS.......: Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Philip Ide
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Philip Ide and is placed in the
  12.  * public domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_PUSHCUR()
  24.  *  $CATEGORY$
  25.  *      Environment
  26.  *  $ONELINER$
  27.  *      Place cursor state on the stack, optionaly change state
  28.  *  $SYNTAX$
  29.  *      GT_PUSHCUR([<nNewState>]) -> <nOldState>
  30.  *  $ARGUMENTS$
  31.  *      <nNewState> is a numeric constant which identifies the new cursor
  32.  *                  state.  Manifest constants from setcurs.ch are
  33.  *                  recommended.
  34.  *  $RETURNS$
  35.  *      <nOldState> is the state of the cursor before any changes are
  36.  *      applied.
  37.  *  $DESCRIPTION$
  38.  *      This function pushes the current cursor state onto a stack, and then
  39.  *      optionaly changes the state.  To restore the cursor is simply a
  40.  *      matter of 'popping' the stack by calling GT_POPCUR().
  41.  *
  42.  *      It is important to pop the stack as many times as you push it,
  43.  *      otherwise you may get the wrong cursor shape back.
  44.  *  $EXAMPLES$
  45.  *      GT_PUSHCUR(SC_NONE)   // push cursor and turn it off
  46.  *        ..code..            // do something, maybe display a message
  47.  *        ...
  48.  *      GT_POPCUR()           // restore cursor
  49.  *  $SEEALSO$
  50.  *      GT_POPCUR()
  51.  *  $INCLUDE$
  52.  *      SETCURS.CH  GT_LIB.CH
  53.  *  $END$
  54.  */
  55. /*  $DOC$
  56.  *  $FUNCNAME$
  57.  *      GT_POPCUR()
  58.  *  $CATEGORY$
  59.  *      Environment
  60.  *  $ONELINER$
  61.  *      Pop cursor state from the stack.
  62.  *  $SYNTAX$
  63.  *      GT_POPCUR() -> <nOldState>
  64.  *  $ARGUMENTS$
  65.  *  $RETURNS$
  66.  *      <nOldState> is the state of the cursor before any changes are
  67.  *      applied.
  68.  *  $DESCRIPTION$
  69.  *      This function pops the current cursor state off a stack, having
  70.  *      previously been placed there by calling GT_PUSHCUR().
  71.  *
  72.  *      This is used to restore the cursor shape after a temporary change.
  73.  *
  74.  *      It is important to pop the stack as many times as you push it,
  75.  *      otherwise you may get the wrong cursor shape back.
  76.  *  $EXAMPLES$
  77.  *      GT_PUSHCUR(SC_NONE)   // push cursor and turn it off
  78.  *        ..code..            // do something, maybe display a message
  79.  *        ...
  80.  *      GT_POPCUR()           // restore cursor
  81.  *  $SEEALSO$
  82.  *      GT_PUSHCUR()
  83.  *  $INCLUDE$
  84.  *      SETCURS.CH  GT_LIB.CH
  85.  *  $END$
  86.  */
  87.  
  88. #include "gt_lib.ch"
  89.  
  90. STATIC aCursor
  91.  
  92. /***
  93. *
  94. */
  95. FUNCTION GT_PUSHCUR(nNewState)      // save cursor state
  96.          LOCAL nOldState
  97.  
  98.          DEFAULT aCursor TO {}      // initialise static array (stack)
  99.  
  100.          nOldState := SetCursor(nNewState)
  101.          AADD(aCursor,nOldState)
  102.          Return (aCursor[Len(aCursor)])
  103.  
  104. /***
  105. *
  106. */
  107. FUNCTION GT_POPCUR()                // restore cursor shape
  108.          LOCAL nOldState, nNewState
  109.  
  110.          DEFAULT aCursor TO {}      // initialise static array (stack)
  111.  
  112.          IF Len(aCursor) > 0
  113.             nNewState := aCursor[Len(aCursor)]
  114.             aCursor := ASize(aCursor,Len(aCursor)-1)
  115.          End
  116.  
  117.          Return(nOldState := SetCursor(nNewState))
  118.  
  119.  
  120.