home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / EXBOX.PRG < prev    next >
Encoding:
Text File  |  1991-04-23  |  2.8 KB  |  86 lines

  1. /*
  2.    Program: EXBOX()
  3.    System: GRUMPFISH LIBRARY
  4.    Author: Greg Lief
  5.    Copyright (c) 1988-90, Greg Lief
  6.    Clipper 5.x version
  7.    Compile instructions: clipper exbox /n/w/a
  8.    Draws exploding box
  9.    Calls: BOX_TITLE()      (Function in FBOXTIT.PRG)
  10. */
  11.  
  12. //───── begin preprocessor directives
  13.  
  14. #include "grump.ch"
  15.  
  16. //───── end preprocessor directives
  17.  
  18. function exbox(ntop, nleft, nbottom, nright, ntype, ndelay, cfill, ;
  19.                lshadow, ctitle, lcrossbar)
  20. local medver, medhor, dom, x, y, ttop, tbottom, tleft, tright, ret_val, ;
  21.       boxstring
  22. //───── establish defaults if not passed
  23. default cfill to chr(32)
  24. default lshadow to .f.
  25. default ctitle to []
  26. ntype :=  if(ntype > 6, 1, ntype)  /* limit border to 6 to avoid array crash */
  27. lcrossbar := (pcount() > 9)
  28. //───── if they passed a null string for the fill character, make it a space
  29. cfill := if(len(cfill) == 0, chr(32), cfill)
  30.  
  31. //───── construct array containing coordinates & contents of screen
  32. //───── area underneath this box - this can be used with byebyebox()
  33. ret_val := { ntop, nleft, nbottom + if(lshadow, 1, 0), ;
  34.              nright + if(lshadow, 2, 0), savescreen(ntop, nleft, ;
  35.              nbottom + if(lshadow, 1, 0), nright + if(lshadow, 2, 0)) }
  36. boxstring := substr(BOXFRAMES[ntype], 1, 8) + cfill + ;
  37.              substr(BOXFRAMES[ntype], 10, 4)
  38. if iscolor() .and. ndelay > 0         && color monitor for full effect
  39.    medver := int(((nbottom - ntop) + 1) / 2)   && determine vertical median
  40.    medhor := int(((nright - nleft) + 1) / 2)   && determine horizontal median
  41.    dom := max(medver, medhor)
  42.    //───── determine dynamic box coordinates
  43.    ttop := ntop + medver
  44.    tbottom := nbottom - medver
  45.    tleft := nleft + medhor
  46.    tright := nright - medhor
  47.  
  48.    //───── main loop -- draw box out from center
  49.    for x = 1 to dom
  50.       @ ttop, tleft, tbottom, tright box boxstring
  51.       for y = 1 to ndelay              && slow down explosion as desired
  52.       next
  53.  
  54.       //───── test for border and expand if required
  55.       if x < medver
  56.          ttop--
  57.          tbottom++
  58.       endif
  59.       if x < medhor
  60.          tleft--
  61.          tright++
  62.       endif
  63.    next
  64. endif
  65.  
  66. //───── draw shadow if called for and coordinates are valid
  67. if lshadow .and. iscolor() .and. nbottom < maxrow() .and. nright < maxcol()-1
  68.    gfattr(ntop + 1, nright + 1, nbottom + 1, nright + 2, 8)
  69.    gfattr(min(nbottom + 1, maxrow()-1), nleft + 2, nbottom + 1, nright + 2, 8)
  70. endif
  71.  
  72. //───── draw outer box border
  73. @ ntop, nleft, nbottom, nright box boxstring
  74.  
  75. //───── draw title if requested
  76. if len(ctitle) > 0
  77.    box_title(ntop, nleft, nright, ctitle, boxstring, lcrossbar)
  78. endif
  79.  
  80. return (ret_val)
  81.  
  82. * end function ExBox()
  83. *--------------------------------------------------------------------*
  84.  
  85. * eof exbox.prg
  86.