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

  1. /*
  2.     bdboxlt.c    7/27/88
  3.  
  4.     % box border with scroll lights.
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1988, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      9/12/88 jmd    Added in and out data
  13.     11/13/88 jmd    Upgraded to new border stuff
  14.     11/20/88 jmd    Added ID to obj struct
  15.     12/20/88 jmd    removed SETSIZE msg
  16.  
  17.      5/28/89 jmd    added Shadow support
  18. */
  19.  
  20. #include "oakhead.h"
  21. #include "disppriv.h"
  22. #include "bordobj.h"
  23. #include "bordod.h"
  24.  
  25. #define OUTER_BOX     "\332\304\277\263\331\304\300\263"
  26.  
  27. /* scroll light macros */
  28. #ifdef BORDER_CHARS
  29. #define    uplight(flag)    ((flag) ? "\030" : "\263")
  30. #define    downlight(flag)    ((flag) ? "\031" : "\263")
  31. #else
  32. #define    uplight(flag)    ((flag) ? "*" : "\263")
  33. #define    downlight(flag)    ((flag) ? "*" : "\263")
  34. #endif
  35.  
  36. /* border object data */
  37.  
  38. typedef struct {
  39.     border_od    bdd;              /* common object super class */
  40.     boolean      up;                /* up and down lights */
  41.     boolean        down;
  42. } bdboxlight_od;
  43.  
  44. int bd_boxlight(objdata, msg, indata, outdata)
  45.     VOID *objdata;
  46.     int msg;
  47.     VOID *indata;                /* message input data */
  48.     VOID *outdata;                /* message output data */
  49. /*
  50.     This is a simple single lined border.
  51.     With an overwritten title and scroll lights on the bottom.
  52.     The title is pointed to by the border data pointer.
  53.     Example:
  54.                      +-----Title-----+
  55.                      |               *  <--- Scroll Lights
  56.                      |               |
  57.                      |               |
  58.                      |               *  <--- Scroll Lights
  59.                      +---------------+
  60.  
  61. */
  62. {
  63.     bdboxlight_od     *bdboxltd;
  64.     ocbox        cbox;
  65.     ptd_struct *ptd;
  66.     int            tw, len;
  67.     boolean        oldup, olddown;
  68.     boolean        left, right;        /* dummy values */
  69.     byte        attr;
  70.  
  71.     bdboxltd = (bdboxlight_od *)objdata;
  72.  
  73.     switch(msg) {
  74.     case OBJM_GETDATASIZE:
  75.         ((ogds_struct *) outdata)->odsize = sizeof(bdboxlight_od);
  76.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  77.         ((ogds_struct *) outdata)->id = ID_BDBOXLIGHT;
  78.         break;
  79.  
  80.     case OBJM_OPEN:
  81.         if (!border_DoRaw(&bdboxltd->bdd, msg, indata, outdata)) {
  82.             return(FALSE);
  83.         }
  84.         bord_SetSides(bdboxltd->bdd.win, -1, -1, 1, 1);
  85.  
  86.         bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
  87.         break;
  88.  
  89.     case BDM_SETTITLE:
  90.         if (bdboxltd->bdd.title != NULL) {
  91.             ofree(OA_BDTITLE, (VOID *) bdboxltd->bdd.title);
  92.             bdboxltd->bdd.title = NULL;
  93.         }
  94.  
  95.         if (indata != NULL && (bdboxltd->bdd.title = (char *) omalloc(OA_BDTITLE, strlen((char *)indata) + 1)) != NULL) {
  96.             strcpy(bdboxltd->bdd.title, (char *) indata);
  97.         }
  98.         break;
  99.  
  100.     case BDM_RESIZE:
  101.         /* our window has changed size, reset the scroll lights */
  102.         bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
  103.         break;
  104.  
  105.     case BDM_SCROLL:
  106.         /* adjust the up and down lights */
  107.         oldup = bdboxltd->up;
  108.         olddown = bdboxltd->down;
  109.         bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
  110.  
  111.         /* Only paint if arrows have changed */
  112.         if (oldup != bdboxltd->up || olddown != bdboxltd->down) {
  113.             /* paint up arrow */
  114.             cbox.toprow   = 0;
  115.             cbox.leftcol  = win_GetWidth(bdboxltd->bdd.win);
  116.             cbox.botrow   = cbox.toprow;
  117.             cbox.rightcol = cbox.leftcol;
  118.             win_PaintBox(bdboxltd->bdd.win, &cbox);
  119.             
  120.             /* paint down arrow */
  121.             cbox.toprow   = win_GetHeight(bdboxltd->bdd.win) - 1;
  122.             cbox.botrow   = cbox.toprow;
  123.             win_PaintBox(bdboxltd->bdd.win, &cbox);
  124.         }
  125.         break;
  126.  
  127.     case BDM_SHADOW:
  128.     case BDM_DRAW:
  129.         /* draw the border */
  130.         ptd = (ptd_struct *)indata;
  131.  
  132.         /* draw the box */
  133.         attr = (msg == BDM_DRAW) ? 
  134.             bord_GetAttr(bdboxltd->bdd.win) : win_GetShadowAttr(bdboxltd->bdd.win);
  135.  
  136.         bord_GetBox(bdboxltd->bdd.win, &cbox);
  137.         ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
  138.  
  139.         /* draw the title if there is one */
  140.         if (bdboxltd->bdd.title != NULL) {
  141.             tw = win_GetWidth(bdboxltd->bdd.win);
  142.             len = strlen(bdboxltd->bdd.title);
  143.             len = (len > tw) ? tw : len;
  144.             ptd_DrawString(ptd, -1, (tw - len) / 2, bdboxltd->bdd.title, attr, len);
  145.         }
  146.  
  147.         /* draw the scroll lights */
  148.         /* uplight */
  149.         ptd_DrawString(ptd, 0, win_GetWidth(bdboxltd->bdd.win), uplight(bdboxltd->up), attr, 1);
  150.  
  151.         /* downlight */
  152.         ptd_DrawString(ptd, win_GetHeight(bdboxltd->bdd.win) - 1, win_GetWidth(bdboxltd->bdd.win), downlight(bdboxltd->down), attr, 1);
  153.  
  154.         /* else no break; pass message up to superclass */
  155.  
  156.     default:
  157.         return(border_DoRaw(&bdboxltd->bdd, msg, indata, outdata));
  158.     }
  159.     return(1);
  160. }
  161.  
  162.