home *** CD-ROM | disk | FTP | other *** search
- /*
- bdprompt.c 12/16/88
-
- % box border with title and prompt
-
- 12/19/88 by Ted.
- Extracted from bdmouse for the purpose of inheriting it back in.
-
- OWL 1.1
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 5/28/89 jmd added Shadow support
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "strdecl.h"
-
- #include "bordobj.h"
- #include "bdpromod.h"
-
- #define OUTER_BOX "\332\304\277\263\331\304\300\263"
-
- enum action_flag { ACT_NO, ACT_SCROLL, ACT_MOVE,
- ACT_SIZE1, ACT_SIZE2, ACT_SIZE3, ACT_SIZE4 };
- /* -------------------------------------------------------------------------- */
-
- int bd_prompt(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 prompt.
- The title is pointed to by the border data pointer.
- Example:
- +-----Title-----+
- | |
- | |
- | |
- | |
- +Prompt---------+
- */
- {
- bdprompt_od *bdpromod;
- ocbox cbox;
- ptd_struct *ptd;
- char *p;
- int width;
- byte attr;
-
- bdpromod = (bdprompt_od *)objdata;
-
- switch(msg) {
- case OBJM_GETDATASIZE:
- ((ogds_struct *) outdata)->odsize = sizeof(bdprompt_od);
- ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
- ((ogds_struct *) outdata)->id = ID_BDPROMPT;
- break;
-
- case OBJM_OPEN:
- if (!border_DoRaw(&bdpromod->bdd, msg, indata, outdata)) {
- return(FALSE);
- }
- bdpromod->prompt[0] = '\0';
-
- bord_SetSides(bdpromod->bdd.win, -1, -1, 1, 1);
- /* No break; fall through to set size */
-
- case BDM_RESIZE:
- /* Reset width of prompt and title */
- width = win_GetWidth(bdpromod->bdd.win);
- bdpromod->plen = int_min(width, strlen(bdpromod->prompt));
- bdpromod->tlen = int_min(width,
- ((bdpromod->bdd.title == NULL) ? 0 : strlen(bdpromod->bdd.title)));
- break;
-
- case BDM_SETTITLE:
- if (bdpromod->bdd.title != NULL) {
- ofree(OA_BDTITLE, (VOID *) bdpromod->bdd.title);
- bdpromod->bdd.title = NULL;
- }
-
- if (indata != NULL && (bdpromod->bdd.title = (char *) omalloc(OA_BDTITLE, strlen((char *)indata) + 1)) != NULL) {
- strcpy(bdpromod->bdd.title, (char *) indata);
- bdpromod->tlen = int_min(win_GetWidth(bdpromod->bdd.win), strlen(bdpromod->bdd.title));
- }
- break;
-
- case BDM_PROMPT:
- /* set the border prompt string */
- p = (indata != NULL) ? ((char *) indata) : "";
-
- /* Test if prompt has changed */
- if (strcmp(p, bdpromod->prompt) != 0) {
- strncpy(bdpromod->prompt, p, BD_PROMPTLEN);
- bdpromod->prompt[BD_PROMPTLEN] = '\0';
- bdpromod->plen = int_min(win_GetWidth(bdpromod->bdd.win),
- strlen(bdpromod->prompt));
- /* Update the prompt */
- cbox.toprow = win_GetHeight(bdpromod->bdd.win);
- cbox.leftcol = 0;
- cbox.botrow = cbox.toprow;
- cbox.rightcol = win_GetWidth(bdpromod->bdd.win) - 1;
- win_PaintBox(bdpromod->bdd.win, &cbox);
- }
- break;
-
- case BDM_SHADOW:
- case BDM_DRAW:
- /* Draw the border */
- ptd = (ptd_struct *)indata;
- width = win_GetWidth(bdpromod->bdd.win);
- attr = (msg == BDM_DRAW) ?
- bord_GetAttr(bdpromod->bdd.win) : win_GetShadowAttr(bdpromod->bdd.win);
-
- /* draw the box */
- bord_GetBox(bdpromod->bdd.win, &cbox);
- ptd_DrawCharBox(ptd, OUTER_BOX, &cbox, attr);
-
- /* Draw the title if there is one */
- if (bdpromod->bdd.title != NULL) {
- ptd_DrawString(ptd, -1, (width - bdpromod->tlen) / 2,
- bdpromod->bdd.title, attr, bdpromod->tlen);
- }
- /* Draw the prompt */
- ptd_DrawString(ptd, win_GetHeight(bdpromod->bdd.win), 0,
- bdpromod->prompt, attr, bdpromod->plen);
-
- /* no break; pass message up to superclass */
-
- default:
- return(border_DoRaw(&bdpromod->bdd, msg, indata, outdata));
- }
- return(1);
- }
- /* -------------------------------------------------------------------------- */
-
-