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

  1. /*
  2.     bordobj.c   2/87
  3.  
  4.     % Routines for borders.
  5.     Includes the border object super class
  6.  
  7.     OWL 1.1
  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.  
  37. #include "oakhead.h"
  38. #include "disppriv.h"
  39. #include "bordobj.h"
  40. #include "bordod.h"
  41.  
  42. OGLOBAL objreq_fptr bdreq_mousefptr = objreq_Null;
  43.  
  44. /* -------------------------------------------------------------------------- */
  45.  
  46. int border_Class(objdata, msg, indata, outdata)
  47.     VOID *objdata;            /* object instance data pointer */
  48.     int msg;                /* message */
  49.     VOID *indata;            /* message input data */
  50.     VOID *outdata;            /* message output data */
  51. /* 
  52.     border object dispatch function
  53. */
  54. {
  55.     border_od  *bdd;
  56.     unsigned int feature;
  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.         bdd->debounced = 0;        /* debounced flag */
  75.         bdd->outline = 0;        /* outline move flag */
  76.         bdd->resize = 0;        /* mouse resize flag */
  77.         bdd->move = 0;            /* mouse move flag */
  78.         bdd->top = 0;            /* mouse window top flag */
  79.  
  80.         /* Set the initial border attribute */
  81.         bord_setxdattr(bordod_GetSelf(bdd), win_GetAttr(bdd->win));
  82.  
  83.         return(common_DoRaw(&(bdd->cd), msg, indata, outdata));
  84.  
  85.     case OBJM_CLOSE:
  86.         /* free the title if there is one */
  87.         if (bdd->title != NULL) {
  88.             ofree(OA_BDTITLE, (VOID *) bdd->title);
  89.         }
  90.  
  91.         /* reset border sides */
  92.         bord_SetSides(bdd->win, 0, 0, 0, 0);
  93.  
  94.         /* No break; fall through to default */
  95.  
  96.     default:
  97.         /* pass other messages to common superclass */
  98.         return(common_DoRaw(&(bdd->cd), msg, indata, outdata));
  99.  
  100.     case OBJM_WHO:
  101.         /* Identify ourselves */
  102.         return (*((int *) indata) == ID_BORDER);
  103.  
  104.     case BDM_GETTITLE:
  105.         *((char **) outdata) = bdd->title;
  106.         break;
  107.  
  108.     case BDM_SETFEATURE:
  109.         /* indata is an unsigned * containing a bit mask */
  110.         feature = *((unsigned *) indata);
  111.  
  112.         bdd->outline = (feature & BD_OUTLINE) ? 1 : 0;     /* outline move flag */
  113.         bdd->resize = (feature & BD_RESIZE) ? 1 : 0;    /* mouse resize flag */
  114.         bdd->move = (feature & BD_MOVE) ? 1 : 0;          /* mouse move flag */
  115.         bdd->top = (feature & BD_TOP) ? 1 : 0;              /* mouse top flag */
  116.         break;
  117.  
  118.     case BDM_GETFEATURE:
  119.         /* outdata is an unsigned * containing a bit mask */
  120.         feature = 0;
  121.  
  122.         feature |= (bdd->outline ? BD_OUTLINE : 0);
  123.         feature |= (bdd->resize ? BD_RESIZE : 0);
  124.         feature |= (bdd->move ? BD_MOVE : 0);
  125.         feature |= (bdd->top ? BD_TOP : 0);
  126.  
  127.         *((unsigned *) outdata) = feature;
  128.         break;
  129.  
  130.     case BDM_STARTMOUSE:
  131.     case BDM_MOUSE:
  132.     case BDM_ENDMOUSE:
  133.         return((*bdreq_mousefptr)(objdata, msg, indata, outdata));
  134.  
  135.     case BDM_SHADOW:
  136.     case BDM_DRAW:
  137.         break;
  138.  
  139.     case BDM_RESIZE:
  140.     case BDM_SCROLL:
  141.     case BDM_SETTITLE:
  142.     case BDM_PROMPT:
  143.         break;
  144.     }
  145.     return(TRUE);
  146. }
  147. /* -------------------------------------------------------------------------- */
  148.  
  149. boolean win_SetBorder(win, func)
  150.     win_type win;
  151.     class_fptr func;
  152. /*
  153.     Creates a border object and links it to the client window.
  154.     Returns FALSE if unable to create the border.
  155.     If func is NULL, close the current border.
  156. */
  157. {
  158.     if (win == NULL) {
  159.         return(FALSE);
  160.     }
  161.  
  162.     bord_Close(win);
  163.  
  164.     if (func == FNULL) {
  165.         return(TRUE);
  166.     }
  167.  
  168.     return(win_setbd(win, obj_Open(func, (VOID *) win)) != NULL);
  169. }
  170. /* -------------------------------------------------------------------------- */
  171.  
  172.