home *** CD-ROM | disk | FTP | other *** search
- /*
- bdhead.c 8/24/89
-
- % a border with a title and line along the top and no side or bottom
-
- OWL 1.1
- Copyright (c) 1989, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #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 */
- } bdhead_od;
-
- int bd_head(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
- -----------------
-
- */
- {
- bdhead_od *bdheadd;
- ocbox cbox;
- ptd_struct *ptd;
- int len;
- byte attr;
-
- bdheadd = (bdhead_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdhead_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDHEAD;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdheadd->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
-
- bord_SetSides(bdheadd->bdd.win, -2, 0, 0, 0);
- break;
-
- case BDM_SETTITLE:
- if (bdheadd->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdheadd->bdd.title);
- bdheadd->bdd.title = NULL;
- }
-
- if (indata != NULL) {
- len = strlen((char *) indata);
- if ((bdheadd->bdd.title = (char *) omalloc(OA_BDTITLE, len + 2)) == NULL) {
- return(FALSE);
- }
- strcpy(bdheadd->bdd.title, (char *) indata);
-
- /* get rid of '\n' if there is one */
- if (len > 0 && bdheadd->bdd.title[len-1] == '\n') {
- bdheadd->bdd.title[len-1] = '\0';
- }
- }
- else {
- bdheadd->bdd.title = NULL;
- }
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- ptd = (ptd_struct *)indata;
-
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdheadd->bdd.win) : win_GetShadowAttr(bdheadd->bdd.win);
-
- /* Draw the title */
-
- ptd_DrawString(ptd,
- -2,
- 0,
- (bdheadd->bdd.title == NULL) ? "" : bdheadd->bdd.title,
- attr,
- win_GetWidth(bdheadd->bdd.win));
-
-
- /* Draw the horizontal lines */
- cbox.toprow = -1;
- cbox.leftcol = 0;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdheadd->bdd.win) - 1;
- ptd_DrawCharLine(ptd, HZ_LINE, &cbox, attr);
-
- /* else no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdheadd->bdd, msg, indata, outdata));
- }
- return(1);
- }
-
-