home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / MSGWIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-23  |  2.3 KB  |  104 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.2
  11.     Copyright (c) 1989, by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16.     11/06/89 jmd    removed DoRaw macros
  17.      3/28/90 jmd    ansi-fied
  18. */
  19.  
  20. #include "oakhead.h"
  21. #include "disppriv.h"
  22. #include "msgwin.h"
  23.  
  24. /*** msgwinod ***/
  25.  
  26. #include "winod.h"
  27.  
  28. /* The message window class */
  29.  
  30. typedef struct _msgwinod {
  31.     win_od        wd;                  /* window super class */
  32. } msgwin_od;
  33.  
  34. #define msgwinod_GetSelf(msgwdd)       (winod_GetSelf(&(msgwdd)->wd))
  35.  
  36. /* -------------------------------------------------------------------------- */
  37.  
  38. int msgwin_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  39. /* 
  40.     message window object dispatch function
  41. */
  42. {
  43.     msgwin_od      *mwd;
  44.     opbox               relbox;
  45.     ptd_struct       *ptd;
  46.     ptd_struct         inptd;        /* for use in inner-coordinate computations */
  47.     opbox             inbox;        /* ditto; gets hooked in by ptd_SetInner */
  48.     win_type        win;
  49.     char            *string;
  50.     int                len;
  51.  
  52.     mwd = (msgwin_od *) objdata;
  53.  
  54.     switch(msg) {
  55.     case OBJM_GETDATASIZE:
  56.         ((ogds_struct *) outdata)->odsize = sizeof(msgwin_od);
  57.         ((ogds_struct *) outdata)->xdsize = sizeof(msgwin_xd);
  58.         ((ogds_struct *) outdata)->id = ID_MSGWIN;
  59.         break;
  60.  
  61.     case OBJM_OPEN:
  62.         /* initialize xd */
  63.         msgwin_SetMsg(msgwinod_GetSelf(mwd), NULL);
  64.         /* no break, fall through to default */
  65.  
  66.     default:
  67.         /* pass other messages to win superclass */
  68.         return(win_Class(&(mwd->wd), msg, indata, outdata));
  69.  
  70.     case OBJM_WHO:
  71.         /* Identify ourselves */
  72.         if (*((int *) indata) == ID_MSGWIN) {
  73.             return(TRUE);
  74.         }
  75.         return(win_Class(&(mwd->wd), msg, indata, outdata));
  76.  
  77.     case WINM_PAINT:
  78.         /* paint the msg */
  79.         ptd = (ptd_struct *)indata;
  80.         win = ptd->win;
  81.  
  82.         if (ptd_SetInner(ptd, &inptd, &inbox)) {
  83.             /* The inner ptd does not include the window border */
  84.             opbox_copy(&relbox, inptd.relboxp);
  85.  
  86.             if ((string = msgwin_GetMsg(win)) == NULL) {
  87.                 len = 0;
  88.             }
  89.             else {    
  90.                 ptd_DrawString(&inptd, 0, 0, string, win_GetAttr(win), (len = strlen(string)));
  91.             }
  92.  
  93.             ptd_ClearFrame(&inptd, 0, 0, 
  94.                 len * win_GetFontWidth(win), win_GetFontHeight(win), 
  95.                 win_GetBgColor(ptd->win));
  96.         }
  97.  
  98.         win_Class(&(mwd->wd), msg, indata, outdata);
  99.         break;
  100.     }
  101.  
  102.     return(TRUE);
  103. }
  104.