home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 13.56 Resizing a Box with Virtual Windowing
- Author: Greg Lief
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- //───── NOTE: must compile with the /N option!
-
- #include "box.ch"
- #include "inkey.ch"
- #define DIAMOND chr(4)
-
- /*
- Function: MOVEMENT()
- Purpose: Resize a box with the arrow keys
- */
- function Movement(noflicker)
- local t := 10, l := 10, b := 12, r := 69, x, oldscrn, key := 0
-
- //───── if no parameter passed, allow screen flicker
- noflicker := ! (noflicker == NIL)
- if noflicker
- ? "Screen flicker suppressed..."
- else
- ? "Next time you run this program, pass any parameter to avoid flicker"
- endif
- ? "Press any key to get on with it"
- inkey(0)
- setcursor(0)
- setcolor('w/b')
-
- //───── draw bogus backdrop to prove the point
- for x = 0 to maxrow()
- @ x, 0 say replicate(chr(x), maxcol() + 1)
- next
- oldscrn := savescreen(0, 0, maxrow(), maxcol())
- dispbox(t, l, b, r, DIAMOND + substr(B_SINGLE, 2) + ' ', 'n/bg')
-
- //───── first allow anchoring of top left corner
- do while key != K_ESC .and. key != K_ENTER
- key := inkey(0)
- do case
- case key == K_LEFT .and. l > 0
- l--
- case key == K_RIGHT .and. l < r + 1
- l++
- case key == K_UP .and. t > 0
- t--
- case key == K_DOWN .and. t < b - 1
- t++
- endcase
- if noflicker
- dispbegin()
- endif
- restscreen(0, 0, maxrow(), maxcol(), oldscrn)
- dispbox(t, l, b, r, DIAMOND + substr(B_SINGLE, 2) + ' ', 'n/bg')
- if noflicker
- dispend()
- endif
- enddo
- key := 0
- dispbox(t, l, b, r, substr(B_SINGLE, 1, 4) + DIAMOND + ;
- substr(B_SINGLE, 6) + ' ', 'n/bg')
-
- //───── now allow anchoring of bottom right corner
- do while key != K_ESC .and. key != K_ENTER
- key := inkey(0)
- do case
- case key == K_LEFT .and. r > l + 1
- r--
- case key == K_RIGHT .and. r < maxcol()
- r++
- case key == K_UP .and. b > t + 1
- b--
- case key == K_DOWN .and. b < maxrow()
- b++
- endcase
- if noflicker
- dispbegin()
- endif
- restscreen(0, 0, maxrow(), maxcol(), oldscrn)
- dispbox(t, l, b, r, substr(B_SINGLE, 1, 4) + DIAMOND + ;
- substr(B_SINGLE, 6) + ' ', 'n/bg')
- if noflicker
- dispend()
- endif
- enddo
- return nil
-
- // end of file CHP1356.PRG
-