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

  1. /*
  2.     msgwin.c    8/07/89
  3.  
  4.     % msg window object.
  5.     By jmd.
  6.  
  7.     This is a window that display a one line message.
  8.     It is used by bd_null.
  9.  
  10.     OWL 1.1
  11.     Copyright (c) 1989, by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16. */
  17.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. #include "msgwin.h"
  21.  
  22. /*** msgwinod ***/
  23.  
  24. #include "winod.h"
  25.  
  26. /* The message window class */
  27.  
  28. typedef struct {
  29.     win_od        wd;                  /* window super class */
  30. } msgwin_od;
  31.  
  32. #define msgwinod_GetSelf(msgwdd)       (winod_GetSelf(&(msgwdd)->wd))
  33.  
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. int msgwin_Class(objdata, msg, indata, outdata)
  37.     VOID *objdata;            /* object instance data pointer */
  38.     int msg;                /* message */
  39.     VOID *indata;            /* message input data */
  40.     VOID *outdata;            /* message output data */
  41. /* 
  42.     message window object dispatch function
  43. */
  44. {
  45.     msgwin_od      *mwd;
  46.     opbox               relbox;
  47.     ptd_struct       *ptd;
  48.     ptd_struct         inptd;        /* for use in inner-coordinate computations */
  49.     opbox             inbox;        /* ditto; gets hooked in by ptd_SetInner */
  50.     win_type        win;
  51.     char            *string;
  52.     int                len;
  53.  
  54.     mwd = (msgwin_od *) objdata;
  55.  
  56.     switch(msg) {
  57.     case OBJM_GETDATASIZE:
  58.         ((ogds_struct *) outdata)->odsize = sizeof(msgwin_od);
  59.         ((ogds_struct *) outdata)->xdsize = sizeof(msgwin_xd);
  60.         ((ogds_struct *) outdata)->id = ID_MSGWIN;
  61.         break;
  62.  
  63.     case OBJM_OPEN:
  64.         /* initialize xd */
  65.         msgwin_SetMsg(msgwinod_GetSelf(mwd), NULL);
  66.         /* no break, fall through to default */
  67.  
  68.     default:
  69.         /* pass other messages to win superclass */
  70.         return(win_DoRaw(&(mwd->wd), msg, indata, outdata));
  71.  
  72.     case OBJM_WHO:
  73.         /* Identify ourselves */
  74.         if (*((int *) indata) == ID_MSGWIN) {
  75.             return(TRUE);
  76.         }
  77.         return(win_DoRaw(&(mwd->wd), msg, indata, outdata));
  78.  
  79.     case WINM_PAINT:
  80.         /* paint the msg */
  81.         ptd = (ptd_struct *)indata;
  82.         win = ptd->win;
  83.  
  84.         if (ptd_SetInner(ptd, &inptd, &inbox)) {
  85.             /* The inner ptd does not include the window border */
  86.             opbox_copy(&relbox, inptd.relboxp);
  87.  
  88.             if ((string = msgwin_GetMsg(win)) == NULL) {
  89.                 len = 0;
  90.             }
  91.             else {    
  92.                 ptd_DrawString(&inptd, 0, 0, string, win_GetAttr(win), (len = strlen(string)));
  93.             }
  94.  
  95.             ptd_ClearFrame(&inptd, 0, 0, 
  96.                 len * win_GetFontWidth(win), win_GetFontHeight(win), 
  97.                 win_GetBgColor(ptd->win));
  98.         }
  99.  
  100.         win_DoRaw(&(mwd->wd), msg, indata, outdata);
  101.         break;
  102.     }
  103.  
  104.     return(TRUE);
  105. }
  106.