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

  1. /*
  2.     winlist.c    1/20/88
  3.  
  4.     % Window list management functions
  5.     by Ted.
  6.  
  7.     Note: these functions do not explicitly protect themselves for reentrancy
  8.     because we assume they will only be called from functions which already do.
  9.  
  10.     OWL 1.1
  11.     Copyright (c) 1988, by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16.      3/10/88 Ted    rewrote for the window function/data pointer concept.
  17.                     All 'iwind's removed to higher level text-window objects
  18.      3/22/88 Ted     Installed linked windows handling.
  19.      5/02/88 Ted     Added list head window concept.
  20.      8/15/88 jmd    added arg to dwmgr_CreateWin
  21.     10/31/88 Ted:    Removed linked windows handling.
  22.      4/12/89 ted    Made ListClose unlink windows because of complications
  23.                      arising when a parent closes its children in shutting down.
  24.      8/12/89 jdc    added win_Close trickery in wmgr_ListClose
  25. */
  26.  
  27. #include "oakhead.h"
  28. #include "disppriv.h"
  29.  
  30. OSTATIC void OWLPRIV linkin(_arg3(win_type, win_type, win_type));
  31. /* -------------------------------------------------------------------------- */
  32.  
  33. win_type OWLPRIV wmgr_ListOpen()
  34. /*
  35.     Open a window list by opening a list head window.
  36. */
  37. {
  38.     winopendata_struct wod;
  39.     opbox zbox;
  40.  
  41.     zbox.xmin = zbox.xmax = zbox.ymin = zbox.ymax = 0;
  42.     wod.boxp = &zbox;
  43.     wod.font = NULL;
  44.     wod.list = NULL;
  45.  
  46.     return(win_OpenRaw(npwin_Class, &wod));
  47. }
  48. /* -------------------------------------------------------------------------- */
  49.  
  50. void OWLPRIV wmgr_ListClose(listtop)
  51.     win_type listtop;
  52. /*
  53.     Close a window list by closing all windows in it, including the list head.
  54. */
  55. {
  56.     win_type twin;
  57.  
  58.     for (twin = win_GetBelow(listtop); twin != NULL; twin = win_GetBelow(listtop)) {
  59.         win_setemployed(twin, FALSE);    /* trick win_Close */
  60.         win_Close(twin);
  61.     }
  62.     obj_Close(listtop);
  63. }
  64. /* -------------------------------------------------------------------------- */
  65.  
  66. void OWLPRIV win_ListAdd(listtop, win)
  67.     win_type listtop, win;
  68. /*
  69.     Adds 'win' to list below 'listtop'.
  70.     'win' must be unattached.
  71. */
  72. {
  73.     if (listtop == NULL) return;    /* Error */
  74.     if (win == NULL) return;        /* Error */
  75.     if (win_GetAbove(win) != NULL) return;    /* Error - 'win' must be fresh */
  76.  
  77.     linkin(listtop, win, win);
  78. }
  79. /* -------------------------------------------------------------------------- */
  80.  
  81. void OWLPRIV win_ListRemove(win)
  82.     win_type win;
  83. /*
  84.     Removes 'win' from list.
  85. */
  86. {
  87.     if (win == NULL) return;            /* Error */
  88.     if (win_GetAbove(win) == NULL) return;        /* Error - can't remove list head */
  89.  
  90.     win_GetBelow(win_GetAbove(win)) = win_GetBelow(win);
  91.     if (win_GetBelow(win) != NULL) {
  92.         win_GetAbove(win_GetBelow(win)) = win_GetAbove(win);
  93.     }
  94.     win_GetAbove(win) = NULL;
  95.     win_GetBelow(win) = NULL;
  96. }
  97. /* -------------------------------------------------------------------------- */
  98.  
  99. static void OWLPRIV linkin(listtop, topwin, botwin)
  100.     win_type listtop, topwin, botwin;
  101. /*
  102.     Link windows between and including topwin and botwin into list below listtop.
  103.     No error checking provided - for local use only.
  104. */
  105. {
  106.     win_GetAbove(topwin) = listtop;
  107.     win_GetBelow(botwin) = win_GetBelow(listtop);
  108.  
  109.     win_GetBelow(win_GetAbove(topwin)) = topwin;
  110.     if (win_GetBelow(botwin) != NULL) {
  111.         win_GetAbove(win_GetBelow(botwin)) = botwin;
  112.     }
  113. }
  114. /* -------------------------------------------------------------------------- */
  115.  
  116.