home *** CD-ROM | disk | FTP | other *** search
- /*
- pmwin.c 3/11/88
-
- % Pixel map window object.
- Implements a display-only graphics window on the display.
- By Ted.
-
- OWL 1.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/09/88 jmd revised to use new object stuff
- 8/15/88 jmd OPEN now takes a winopen_struct (not anymore)
- 9/11/88 ted separated saving operations into a subclass grwin_Class
- 9/12/88 jmd Added in and out data to objects
- 11/20/88 jmd Added ID to obj struct
- 12/13/88 ted Extracted REQ message handlers
-
- 8/12/89 jdc Added INIT and WHO message
- 8/13/89 jmd Added test for NULL pmap in INPOS message
- 8/31/89 jmd Moved SetCharSize to OPEN msg
-
- 11/06/89 jmd removed DoRaw macros
- 11/10/89 jmd added GRAB support
- 3/28/90 jmd ansi-fied
- 6/06/90 ted Added SHADOW case with planemask emsgdata for plane shadows.
- 6/12/90 jmd Fixed shadow clearframe
- 6/17/90 ted Got planemask from shadow attr foreground pixval.
- 6/17/90 ted Moved x and y offsets to pmwin_xd, added and initted 'win' var.
- 10/04/90 jmd added some casts for UNIX compiler happiness
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "pmwinobj.h"
- #include "pmwinod.h"
-
- OGLOBAL objreq_fptr pmwinreq_mousefptr = objreq_Null;
-
- /* -------------------------------------------------------------------------- */
-
- int pmwin_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
- /*
- pmap window object dispatch function
- A pmap window displays a pixel map. It must be opened and then
- pmwin_SetPmap must be called to make it point to the pixel map it is
- supposed to display. Handy functions called pmwin_Open() & pmwin_PixOpen()
- are available to take care of this if the window is to be the same size
- as the pmap.
- */
- {
- pmwin_od *pmwd;
- pmap_type pmap;
- win_type win;
-
- if (msg != OBJM_GETDATASIZE) { /* pmwd isn't valid yet in GETDATASIZE msg */
- pmwd = (pmwin_od *) objdata;
- win = pmwinod_GetSelf(pmwd);
- }
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(pmwin_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(pmwin_xd);
- ((ogds_struct *) outdata)->id = ID_PMWIN;
- break;
-
- case OBJM_WHO:
- /* Identify ourselves */
- if (*((int *) indata) == ID_PMWIN) {
- return(TRUE);
- }
- return(win_Class(&(pmwd->wd), msg, indata, outdata));
-
- case OBJM_OPEN:
- {
- int ret;
-
- pmwin_getxd(win)->pmap = NULL; /* (Don't use SetPmap because it calls border) */
- pmwin_setxyoffs(win, 0, 0); /* offsets for scrolling pmap within window */
-
- /* Send OPEN to win superclass */
- ret = win_Class(&(pmwd->wd), msg, indata, outdata);
-
- /* Override win default: allow any pix size for pmwin's */
- win_SetCharSize(win, FALSE);
-
- return(ret);
- }
-
- case WINM_GRAB:
- {
- ptd_struct *ptd;
- ptd_struct inptd;
- opbox inbox;
- opbox relbox;
-
- /* grab an image from the display */
- ptd = (ptd_struct *)indata;
- if (ptd_SetInner(ptd, &inptd, &inbox)) {
- opbox_copy(&relbox, inptd.relboxp);
- opbox_trans(&relbox, pmwin_GetXoffs(win), pmwin_GetYoffs(win));
-
- if ((pmap = pmwin_GetPmap(win)) != NULL) {
- ptd_ReadPixmap(&inptd, pmap, &relbox);
- }
- }
- break;
- }
-
- case WINM_SHADOW:
- case WINM_PAINT:
- {
- ptd_struct *ptd;
- ptd_struct inptd;
- opbox inbox;
- opbox relbox;
- int hgt, wid;
- byte attr;
- opixval planemask;
-
- ptd = (ptd_struct *)indata;
-
- if (ptd_SetInner(ptd, &inptd, &inbox)) {
-
- /* initialize emsgdata */
- inptd.emsgdata = NULL;
-
- if ((pmap = pmwin_GetPmap(win)) != NULL) {
- hgt = pmap_GetHeight(pmap);
- wid = pmap_GetWidth(pmap);
- }
- else {
- hgt = 0;
- wid = 0;
- }
- opbox_copy(&relbox, inptd.relboxp);
- opbox_trans(&relbox, pmwin_GetXoffs(win), pmwin_GetYoffs(win));
-
- /* Clear the region outside the pmap, use shadow attr if appropriate */
- attr = (msg == WINM_SHADOW) ?
- win_GetShadowAttr(ptd->win) : win_GetAttr(ptd->win);
-
- ptd_ClearFrame(&inptd, -pmwin_GetXoffs(win), -pmwin_GetYoffs(win),
- wid, hgt, disp_GetAttrBgColor(attr));
-
- if (pmap != NULL) {
- if (msg == WINM_SHADOW && disp_GetInfo()->nplanes > 1) {
-
- planemask = disp_GetAttrFgColor(attr);
-
- /* Send shadow val to ptd_DrawPixmap as planemask parameter */
- inptd.emsgdata = (VOID *) &planemask;
- /* Make ptd emsgdata non-NULL so win_Class won't draw shadow */
- ptd->emsgdata = (VOID *) &planemask;
- }
- ptd_DrawPixmap(&inptd, pmap, &relbox);
- }
- }
- /* No break; fall through to win superclass */
- }
- case OBJM_INIT:
- default:
- /* pass other messages to win superclass */
- return(win_Class(&(pmwd->wd), msg, indata, outdata));
-
- case WINM_GETINPOS:
- {
- inposdata_struct *ipd;
-
- ipd = (inposdata_struct *)outdata;
- pmap = pmwin_GetPmap(win);
-
- /* make sure pmap is valid (we could be in the middle of being
- loaded from a screen file)
- */
- if (pmap == NULL) {
- return(win_Class(&(pmwd->wd), msg, indata, outdata));
- }
-
- ipd->inbox.xmin = -pmwin_GetXoffs(win);
- ipd->inbox.xmax = -pmwin_GetXoffs(win) + pmap_GetWidth(pmap);
- ipd->inbox.ymin = -pmwin_GetYoffs(win);
- ipd->inbox.ymax = -pmwin_GetYoffs(win) + pmap_GetHeight(pmap);
- break;
- }
- case WINM_SCROLLREQ:
- return((*pmwinreq_mousefptr)(pmwd, msg, indata, outdata));
-
- case WINM_STARTCUR: /* no text cursor in this window class */
- case WINM_STOPCUR:
- break;
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
-