home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / BORDOBJ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-28  |  3.7 KB  |  145 lines

  1. /*
  2.     bordobj.c   2/87
  3.  
  4.     % Routines for borders.
  5.     Includes the border object super class
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1986-1989, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.      6/23/88 jmd    converted generic pointers to VOID*
  14.      7/09/88 jmd    added windows
  15.      8/08/88 jmd    added bord_FixSides
  16.      8/09/88 jmd    added new object stuff
  17.      8/13/88 jmd    added bord_Open and bord_Close
  18.      9/12/88 jmd    Added in and out data to objects
  19.     10/05/88 jmd    Added win_PutUnder
  20.     10/31/88 Ted    Removed linking
  21.     11/15/88 Ted    Fixed GetBox x/y col/row bug
  22.     11/20/88 jmd    Added ID to obj struct
  23.     12/01/88 jmd    Fixed NULL func in bord_Open
  24.  
  25.      4/21/89 jmd    Added GET TITLE msg, intercepted other messages
  26.      4/24/89 jdc    made the GET TITLE msg return the title
  27.      5/12/89 jmd    renamed bord_Open to win_SetBorder
  28.      5/23/89 jmd    added "border features"
  29.      5/28/89 jmd    added Shadow support
  30.      7/07/89 gam    changed NULL to FNULL
  31.      8/04/89 jmd    added BD_TOP feature
  32.      8/10/89 ted    Moved Shadow support to winexpos.
  33.      8/12/89 jdc    renamed from border.c
  34.      8/12/89 jmd    added WHO message
  35.  
  36.     11/06/89 jmd    removed DoRaw macros
  37.     12/20/89 ted    Moved features from border od to xd.
  38.      2/01/90 jmd    set title to NULL after closing
  39.      3/28/90 jmd    ansi-fied
  40. */
  41.  
  42. #include "oakhead.h"
  43. #include "disppriv.h"
  44. #include "bordobj.h"
  45. #include "bordod.h"
  46.  
  47. OGLOBAL objreq_fptr bdreq_mousefptr = objreq_Null;
  48.  
  49. /* -------------------------------------------------------------------------- */
  50.  
  51. int border_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  52. /* 
  53.     border object dispatch function
  54. */
  55. {
  56.     border_od  *bdd;
  57.  
  58.     bdd = (border_od *) objdata;
  59.  
  60.     switch(msg) {
  61.     case OBJM_GETDATASIZE:
  62.         /* This Class has no ID of its own. 
  63.            It is inherited from a specific border type
  64.         */
  65.         ((ogds_struct *) outdata)->odsize = sizeof(border_od);
  66.         ((ogds_struct *) outdata)->xdsize = sizeof(border_xd);
  67.         break;
  68.  
  69.     case OBJM_OPEN:
  70.         /* indata should be the window getting the border */
  71.         bdd->win = (win_type) indata;
  72.         bdd->title = NULL;
  73.  
  74.         /* Set the initial border attribute */
  75.         bord_setxdattr(bordod_GetSelf(bdd), win_GetAttr(bdd->win));
  76.         bord_setxdfeature(bordod_GetSelf(bdd), 0);
  77.         bord_setxdscaling(bordod_GetSelf(bdd), BDS_CHARSIZE);
  78.  
  79.         return(common_Class(&(bdd->cd), msg, indata, outdata));
  80.  
  81.     case OBJM_CLOSE:
  82.         /* free the title if there is one */
  83.         if (bdd->title != NULL) {
  84.             ofree(OA_BDTITLE, (VOID *) bdd->title);
  85.             bdd->title = NULL;
  86.         }
  87.  
  88.         /* reset border sides */
  89.         bord_SetSides(bdd->win, 0, 0, 0, 0);
  90.  
  91.         /* No break; fall through to default */
  92.  
  93.     default:
  94.         /* pass other messages to common superclass */
  95.         return(common_Class(&(bdd->cd), msg, indata, outdata));
  96.  
  97.     case OBJM_WHO:
  98.         /* Identify ourselves */
  99.         return (*((int *) indata) == ID_BORDER);
  100.  
  101.     case BDM_GETTITLE:
  102.         *((char **) outdata) = bdd->title;
  103.         break;
  104.  
  105.     case BDM_STARTMOUSE:
  106.     case BDM_MOUSE:
  107.     case BDM_ENDMOUSE:
  108.         return((*bdreq_mousefptr)(objdata, msg, indata, outdata));
  109.  
  110.     case BDM_SHADOW:
  111.     case BDM_DRAW:
  112.         break;
  113.  
  114.     case BDM_RESIZE:
  115.     case BDM_SCROLL:
  116.     case BDM_SETTITLE:
  117.     case BDM_PROMPT:
  118.         break;
  119.     }
  120.     return(TRUE);
  121. }
  122. /* -------------------------------------------------------------------------- */
  123.  
  124. boolean win_SetBorder(win_type win, class_fptr func)
  125. /*
  126.     Creates a border object and links it to the client window.
  127.     Returns FALSE if unable to create the border.
  128.     If func is NULL, close the current border.
  129. */
  130. {
  131.     if (win == NULL) {
  132.         return(FALSE);
  133.     }
  134.  
  135.     bord_Close(win);
  136.  
  137.     if (func == FNULL) {
  138.         return(TRUE);
  139.     }
  140.  
  141.     return(win_setbd(win, obj_Open(func, (VOID *) win)) != NULL);
  142. }
  143. /* -------------------------------------------------------------------------- */
  144.  
  145.