home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / intuition / modifyidcmp.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  4KB  |  141 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: modifyidcmp.c,v 1.7 1997/01/27 00:36:40 ldp Exp $
  4.     $Log: modifyidcmp.c,v $
  5.     Revision 1.7  1997/01/27 00:36:40  ldp
  6.     Polish
  7.  
  8.     Revision 1.6  1996/12/10 14:00:05  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.5  1996/11/08 11:28:03  aros
  12.     All OS function use now Amiga types
  13.  
  14.     Moved intuition-driver protos to intuition_intern.h
  15.  
  16.     Revision 1.4  1996/10/24 15:51:22  aros
  17.     Use the official AROS macros over the __AROS versions.
  18.  
  19.     Revision 1.3  1996/08/29 13:33:31  digulla
  20.     Moved common code from driver to Intuition
  21.     More docs
  22.  
  23.     Revision 1.2  1996/08/23 17:25:30  digulla
  24.     Added include intuition/intuition.h to user-docs
  25.  
  26.     Revision 1.1  1996/08/13 15:37:27  digulla
  27.     First function for intuition.library
  28.  
  29.  
  30.     Desc:
  31.     Lang: english
  32. */
  33. #include "intuition_intern.h"
  34. #include <proto/exec.h>
  35.  
  36. /*****************************************************************************
  37.  
  38.     NAME */
  39. #include <intuition/intuition.h>
  40. #include <proto/intuition.h>
  41.  
  42.     AROS_LH2(BOOL, ModifyIDCMP,
  43.  
  44. /*  SYNOPSIS */
  45.     AROS_LHA(struct Window *, window, A0),
  46.     AROS_LHA(ULONG          , flags, D0),
  47.  
  48. /*  LOCATION */
  49.     struct IntuitionBase *, IntuitionBase, 25, Intuition)
  50.  
  51. /*  FUNCTION
  52.     This routine modifies the state of your window's IDCMP (Intuition
  53.     Direct Communication Message Port).
  54.  
  55.     Depending on the current state in the IDCMPFlags of the window and
  56.     the specified flags these actions are possible:
  57.  
  58.     IDCMP    flags    Action
  59.       0      0    Nothing happens
  60.       0     !=0    The flags are copied in the IDCMPFlags of the window
  61.             and a MessagePort is created and stored in the
  62.             UserPort of the window.
  63.      !=0      0    The IDCMPFlags are cleared and the MessagePort in the
  64.             UserPort is deleted.
  65.      !=0     !=0    The flags are copied to the IDCMPFlags of the
  66.             window.
  67.  
  68.     INPUTS
  69.     window - The window to change the IDCMPFlags in.
  70.     flags - New flags for the IDCMPFlags of the window. See
  71.         intuition/intuition.h for the available flags.
  72.  
  73.     RESULT
  74.     TRUE if the change could be made and FALSE otherwise.
  75.  
  76.     NOTES
  77.     You can set up the Window->UserPort to any port of your own
  78.     before you call ModifyIDCMP().  If IDCMPFlags is non-null but
  79.     your UserPort is already initialized, Intuition will assume that
  80.     it's a valid port with task and signal data preset and Intuition
  81.     won't disturb your set-up at all, Intuition will just allocate
  82.     the Intuition message port half of it.    The converse is true
  83.     as well:  if UserPort is NULL when you call here with
  84.     IDCMPFlags == NULL, Intuition will deallocate only the Intuition
  85.     side of the port.
  86.  
  87.     This allows you to use a port that you already have allocated:
  88.  
  89.     - OpenWindow() with IDCMPFlags equal to NULL (open no ports)
  90.     - set the UserPort variable of your window to any valid port of your
  91.       own choosing
  92.     - call ModifyIDCMP with IDCMPFlags set to what you want
  93.     - then, to clean up later, set UserPort equal to NULL before calling
  94.       CloseWindow() (leave IDCMPFlags alone)  BUT FIRST: you must make
  95.       sure that no messages sent your window are queued at the port,
  96.       since they will be returned to the memory free pool.
  97.  
  98.     For an example of how to close a window with a shared IDCMP,
  99.     see the description for CloseWindow().
  100.  
  101.     EXAMPLE
  102.  
  103.     BUGS
  104.  
  105.     SEE ALSO
  106.     OpenWindow(), CloseWindow()
  107.  
  108.     INTERNALS
  109.  
  110.     HISTORY
  111.     29-10-95    digulla automatically created from
  112.                 intuition_lib.fd and clib/intuition_protos.h
  113.  
  114. *****************************************************************************/
  115. {
  116.     AROS_LIBFUNC_INIT
  117.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  118.  
  119.     if (!window->IDCMPFlags && flags)
  120.     {
  121.     window->UserPort = CreateMsgPort ();
  122.  
  123.     if (!window->UserPort)
  124.         return FALSE;
  125.     }
  126.  
  127.     window->IDCMPFlags = flags;
  128.  
  129.     if (!flags)
  130.     {
  131.     if (window->UserPort)
  132.     {
  133.         DeleteMsgPort (window->UserPort);
  134.         window->UserPort = NULL;
  135.     }
  136.     }
  137.  
  138.     return TRUE;
  139.     AROS_LIBFUNC_EXIT
  140. } /* ModifyIDCMP */
  141.