home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP13.EXE / CHP1356.PRG < prev    next >
Encoding:
Text File  |  1991-06-12  |  2.5 KB  |  95 lines

  1. /*
  2.    Listing 13.56 Resizing a Box with Virtual Windowing
  3.    Author: Greg Lief
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. #include "box.ch"
  14. #include "inkey.ch"
  15. #define DIAMOND  chr(4)
  16.  
  17. /*
  18.      Function: MOVEMENT()
  19.      Purpose:  Resize a box with the arrow keys
  20. */
  21. function Movement(noflicker)
  22. local t := 10, l := 10, b := 12, r := 69, x, oldscrn, key := 0
  23.  
  24. //───── if no parameter passed, allow screen flicker
  25. noflicker := ! (noflicker == NIL)
  26. if noflicker
  27.    ? "Screen flicker suppressed..."
  28. else
  29.    ? "Next time you run this program, pass any parameter to avoid flicker"
  30. endif
  31. ? "Press any key to get on with it"
  32. inkey(0)
  33. setcursor(0)
  34. setcolor('w/b')
  35.  
  36. //───── draw bogus backdrop to prove the point
  37. for x = 0 to maxrow()
  38.    @ x, 0 say replicate(chr(x), maxcol() + 1)
  39. next
  40. oldscrn := savescreen(0, 0, maxrow(), maxcol())
  41. dispbox(t, l, b, r, DIAMOND + substr(B_SINGLE, 2) + ' ', 'n/bg')
  42.  
  43. //───── first allow anchoring of top left corner
  44. do while key != K_ESC .and. key != K_ENTER
  45.    key := inkey(0)
  46.    do case
  47.       case key == K_LEFT .and. l > 0
  48.          l--
  49.       case key == K_RIGHT .and. l < r + 1
  50.          l++
  51.       case key == K_UP .and. t > 0
  52.          t--
  53.       case key == K_DOWN .and. t < b - 1
  54.          t++
  55.    endcase
  56.    if noflicker
  57.       dispbegin()
  58.    endif
  59.    restscreen(0, 0, maxrow(), maxcol(), oldscrn)
  60.    dispbox(t, l, b, r, DIAMOND + substr(B_SINGLE, 2) + ' ', 'n/bg')
  61.    if noflicker
  62.       dispend()
  63.    endif
  64. enddo
  65. key := 0
  66. dispbox(t, l, b, r, substr(B_SINGLE, 1, 4) + DIAMOND + ;
  67.                     substr(B_SINGLE, 6) + ' ', 'n/bg')
  68.  
  69. //───── now allow anchoring of bottom right corner
  70. do while key != K_ESC .and. key != K_ENTER
  71.    key := inkey(0)
  72.    do case
  73.       case key == K_LEFT .and. r > l + 1
  74.          r--
  75.       case key == K_RIGHT .and. r < maxcol()
  76.          r++
  77.       case key == K_UP .and. b > t + 1
  78.          b--
  79.       case key == K_DOWN .and. b < maxrow()
  80.          b++
  81.    endcase
  82.    if noflicker
  83.       dispbegin()
  84.    endif
  85.    restscreen(0, 0, maxrow(), maxcol(), oldscrn)
  86.    dispbox(t, l, b, r, substr(B_SINGLE, 1, 4) + DIAMOND + ;
  87.                        substr(B_SINGLE, 6) + ' ', 'n/bg')
  88.    if noflicker
  89.       dispend()
  90.    endif
  91. enddo
  92. return nil
  93.  
  94. // end of file CHP1356.PRG
  95.