home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / WNOVRLAP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.3 KB  |  48 lines

  1. /**
  2. *
  3. * Name        wnovrlap -- Report whether two rectangular regions
  4. *                overlap.
  5. *
  6. * Synopsis    result = wnovrlap(pcorner1,pdim1,pcorner2,pdim2);
  7. *
  8. *        int result      1 if they overlap, 0 if not.
  9. *        LOC *pcorner1,
  10. *            *pcorner2      Pointers to structures designating
  11. *                  upper left corners of the two regions.
  12. *        DIM *pdim1,
  13. *            *pdim2      Pointers to structures designating
  14. *                  the dimensions of the two regions.
  15. *
  16. * Description    This function compares two rectangular regions (assumed
  17. *        to lie on the same display screen) and reports whether
  18. *        they overlap.
  19. *
  20. *        This function assumes that all its data is correct and
  21. *        performs no data checking.
  22. *
  23. * Returns    result          1 if they overlap, 0 if not.
  24. *
  25. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  26. *
  27. **/
  28.  
  29. #include <bwindow.h>
  30.  
  31. int wnovrlap(pcorner1,pdim1,pcorner2,pdim2)
  32. LOC *pcorner1;
  33. DIM *pdim1;
  34. LOC *pcorner2;
  35. DIM *pdim2;
  36. {
  37.  
  38. #define  bot_row1  (pcorner1->row + pdim1->h - 1)
  39. #define  bot_row2  (pcorner2->row + pdim2->h - 1)
  40. #define  rt_col1   (pcorner1->col + pdim1->w - 1)
  41. #define  rt_col2   (pcorner2->col + pdim2->w - 1)
  42.  
  43.     return (   bot_row1 >= pcorner2->row
  44.         && bot_row2 >= pcorner1->row
  45.         && rt_col1    >= pcorner2->col
  46.         && rt_col2    >= pcorner1->col);
  47. }
  48.