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

  1. /*
  2.     pmwin.c    3/11/88
  3.  
  4.     % Pixel map window object.
  5.     Implements a display-only 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.      8/09/88 jmd    revised to use new object stuff
  15.      8/15/88 jmd    OPEN now takes a winopen_struct (not anymore)
  16.      9/11/88 ted    separated saving operations into a subclass grwin_Class
  17.      9/12/88 jmd    Added in and out data to objects
  18.     11/20/88 jmd    Added ID to obj struct
  19.     12/13/88 ted    Extracted REQ message handlers
  20.  
  21.      8/12/89 jdc    Added INIT and WHO message
  22.      8/13/89 jmd    Added test for NULL pmap in INPOS message
  23.      8/31/89 jmd    Moved SetCharSize to OPEN msg
  24. */
  25.  
  26. #include "oakhead.h"
  27. #include "disppriv.h"
  28. #include "pmwinobj.h"
  29. #include "pmwinod.h"
  30.  
  31. OGLOBAL objreq_fptr pmwinreq_mousefptr =  objreq_Null;
  32.  
  33. /* -------------------------------------------------------------------------- */
  34.  
  35. int pmwin_Class(objdata, msg, indata, outdata)
  36.     VOID *objdata;            /* object instance data pointer */
  37.     int msg;                /* message */
  38.     VOID *indata;            /* message input data */
  39.     VOID *outdata;            /* message output data */
  40. /* 
  41.     pmap window object dispatch function
  42.     A pmap window displays a pixel map. It must be opened and then
  43.     pmwin_SetPmap must be called to make it point to the pixel map it is
  44.     supposed to display. A handy function called dwmgr_OpenPmWin is available to
  45.     take care of this if the window is to be the same size as the pmap.
  46. */
  47. {
  48.     pmwin_od    *pmwd;
  49.     pmap_type    pmap;
  50.  
  51.     pmwd = (pmwin_od *) objdata;
  52.  
  53.     switch(msg) {
  54.     case OBJM_GETDATASIZE:
  55.         ((ogds_struct *) outdata)->odsize = sizeof(pmwin_od);
  56.         ((ogds_struct *) outdata)->xdsize = sizeof(pmwin_xd);
  57.         ((ogds_struct *) outdata)->id = ID_PMWIN;
  58.         break;
  59.  
  60.     case OBJM_WHO:
  61.         /* Identify ourselves */
  62.         if (*((int *) indata) == ID_PMWIN) {
  63.             return(TRUE);
  64.         }
  65.         return(win_DoRaw(&(pmwd->wd), msg, indata, outdata));
  66.  
  67.     case OBJM_OPEN:
  68.     {
  69.         int ret;
  70.  
  71.         pmwd->xoffs = 0;    /* offsets for scrolling pmap within window */
  72.         pmwd->yoffs = 0;
  73.         pmwin_getxd(pmwinod_GetSelf(pmwd))->pmap = NULL;
  74.  
  75.         /* Send OPEN to win superclass */
  76.         ret = win_DoRaw(&(pmwd->wd), msg, indata, outdata);
  77.  
  78.         /* Override win default: allow any pix size for pmwin's */
  79.         win_SetCharSize(pmwinod_GetSelf(pmwd), FALSE);
  80.  
  81.         return(ret);
  82.     }
  83.     case WINM_PAINT:
  84.     {
  85.         ptd_struct    *ptd;
  86.         ptd_struct    inptd;
  87.         opbox        inbox;
  88.         opbox        relbox;
  89.         int            hgt, wid;
  90.  
  91.         ptd = (ptd_struct *)indata;
  92.  
  93.         if (ptd_SetInner(ptd, &inptd, &inbox)) {
  94.             if ((pmap = pmwin_GetPmap(pmwinod_GetSelf(pmwd))) != NULL) {
  95.                 hgt = pmap_GetHeight(pmap);
  96.                 wid = pmap_GetWidth(pmap);
  97.             }
  98.             else {
  99.                 hgt = 0;
  100.                 wid = 0;
  101.             }
  102.             opbox_copy(&relbox, inptd.relboxp);
  103.             opbox_trans(&relbox, pmwd->xoffs, pmwd->yoffs);
  104.             ptd_ClearFrame(&inptd, -pmwd->xoffs, -pmwd->yoffs,
  105.                             wid, hgt, 
  106.                             win_GetBgColor(ptd->win));
  107.  
  108.             if (pmap != NULL) {
  109.                 ptd_DrawPixmap(&inptd, pmap, &relbox);
  110.             }
  111.         }
  112.         /* No break; fall through to win superclass */
  113.     }
  114.     case OBJM_INIT:
  115.     default:
  116.         /* pass other messages to win superclass */
  117.         return(win_DoRaw(&(pmwd->wd), msg, indata, outdata));
  118.  
  119.     case WINM_GETINPOS:
  120.     {
  121.         inposdata_struct *ipd;
  122.  
  123.         ipd = (inposdata_struct *)outdata;
  124.         pmap = pmwin_GetPmap(pmwinod_GetSelf(pmwd));
  125.  
  126.         /* make sure pmap is valid (we could be in the middle of being 
  127.                                     loaded from a screen file)
  128.         */
  129.         if (pmap == NULL) {
  130.             return(win_DoRaw(&(pmwd->wd), msg, indata, outdata));
  131.         }
  132.  
  133.         ipd->inbox.xmin = -pmwd->xoffs;
  134.         ipd->inbox.xmax = -pmwd->xoffs + pmap_GetWidth(pmap);
  135.         ipd->inbox.ymin = -pmwd->yoffs;
  136.         ipd->inbox.ymax = -pmwd->yoffs + pmap_GetHeight(pmap);
  137.         break;
  138.     }
  139.     case WINM_SCROLLREQ:
  140.         return((*pmwinreq_mousefptr)(pmwd, msg, indata, outdata));
  141.  
  142.     case WINM_STARTCUR:    /* no text cursor in this window class */
  143.     case WINM_STOPCUR:
  144.         break;
  145.     }
  146.     return(TRUE);
  147. }
  148. /* -------------------------------------------------------------------------- */
  149.  
  150.