home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / EXPBOX.PRG < prev    next >
Encoding:
Text File  |  1991-07-02  |  3.6 KB  |  112 lines

  1. /*
  2.     Program: EXPBOX()
  3.     System:  GRUMPFISH LIBRARY
  4.     Author:  Greg Lief w/ special thanks to Mike Clerc
  5.     Copyright (c) 1990, Grumpfish Inc.
  6.     Clipper 5.01 Version
  7.     Compile instructions: clipper explode /n/w/a
  8.  
  9.     Draws exploding box and saves array for TRUE implosion
  10.     5.0 NOTES: you need not pass an array name as a parameter!
  11.     Syntax: ExpBox(<top>, <left>, <bottom>, <right>,
  12.             [<style>, <speed>, <color>, <title>])
  13.  
  14.           Calls: Box_Title()   (Function in BOXTITLE.PRG)
  15.                  GfAttr()      (ASM Function in GRUMPATT.ASM)
  16. */
  17.  
  18. #include "grump.ch"
  19.  
  20. static boxstack_ := {}
  21.  
  22. function expbox(ntop, nleft, nbottom, nright, ntype, ndelay, mcolor, ctitle)
  23. local seed1, seed2, mtop, mleft, mbottom, mright, xx, boxstring, ;
  24.       kounter := 1, boxarray_ := {}, tbottom, tright
  25. //───── make sure coordinates are all numerics -- pretty obvious
  26. if valtype(ntop)+valtype(nleft)+valtype(nbottom)+valtype(nright) != "NNNN" ;
  27.      .or. nbottom > maxrow() .or. nright > maxcol()
  28.    return .F.
  29. endif
  30. GFSaveEnv()
  31. default ntype to 1
  32. default ndelay to 35
  33. default ctitle to ''
  34. //───── limit border # to 6 to avoid array crash
  35. boxstring := BOXFRAMES[if(ntype > 6, 1, ntype)]
  36. seed1 := int((nbottom - ntop) / 2)
  37. seed2 := int((nright - nleft) / 2)
  38. mtop := mbottom := ntop + seed1
  39. mleft := mright := nleft + seed2
  40. kounter := 1
  41. //───── establish TBOTTOM and TRIGHT, to ensure that savescreen() does not
  42. //───── go beyond the maxrow() and maxcol() limits
  43. tbottom := min(nbottom + 2, maxrow())
  44. tright  := min(nright + 2, maxcol())
  45. aadd(boxarray_, { ntop, nleft, tbottom, tright } )
  46. aadd(boxarray_, savescreen(ntop, nleft, tbottom, tright) )
  47. if ndelay > 1
  48.    do while (mtop > ntop .and. mleft > nleft) .and. ;
  49.             (mbottom < nbottom .and. mright < nright)
  50.       @ mtop, mleft, mbottom, mright box boxstring color mcolor
  51.       aadd(boxarray_, savescreen(ntop, nleft, tbottom, tright))
  52.       for xx = 1 to ndelay
  53.       next
  54.       mtop--
  55.       mleft -= (seed2 / seed1)
  56.       mbottom++
  57.       mright += (seed2 / seed1)
  58.    enddo
  59. endif
  60. //───── draw shadow if coordinates are valid
  61. if nbottom < maxrow() .and. nright < maxcol() - 1
  62.    gfattr(ntop + 1, nright + 1, nbottom + 1, nright + 2, 8)
  63.    gfattr(nbottom + 1, nleft + 2, nbottom + 1, nright + 2, 8)
  64. endif
  65. @ ntop, nleft, nbottom, nright box boxstring color mcolor
  66. //───── draw title if requested
  67. if len(ctitle) > 0
  68.    box_title(ntop, nleft, nright, ctitle, boxstring, , mcolor)
  69. endif
  70. GFRestEnv()
  71. //───── add this array of saved screens to the window stack
  72. aadd(boxstack_, boxarray_)
  73. return len(boxstack_)
  74.  
  75. * end function ExpBox()
  76. *--------------------------------------------------------------------*
  77.  
  78.  
  79. /*
  80.    Program: IMPBOX()
  81.    System: GRUMPFISH LIBRARY
  82.    Author: Greg Lief w/ thanks to Mike Clerc
  83.    Copyright (c) 1990, Grumpfish Inc.
  84.    Implodes a previously-exploded box
  85.    Syntax: ImpBox([<speed>])
  86. */
  87.  
  88. #define TOP    boxarray_[1, 1]
  89. #define LEFT   boxarray_[1, 2]
  90. #define BOTTOM boxarray_[1, 3]
  91. #define RIGHT  boxarray_[1, 4]
  92.  
  93. function impbox(ndelay)
  94. local xx, yy, boxarray_
  95. if len(boxstack_) > 0   // preclude crash on empty array
  96.    boxarray_ := atail(boxstack_)
  97.    default ndelay to 35
  98.    for xx = len(boxarray_) to 2 step -1
  99.       restscreen(TOP, LEFT, BOTTOM, RIGHT, boxarray_[xx])
  100.       for yy = 1 to ndelay
  101.       next
  102.    next
  103.    //───── decrease the size of the window stack by one element
  104.    truncate(boxstack_)
  105. endif
  106. return NIL
  107.  
  108. * end function ImpBox()
  109. *--------------------------------------------------------------------*
  110.  
  111. * eof explode.prg
  112.