home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / GRWIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-06  |  3.1 KB  |  117 lines

  1. /*
  2.     grwin.c
  3.  
  4.     % Graphics window object.
  5.     Implements a display/draw graphics window on the display.
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     9/11/88 By Ted.
  12.  
  13.     Revision History:
  14.     -----------------
  15.      9/12/88 jmd    Added in and out data to objects
  16.     11/20/88 jmd    Added ID to obj struct
  17.      8/12/89 jdc    Added INIT and WHO message
  18.  
  19.     11/06/89 jmd    removed DoRaw macros
  20.     11/10/89 jmd    SAVE handling now uses inheritance
  21.      3/28/90 jmd    ansi-fied
  22.     12/05/90 ted    added EXPLODE ISAVE handling.
  23. */
  24.  
  25. #include "oakhead.h"
  26. #include "disppriv.h"
  27. #include "pmwinobj.h"
  28. #include "pmwinod.h"
  29.  
  30. #include "bordobj.h"        /* for pmwin_SetPmap */
  31.  
  32. /* -------------------------------------------------------------------------- */
  33.  
  34. int grwin_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  35. /* 
  36.     graphics window object dispatch function.
  37.     A grmap displays a pixel map and causes the pixel map to absorb from the
  38.     screen any graphics that are written into the window.
  39. */
  40. {
  41.     grwin_od    *grwd;
  42.     pmap_type    pmap;
  43.     winopendata_struct *wod;
  44.     win_type    win;
  45.  
  46.     grwd = (grwin_od *) objdata;
  47.  
  48.     switch(msg) {
  49.     case OBJM_GETDATASIZE:
  50.         ((ogds_struct *) outdata)->odsize = sizeof(grwin_od);
  51.         ((ogds_struct *) outdata)->xdsize = sizeof(grwin_xd);
  52.         ((ogds_struct *) outdata)->id = ID_GRWIN;
  53.         break;
  54.  
  55.     case OBJM_INIT:
  56.  
  57.         /* initialize pmap data */
  58.         wod = (winopendata_struct *) indata;
  59.  
  60.         /* Allocate pixel map */
  61.         if ((pmap = pmap_Open(opbox_GetWidth(wod->boxp), opbox_GetHeight(wod->boxp))) == NULL) {
  62.             return(FALSE);
  63.         }
  64.         win = grwinod_GetSelf(grwd);
  65.  
  66.         /* Note: pmwin open function initializes with NULL pmap pointer, */
  67.         /* so we have to set the pmap after the OPEN message. */
  68.         grwin_SetPmap(win, pmap);
  69.  
  70.         /* Make this function its own object's Explode function */
  71.         win_SetExplode(win, grwin_Class);
  72.  
  73.         return(pmwin_Class(&(grwd->pmwd), msg, indata, outdata));
  74.  
  75.     case OBJM_CLOSE:
  76.         /* close pmap */
  77.         pmap = grwin_GetPmap(grwinod_GetSelf(grwd));
  78.         if (pmap != NULL) {
  79.             pmap_Close(pmap);
  80.         }
  81.         /* No break: send CLOSE to win superclass */
  82.     default:
  83.     case OBJM_OPEN:
  84.     case WINM_PAINT:
  85.     case WINM_GETINPOS:
  86.         /* pass other messages to win superclass */
  87.         return(pmwin_Class(&(grwd->pmwd), msg, indata, outdata));
  88.  
  89.     case OBJM_WHO:
  90.         /* Identify ourselves */
  91.         if (*((int *) indata) == ID_GRWIN) {
  92.             return(TRUE);
  93.         }
  94.         return(pmwin_Class(&(grwd->pmwd), msg, indata, outdata));
  95.  
  96.     case WINM_ISAVE:    /* This is called during wmgr_Init if we're bgwin */
  97.     case WINM_SAVE:
  98.     case WINM_GRAB:
  99.     case WINM_EXPLODE:    /* A tricky trick to do ISAVE at employment time */
  100.         /* pass GRAB message up to pmwin to grab from the display */
  101.         pmwin_Class(&(grwd->pmwd), WINM_GRAB, indata, outdata);
  102.  
  103.         /* pass SAVE and ISAVE messages up for processing by win class */
  104.         if (msg == WINM_SAVE || msg == WINM_ISAVE) {
  105.             pmwin_Class(&(grwd->pmwd), msg, indata, outdata);
  106.         }
  107.         break;
  108.  
  109.     case WINM_STARTCUR:    /* no text cursor in this window class */
  110.     case WINM_STOPCUR:
  111.         break;
  112.     }
  113.     return(TRUE);
  114. }
  115. /* -------------------------------------------------------------------------- */
  116.  
  117.