home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / BDNULL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.1 KB  |  120 lines

  1. /*
  2.     bdnull.c    5/07/87
  3.  
  4.     % The null border.
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1986, 1987, by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      8/08/88 jmd     Upgraded to new border stuff
  13.      9/12/88 jmd    Added in and out data
  14.     10/05/88 jmd    Prompts now use a fixed (allocated) data buffer
  15.     11/15/88 jmd    Prompts now use a cmap window
  16.     11/20/88 jmd    Added ID to obj struct
  17.      8/08/89 jmd    Prompts now the new msg window
  18. */
  19.  
  20. #include "oakhead.h"
  21. #include "disppriv.h"
  22. #include "msgwin.h"
  23. #include "bordobj.h"
  24. #include "bordod.h"
  25.  
  26. /* border object data */
  27.  
  28. typedef struct {
  29.     border_od    bdd;                          /* common object super class */
  30.     win_type     msgwin;                        /* prompt window */
  31.     char         prompt[BD_PROMPTLEN + 1];    /* space for border prompt */
  32. } bdnull_od;
  33.  
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. int bd_null(objdata, msg, indata, outdata)
  37.     VOID *objdata;
  38.     int msg;
  39.     VOID *indata;                /* message input data */
  40.     VOID *outdata;                /* message output data */
  41. /*
  42.     This is the "null" border used by some C-scape library
  43.     routines.
  44.     It is actully not a border but simply a function that 
  45.     will intercept requests to display prompt strings and place 
  46.     them in a window on the bottom line of the display.
  47.  
  48.     The prompt is limited to the width of the display.
  49. */
  50. {
  51.     bdnull_od      *bdnulld;
  52.     char              *p;
  53.     ocbox         cbox;
  54.  
  55.     bdnulld = (bdnull_od *)objdata;
  56.  
  57.     switch(msg) {
  58.     case OBJM_GETDATASIZE:
  59.         ((ogds_struct *) outdata)->odsize = sizeof(bdnull_od);
  60.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  61.         ((ogds_struct *) outdata)->id = ID_BDNULL;
  62.         break;
  63.  
  64.     case OBJM_OPEN:
  65.         if (!border_DoRaw(&bdnulld->bdd, msg, indata, outdata)) {
  66.             return(FALSE);
  67.         }
  68.  
  69.         /* open a msgwin for the prompt */
  70.         cbox.toprow   = disp_GetHeight() - 1;
  71.         cbox.leftcol  = 0;
  72.         cbox.botrow   = cbox.toprow;
  73.         cbox.rightcol = disp_GetWidth() - 1;
  74.  
  75.         if ((bdnulld->msgwin = win_Open(msgwin_Class, &cbox)) == NULL) {
  76.             return(FALSE);
  77.         }
  78.  
  79.         bdnulld->prompt[0] = '\0';
  80.  
  81.         win_SetAttr(bdnulld->msgwin, win_GetAttr(bdnulld->bdd.win));
  82.  
  83.         /* move the prompt window above the client window */
  84.         win_PutUnder(bdnulld->msgwin, win_GetAbove(bdnulld->bdd.win));
  85.         break;
  86.  
  87.     case BDM_PROMPT:
  88.         /* write the border prompt string to the msgwin */
  89.         /* set the border prompt string */
  90.         p = (indata != NULL) ? ((char *) indata) : "";
  91.  
  92.         /* Test if prompt has changed */
  93.         if (strcmp(p, bdnulld->prompt) != 0) {
  94.             strncpy(bdnulld->prompt, p, BD_PROMPTLEN);
  95.             bdnulld->prompt[BD_PROMPTLEN] = '\0';
  96.  
  97.             /* update the prompt */
  98.             msgwin_SetMsg(bdnulld->msgwin, bdnulld->prompt);
  99.             win_Paint(bdnulld->msgwin);
  100.         }
  101.  
  102.         /* move the prompt window above the client window */
  103.         win_PutUnder(bdnulld->msgwin, win_GetAbove(bdnulld->bdd.win));
  104.         break;
  105.  
  106.     case OBJM_CLOSE:
  107.         /* Close the msgwin */
  108.         win_Close(bdnulld->msgwin);
  109.  
  110.         /* No break; fall through to default */
  111.  
  112.     default:
  113.         return(border_DoRaw(&bdnulld->bdd, msg, indata, outdata));
  114.     }
  115.  
  116.     return(1);
  117. }
  118. /* -------------------------------------------------------------------------- */
  119.  
  120.