home *** CD-ROM | disk | FTP | other *** search
- /*
- bdstd.c 2/16/87
-
- % the standard border with title, message line, and scroll lights.
-
- OWL 1.1
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 7/16/87 jmd Fixed bug in BD_CLOSE (free'd wrong thing !)
- 11/22/87 jmd Replaced line characters with octal escape sequences
- 7/27/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 "strdecl.h" /* for strwrap() */
- #include "bordobj.h"
- #include "bordod.h"
-
- #define OUTER_BOX "\332\304\267\272\274\315\324\263"
- #define HZ_LINE "\303\304\266"
- #define VT_LINE "\263\263\263"
-
- /* scroll light macros */
- #ifdef BORDER_CHARS
- # define uplight(flag) ((flag) ? "\x1e" : " ")
- # define downlight(flag) ((flag) ? "\x1f" : " ")
- #else
- # define uplight(flag) ((flag) ? "*" : " ")
- # define downlight(flag) ((flag) ? "*" : " ")
- #endif
-
- /* border object data */
-
- typedef struct {
- border_od bdd; /* border object super class */
- char prompt[BD_PROMPTLEN + 1]; /* space for border prompt */
- boolean up; /* up and down lights */
- boolean down;
- int theight; /* title height */
- } bdstd_od;
-
- int bd_std(objdata, msg, indata, outdata)
- VOID *objdata;
- int msg;
- VOID *indata; /* message input data */
- VOID *outdata; /* message output data */
- /*
- This is the standard border used by some C-scape library
- routines.
- It is a border with double lines on the right and lower
- sides and single lines on the left and top sides.
- There is a title and two "lights" (defined in bdf_struct).
- The title is a string of varying length with '\n's at the
- end of each line.
- The up light and down light are booleans. They are
- designed to display up and down arrows to indicate whether or
- not there is more text to display in the enclosed sed.
- A TRUE value indicates that the light should be visible.
-
- There is a line on the bottom of the border reserved
- for a message. sed_BorderPrompt() can be used to display
- a message here.
- The prompt is limited to BD_PROMPTLEN (80) characters in length.
-
- Example:
- +---------------+
- | Title |
- |---------------|
- Up light -----> |*| |
- | | |
- Down light ---> |*| |
- +---------------+
- | Prompt |
- +---------------+
- */
- {
- bdstd_od *bdstdd;
- ocbox cbox;
- ptd_struct *ptd;
- int tw;
- char *p;
- boolean oldup, olddown;
- boolean left, right; /* dummy values */
- byte attr;
-
- bdstdd = (bdstd_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdstd_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDSTD;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdstdd->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
-
- bdstdd->prompt[0] = '\0';
- bdstdd->theight = 0;
- bord_SetSides(bdstdd->bdd.win, - (bdstdd->theight + 1), -3, 3, 1);
- bord_GetLights(bdstdd->bdd.win, &bdstdd->up, &bdstdd->down, &left, &right);
- break;
-
- case BDM_RESIZE:
- /* our window has changed size, reset the scroll lights */
- bord_GetLights(bdstdd->bdd.win, &bdstdd->up, &bdstdd->down, &left, &right);
- break;
-
- case BDM_PROMPT:
- /* set the border prompt string */
- p = (indata != NULL) ? ((char *) indata) : "";
-
- /* Test if prompt has changed */
- if (strcmp(p, bdstdd->prompt) != 0) {
- strncpy(bdstdd->prompt, p, BD_PROMPTLEN);
- bdstdd->prompt[BD_PROMPTLEN] = '\0';
-
- /* update the prompt */
- cbox.toprow = win_GetHeight(bdstdd->bdd.win) + 1;
- cbox.leftcol = -2;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdstdd->bdd.win);
- win_PaintBox(bdstdd->bdd.win, &cbox);
- }
- break;
-
- case BDM_SETTITLE:
- if (bdstdd->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdstdd->bdd.title);
- bdstdd->bdd.title = NULL;
- }
-
- if (indata == NULL) {
- bdstdd->theight = 0;
- bord_SetSides(bdstdd->bdd.win, - (bdstdd->theight + 1), -3, 3, 1);
- break;
- }
-
- tw = win_GetWidth(bdstdd->bdd.win) + 1;
- if ((bdstdd->bdd.title = strwrap((char *) indata, &bdstdd->theight, tw)) == NULL) {
- return(FALSE);
- }
-
- /* add for line at bottom of title */
- (bdstdd->theight)++;
-
- /* adjust the border size */
- bord_SetSides(bdstdd->bdd.win, - (bdstdd->theight + 1), -3, 3, 1);
- break;
-
- case BDM_SCROLL:
- /* adjust the up and down lights */
- oldup = bdstdd->up;
- olddown = bdstdd->down;
- bord_GetLights(bdstdd->bdd.win, &bdstdd->up, &bdstdd->down, &left, &right);
-
- /* Only paint if arrows have changed */
- if (oldup != bdstdd->up || olddown != bdstdd->down) {
-
- /* paint up arrow */
- cbox.toprow = 0;
- cbox.leftcol = -2;
- cbox.botrow = 0;
- cbox.rightcol = -2;
- win_PaintBox(bdstdd->bdd.win, &cbox);
-
- /* paint down arrow */
- cbox.toprow = win_GetHeight(bdstdd->bdd.win) - 1;
- cbox.botrow = cbox.toprow;
- win_PaintBox(bdstdd->bdd.win, &cbox);
- }
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- /* draw the border */
- ptd = (ptd_struct *)indata;
-
- /* draw the outer box */
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdstdd->bdd.win) : win_GetShadowAttr(bdstdd->bdd.win);
-
- bord_GetBox(bdstdd->bdd.win, &cbox);
- ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
-
- /* draw the vertical bars */
- cbox.toprow = 0;
- cbox.leftcol = -1;
- cbox.botrow = win_GetHeight(bdstdd->bdd.win) - 1;
- cbox.rightcol = -1;
- ptd_DrawCharLine(ptd, VT_LINE, &cbox, attr);
-
- cbox.leftcol = -2; /* top and bottom don't change */
- cbox.rightcol = -2;
- ptd_DrawCharLine(ptd, " ", &cbox, attr);
-
- /* draw the scroll lights */
- /* uplight */
- ptd_DrawString(ptd, 0, -2, uplight(bdstdd->up), attr, 1);
- /* downlight */
- ptd_DrawString(ptd, cbox.botrow, -2, downlight(bdstdd->down), attr, 1);
-
- /* draw the title if there is one */
- if (bdstdd->bdd.title != NULL) {
- /* draw the horizontal bar */
- cbox.toprow = -1;
- cbox.leftcol = -3;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdstdd->bdd.win);
- ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
-
- tw = win_GetWidth(bdstdd->bdd.win) + 2;
- bord_DrawTitle(ptd, -bdstdd->theight, -2, bdstdd->bdd.title, attr, tw);
- }
-
- /* draw the prompt */
- ptd_DrawString(ptd,
- win_GetHeight(bdstdd->bdd.win) + 1,
- -2,
- bdstdd->prompt,
- attr,
- win_GetWidth(bdstdd->bdd.win) + 2);
-
- /* draw the bottom horizontal bar */
- cbox.toprow = win_GetHeight(bdstdd->bdd.win);
- cbox.leftcol = -3;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdstdd->bdd.win);
- ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
-
- /* else no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdstdd->bdd, msg, indata, outdata));
- }
- return(1);
- }
-
-