home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / BDXREF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-23  |  4.0 KB  |  164 lines

  1. /*
  2.     bdxref.c    7/07/87
  3.  
  4.     % The help_Xref border.
  5.  
  6.     OWL 1.2
  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.     11/06/89 jmd    removed DoRaw macros
  24.      2/21/90 ted    Added SetCharSize(TRUE) because border won't work otherwise.
  25.      3/28/90 jmd    ansi-fied
  26. */
  27.  
  28. #include "oakhead.h"
  29. #include "disppriv.h"
  30. #include "bordobj.h"
  31. #include "bordod.h"
  32.  
  33. #define HZ_LINE        "\304\304\304"
  34.  
  35. /* border object data */
  36.  
  37. typedef struct _bdxrefod {
  38.     border_od    bdd;                          /* common object super class */
  39.     char         prompt[BD_PROMPTLEN + 1];    /* space for prompt */
  40.  
  41. } bdxref_od;
  42.  
  43. int bd_xref(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  44. /*
  45.     This is the border used by the help_Xref routine.
  46.     There a title at the top and
  47.     a prompt line along the bottom.
  48.     The prompt is limited to BD_PROMPTLEN (80) characters in length.
  49.     Example:            Title
  50.                         ----------------------------------------
  51.                         
  52.                         ----------------------------------------
  53.                         Prompt
  54. */
  55. {
  56.     bdxref_od  *bdxrefd;
  57.     ocbox        cbox;
  58.     char          *p;    
  59.     ptd_struct *ptd;
  60.     int            l;
  61.     byte        attr;
  62.  
  63.     bdxrefd = (bdxref_od *)objdata;
  64.     
  65.     switch(msg) {
  66.     case OBJM_GETDATASIZE:
  67.         ((ogds_struct *) outdata)->odsize = sizeof(bdxref_od);
  68.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  69.         ((ogds_struct *) outdata)->id = ID_BDXREF;
  70.         break;
  71.  
  72.     case OBJM_OPEN:
  73.         if (!border_Class(&bdxrefd->bdd, msg, indata, outdata)) {
  74.             return(FALSE);
  75.         }
  76.  
  77.         bdxrefd->prompt[0] = '\0';
  78.         win_SetCharSize(bdxrefd->bdd.win, TRUE);    /* This bord must be charsize */
  79.         bord_SetSides(bdxrefd->bdd.win, -2, 0, 2, 0);
  80.         break;
  81.  
  82.     case BDM_SETTITLE:
  83.         if (bdxrefd->bdd.title != NULL) {
  84.             ofree(OA_BDTITLE, (VOID *) bdxrefd->bdd.title);
  85.             bdxrefd->bdd.title = NULL;
  86.         }
  87.  
  88.         if (indata != NULL) {
  89.             l = strlen((char *) indata);
  90.             if ((bdxrefd->bdd.title = (char *) omalloc(OA_BDTITLE, l + 2)) == NULL) {
  91.                 return(FALSE);
  92.             }
  93.             strcpy(bdxrefd->bdd.title, (char *) indata);
  94.  
  95.             /* get rid of '\n' if there is one */
  96.             if (l > 0 && bdxrefd->bdd.title[l-1] == '\n') {
  97.                 bdxrefd->bdd.title[l-1] = '\0';
  98.             }
  99.         }
  100.         else {
  101.             bdxrefd->bdd.title = NULL;
  102.         }
  103.         break;
  104.  
  105.     case BDM_PROMPT:
  106.         /* set the border prompt string */
  107.         p = (indata != NULL) ? ((char *) indata) : "";
  108.         strncpy(bdxrefd->prompt, p, BD_PROMPTLEN);
  109.         bdxrefd->prompt[BD_PROMPTLEN] = '\0';
  110.  
  111.         /* update the prompt */
  112.         cbox.toprow   = win_GetHeight(bdxrefd->bdd.win) + 1,
  113.         cbox.leftcol  = 0;
  114.         cbox.botrow   = cbox.toprow;
  115.         cbox.rightcol = win_GetWidth(bdxrefd->bdd.win);
  116.         win_PaintBox(bdxrefd->bdd.win, &cbox);
  117.         break;
  118.  
  119.     case BDM_SHADOW:
  120.     case BDM_DRAW:
  121.         ptd = (ptd_struct *)indata;
  122.  
  123.         attr = (msg == BDM_DRAW) ? 
  124.             bord_GetAttr(bdxrefd->bdd.win) : win_GetShadowAttr(bdxrefd->bdd.win);
  125.  
  126.         /* Draw the title */
  127.  
  128.         ptd_DrawString(ptd,
  129.                        -2,
  130.                         0,
  131.                         (bdxrefd->bdd.title == NULL) ? "" : bdxrefd->bdd.title,
  132.                         attr,
  133.                         win_GetWidth(bdxrefd->bdd.win));
  134.  
  135.  
  136.         /* Draw the two horizontal lines */
  137.         cbox.toprow   = -1;
  138.         cbox.leftcol  = 0;
  139.         cbox.botrow   = cbox.toprow;
  140.         cbox.rightcol = win_GetWidth(bdxrefd->bdd.win) - 1;
  141.         ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
  142.  
  143.         cbox.toprow   = win_GetHeight(bdxrefd->bdd.win);
  144.         cbox.botrow   = cbox.toprow;
  145.         ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
  146.  
  147.         /* Draw the prompt */
  148.         ptd_DrawString(ptd,
  149.                         win_GetHeight(bdxrefd->bdd.win) + 1,
  150.                         0,
  151.                         bdxrefd->prompt,
  152.                         attr,
  153.                         win_GetWidth(bdxrefd->bdd.win));
  154.  
  155.         /* else no break; pass message up to superclass */
  156.  
  157.     default:
  158.         return(border_Class(&bdxrefd->bdd, msg, indata, outdata));
  159.     }
  160.  
  161.     return(1);
  162. }
  163.  
  164.