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

  1. /*
  2.     bdbox.c     11/19/87
  3.  
  4.     % single lined border with overwritten title routine.
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1986, 1987, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.     11/22/87 jmd     Replaced line characters with octal escape sequences
  13.      7/27/88 jmd     Upgraded to new border stuff
  14.      9/12/88 jmd    Added in and out data
  15.     11/13/88 jmd    Upgraded to new border stuff
  16.     11/20/88 jmd    Added ID to obj struct
  17.     12/20/88 jmd    removed SETSIZE msg
  18.  
  19.      5/28/89 jmd    added Shadow support
  20. */
  21.  
  22. #include "oakhead.h"
  23. #include "disppriv.h"
  24. #include "bordobj.h"
  25. #include "bordod.h"
  26.  
  27. #define OUTER_BOX    "\332\304\277\263\331\304\300\263"
  28.  
  29. /* border object data */
  30.  
  31. typedef struct {
  32.     border_od    bdd;              /* common object super class */
  33. } bdbox_od;
  34.  
  35. int bd_box(objdata, msg, indata, outdata)
  36.     VOID *objdata;
  37.     int msg;
  38.     VOID *indata;                /* message input data */
  39.     VOID *outdata;                /* message output data */
  40. /*
  41.     This is a simple single lined border.
  42.     With an overwritten title.
  43.     The title is pointed to by the border data pointer.
  44.     Example:
  45.                     +-----Title-----+
  46.                     |               |
  47.                     |               |
  48.                     |               |
  49.                     |               |
  50.                     +---------------+
  51. */
  52. {
  53.     bdbox_od     *bdboxd;
  54.     ocbox         cbox;
  55.     ptd_struct     *ptd;
  56.     int          len, tw;
  57.     byte         attr;
  58.  
  59.     bdboxd = (bdbox_od *)objdata;
  60.  
  61.     switch(msg) {
  62.     case OBJM_GETDATASIZE:
  63.         ((ogds_struct *) outdata)->odsize = sizeof(bdbox_od);
  64.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  65.         ((ogds_struct *) outdata)->id = ID_BDBOX;
  66.         break;
  67.  
  68.     case OBJM_OPEN:
  69.         if (!border_DoRaw(&bdboxd->bdd, msg, indata, outdata)) {
  70.             return(FALSE);
  71.         }
  72.         bord_SetSides(bdboxd->bdd.win, -1, -1, 1, 1);
  73.         break;
  74.  
  75.     case BDM_SETTITLE:
  76.         if (bdboxd->bdd.title != NULL) {
  77.             ofree(OA_BDTITLE, (VOID *) bdboxd->bdd.title);
  78.             bdboxd->bdd.title = NULL;
  79.         }
  80.  
  81.         if (indata != NULL && (bdboxd->bdd.title = (char *) omalloc(OA_BDTITLE, strlen(indata) + 1)) != NULL) {
  82.             strcpy(bdboxd->bdd.title, indata);
  83.         }
  84.         break;
  85.  
  86.     case BDM_SHADOW:
  87.     case BDM_DRAW:
  88.         /* draw the border */
  89.         ptd = (ptd_struct *)indata;
  90.  
  91.         attr = (msg == BDM_DRAW) ? 
  92.             bord_GetAttr(bdboxd->bdd.win) : win_GetShadowAttr(bdboxd->bdd.win);
  93.  
  94.         /* draw the box */
  95.         bord_GetBox(bdboxd->bdd.win, &cbox);
  96.         ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
  97.  
  98.         /* draw the title if there is one */
  99.         if (bdboxd->bdd.title != NULL) {
  100.             tw = win_GetWidth(bdboxd->bdd.win);
  101.             len = strlen(bdboxd->bdd.title);
  102.             len = (len > tw) ? tw : len;
  103.             ptd_DrawString(ptd, -1, (tw - len) / 2, bdboxd->bdd.title, attr, len);
  104.         }
  105.         /* else no break; pass message up to superclass */
  106.  
  107.     default:
  108.         return(border_DoRaw(&bdboxd->bdd, msg, indata, outdata));
  109.     }
  110.     return(1);
  111. }
  112.