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

  1. /*
  2.     winsize.c    7/7/88
  3.  
  4.     % win_SetPixSize, win_ReallySetPixSize.
  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.      5/01/89 ted    Added wmgr_SetNewCurrentFlag call to fix mouse support.
  16.      5/24/89 jmd    Added border message to unemployed case
  17.      7/07/89 gam    Changed NULL to FNULL where necessary
  18.      8/08/89 jmd    Added win_Really funcs.
  19.      8/10/89 ted    added allowances for shadows.
  20. */
  21.  
  22. #include "oakhead.h"
  23. #include "disppriv.h"
  24. #include "bordobj.h"
  25. /* -------------------------------------------------------------------------- */
  26.  
  27. void win_SetPixSize(win, width, height)
  28.     win_type win;
  29.     odim width;
  30.     odim height;
  31. /*
  32.     Change window dimensions on screen. Save part of screen about to be
  33.     obscured, and paint the whole window in its new size.
  34.  
  35.     Sends a WINM_SETSIZE message to the window class which, in turn,
  36.     call win_ReallySetPixSize
  37. */
  38. {
  39.     opoint pnt;
  40.  
  41.     pnt.x = (opcoord) width;
  42.     pnt.y = (opcoord) height;
  43.  
  44.     win_Do(win, WINM_SETSIZE, &pnt, NULL);
  45. }
  46. /* -------------------------------------------------------------------------- */
  47.  
  48. void win_ReallySetPixSize(win, width, height)
  49.     win_type win;
  50.     odim width;
  51.     odim height;
  52. /*
  53.     Really change window dimensions on screen. Save part of screen about to be
  54.     obscured, and paint the whole window in its new size.
  55. */
  56. {
  57. /*
  58.     NOTE: In this function the assumption is made that borders do not need to
  59.     be saved, and that the window contents need to be saved before the border
  60.     is shrunk to obscure them.
  61. */
  62.     opcoord dwidth, dheight;
  63.     opbox wsavebox, hsavebox;
  64.     opbox wpaintbox, hpaintbox;
  65.  
  66.     if (win == NULL) {
  67.         return;
  68.     }
  69.     hard_Claim();        /* Here for re-entrancy protection */
  70.  
  71.     if (win_IsCharSize(win) || !disp_TextFree()) {
  72.         width += win_GetFontWidth(win) - 1;        /* Round up instead of down */
  73.         height += win_GetFontHeight(win) - 1;
  74.         opcoord_GridRound((opcoord *)&width, (opcoord *)&height, win_GetFont(win));
  75.     }
  76.     dwidth  = width - win_GetPixWidth(win);
  77.     dheight = height - win_GetPixHeight(win);
  78.  
  79.     if (!win_IsEmployed(win)) {
  80.         /* Fix the window size */
  81.         win_pixboxp(win)->xmax += dwidth;
  82.         win_inboxp(win)->xmax += dwidth;
  83.  
  84.         win_pixboxp(win)->ymax += dheight;
  85.         win_inboxp(win)->ymax += dheight;
  86.  
  87.         /* Notify the border (if there is one) of the resizing */
  88.         bord_SendMsg(win, BDM_RESIZE, NULL, NULL);
  89.     }
  90.     else {
  91.     /* Find the regions of change and save them */
  92.  
  93.         disp_Cache();
  94.  
  95.         if (dwidth < 0) {    /* shrinking x */
  96.             win_getwinbox(win, &wsavebox);
  97.             win_getshadowbox(win, &wpaintbox);
  98.  
  99.             wsavebox.xmin  = wsavebox.xmax + dwidth;
  100.             wpaintbox.xmin = wpaintbox.xmax + dwidth;
  101.         }
  102.         else {    /* expanding x */
  103.             win_getshadowbox(win, &wsavebox);
  104.             wsavebox.xmin = wsavebox.xmax;
  105.             wsavebox.xmax += dwidth;
  106.         }
  107.  
  108.         if (dheight < 0) {    /* shrinking y */
  109.             win_getwinbox(win, &hsavebox);
  110.             win_getshadowbox(win, &hpaintbox);
  111.  
  112.             hsavebox.ymin  = hsavebox.ymax + dheight;
  113.             hpaintbox.ymin = hpaintbox.ymax + dheight;
  114.  
  115.             if (dwidth < 0) {    /* shrinking x, y */
  116.                 wpaintbox.ymax += dheight;
  117.             }
  118.             wsavebox.ymax  += dheight;
  119.         }
  120.         else {    /* expanding y */
  121.             win_getshadowbox(win, &hsavebox);
  122.             hsavebox.ymin = hsavebox.ymax;
  123.             hsavebox.ymax += dheight;
  124.  
  125.             hsavebox.xmax += dwidth;
  126.         }
  127.         wmgr_SavePixBox(win, &wsavebox);
  128.         wmgr_SavePixBox(win, &hsavebox);
  129.  
  130.         /* Fix the window size */
  131.         win_pixboxp(win)->xmax += dwidth;
  132.         win_inboxp(win)->xmax += dwidth;
  133.         win_pixboxp(win)->ymax += dheight;
  134.         win_inboxp(win)->ymax += dheight;
  135.  
  136.         /* If window shrank, paint exposed regions outside of it */
  137.         if (dwidth < 0) {
  138.             wmgr_PaintPixBox(win, &wpaintbox);
  139.         }
  140.         if (dheight < 0) {
  141.             wmgr_PaintPixBox(win, &hpaintbox);
  142.         }
  143.  
  144.         /* Repaint whole window because its contents may have been scaled */
  145.         bord_SendMsg(win, BDM_RESIZE, NULL, NULL);
  146.         win_getshadowbox(win, &wsavebox);
  147.         wmgr_PaintPixBox(win, &wsavebox);
  148.  
  149.         /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
  150.         if (wmgr_SMMptr() != FNULL) {
  151.             wmgr_SetNewCurrentFlag(TRUE);
  152.         }
  153.         disp_Flush();
  154.     }
  155.     hard_Release();
  156. }
  157. /* -------------------------------------------------------------------------- */
  158.  
  159.