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

  1. /*
  2.     grwin.c    9/11/88
  3.  
  4.     % Graphics window object.
  5.     Implements a display/draw graphics window on the display.
  6.     By Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      9/12/88 jmd    Added in and out data to objects
  15.     11/20/88 jmd    Added ID to obj struct
  16.      8/12/89 jdc    Added INIT and WHO message
  17. */
  18.  
  19. #include "oakhead.h"
  20. #include "disppriv.h"
  21. #include "pmwinobj.h"
  22. #include "pmwinod.h"
  23.  
  24. #include "bordobj.h"        /* for pmwin_SetPmap */
  25.  
  26. /* -------------------------------------------------------------------------- */
  27.  
  28. int grwin_Class(objdata, msg, indata, outdata)
  29.     VOID *objdata;            /* object instance data pointer */
  30.     int msg;                /* message */
  31.     VOID *indata;            /* message input data */
  32.     VOID *outdata;            /* message output data */
  33. /* 
  34.     graphics window object dispatch function.
  35.     A grmap displays a pixel map and causes the pixel map to absorb from the
  36.     screen any graphics that are written into the window.
  37. */
  38. {
  39.     grwin_od    *grwd;
  40.     opbox        relbox;
  41.     ptd_struct    *ptd;
  42.     ptd_struct    inptd;    /* for use in inner-coordinate computations */
  43.     opbox        inbox;    /* ditto; gets hooked in by ptd_SetInner */
  44.     pmap_type    pmap;
  45.     winopendata_struct *wod;
  46.  
  47.     grwd = (grwin_od *) objdata;
  48.  
  49.     switch(msg) {
  50.     case OBJM_GETDATASIZE:
  51.         ((ogds_struct *) outdata)->odsize = sizeof(grwin_od);
  52.         ((ogds_struct *) outdata)->xdsize = sizeof(grwin_xd);
  53.         ((ogds_struct *) outdata)->id = ID_GRWIN;
  54.         break;
  55.  
  56.     case OBJM_INIT:
  57.  
  58.         /* initialize pmap data */
  59.         wod = (winopendata_struct *) indata;
  60.  
  61.         /* Allocate pixel map */
  62.         if ((pmap = pmap_Open(opbox_GetWidth(wod->boxp), opbox_GetHeight(wod->boxp))) == NULL) {
  63.             return(FALSE);
  64.         }
  65.         /* Note: pmwin open function initializes with NULL pmap pointer, */
  66.         /* so we have to send a SETPMAP message after the OPEN message. */
  67.         pmwin_getxd(grwinod_GetSelf(grwd))->pmap = pmap;
  68.  
  69.         return(pmwin_DoRaw(&(grwd->pmwd), msg, indata, outdata));
  70.  
  71.     case OBJM_CLOSE:
  72.         /* close pmap */
  73.         pmap = grwin_GetPmap(grwinod_GetSelf(grwd));
  74.         if (pmap != NULL) {
  75.             pmap_Close(pmap);
  76.         }
  77.         /* No break: send CLOSE to win superclass */
  78.     default:
  79.     case OBJM_OPEN:
  80.     case WINM_PAINT:
  81.     case WINM_GETINPOS:
  82.         /* pass other messages to win superclass */
  83.         return(pmwin_DoRaw(&(grwd->pmwd), msg, indata, outdata));
  84.  
  85.     case OBJM_WHO:
  86.         /* Identify ourselves */
  87.         if (*((int *) indata) == ID_GRWIN) {
  88.             return(TRUE);
  89.         }
  90.         return(pmwin_DoRaw(&(grwd->pmwd), msg, indata, outdata));
  91.  
  92.     case WINM_ISAVE:
  93.     case WINM_SAVE:
  94.         ptd = (ptd_struct *)indata;
  95.         if (ptd_SetInner(ptd, &inptd, &inbox)) {
  96.             opbox_copy(&relbox, inptd.relboxp);
  97.             opbox_trans(&relbox, grwd->pmwd.xoffs, grwd->pmwd.yoffs);
  98.  
  99.             pmap = grwin_GetPmap(grwinod_GetSelf(grwd));
  100.             ptd_ReadPixmap(&inptd, pmap, &relbox);
  101.         }
  102.         pmwin_DoRaw(&(grwd->pmwd), msg, indata, outdata);
  103.         break;
  104.  
  105.     case WINM_STARTCUR:    /* no text cursor in this window class */
  106.     case WINM_STOPCUR:
  107.         break;
  108.     }
  109.     return(TRUE);
  110. }
  111. /* -------------------------------------------------------------------------- */
  112.  
  113.