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.1
- 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
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "pmwinobj.h"
- #include "pmwinod.h"
-
- OGLOBAL objreq_fptr pmwinreq_mousefptr = objreq_Null;
-
- /* -------------------------------------------------------------------------- */
-
- int pmwin_Class(objdata, msg, indata, outdata)
- VOID *objdata; /* object instance data pointer */
- int msg; /* message */
- VOID *indata; /* message input data */
- VOID *outdata; /* message output data */
- /*
- 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. A handy function called dwmgr_OpenPmWin is available to
- take care of this if the window is to be the same size as the pmap.
- */
- {
- pmwin_od *pmwd;
- pmap_type pmap;
-
- pmwd = (pmwin_od *) objdata;
-
- 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_DoRaw(&(pmwd->wd), msg, indata, outdata));
-
- case OBJM_OPEN:
- {
- int ret;
-
- pmwd->xoffs = 0; /* offsets for scrolling pmap within window */
- pmwd->yoffs = 0;
- pmwin_getxd(pmwinod_GetSelf(pmwd))->pmap = NULL;
-
- /* Send OPEN to win superclass */
- ret = win_DoRaw(&(pmwd->wd), msg, indata, outdata);
-
- /* Override win default: allow any pix size for pmwin's */
- win_SetCharSize(pmwinod_GetSelf(pmwd), FALSE);
-
- return(ret);
- }
- case WINM_PAINT:
- {
- ptd_struct *ptd;
- ptd_struct inptd;
- opbox inbox;
- opbox relbox;
- int hgt, wid;
-
- ptd = (ptd_struct *)indata;
-
- if (ptd_SetInner(ptd, &inptd, &inbox)) {
- if ((pmap = pmwin_GetPmap(pmwinod_GetSelf(pmwd))) != NULL) {
- hgt = pmap_GetHeight(pmap);
- wid = pmap_GetWidth(pmap);
- }
- else {
- hgt = 0;
- wid = 0;
- }
- opbox_copy(&relbox, inptd.relboxp);
- opbox_trans(&relbox, pmwd->xoffs, pmwd->yoffs);
- ptd_ClearFrame(&inptd, -pmwd->xoffs, -pmwd->yoffs,
- wid, hgt,
- win_GetBgColor(ptd->win));
-
- if (pmap != NULL) {
- ptd_DrawPixmap(&inptd, pmap, &relbox);
- }
- }
- /* No break; fall through to win superclass */
- }
- case OBJM_INIT:
- default:
- /* pass other messages to win superclass */
- return(win_DoRaw(&(pmwd->wd), msg, indata, outdata));
-
- case WINM_GETINPOS:
- {
- inposdata_struct *ipd;
-
- ipd = (inposdata_struct *)outdata;
- pmap = pmwin_GetPmap(pmwinod_GetSelf(pmwd));
-
- /* make sure pmap is valid (we could be in the middle of being
- loaded from a screen file)
- */
- if (pmap == NULL) {
- return(win_DoRaw(&(pmwd->wd), msg, indata, outdata));
- }
-
- ipd->inbox.xmin = -pmwd->xoffs;
- ipd->inbox.xmax = -pmwd->xoffs + pmap_GetWidth(pmap);
- ipd->inbox.ymin = -pmwd->yoffs;
- ipd->inbox.ymax = -pmwd->yoffs + 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);
- }
- /* -------------------------------------------------------------------------- */
-