home *** CD-ROM | disk | FTP | other *** search
- /*
- bdxref.c 7/07/87
-
- % The help_Xref border.
-
- OWL 1.1
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/06/87 jmd Fixed prompt bug in BD_DRAW
- 11/22/87 jmd Replaced line characters with octal escape sequences
- 8/08/88 jmd Upgraded to new border stuff
- 9/12/88 jmd Added in and out data
- 10/05/88 jmd Prompts now use a fixed data buffer
- 11/13/88 jmd Upgraded to new border stuff
- 11/20/88 jmd Added ID to obj struct
- 12/20/88 jmd removed SETSIZE msg
-
- 5/28/89 jmd added Shadow support
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "bordobj.h"
- #include "bordod.h"
-
- #define HZ_LINE "\304\304\304"
-
- /* border object data */
-
- typedef struct {
- border_od bdd; /* common object super class */
- char prompt[BD_PROMPTLEN + 1]; /* space for prompt */
-
- } bdxref_od;
-
- int bd_xref(objdata, msg, indata, outdata)
- VOID *objdata;
- int msg;
- VOID *indata; /* message input data */
- VOID *outdata; /* message output data */
- /*
- This is the border used by the help_Xref routine.
-
- There a title at the top and
- a prompt line along the bottom.
- The prompt is limited to BD_PROMPTLEN (80) characters in length.
-
- Example: Title
- ----------------------------------------
-
-
- ----------------------------------------
- Prompt
- */
- {
- bdxref_od *bdxrefd;
- ocbox cbox;
- char *p;
- ptd_struct *ptd;
- int l;
- byte attr;
-
- bdxrefd = (bdxref_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdxref_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDXREF;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdxrefd->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
-
- bdxrefd->prompt[0] = '\0';
- bord_SetSides(bdxrefd->bdd.win, -2, 0, 2, 0);
- break;
-
- case BDM_SETTITLE:
- if (bdxrefd->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdxrefd->bdd.title);
- bdxrefd->bdd.title = NULL;
- }
-
- if (indata != NULL) {
- l = strlen((char *) indata);
- if ((bdxrefd->bdd.title = (char *) omalloc(OA_BDTITLE, l + 2)) == NULL) {
- return(FALSE);
- }
- strcpy(bdxrefd->bdd.title, (char *) indata);
-
- /* get rid of '\n' if there is one */
- if (l > 0 && bdxrefd->bdd.title[l-1] == '\n') {
- bdxrefd->bdd.title[l-1] = '\0';
- }
- }
- else {
- bdxrefd->bdd.title = NULL;
- }
- break;
-
- case BDM_PROMPT:
- /* set the border prompt string */
- p = (indata != NULL) ? ((char *) indata) : "";
- strncpy(bdxrefd->prompt, p, BD_PROMPTLEN);
- bdxrefd->prompt[BD_PROMPTLEN] = '\0';
-
- /* update the prompt */
- cbox.toprow = win_GetHeight(bdxrefd->bdd.win) + 1,
- cbox.leftcol = 0;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdxrefd->bdd.win);
- win_PaintBox(bdxrefd->bdd.win, &cbox);
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- ptd = (ptd_struct *)indata;
-
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdxrefd->bdd.win) : win_GetShadowAttr(bdxrefd->bdd.win);
-
- /* Draw the title */
-
- ptd_DrawString(ptd,
- -2,
- 0,
- (bdxrefd->bdd.title == NULL) ? "" : bdxrefd->bdd.title,
- attr,
- win_GetWidth(bdxrefd->bdd.win));
-
-
- /* Draw the two horizontal lines */
- cbox.toprow = -1;
- cbox.leftcol = 0;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdxrefd->bdd.win) - 1;
- ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
-
- cbox.toprow = win_GetHeight(bdxrefd->bdd.win);
- cbox.botrow = cbox.toprow;
- ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
-
- /* Draw the prompt */
- ptd_DrawString(ptd,
- win_GetHeight(bdxrefd->bdd.win) + 1,
- 0,
- bdxrefd->prompt,
- attr,
- win_GetWidth(bdxrefd->bdd.win));
-
- /* else no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdxrefd->bdd, msg, indata, outdata));
- }
-
- return(1);
- }
-
-