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

  1. /*
  2.  * GT CLIPPER STANDARD HEADER
  3.  *
  4.  * File......: restscr.prg
  5.  * Author....: Andy M Leighton
  6.  * BBS.......: The Dark Knight Returns
  7.  * Net/Node..: 050/069
  8.  * User Name.: Andy Leighton
  9.  * Date......: $Date$
  10.  * Revision..: $Revision$
  11.  *
  12.  * This is an original work by Andy Leighton and is placed in the
  13.  * public domain.
  14.  *
  15.  * Modification history:
  16.  * ---------------------
  17.  *
  18.  * $Log$
  19.  *
  20.  */
  21.  
  22. /*  $DOC$
  23.  *  $FUNCNAME$
  24.  *       GT_RESTSCR()
  25.  *  $CATEGORY$
  26.  *       Video
  27.  *  $ONELINER$
  28.  *       Restore a screen.
  29.  *  $SYNTAX$
  30.  *       GT_restScr(<cScr>, [<nTop>], [<nLeft>],
  31.  *                          [<nBottom>], [<nRight>]) --> lRet
  32.  *  $ARGUMENTS$
  33.  *       <cScr>      -  A string previously returned by saveScr()
  34.  *       <nTop>      -  Top line of screen area to restore
  35.  *       <nLeft>     -  Leftmost col. of screen area to restore
  36.  *       <nRight>    -  Rightmose col. of screen area to restore
  37.  *       <nBottom>   -  Bottom line of screen area to restore
  38.  *  $RETURNS$
  39.  *       lRet          - .T. if the screen is restored
  40.  *  $DESCRIPTION$
  41.  *       Restore a previously saved screen
  42.  *
  43.  *       The positioning information is optional and if it is  left
  44.  *       out the screen will restore  to the postion it was  saved.
  45.  *       If coordinates  are passed,  they must  represent an  area
  46.  *       exactly equal to that of the saved screen and in the  same
  47.  *        proportion otherwise the function will return .F.
  48.  * $SEEALSO$
  49.  *       GT_SAVESCR()
  50.  *  $EXAMPLES$
  51.  *  $END$
  52.  */
  53.  
  54. #include "gt_lib.ch"
  55.  
  56. function GT_restScr(cScr, nTop, nLeft, nBottom, nRight)
  57.  
  58.    local lRet       := TRUE
  59.    local nHorizArea
  60.    local nVertArea
  61.  
  62.    do case
  63.       case pcount() == 0                        // no parameters do nothing
  64.          lRet := FALSE
  65.       case pcount() == 1                        // restore screen to saved
  66.          nTop    := asc(substr(cScr, 1, 1))     // position
  67.          nLeft   := asc(substr(cScr, 2, 1))
  68.          nBottom := asc(substr(cScr, 3, 1))
  69.          nRight  := asc(substr(cScr, 4, 1))
  70.          restscreen(nTop, nLeft, nBottom, nRight, substr(cScr, 5))
  71.       otherwise                                 // restore to specified
  72.          default nTop    to 0                   // coordinates
  73.          default nLeft   to 0
  74.          default nBottom to maxrow()
  75.          default nRight  to maxcol()
  76.          nHorizArea := asc(substr(cScr, 4, 1)) - asc(substr(cScr, 2, 1))
  77.          nVertArea  := asc(substr(cScr, 3, 1)) - asc(substr(cScr, 1, 1))
  78.  
  79.          if (nRight - nLeft == nHorizArea) .and.            ;
  80.             (nBottom - nTop == nVertArea)
  81.             restscreen(nTop, nLeft, nBottom, nRight, substr(cScr, 5))
  82.          else
  83.             lRet := FALSE                       // specified area != size of
  84.                                                 // saved area
  85.          endif
  86.    endcase
  87.  
  88. return lRet
  89.