home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / WINSETP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-13  |  4.4 KB  |  147 lines

  1. /*
  2.     winsetp.c    3/15/88
  3.  
  4.     % window moving routines.
  5.     by Ted.
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.      3/22/88 ted    Installed linked windows handling
  14.      8/15/88 jmd    Added win_GetPosition
  15.     10/19/88 ted    Extracted win_Top to wintop.c
  16.     10/19/88 ted    Extracted win_Get(Pix)PositionTop to wingetp.c
  17.     10/31/88 ted    Removed linking.
  18.     12/09/88 ted    Added ddisp_Cache/Flush calls for mouse.
  19.     12/11/88 ted    Added dhard_Claim/Release calls for reentrancy.
  20.      5/01/89 ted    Added wmgr_SetNewCurrentFlag call to fix mouse support.
  21.      7/07/89 gam    Changed NULL to FNULL where necessary
  22.      8/08/89 jmd    Added win_Really funcs.
  23.      8/10/89 ted    added allowances for shadows.
  24.  
  25.     11/06/89 ted    Added code for handling painting of nested windows.
  26.  
  27.      3/19/90 jmd    moved hard_Release to end of ReallySetPixPosition
  28.      3/28/90 jmd    ansi-fied
  29.      8/03/90 jmd    added aux messages
  30. */
  31.  
  32. #include "oakhead.h"
  33. #include "disppriv.h"
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. void win_SetPixPosition(win_type win, opcoord xpos, opcoord ypos)
  37. /*
  38.     Change the position of window.
  39.     Sends a WINM_SETPOS message to the window class which, in turn,
  40.     call win_ReallySetPixPosition
  41. */
  42. {
  43.     opoint pnt;
  44.  
  45.     pnt.x = xpos;
  46.     pnt.y = ypos;
  47.  
  48.     /* notify window aux function of upcoming move */
  49.     if (obj_DoAux(win, WINA_MOVE, &pnt, NULL) != 0) {
  50.  
  51.         /* send move request to window class */
  52.         win_Do(win, WINM_SETPOS, &pnt, NULL);
  53.     }
  54. }
  55. /* -------------------------------------------------------------------------- */
  56.  
  57. void win_ReallySetPixPosition(win_type win, opcoord xpos, opcoord ypos)
  58. /*
  59.     Really Change the position of window.
  60. */
  61. {
  62.     int xdisp, ydisp;
  63.     opbox partbox;
  64.     opbox pbox;
  65.     win_type topchild;
  66.     opbox partbox2;
  67.     opbox pbox2;
  68.  
  69.     if (win == NULL) {
  70.         return;
  71.     }
  72.     if (!disp_TextFree()) {
  73.         opcoord_GridRound(&xpos, &ypos, win_GetFont(win));
  74.     }
  75.     hard_Claim();        /* Here for re-entrancy protection */
  76.  
  77.     /* remember x and y displacements */
  78.     xdisp = xpos - win_GetXmin(win);
  79.     ydisp = ypos - win_GetYmin(win);
  80.  
  81.     /* quit if no work to do */
  82.     if (xdisp == 0 && ydisp == 0) {
  83.         hard_Release();
  84.         return;
  85.     }
  86.  
  87.     if (!win_IsEmployed(win)) {
  88.         opbox_trans(win_pixboxp(win), xdisp, ydisp);
  89.     }
  90.     else {        /* redisplay window */
  91.         disp_Cache();
  92.  
  93.         topchild = win_TopChild(win);
  94.  
  95.         /* Save in win from part that might get obscured in its new home */
  96.         /* (i.e. everything that's showing.) */
  97.         win_getwinbox(win, &pbox);
  98.         wmgr_SavePixBox(win, &pbox);
  99.  
  100.         /* Save in box from windows below where win is going */
  101.         win_getshadowbox(win, &pbox);            /* pbox gets old location */
  102.         opbox_copy(&partbox, &pbox);
  103.         opbox_trans(&partbox, xdisp, ydisp);    /* partbox gets new location */
  104.         opbox_uncover(&pbox, &partbox);            /* partbox now gets diff box */
  105.         wmgr_SavePixBox(win_GetBelow(win), &partbox);
  106.  
  107.         /* Save from parts of child wins that get obscured */
  108.         if (topchild != win) {
  109.             win_getwinbox(win, &pbox2);                /* pbox2 gets old location */
  110.             opbox_copy(&partbox2, &pbox2);
  111.             opbox_trans(&partbox2, xdisp, ydisp);    /* partbox2 gets new location */
  112.             opbox_uncover(&partbox2, &pbox2);        /* pbox2 now gets diff box */
  113.             wmgr_SavePixLayer(topchild, win, &pbox2);
  114.         }
  115.         /* Move the window box */
  116.         opbox_trans(win_pixboxp(win), xdisp, ydisp);
  117.  
  118.         /* Paint in box from windows below where win was */
  119.         opbox_copy(&partbox, &pbox);            /* partbox gets old location */
  120.         opbox_trans(&pbox, xdisp, ydisp);        /* pbox gets new location */
  121.         opbox_uncover(&pbox, &partbox);            /* partbox now gets diff box */
  122.         wmgr_PaintPixBox(win_GetBelow(win), &partbox);
  123.  
  124.         /* Paint in parts of child wins that get unobscured */
  125.         if (topchild != win) {
  126.             opbox_copy(&pbox2, &partbox2);            /* pbox2 gets new location */
  127.             opbox_trans(&partbox2, -xdisp, -ydisp);    /* partbox2 gets old location */
  128.             opbox_uncover(&partbox2, &pbox2);        /* pbox2 now gets diff box */
  129.             wmgr_PaintPixLayer(topchild, win, &pbox2);
  130.         }
  131.     /* Paint in box from window in its new location */
  132.         /* (i.e. everything that's showing.) */
  133.         win_getshadowbox(win, &pbox);
  134.         wmgr_PaintPixBox(win, &pbox);
  135.  
  136.         /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
  137.         if (wmgr_SMMptr() != FNULL) {
  138.             wmgr_SetNewCurrentFlag(TRUE);
  139.         }
  140.         disp_Flush();
  141.     }
  142.  
  143.     hard_Release();
  144. }
  145. /* -------------------------------------------------------------------------- */
  146.  
  147.