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

  1. /*
  2.     winexpos.c    3/9/88
  3.  
  4.     % window exposure routines.
  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.      8/17/88 jmd      removed  eNOMEM
  14.      9/12/88 jmd    Added in and out data to objects
  15.     10/14/88 ted    Moved wmgr_IsObscuredPixBox out to winobsc.c
  16.     12/09/88 ted    Added ddisp_Cache/Flush calls for mouse.
  17.     12/11/88 ted    Added dhard_Claim/Release calls for reentrancy.
  18.      3/15/89 ted    Removed dmgr/wmgr args - now we use global structure.
  19.      6/23/89 jmd    Added background window shadow support
  20.      8/10/89 ted    Added shadow tiling.
  21.      9/01/89 jmd    Changed kid enum to int
  22. */
  23.  
  24. #include "oakhead.h"
  25. #include "disppriv.h"
  26. #include "vadecl.h"
  27.  
  28. #define xDEBUG
  29. #ifdef DEBUG
  30.     static int diddle = -1;
  31. #endif
  32. #define xDEBUG2
  33. #ifdef DEBUG2
  34.     static boolean diddle2 = TRUE;
  35. #endif
  36. /* -------------------------------------------------------------------------- */
  37.  
  38. /* ID's for the various subtiles ("kids") a tile is broken into. */
  39. /* Note: These values MUST match the diagram below */
  40.  
  41. #define TOPBAR        0
  42. #define LEFTBOX        1
  43. #define TOPNIB        2    /* Only in shadow case */
  44. #define XSHADOW        3    /* Only in shadow case */
  45. #define RTBOX        4
  46. #define BOTNIB        5    /* Only in shadow case */
  47. #define YSHADOW        6    /* Only in shadow case */
  48. #define BOTBAR        7
  49. #define ALLDONE        8
  50.  
  51. #define FIRSTKID    TOPBAR
  52.  
  53. /* This is an illustration of how a tile is split into sub-tiles around
  54.     a window found underneath it:
  55.  
  56.     0000000000000
  57.     1111WWWW22222
  58.     1111WWWW34444
  59.     1111WWWW34444
  60.     1111WWWW34444
  61.     5555566664444
  62.     7777777777777
  63. */
  64. typedef struct tile_struct {
  65.     win_type win;
  66.     int     inlayer;        /* flag for inlayer win in employed stack */
  67.     int        emsg;            /* message to pass down */
  68.     VOID *emsgdata;            /* msgdata to pass down */
  69.     int     ikid;            /* flag for gender of current kid */
  70.     struct     tile_struct *dad;
  71.     struct     tile_struct *kid;
  72.     opbox     box;            /* box of this tile */
  73.     opcoord    boxtop;            /* falling ceiling of box to use */
  74.     opbox     winbox;            /* box of tile window clipped against its parent windows */
  75.     opcoord rtshad;            /* clipped remnant of right shadow */
  76.     opcoord botshad;        /* clipped remnant of bottom shadow */
  77. } *tile_type;
  78.  
  79. /* -------------------------------------------------------------------------- */
  80. OSTATIC boolean   OWLPRIV tile_KidCreate(_arg4(VOID *, tile_type, win_type, win_type));
  81. OSTATIC tile_type OWLPRIV tile_Create(_arg2(VOID *, tile_type));
  82.  
  83. #define tile_Free(td, tile)                \
  84.     va_freeelem((varray)(td), (va_index) va_getelemtag((varray)(td), tile))
  85. /* -------------------------------------------------------------------------- */
  86.  
  87. void win_Expose(win, msg, emsgdata)
  88.     win_type win;
  89.     int msg;
  90.     VOID *emsgdata;
  91. /*
  92.     Exposes all unobscured parts of win (but not border).
  93. */
  94. {
  95.     opbox tbox;
  96.  
  97.     if (win == NULL) {
  98.         return;
  99.     }
  100.     tbox.xmin = win_GetXmin(win);
  101.     tbox.ymin = win_GetYmin(win);
  102.     tbox.xmax = tbox.xmin + win_GetPixWidth(win);
  103.     tbox.ymax = tbox.ymin + win_GetPixHeight(win);
  104.  
  105.     wmgr_ExposePixBox(win, NULL, &tbox, msg, emsgdata);
  106. }
  107. /* -------------------------------------------------------------------------- */
  108.  
  109. void win_ExposePixBox(win, relboxp, msg, emsgdata)
  110.     win_type win;
  111.     opbox *relboxp;
  112.     int msg;
  113.     VOID *emsgdata;
  114. /*
  115.     Exposes all unobscured parts of win in relboxp.
  116.     Note that relboxp is relative to the window.
  117. */
  118. {
  119.     opbox tbox;
  120.  
  121.     if (win == NULL) {
  122.         return;
  123.     }
  124.     opbox_copy(&tbox, relboxp);
  125.     opbox_trans(&tbox, win_GetXmin(win), win_GetYmin(win));
  126.  
  127.     wmgr_ExposePixBox(win, NULL, &tbox, msg, emsgdata);
  128. }
  129. /* -------------------------------------------------------------------------- */
  130.  
  131. boolean OWLPRIV wmgr_ExposePixBox(topwin, botwin, boxp, exposemsg, emsgdata)
  132.     win_type topwin;    /* window to expose equal to or below */
  133.     win_type botwin;    /* window to not expose equal to or below */
  134.     opbox *boxp;        /* box within which to do the exposure */
  135.     int exposemsg;        /* do-what flag to pass to exposefunc */
  136.     VOID *emsgdata;
  137. /*
  138.     Finds all the rectangular pieces of windows that combine to tile the 'boxp'.
  139.     Note that boxp is relative to the whole display, not any window.
  140.     For each piece belonging to a window in the employed list equal to or
  141.     below 'topwin' and above 'botwin, calls that window with 'exposemsg'
  142.     and the coordinates of the exposed piece of window.
  143. */
  144. {
  145.     tile_type tile, ttile;
  146.     ptd_struct ptdata;
  147. #ifdef DEBUG
  148.     int ididd;
  149. #endif
  150.  
  151.     owl_Assert(disp_Ok(), OE_WE_DISP);
  152.  
  153.     owl_Assert(curr_wmgr->tilerdata != NULL, OE_WE_TDATA);
  154.  
  155.     /* Set up starting conditions */
  156.     tile = tile_Create(curr_wmgr->tilerdata, NULL);    /* dad tile */
  157.     if (tile == NULL) {
  158.         return(FALSE);
  159.     }
  160.     hard_Claim();        /* Here for re-entrancy protection */
  161.  
  162.     tile->win = win_GetBelow(curr_wmgr->employedhead);    /* init top tile win */
  163.     if (topwin == curr_wmgr->employedhead) {
  164.         topwin = win_GetBelow(curr_wmgr->employedhead);
  165.     }
  166.  
  167.     /* Set up coords: box clipped to display */
  168.     opbox_copy(&tile->box, boxp);
  169.     if (opbox_empty(&tile->box) || !disp_clipbox(&tile->box)) {
  170.         tile_Free(curr_wmgr->tilerdata, tile);        /* tile is empty to start out, so quit */
  171.         hard_Release();
  172.         return(TRUE);
  173.     }
  174.     tile->inlayer = FALSE;
  175.     tile->emsg = exposemsg;
  176.     tile->emsgdata = emsgdata;
  177.  
  178.     disp_Cache();
  179.  
  180.     /* Recurse through the stack of windows until done */
  181.     for (;;) {
  182.         if (tile_KidCreate(curr_wmgr->tilerdata, tile, topwin, botwin)) {
  183.             tile = tile->kid;    /* Do kid next time around loop */
  184.             continue;
  185.         }
  186.     /* No kids left - end of this family line - draw tile then free it */
  187.     /* Note: tile can have shadow children even w/its window obscured */
  188.         if (tile->inlayer && !opbox_empty(&tile->winbox)) {
  189. #ifdef DEBUG
  190.             /* every time we get a tile, diddle it until a keystroke comes */
  191.             if (diddle &&
  192.                 (tile->emsg == WINM_PAINT || tile->emsg == WINM_SHADOW)) {
  193.                 for (ididd = diddle; ididd != 0; ) {
  194.                     ptdata.win = disp_GetDispWin();
  195.                     ptdata.relboxp = &tile->winbox;
  196.  
  197.                     ptd_Clear(&ptdata, 0);
  198.                     ptd_Clear(&ptdata, 7);
  199.                     if (ididd == -1) {
  200.                         if (kb_Check()) {
  201.                             kb_Read();
  202.                             break;
  203.                         }
  204.                     }
  205.                     else ididd--;
  206.                 }
  207.             }
  208. #endif
  209.             if (tile->win == NULL) {    /* if no window, just clear box */
  210.                 if (tile->emsg == WINM_PAINT || tile->emsg == WINM_SHADOW) {
  211.                     ptdata.win = disp_GetDispWin();
  212.                     ptdata.relboxp = &tile->winbox;
  213.                     ptdata.emsgdata = tile->emsgdata;
  214.  
  215.                     ptd_Clear(&ptdata, (tile->emsg == WINM_PAINT) ?
  216.                         win_GetBgColor(ptdata.win) :
  217.                         disp_GetAttrBgColor(win_GetShadowAttr(ptdata.win)));
  218.                 }
  219.             }
  220.             else {    /* Plot piece of window */
  221.                 ptdata.win = tile->win;
  222.                 opbox_trans(&tile->winbox, -win_GetXmin(tile->win),
  223.                                              -win_GetYmin(tile->win));
  224.                 ptdata.relboxp = &tile->winbox;
  225.                 ptdata.emsgdata = tile->emsgdata;
  226.                 win_Do(tile->win, tile->emsg, &ptdata, NULL);
  227.             }
  228.         }
  229.         /* Free the current leaf; back up the tree one node */
  230.         ttile = tile;
  231.         tile = tile->dad;
  232.         tile_Free(curr_wmgr->tilerdata, ttile);
  233.  
  234.         /* If back to top of tree, quit */
  235.         if (tile == NULL) {
  236.             break;
  237.         }
  238.         tile->kid = NULL;
  239.     }
  240.     disp_Flush();
  241.     hard_Release();
  242.     return(TRUE);
  243. }
  244. /* -------------------------------------------------------------------------- */
  245.  
  246. static boolean OWLPRIV tile_KidCreate(td, tile, topwin, botwin)
  247.     VOID *td;
  248.     tile_type tile;
  249.     win_type topwin;
  250.     win_type botwin;
  251. /*
  252.     Make a new kid tile for tile, containing a sub_rectangle.
  253.     Shaves off parts of tile box that are not in tile win and gives the shavings
  254.     to the kids.
  255.     Skip over non-intersecting windows, but check them for the 'inlayer' flag.
  256.     Return FALSE if no kid can be created for the given tile (either
  257.     the tile is completely within the next window under it, or the end of
  258.     the employed window list has been reached. (The latter should never happen).
  259. */
  260. {
  261.     tile_type newtile;
  262.     opbox kidbox;
  263.     opcoord botshad, rtshad;
  264.     opcoord topshad, lshad;
  265.     boolean doshad, gotone;
  266.     opcoord newtop;
  267. #ifdef DEBUG2
  268.     ptd_struct ptdata;
  269.     opbox tbox, tsbox;
  270. #endif
  271.  
  272.     /* If this tile is virgin, find a suitable window for it. */
  273.     if (tile->ikid == FIRSTKID) {
  274.         /* Skip over non-intersecting windows, checking for inlayer */
  275.         for (;;) {
  276.             /* Set inlayer flag: */
  277.             /* If topwin == NULL, last tile (VACUUM) is inlayer anyway. */
  278.             if (tile->win == topwin) tile->inlayer = TRUE;
  279.  
  280.             /* If botwin == NULL, all tiles below or equal topwin are inlayer */
  281.             if (tile->win == NULL) {
  282.                 opbox_copy(&tile->winbox, &tile->box);
  283.                 return(FALSE);
  284.             }
  285.             if (tile->win == botwin) {
  286.                 tile->inlayer = FALSE;
  287.                 return(FALSE);
  288.             }
  289.             /* Skip right past uninvolved windows - also set up tile->winbox */
  290.  
  291.             /*  Only look at employed windows */
  292.             if (win_IsEmployed(tile->win)) {
  293.  
  294.                 doshad = (tile->emsg == WINM_PAINT || tile->emsg == WINM_SAVE ||
  295.                           tile->emsg == WINM_SCROLL || tile->emsg == WINM_CLEAR);
  296.  
  297.                 /* Only look at windows not completely clipped by their parents */
  298.                 if (win_ParentClip(tile->win, &tile->winbox, doshad)) {
  299.  
  300.                     /* Set up shadow dimensions; shadow only under certain messages */
  301.                     if (doshad) {
  302.                         rtshad = tile->winbox.xmax - win_pixboxp(tile->win)->xmax;
  303.                         if (rtshad < 0) rtshad = 0;
  304.                         else tile->winbox.xmax -= rtshad;
  305.  
  306.                         botshad = tile->winbox.ymax - win_pixboxp(tile->win)->ymax;
  307.                         if (botshad < 0) botshad = 0;
  308.                         else tile->winbox.ymax -= botshad;
  309.  
  310.                         lshad = win_pixboxp(tile->win)->xmin +
  311.                                 win_GetShadowX(tile->win) -
  312.                                 tile->winbox.xmin;
  313.                         if (lshad < 0) lshad = 0;
  314.  
  315.                         topshad = win_pixboxp(tile->win)->ymin +
  316.                                 win_GetShadowY(tile->win) -
  317.                                 tile->winbox.ymin;
  318.                         if (topshad < 0) topshad = 0;
  319.                     }
  320.                     else rtshad = botshad = 0;
  321.  
  322.                     /* Only look at windows at least partly inside this tile */
  323.                     opbox_copy(&kidbox, &tile->box);
  324.  
  325.                     /* Test for winbox overlapping starting tile */
  326.                     gotone = (kidbox.xmin < tile->winbox.xmax &&
  327.                               kidbox.xmax > tile->winbox.xmin &&
  328.                               kidbox.ymin < tile->winbox.ymax &&
  329.                               kidbox.ymax > tile->winbox.ymin);
  330.  
  331.                     /* Test for shadow box overlapping starting tile */
  332.                     if (gotone ||
  333.                         ((botshad != 0 || rtshad != 0) &&
  334.                             (kidbox.xmin < tile->winbox.xmax + rtshad  &&
  335.                              kidbox.xmax > tile->winbox.xmin + lshad   &&
  336.                              kidbox.ymin < tile->winbox.ymax + botshad &&
  337.                              kidbox.ymax > tile->winbox.ymin + topshad))) {
  338. #ifdef DEBUG2
  339.             /* diddle the winbox and its shadow that we will be tiling. */
  340.             if (diddle2 &&
  341.                 (tile->emsg == WINM_PAINT || tile->emsg == WINM_SHADOW)) {
  342.                 opbox_copy(&tbox, &tile->winbox);
  343.                 opbox_copy(&tsbox, &tbox);
  344.                 opbox_trans(&tsbox, rtshad, botshad);
  345.                 opbox_clipbox(&tile->box, &tbox);
  346.                 opbox_clipbox(&tile->box, &tsbox);
  347.                 for (;;) {
  348.                     ptdata.win = disp_GetDispWin();
  349.  
  350.                     ptdata.relboxp = &tbox;
  351.                     ptd_Clear(&ptdata, 0);
  352.                     ptdata.relboxp = &tsbox;
  353.                     ptd_Clear(&ptdata, 0);
  354.  
  355.                     ptdata.relboxp = &tbox;
  356.                     ptd_Clear(&ptdata, 1);    /* blue */
  357.                     ptdata.relboxp = &tsbox;
  358.                     ptd_Clear(&ptdata, 1);    /* blue */
  359.  
  360.                     if (kb_Check()) {
  361.                         kb_Read();
  362.                         break;
  363.                     }
  364.                 }
  365.             }
  366. #endif
  367.                         tile->boxtop = tile->box.ymin;
  368.                         tile->rtshad  = rtshad;
  369.                         tile->botshad = botshad;
  370.                         break;
  371.                     }
  372.                 }
  373.             }
  374.             tile->win = win_GetBelow(tile->win);    /* skip to next window. */
  375.         }
  376.     }
  377.     else {    /* If this tile has already had a kid, it must have a good window */
  378.         opbox_copy(&kidbox, &tile->box);
  379.  
  380.         /* Set up shadow dimensions; shadow only under certain messages */
  381.         doshad = (tile->emsg == WINM_PAINT || tile->emsg == WINM_SAVE ||
  382.                   tile->emsg == WINM_SCROLL || tile->emsg == WINM_CLEAR);
  383.         if (doshad) {
  384.             rtshad  = tile->rtshad;
  385.             botshad = tile->botshad;
  386.             lshad   = win_pixboxp(tile->win)->xmin + win_GetShadowX(tile->win) -
  387.                     tile->winbox.xmin;
  388.             if (lshad < 0) lshad = 0;
  389.             topshad = win_pixboxp(tile->win)->ymin + win_GetShadowY(tile->win) -
  390.                     tile->winbox.ymin;
  391.             if (topshad < 0) topshad = 0;
  392.         }
  393.         else rtshad = botshad = 0;
  394.     }
  395.     /* Loop until a real subtile is found - find kid box. */
  396.     newtop = tile->boxtop;
  397.     for (gotone = FALSE; gotone == FALSE; tile->ikid++) {
  398.         kidbox.ymin = tile->boxtop;    /* keep this up to date as we go around again */
  399.         if (tile->boxtop >= tile->box.ymax) {
  400.             /* All done if we've squished the tile box to nothing */
  401.             tile->ikid = ALLDONE;
  402.         }
  403.         switch (tile->ikid) {
  404.          case TOPBAR:
  405.             if (kidbox.ymin < tile->winbox.ymin) {
  406.                     /* There's a strip at the top */
  407.                 kidbox.ymax    = tile->winbox.ymin;
  408.                 gotone = TRUE;
  409.             }
  410.             newtop = tile->winbox.ymin;    /* Chop this to save later testing */
  411.             break;
  412.          case LEFTBOX:
  413.             if (kidbox.xmin < tile->winbox.xmin &&
  414.                 kidbox.ymin < tile->winbox.ymax) {
  415.                     /* There's a strip at the left */
  416.                 kidbox.xmax = tile->winbox.xmin;
  417.                 if (kidbox.ymax > tile->winbox.ymax) {
  418.                     kidbox.ymax = tile->winbox.ymax;
  419.                 }
  420.                 gotone = TRUE;
  421.             }
  422.             break;
  423.          case TOPNIB:
  424.             if (topshad != 0) {
  425.                 if (kidbox.xmax > tile->winbox.xmax &&
  426.                     kidbox.ymin < tile->winbox.ymin + topshad) {
  427.                         /* There's a nib strip at the top right */
  428.                     kidbox.xmin = tile->winbox.xmax;
  429.                     if (kidbox.ymax > tile->winbox.ymin + topshad) {
  430.                         kidbox.ymax = tile->winbox.ymin + topshad;
  431.                     }
  432.                     gotone = TRUE;
  433.                 }
  434.                 newtop = tile->winbox.ymin + topshad;    /* Chop this to save later testing */
  435.             }
  436.             break;
  437.          case XSHADOW:
  438.             if (rtshad != 0 &&
  439.                  kidbox.xmax > tile->winbox.xmax &&
  440.                 kidbox.ymin < tile->winbox.ymax) {
  441.                     /* There's a shadow strip at the right */
  442.                 if (kidbox.xmin < tile->winbox.xmax) {
  443.                     kidbox.xmin = tile->winbox.xmax;
  444.                 }
  445.                 if (kidbox.xmax > tile->winbox.xmax + rtshad) {
  446.                     kidbox.xmax = tile->winbox.xmax + rtshad;
  447.                 }
  448.                 if (kidbox.ymax > tile->winbox.ymax) {
  449.                     kidbox.ymax = tile->winbox.ymax;
  450.                 }
  451.                 gotone = TRUE;
  452.             }
  453.             break;
  454.          case RTBOX:
  455.             if (kidbox.xmax > tile->winbox.xmax + rtshad) {
  456.                     /* There's a strip at the right */
  457.                 kidbox.xmin = tile->winbox.xmax + rtshad;
  458.                 if (kidbox.ymax > tile->winbox.ymax + botshad) {
  459.                     kidbox.ymax = tile->winbox.ymax + botshad;
  460.                 }
  461.                 gotone = TRUE;
  462.             }
  463.             newtop = tile->winbox.ymax;    /* Chop this to save later testing */
  464.             break;
  465.          case BOTNIB:
  466.             if (botshad != 0 &&
  467.                 kidbox.xmin < tile->winbox.xmin + lshad) {
  468.                     /* There's a nib strip at the bottom left */
  469.                 if (kidbox.xmax > tile->winbox.xmin + lshad) {
  470.                     kidbox.xmax = tile->winbox.xmin + lshad;
  471.                 }
  472.                 if (kidbox.ymax > tile->winbox.ymax + botshad) {
  473.                     kidbox.ymax = tile->winbox.ymax + botshad;
  474.                 }
  475.                 gotone = TRUE;
  476.             }
  477.             break;
  478.          case YSHADOW:
  479.             if (botshad != 0) {
  480.                 if (TRUE) {        /* Must intersect to get here */
  481.                         /* There's a bottom shadow strip */
  482.                     if (kidbox.xmin < tile->winbox.xmin + lshad) {
  483.                         kidbox.xmin = tile->winbox.xmin + lshad;
  484.                     }
  485.                     if (kidbox.xmax > tile->winbox.xmax + rtshad) {
  486.                         kidbox.xmax = tile->winbox.xmax + rtshad;
  487.                     }
  488.                     if (kidbox.ymax > tile->winbox.ymax + botshad) {
  489.                         kidbox.ymax = tile->winbox.ymax + botshad;
  490.                     }
  491.                     gotone = TRUE;
  492.                 }
  493.                 newtop = tile->winbox.ymax + botshad;    /* Chop this to save later testing */
  494.             }
  495.             break;
  496.          case BOTBAR:
  497.             if (TRUE) {        /* Must intersect to get here */
  498.                     /* There's a strip at the bottom */
  499.                 kidbox.ymin = tile->winbox.ymax + botshad;
  500.                 gotone = TRUE;
  501.             }
  502.             break;
  503.          default:
  504.          case ALLDONE:    /* Total overlap; no more strips, no more kids */
  505.             /* Clip winbox to within starting tile */
  506.             opbox_clipbox(&tile->box, &tile->winbox);
  507.             return(FALSE);
  508.         }
  509.         /* keep this up to date as we go around again */
  510.         if (tile->boxtop < newtop) {
  511.             tile->boxtop = newtop;
  512.         }
  513.     }
  514.     newtile = tile_Create(td, tile);
  515.     if (newtile == NULL) {
  516.         tile->win = NULL;
  517.         opbox_clipbox(&tile->box, &tile->winbox);
  518.         return(FALSE);
  519.     }
  520.     opbox_copy(&newtile->box, &kidbox);
  521.     if (tile->ikid - 1 == XSHADOW || tile->ikid - 1 == YSHADOW) {
  522.         if (tile->emsg == WINM_SAVE) {
  523.             newtile->emsg = WINM_SHADOWSAVE;
  524.         }
  525.         else newtile->emsg = WINM_SHADOW;
  526.         tile->emsgdata = NULL;
  527.     }
  528.     tile->kid = newtile;
  529. #ifdef DEBUG2
  530.     /* diddle the new tile. */
  531.     if (diddle2 &&
  532.         (tile->emsg == WINM_PAINT || tile->emsg == WINM_SHADOW)) {
  533.         for (;;) {
  534.             ptdata.win = disp_GetDispWin();
  535.             ptdata.relboxp = &kidbox;
  536.  
  537.             ptd_Clear(&ptdata, 0);
  538.             ptd_Clear(&ptdata, 4);    /* red */
  539.             if (kb_Check()) {
  540.                 kb_Read();
  541.                 break;
  542.             }
  543.         }
  544.     }
  545. #endif
  546.     return(TRUE);
  547. }
  548. /* -------------------------------------------------------------------------- */
  549. /* The tile allocation scheme. Because each tile has only one kid and dad,  */
  550. /* and no list splicing is done, we are assured that the tiles will be  */
  551. /* allocated and freed in a LIFO manner */
  552. /* This fact insures that the varray free mechanism will work efficiently */
  553.  
  554. #define INITSTACK    20
  555. /* -------------------------------------------------------------------------- */
  556.  
  557. boolean OWLPRIV wmgr_OpenTiler()
  558. {
  559.     curr_wmgr->tilerdata =
  560.         (VOID *) va_make(INITSTACK, sizeof(struct tile_struct), NULL, FALSE, 0);
  561.     return(curr_wmgr->tilerdata != NULL);
  562. }
  563. /* -------------------------------------------------------------------------- */
  564.  
  565. void OWLPRIV wmgr_CloseTiler()
  566. {
  567.     if (curr_wmgr->tilerdata != NULL) {
  568.         va_free((varray) curr_wmgr->tilerdata);
  569.         curr_wmgr->tilerdata = NULL;
  570.     }
  571. }
  572. /* -------------------------------------------------------------------------- */
  573.  
  574. static tile_type OWLPRIV tile_Create(td, dad)
  575.     VOID *td;
  576.     tile_type dad;
  577. /*
  578.     allocate a new tile structure, filling in relevant values from its dad.
  579. */
  580. {
  581.     tile_type tile;
  582.     va_index id;
  583.  
  584.     id = va_findfree((varray) td);
  585.     tile = (tile_type) va_elem((varray) td, id);
  586.  
  587.     if (tile != NULL) {
  588.         va_setelemtag((varray) td, tile, (va_tag)id);
  589.  
  590.         tile->ikid = FIRSTKID;    /* flag for gender of current kid */
  591.         tile->kid = NULL;        /* current kid */
  592.  
  593.         tile->dad = dad;
  594.  
  595.         if (dad != NULL) {
  596.             tile->win = win_GetBelow(dad->win);
  597.             tile->inlayer = dad->inlayer;
  598.             tile->emsg = dad->emsg;
  599.             tile->emsgdata = dad->emsgdata;
  600.         }
  601.     }
  602.     return(tile);
  603. }
  604. /* -------------------------------------------------------------------------- */
  605.  
  606.