home *** CD-ROM | disk | FTP | other *** search
- /*
- winsize.c 7/7/88
-
- % win_SetPixSize, win_ReallySetPixSize.
- by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 12/09/88 ted: Added ddisp_Cache/Flush calls for mouse.
- 12/11/88 ted: Added dhard_Claim/Release calls for reentrancy.
- 5/01/89 ted Added wmgr_SetNewCurrentFlag call to fix mouse support.
- 5/24/89 jmd Added border message to unemployed case
- 7/07/89 gam Changed NULL to FNULL where necessary
- 8/08/89 jmd Added win_Really funcs.
- 8/10/89 ted added allowances for shadows.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "bordobj.h"
- /* -------------------------------------------------------------------------- */
-
- void win_SetPixSize(win, width, height)
- win_type win;
- odim width;
- odim height;
- /*
- Change window dimensions on screen. Save part of screen about to be
- obscured, and paint the whole window in its new size.
-
- Sends a WINM_SETSIZE message to the window class which, in turn,
- call win_ReallySetPixSize
- */
- {
- opoint pnt;
-
- pnt.x = (opcoord) width;
- pnt.y = (opcoord) height;
-
- win_Do(win, WINM_SETSIZE, &pnt, NULL);
- }
- /* -------------------------------------------------------------------------- */
-
- void win_ReallySetPixSize(win, width, height)
- win_type win;
- odim width;
- odim height;
- /*
- Really change window dimensions on screen. Save part of screen about to be
- obscured, and paint the whole window in its new size.
- */
- {
- /*
- NOTE: In this function the assumption is made that borders do not need to
- be saved, and that the window contents need to be saved before the border
- is shrunk to obscure them.
- */
- opcoord dwidth, dheight;
- opbox wsavebox, hsavebox;
- opbox wpaintbox, hpaintbox;
-
- if (win == NULL) {
- return;
- }
- hard_Claim(); /* Here for re-entrancy protection */
-
- if (win_IsCharSize(win) || !disp_TextFree()) {
- width += win_GetFontWidth(win) - 1; /* Round up instead of down */
- height += win_GetFontHeight(win) - 1;
- opcoord_GridRound((opcoord *)&width, (opcoord *)&height, win_GetFont(win));
- }
- dwidth = width - win_GetPixWidth(win);
- dheight = height - win_GetPixHeight(win);
-
- if (!win_IsEmployed(win)) {
- /* Fix the window size */
- win_pixboxp(win)->xmax += dwidth;
- win_inboxp(win)->xmax += dwidth;
-
- win_pixboxp(win)->ymax += dheight;
- win_inboxp(win)->ymax += dheight;
-
- /* Notify the border (if there is one) of the resizing */
- bord_SendMsg(win, BDM_RESIZE, NULL, NULL);
- }
- else {
- /* Find the regions of change and save them */
-
- disp_Cache();
-
- if (dwidth < 0) { /* shrinking x */
- win_getwinbox(win, &wsavebox);
- win_getshadowbox(win, &wpaintbox);
-
- wsavebox.xmin = wsavebox.xmax + dwidth;
- wpaintbox.xmin = wpaintbox.xmax + dwidth;
- }
- else { /* expanding x */
- win_getshadowbox(win, &wsavebox);
- wsavebox.xmin = wsavebox.xmax;
- wsavebox.xmax += dwidth;
- }
-
- if (dheight < 0) { /* shrinking y */
- win_getwinbox(win, &hsavebox);
- win_getshadowbox(win, &hpaintbox);
-
- hsavebox.ymin = hsavebox.ymax + dheight;
- hpaintbox.ymin = hpaintbox.ymax + dheight;
-
- if (dwidth < 0) { /* shrinking x, y */
- wpaintbox.ymax += dheight;
- }
- wsavebox.ymax += dheight;
- }
- else { /* expanding y */
- win_getshadowbox(win, &hsavebox);
- hsavebox.ymin = hsavebox.ymax;
- hsavebox.ymax += dheight;
-
- hsavebox.xmax += dwidth;
- }
- wmgr_SavePixBox(win, &wsavebox);
- wmgr_SavePixBox(win, &hsavebox);
-
- /* Fix the window size */
- win_pixboxp(win)->xmax += dwidth;
- win_inboxp(win)->xmax += dwidth;
- win_pixboxp(win)->ymax += dheight;
- win_inboxp(win)->ymax += dheight;
-
- /* If window shrank, paint exposed regions outside of it */
- if (dwidth < 0) {
- wmgr_PaintPixBox(win, &wpaintbox);
- }
- if (dheight < 0) {
- wmgr_PaintPixBox(win, &hpaintbox);
- }
-
- /* Repaint whole window because its contents may have been scaled */
- bord_SendMsg(win, BDM_RESIZE, NULL, NULL);
- win_getshadowbox(win, &wsavebox);
- wmgr_PaintPixBox(win, &wsavebox);
-
- /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
- if (wmgr_SMMptr() != FNULL) {
- wmgr_SetNewCurrentFlag(TRUE);
- }
- disp_Flush();
- }
- hard_Release();
- }
- /* -------------------------------------------------------------------------- */
-
-