home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / BDNULL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-23  |  3.2 KB  |  122 lines

  1. /*
  2.     bdnull.c    5/07/87
  3.  
  4.     % The null border.
  5.  
  6.     OWL 1.2
  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.     11/06/89 jmd    removed DoRaw macros
  20.     11/11/89 jmd    fixed attr problem
  21.      2/01/90 jmd    really fixed attr problem
  22.      3/28/90 jmd    ansi-fied
  23. */
  24.  
  25. #include "oakhead.h"
  26. #include "disppriv.h"
  27. #include "msgwin.h"
  28. #include "bordobj.h"
  29. #include "bordod.h"
  30.  
  31. /* border object data */
  32.  
  33. typedef struct _bdnullod {
  34.     border_od    bdd;                          /* common object super class */
  35.     win_type     msgwin;                        /* prompt window */
  36.     char         prompt[BD_PROMPTLEN + 1];    /* space for border prompt */
  37. } bdnull_od;
  38.  
  39. /* -------------------------------------------------------------------------- */
  40.  
  41. int bd_null(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  42. /*
  43.     This is the "null" border used by some C-scape library
  44.     routines.
  45.     It is actully not a border but simply a function that 
  46.     will intercept requests to display prompt strings and place 
  47.     them in a window on the bottom line of the display.
  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_Class(&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, bord_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.             win_SetAttr(bdnulld->msgwin, bord_GetAttr(bdnulld->bdd.win));
  98.  
  99.             /* update the prompt */
  100.             msgwin_SetMsg(bdnulld->msgwin, bdnulld->prompt);
  101.             win_Paint(bdnulld->msgwin);
  102.         }
  103.  
  104.         /* move the prompt window above the client window */
  105.         win_PutUnder(bdnulld->msgwin, win_GetAbove(bdnulld->bdd.win));
  106.         break;
  107.  
  108.     case OBJM_CLOSE:
  109.         /* Close the msgwin */
  110.         win_Close(bdnulld->msgwin);
  111.  
  112.         /* No break; fall through to default */
  113.  
  114.     default:
  115.         return(border_Class(&bdnulld->bdd, msg, indata, outdata));
  116.     }
  117.  
  118.     return(1);
  119. }
  120. /* -------------------------------------------------------------------------- */
  121.  
  122.