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

  1. /*
  2.     bdxref.c    7/07/87
  3.  
  4.     % The help_Xref border.
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1986, 1987, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      8/06/87 jmd    Fixed prompt bug in BD_DRAW
  13.     11/22/87 jmd     Replaced line characters with octal escape sequences
  14.      8/08/88 jmd     Upgraded to new border stuff
  15.      9/12/88 jmd    Added in and out data
  16.     10/05/88 jmd    Prompts now use a fixed data buffer
  17.     11/13/88 jmd    Upgraded to new border stuff
  18.     11/20/88 jmd    Added ID to obj struct
  19.     12/20/88 jmd    removed SETSIZE msg
  20.  
  21.      5/28/89 jmd    added Shadow support
  22. */
  23.  
  24. #include "oakhead.h"
  25. #include "disppriv.h"
  26. #include "bordobj.h"
  27. #include "bordod.h"
  28.  
  29. #define HZ_LINE        "\304\304\304"
  30.  
  31. /* border object data */
  32.  
  33. typedef struct {
  34.     border_od    bdd;                          /* common object super class */
  35.     char         prompt[BD_PROMPTLEN + 1];    /* space for prompt */
  36.  
  37. } bdxref_od;
  38.  
  39. int bd_xref(objdata, msg, indata, outdata)
  40.     VOID *objdata;
  41.     int msg;
  42.     VOID *indata;                /* message input data */
  43.     VOID *outdata;                /* message output data */
  44. /*
  45.     This is the border used by the help_Xref routine.
  46.  
  47.     There a title at the top and
  48.     a prompt line along the bottom.
  49.     The prompt is limited to BD_PROMPTLEN (80) characters in length.
  50.  
  51.     Example:            Title
  52.                         ----------------------------------------
  53.                         
  54.  
  55.                         ----------------------------------------
  56.                         Prompt
  57. */
  58. {
  59.     bdxref_od  *bdxrefd;
  60.     ocbox        cbox;
  61.     char          *p;    
  62.     ptd_struct *ptd;
  63.     int            l;
  64.     byte        attr;
  65.  
  66.     bdxrefd = (bdxref_od *)objdata;
  67.     
  68.     switch(msg) {
  69.     case OBJM_GETDATASIZE:
  70.         ((ogds_struct *) outdata)->odsize = sizeof(bdxref_od);
  71.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  72.         ((ogds_struct *) outdata)->id = ID_BDXREF;
  73.         break;
  74.  
  75.     case OBJM_OPEN:
  76.         if (!border_DoRaw(&bdxrefd->bdd, msg, indata, outdata)) {
  77.             return(FALSE);
  78.         }
  79.  
  80.         bdxrefd->prompt[0] = '\0';
  81.         bord_SetSides(bdxrefd->bdd.win, -2, 0, 2, 0);
  82.         break;
  83.  
  84.     case BDM_SETTITLE:
  85.         if (bdxrefd->bdd.title != NULL) {
  86.             ofree(OA_BDTITLE, (VOID *) bdxrefd->bdd.title);
  87.             bdxrefd->bdd.title = NULL;
  88.         }
  89.  
  90.         if (indata != NULL) {
  91.             l = strlen((char *) indata);
  92.             if ((bdxrefd->bdd.title = (char *) omalloc(OA_BDTITLE, l + 2)) == NULL) {
  93.                 return(FALSE);
  94.             }
  95.             strcpy(bdxrefd->bdd.title, (char *) indata);
  96.  
  97.             /* get rid of '\n' if there is one */
  98.             if (l > 0 && bdxrefd->bdd.title[l-1] == '\n') {
  99.                 bdxrefd->bdd.title[l-1] = '\0';
  100.             }
  101.         }
  102.         else {
  103.             bdxrefd->bdd.title = NULL;
  104.         }
  105.         break;
  106.  
  107.     case BDM_PROMPT:
  108.         /* set the border prompt string */
  109.         p = (indata != NULL) ? ((char *) indata) : "";
  110.         strncpy(bdxrefd->prompt, p, BD_PROMPTLEN);
  111.         bdxrefd->prompt[BD_PROMPTLEN] = '\0';
  112.  
  113.         /* update the prompt */
  114.         cbox.toprow   = win_GetHeight(bdxrefd->bdd.win) + 1,
  115.         cbox.leftcol  = 0;
  116.         cbox.botrow   = cbox.toprow;
  117.         cbox.rightcol = win_GetWidth(bdxrefd->bdd.win);
  118.         win_PaintBox(bdxrefd->bdd.win, &cbox);
  119.         break;
  120.  
  121.     case BDM_SHADOW:
  122.     case BDM_DRAW:
  123.         ptd = (ptd_struct *)indata;
  124.  
  125.         attr = (msg == BDM_DRAW) ? 
  126.             bord_GetAttr(bdxrefd->bdd.win) : win_GetShadowAttr(bdxrefd->bdd.win);
  127.  
  128.         /* Draw the title */
  129.  
  130.         ptd_DrawString(ptd,
  131.                        -2,
  132.                         0,
  133.                         (bdxrefd->bdd.title == NULL) ? "" : bdxrefd->bdd.title,
  134.                         attr,
  135.                         win_GetWidth(bdxrefd->bdd.win));
  136.  
  137.  
  138.         /* Draw the two horizontal lines */
  139.         cbox.toprow   = -1;
  140.         cbox.leftcol  = 0;
  141.         cbox.botrow   = cbox.toprow;
  142.         cbox.rightcol = win_GetWidth(bdxrefd->bdd.win) - 1;
  143.         ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
  144.  
  145.         cbox.toprow   = win_GetHeight(bdxrefd->bdd.win);
  146.         cbox.botrow   = cbox.toprow;
  147.         ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
  148.  
  149.         /* Draw the prompt */
  150.         ptd_DrawString(ptd,
  151.                         win_GetHeight(bdxrefd->bdd.win) + 1,
  152.                         0,
  153.                         bdxrefd->prompt,
  154.                         attr,
  155.                         win_GetWidth(bdxrefd->bdd.win));
  156.  
  157.         /* else no break; pass message up to superclass */
  158.  
  159.     default:
  160.         return(border_DoRaw(&bdxrefd->bdd, msg, indata, outdata));
  161.     }
  162.  
  163.     return(1);
  164. }
  165.  
  166.