home *** CD-ROM | disk | FTP | other *** search
- /*
- bdboxlt.c 7/27/88
-
- % box border with scroll lights.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 9/12/88 jmd Added in and out data
- 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 OUTER_BOX "\332\304\277\263\331\304\300\263"
-
- /* scroll light macros */
- #ifdef BORDER_CHARS
- #define uplight(flag) ((flag) ? "\030" : "\263")
- #define downlight(flag) ((flag) ? "\031" : "\263")
- #else
- #define uplight(flag) ((flag) ? "*" : "\263")
- #define downlight(flag) ((flag) ? "*" : "\263")
- #endif
-
- /* border object data */
-
- typedef struct {
- border_od bdd; /* common object super class */
- boolean up; /* up and down lights */
- boolean down;
- } bdboxlight_od;
-
- int bd_boxlight(objdata, msg, indata, outdata)
- VOID *objdata;
- int msg;
- VOID *indata; /* message input data */
- VOID *outdata; /* message output data */
- /*
- This is a simple single lined border.
- With an overwritten title and scroll lights on the bottom.
- The title is pointed to by the border data pointer.
- Example:
- +-----Title-----+
- | * <--- Scroll Lights
- | |
- | |
- | * <--- Scroll Lights
- +---------------+
-
- */
- {
- bdboxlight_od *bdboxltd;
- ocbox cbox;
- ptd_struct *ptd;
- int tw, len;
- boolean oldup, olddown;
- boolean left, right; /* dummy values */
- byte attr;
-
- bdboxltd = (bdboxlight_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdboxlight_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDBOXLIGHT;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdboxltd->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
- bord_SetSides(bdboxltd->bdd.win, -1, -1, 1, 1);
-
- bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
- break;
-
- case BDM_SETTITLE:
- if (bdboxltd->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdboxltd->bdd.title);
- bdboxltd->bdd.title = NULL;
- }
-
- if (indata != NULL && (bdboxltd->bdd.title = (char *) omalloc(OA_BDTITLE, strlen((char *)indata) + 1)) != NULL) {
- strcpy(bdboxltd->bdd.title, (char *) indata);
- }
- break;
-
- case BDM_RESIZE:
- /* our window has changed size, reset the scroll lights */
- bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
- break;
-
- case BDM_SCROLL:
- /* adjust the up and down lights */
- oldup = bdboxltd->up;
- olddown = bdboxltd->down;
- bord_GetLights(bdboxltd->bdd.win, &bdboxltd->up, &bdboxltd->down, &left, &right);
-
- /* Only paint if arrows have changed */
- if (oldup != bdboxltd->up || olddown != bdboxltd->down) {
- /* paint up arrow */
- cbox.toprow = 0;
- cbox.leftcol = win_GetWidth(bdboxltd->bdd.win);
- cbox.botrow = cbox.toprow;
- cbox.rightcol = cbox.leftcol;
- win_PaintBox(bdboxltd->bdd.win, &cbox);
-
- /* paint down arrow */
- cbox.toprow = win_GetHeight(bdboxltd->bdd.win) - 1;
- cbox.botrow = cbox.toprow;
- win_PaintBox(bdboxltd->bdd.win, &cbox);
- }
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- /* draw the border */
- ptd = (ptd_struct *)indata;
-
- /* draw the box */
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdboxltd->bdd.win) : win_GetShadowAttr(bdboxltd->bdd.win);
-
- bord_GetBox(bdboxltd->bdd.win, &cbox);
- ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
-
- /* draw the title if there is one */
- if (bdboxltd->bdd.title != NULL) {
- tw = win_GetWidth(bdboxltd->bdd.win);
- len = strlen(bdboxltd->bdd.title);
- len = (len > tw) ? tw : len;
- ptd_DrawString(ptd, -1, (tw - len) / 2, bdboxltd->bdd.title, attr, len);
- }
-
- /* draw the scroll lights */
- /* uplight */
- ptd_DrawString(ptd, 0, win_GetWidth(bdboxltd->bdd.win), uplight(bdboxltd->up), attr, 1);
-
- /* downlight */
- ptd_DrawString(ptd, win_GetHeight(bdboxltd->bdd.win) - 1, win_GetWidth(bdboxltd->bdd.win), downlight(bdboxltd->down), attr, 1);
-
- /* else no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdboxltd->bdd, msg, indata, outdata));
- }
- return(1);
- }
-
-