home *** CD-ROM | disk | FTP | other *** search
- /*
- bdbox.c 11/19/87
-
- % single lined border with overwritten title routine.
-
- OWL 1.1
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 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
- 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"
-
- /* border object data */
-
- typedef struct {
- border_od bdd; /* common object super class */
- } bdbox_od;
-
- int bd_box(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.
- The title is pointed to by the border data pointer.
- Example:
- +-----Title-----+
- | |
- | |
- | |
- | |
- +---------------+
- */
- {
- bdbox_od *bdboxd;
- ocbox cbox;
- ptd_struct *ptd;
- int len, tw;
- byte attr;
-
- bdboxd = (bdbox_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdbox_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDBOX;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdboxd->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
- bord_SetSides(bdboxd->bdd.win, -1, -1, 1, 1);
- break;
-
- case BDM_SETTITLE:
- if (bdboxd->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdboxd->bdd.title);
- bdboxd->bdd.title = NULL;
- }
-
- if (indata != NULL && (bdboxd->bdd.title = (char *) omalloc(OA_BDTITLE, strlen(indata) + 1)) != NULL) {
- strcpy(bdboxd->bdd.title, indata);
- }
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- /* draw the border */
- ptd = (ptd_struct *)indata;
-
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdboxd->bdd.win) : win_GetShadowAttr(bdboxd->bdd.win);
-
- /* draw the box */
- bord_GetBox(bdboxd->bdd.win, &cbox);
- ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
-
- /* draw the title if there is one */
- if (bdboxd->bdd.title != NULL) {
- tw = win_GetWidth(bdboxd->bdd.win);
- len = strlen(bdboxd->bdd.title);
- len = (len > tw) ? tw : len;
- ptd_DrawString(ptd, -1, (tw - len) / 2, bdboxd->bdd.title, attr, len);
- }
- /* else no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdboxd->bdd, msg, indata, outdata));
- }
- return(1);
- }
-