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

  1. /*
  2.     wintop.c    3/15/88
  3.  
  4.     % win_Top
  5.  
  6.     by Ted.
  7.     Extracted from winsetp.c
  8.  
  9.     OWL 1.1
  10.     Copyright (c) 1988, by Oakland Group, Inc.
  11.     ALL RIGHTS RESERVED.
  12.  
  13.     Revision History:
  14.     -----------------
  15.     10/31/88 Ted:    Removed linking.
  16.     12/08/88 ted:    Added ddisp_Cache/Flush calls for mouse.
  17.     12/11/88 ted:    Added dhard_Claim/Release calls for reentrancy.
  18.     12/11/88 ted:    moved win_IsAbove here from winlist.c because only
  19.                     win_PutUnder calls it right now.
  20.     03/09/89 ted:    fixed bug where PutUnder didn't repaint in goingdown case.
  21.      5/01/89 ted    Added wmgr_SetNewCurrentFlag call to fix mouse support.
  22.      5/01/89 ted    Merged in win_Employ, UnEmploy, got rid of winempl.c
  23.      7/07/89 gam    Changed NULL to FNULL where necessary
  24.      8/08/89 jmd    combined win_Top and win_PutUnder into win_ReallyPutUnder
  25.                     switched order of args to PutUnder
  26.      8/10/89 ted    added allowances for shadows.
  27.      8/13/89 jmd    removed GETEXPLODE message
  28. */
  29.  
  30. #include "oakhead.h"
  31. #include "disppriv.h"
  32.  
  33. /* -------------------------------------------------------------------------- */
  34.  
  35. boolean win_ReallyPutUnder(win, destwin)
  36.     win_type win;
  37.     win_type destwin;
  38. /*
  39.     Removes win from the list it is in and inserts it below destwin in
  40.     destwin's list. Thus, if destwin is unemployed, the effect is to retire
  41.     win if it is employed. Likewise, if destwin is employed the effect is to
  42.     employ win if it is unemployed. The display is updated to reflect the new
  43.     position of win.
  44.  
  45.     if destwin is NULL, put the window on top.
  46. */
  47. {
  48.     boolean obscured, goingdown;
  49.     win_type oldunder;
  50.     opbox winbox, wshbox;
  51.  
  52.     if (win == NULL) {
  53.         return(FALSE);
  54.     }
  55.  
  56.     if (destwin == NULL) {
  57.         /* put the window on top */
  58.         if (win_IsEmployed(win)) {
  59.             destwin = wmgr_botsyswin();
  60.         }
  61.         else {    /* move window(s) to top of unemployed list (why not?) */
  62.             destwin = wmgr_unemployedhead();
  63.         }
  64.     }
  65.  
  66.     hard_Claim();            /* Here for re-entrancy protection */
  67.  
  68.     if (win == destwin || win == win_GetBelow(destwin)) {
  69.         hard_Release();
  70.         return(TRUE);        /* Quit if already there */
  71.     }
  72.  
  73.     /* If target is in unemployed list, take care of it */
  74.     if (!win_IsEmployed(destwin)) {
  75.  
  76.         if (win_IsEmployed(win)) {
  77.             win_UnEmploy(win);
  78.         }
  79.         win_ListRemove(win);
  80.         win_ListAdd(destwin, win);
  81.  
  82.         hard_Release();
  83.         return(TRUE);
  84.     }
  85.  
  86.     /* else: Target is in employed list */
  87.     disp_Cache();
  88.  
  89.     /* Save portions that need to be saved and then remove window from list */
  90.     if (win_IsEmployed(win)) {
  91.         goingdown = win_IsAbove(win, destwin);
  92.     }
  93.     else {    /* win is unemployed */
  94.         /* Note: if win is not in the employed list, it will work like NULL */
  95.         /* for IsObscuredPixBox and SavePixLayer. */
  96.         goingdown = FALSE;
  97.     }
  98.  
  99.     /* Find out whether window is obscured and save places it will soon obscure */
  100.     win_getshadowbox(win, &wshbox);
  101.     obscured = (wmgr_IsObscuredPixBox(destwin, win, &wshbox, TRUE) != NULL);
  102.  
  103.     if (!goingdown) {
  104.     /* Save from wins that were obscuring and will be obscured where win's going */
  105.         if (obscured) {
  106.             wmgr_SavePixLayer(win_GetBelow(destwin), win, &wshbox);
  107.         }
  108.     }
  109.     else {    /* if going down */
  110.         /* Save from window only if its insides will be obscured */
  111.         win_getwinbox(win, &winbox);
  112.         if (wmgr_IsObscuredPixBox(win, win_GetBelow(destwin), &winbox, TRUE) != NULL) {
  113.             oldunder = win_GetBelow(win);
  114.             wmgr_SavePixBox(win, &winbox);
  115.         }
  116.     }
  117.  
  118.     /* Update bot_employed pointer if neccesary */
  119.     if (curr_wmgr->bot_employed_win == win) {
  120.         curr_wmgr->bot_employed_win = win_GetAbove(win);
  121.     }
  122.     /* Link window into employed list below destwin */
  123.     win_ListRemove(win);
  124.     win_ListAdd(destwin, win);
  125.  
  126.     /* Update bot_employed pointer if neccesary */
  127.     if (win_GetBelow(win) == NULL) {
  128.         curr_wmgr->bot_employed_win = win;
  129.     }
  130.  
  131.     /* Paint the explode visuals if win is becoming employed */
  132.     if (!win_IsEmployed(win) ) {
  133.         win_setemployed(win, TRUE);    /* Just in case it wasn't already */
  134.  
  135.         if (win_GetExplodeFptr(win) != FNULL) {
  136.             win_Expose(win, WINM_EXPLODE, NULL);
  137.         }
  138.         obscured = TRUE;    /* Force paint for win becoming employed */
  139.      }
  140.  
  141.     /* Paint portions that need to be painted */
  142.     if (obscured) {
  143.         if (!goingdown) {
  144.             wmgr_PaintPixBox(win, &wshbox);
  145.         }
  146.         else {    /* if going down */
  147.             wmgr_PaintPixLayer(oldunder, win, &wshbox);
  148.         }
  149.     }
  150.     /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
  151.     if (wmgr_SMMptr() != FNULL) {
  152.         wmgr_SetNewCurrentFlag(TRUE);
  153.     }
  154.     disp_Flush();
  155.     hard_Release();
  156.     return(TRUE);
  157. }
  158. /* -------------------------------------------------------------------------- */
  159.  
  160. boolean win_ReallyUnEmploy(win)
  161.     win_type win;
  162. /*
  163.     Called by win object in response to WINM_UNEMPLOY message.
  164.     Unemploy a window.
  165.     Remove it from the display.
  166.     Refresh Display
  167. */
  168. {
  169.     win_type newtop;
  170.     opbox pbox;
  171.  
  172.     if (win == NULL) {
  173.         return(FALSE);
  174.     }
  175.     hard_Claim();        /* Here for re-entrancy protection */
  176.  
  177.     if (!win_IsEmployed(win)) {        /* window already retired */
  178.         hard_Release();
  179.         return(TRUE);
  180.     }
  181.     disp_Cache();
  182.  
  183.     /* Remember window's below-window, which will be where we repaint from */
  184.     newtop = win_GetBelow(win);
  185.  
  186.     /* Save contents of win before it goes away */
  187.     win_getwinbox(win, &pbox);
  188.     wmgr_SavePixBox(win, &pbox);
  189.  
  190.     /* Remove window from employed list */
  191.     if (curr_wmgr->bot_employed_win == win) {
  192.         curr_wmgr->bot_employed_win = win_GetAbove(win);
  193.     }
  194.  
  195.     /* Update bot_employed pointer if neccesary */
  196.     if (win_GetBelow(win) == NULL) {
  197.         curr_wmgr->bot_employed_win = win_GetAbove(win);
  198.     }
  199.     win_ListRemove(win);
  200.  
  201.     win_setemployed(win, FALSE);
  202.  
  203.     /* Link window into top of unemployed list */
  204.     win_ListAdd(curr_wmgr->unemployedhead, win);        /* win becomes new top */
  205.  
  206.     /* Restore in box from windows below where win was */
  207.     win_getshadowbox(win, &pbox);
  208.     wmgr_PaintPixBox(newtop, &pbox);
  209.  
  210.     /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
  211.     if (wmgr_SMMptr() != FNULL) {
  212.         wmgr_SetNewCurrentFlag(TRUE);
  213.     }
  214.  
  215.     disp_Flush();
  216.     hard_Release();
  217.     return(TRUE);
  218. }
  219. /* -------------------------------------------------------------------------- */
  220.  
  221. boolean win_IsAbove(winabove, win)
  222.     win_type winabove;
  223.     win_type win;
  224. /*
  225.     Returns TRUE if win is found below winabove in winabove's window list.
  226. */
  227. {
  228.     if (winabove == NULL || win == NULL || win == winabove) {
  229.         return(FALSE);
  230.     }
  231.  
  232.     hard_Claim();        /* Here for re-entrancy protection */
  233.  
  234.     for (;;) {
  235.         winabove = win_GetBelow(winabove);
  236.         if (winabove == NULL) {
  237.             hard_Release();
  238.             return(FALSE);
  239.         }
  240.         if (winabove == win) {
  241.             hard_Release();
  242.             return(TRUE);
  243.         }
  244.     }
  245. }
  246. /* -------------------------------------------------------------------------- */
  247.  
  248.