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

  1. /*
  2.  * File......: GTCLOCK.PRG
  3.  * Author....: Brian Dukes
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Brian Dukes
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Brian Dukes and is placed in the public
  12.  * domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_CLOCK()
  24.  *  $CATEGORY$
  25.  *      Screen Saver
  26.  *  $ONELINER$
  27.  *      Use a BIG Clock as a screen saver
  28.  *  $SYNTAX$
  29.  *      GT_Clock([<nDelay>],[<cColor>],[<lCLS>],[<nTop>],[<nLeft>], ;
  30.  *               [<nXMove>],[<nYMove>]) --> NIL
  31.  *  $ARGUMENTS$
  32.  *      <nDelay> is an optional numeric parameter that is the delay to
  33.  *      use when updating the display. This is in 1/18ths of a second.
  34.  *      If not supplied this parameter defaults to 1.
  35.  *
  36.  *      <cColor> is an optional colour string.  If not supplied this
  37.  *      defaults to "G+/N"  (Bright Green on Black)
  38.  *
  39.  *      <lCLS> is an optional logical parameter that instructs the saver
  40.  *      to clear the screen first, if the value is .T. then the screen is
  41.  *      cleared, if .F. then the clock will be displayed over the current
  42.  *      screen contents.  This defaults to .T.
  43.  *
  44.  *      <nTop> is an optional numeric parameter that tells the save where
  45.  *      to start displaying the clock.  (Top Line)
  46.  *
  47.  *      <nLeft> is an optional numeric parameter that tells the saver where
  48.  *      to start displaying the clock.  (1st Column)
  49.  *
  50.  *      <nXMove> is an optional numeric parameter that tells the saver how
  51.  *      many columns to move on each increment.  If this is set to 0, and
  52.  *      nYMove is set to 1, the clock will just bounce up and down. This
  53.  *      defaults to 1.
  54.  *
  55.  *      <nYMove> is an optional numeric parameter that tells the saver how
  56.  *      many lines to move on each increment.  If this is set to 0, and
  57.  *      nXmove is set to 1, the clock will just bounce right to left. This
  58.  *      defaults to 1.
  59.  *
  60.  *
  61.  *  $RETURNS$
  62.  *      Nothing.
  63.  *
  64.  *  $DESCRIPTION$
  65.  *      GT_Clock() is a screen saver function.  It has the ability of being
  66.  *      altered a great deal by the passed parameters.  The screen saver
  67.  *      will terminate if a GT_Interrupt() codeblock has been sets up and
  68.  *      evaluates TRUE; or if a default codeblock of any key pressed becomes
  69.  *      true.
  70.  *
  71.  *      This function calls GT_BigTime()   to display the clock
  72.  *                          GT_Interrupt() to interrogate completion
  73.  *                          GT_SaveScr()   to save the screen
  74.  *                          GT_RestScr()   to restore the screen
  75.  *
  76.  *  $EXAMPLES$
  77.  *      // Call the screen saver with a delay of 1 second, displaying the
  78.  *      // clock over the current screen.  The Clock will be displayed at
  79.  *      // line 10, and will bounce from right to left.
  80.  *
  81.  *      GT_Clock(1,,.f.,10,,1,0)
  82.  *  $END$
  83.  */
  84.  
  85. #include "gt_lib.ch"
  86.  
  87. function GT_Clock(nDelay,cColor,lCLS,nTop,nLeft,nXMove,nYMove)
  88.    local cScrCap    := ""                ,;
  89.          nBottom    := 3                 ,;
  90.          nRight     := 31                ,;
  91.          nTimeout   := 0                 ,;
  92.          hOldScreen := GT_SaveScr()      ,;
  93.          nOldCursor := setcursor(SC_NONE),;
  94.          cOldColour := setcolor("w/n")   ,;
  95.          bQuit      := GT_Interrupt()
  96.  
  97.    default cColor to "G+/N"
  98.    default lCLS   to .t.
  99.    default nDelay to 1
  100.    default bQuit  to {|| inkey() != 0 }
  101.    default nTop   to 0
  102.    default nLeft  to 0
  103.    default nXMove to 1
  104.    default nYMove to 1
  105.  
  106.    nBottom := nTop + 3        // Four lines deep
  107.    nRight  := nLeft + 31      // 32 Chars wide (HH:MM:SS * 4chars)
  108.  
  109.  
  110.    if lCLS
  111.       clear screen
  112.    endif
  113.  
  114.    do while !eval(bQuit)
  115.       nTimeOut := seconds()
  116.       cScrCap := GT_SaveScr(nTop,nLeft,nBottom,nRight)
  117.       GT_BigTime(nTop,nLeft,cColor)
  118.  
  119.       if nXMove == 1
  120.          nXMove := if(nRight == maxcol(),-1,nXMove)
  121.       else
  122.          nXMove := if(nLeft == 0,1,nXMove)
  123.       endif
  124.       if nYMove == 1
  125.          nYMove := if(nBottom == maxrow(),-1,nYMove)
  126.       else
  127.          nYMove := if(nTop == 0,1,nYMove)
  128.       endif
  129.       nTop    += nYMove
  130.       nLeft   += nXMove
  131.       nBottom += nYMove
  132.       nRight  += nXMove
  133.  
  134.       do while Seconds() - nTimeOut < nDelay ; enddo    // DELAY
  135.       GT_RestScr(cScrCap)
  136.    enddo
  137.  
  138.    setcolor(cOldColour)
  139.    GT_RestScr(hOldScreen)
  140.    setcursor(nOldCursor)
  141.  
  142. return NIL
  143.