home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / WINOBSC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.7 KB  |  141 lines

  1. /*
  2.     winobsc.c    10/14/88
  3.  
  4.     % Window routines for determining who is obscuring who.
  5.     by Ted.
  6.  
  7.     OWL 1.1
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.     12/09/88 ted:    Added ddisp_Cache/Flush calls for mouse.
  14.     12/11/88 ted:    Added dhard_Claim/Release calls for reentrancy.
  15.      3/31/89 ted:    Added wmgr_PointWin.
  16.      4/25/89 ted    Added wmgr_FindBelow. Added check for employed in IsObscured.
  17.      5/11/89 ted    Added win parent clip check.
  18.      8/30/89 ted    Added shadow support to IsObscured and ParentClip.
  19. */
  20.  
  21. #include "oakhead.h"
  22. #include "disppriv.h"
  23.  
  24. /* -------------------------------------------------------------------------- */
  25.     
  26. win_type wmgr_IsObscuredPixBox(topwin, win, boxp, doshad)
  27.     win_type topwin;
  28.     win_type win;
  29.     opbox *boxp;            /* box within which to do the exposure */
  30.     boolean doshad;
  31. /*
  32.     Determines if the given box is covered by an employed window below topwin
  33.     and above win. If win is NULL, all windows below topwin are checked.
  34.     Returns uppermost obscuring window, or NULL if box is unobscured.
  35.     If 'doshad' is TRUE, returns uppermost window whose self or shadow
  36.     obscures the box.
  37. */
  38. {
  39.     opbox tbox;
  40.  
  41.     if (topwin != NULL) {
  42.         hard_Claim();            /* Here for re-entrancy protection */
  43.  
  44.         if (win_IsEmployed(topwin)) {
  45.             for(;;) {
  46.                 topwin = win_GetBelow(topwin);
  47.                 if (topwin == NULL || topwin == win) {
  48.                     break;
  49.                 }
  50.                 if (win_IsEmployed(topwin)) {
  51.                     if (win_ParentClip(topwin, &tbox, doshad)) {
  52.                         if(opbox_clipbox(boxp, &tbox)) {
  53.                         /* windows overlap */
  54.                             hard_Release();
  55.                             return(topwin);
  56.                         }
  57.                     }
  58.                 }
  59.             }
  60.         }
  61.         hard_Release();
  62.     }
  63.     return(NULL);
  64. }
  65. /* -------------------------------------------------------------------------- */
  66.  
  67. unsigned OWLPRIV win_ParentClip(win, boxp, doshad)
  68.     win_type win;
  69.     opbox *boxp;
  70.     boolean doshad;
  71. /*
  72.     Fills the passed boxp with the coordinates of the given window's outer box
  73.     (plus the window's shadow if 'doshad' is TRUE),
  74.     clipped by the inner boxes of all the window's parent windows.
  75.     Return Sutherland clip code for box clipped: 0 if box is completely
  76.     clipped out; otherwise bits saying which side(s) it was clipped on:
  77.     1, 2, 4, 8 for right, top, left, bottom; 16 for coming through at all.
  78. */
  79. {
  80.     unsigned scode, rcode;
  81.     win_type parent;
  82.     opbox winbox;
  83.  
  84.     opbox_copy(boxp, win_pixboxp(win));
  85.     if (doshad) {
  86.         boxp->xmax += win_GetShadowX(win);
  87.         boxp->ymax += win_GetShadowY(win);
  88.     }
  89.     rcode = 16;
  90.     for (;;) {
  91.         parent = win_GetParent(win);
  92.         if (parent == NULL || !win_IsParentClip(win)) {
  93.             return(rcode);
  94.         }
  95.         win_getwinbox(parent, &winbox);
  96.         if ((scode = opbox_clipbox(&winbox, boxp)) == 0) {
  97.             return(0);
  98.         }
  99.         rcode |= scode;
  100.         win = parent;
  101.     }    
  102. }
  103. /* -------------------------------------------------------------------------- */
  104.  
  105. win_type wmgr_PointWin(x, y)
  106.     opcoord x;
  107.     opcoord y;
  108. /*
  109.     Return the first employed window lying below the given point.
  110. */
  111. {
  112.     opbox cursbox;
  113.  
  114.     /* Find which window the mouse point falls in */
  115.     cursbox.xmin = x; cursbox.xmax = cursbox.xmin + 1;
  116.     cursbox.ymin = y; cursbox.ymax = cursbox.ymin + 1;
  117.  
  118.     return(wmgr_IsObscuredPixBox(curr_wmgr->employedhead, NULL, &cursbox, FALSE));
  119. }
  120. /* -------------------------------------------------------------------------- */
  121.  
  122. win_type wmgr_FindBelow(win)
  123.     win_type win;
  124. /*
  125.     Return the first employed window lying below the upper left corner of the
  126.     given window.
  127. */
  128. {
  129.     win_type bwin;
  130.  
  131.     if (win_IsEmployed(win)) {
  132.         win_setemployed(win, FALSE);
  133.         bwin = wmgr_PointWin(win_GetXmin(win), win_GetYmin(win));
  134.         win_setemployed(win, TRUE);
  135.         return(bwin);
  136.     }
  137.     else return(NULL);
  138. }
  139. /* -------------------------------------------------------------------------- */
  140.  
  141.