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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: closescreen.c,v 1.5 1997/01/27 00:36:36 ldp Exp $
  4.     $Log: closescreen.c,v $
  5.     Revision 1.5  1997/01/27 00:36:36  ldp
  6.     Polish
  7.  
  8.     Revision 1.4  1996/12/10 14:00:01  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.3  1996/10/31 13:50:39  aros
  12.     Don't forget to free the RastPort
  13.  
  14.     Revision 1.2  1996/10/24 15:51:18  aros
  15.     Use the official AROS macros over the __AROS versions.
  16.  
  17.     Revision 1.1  1996/09/21 14:11:39  digulla
  18.     Open and close screens
  19.  
  20.  
  21.     Desc:
  22.     Lang: english
  23. */
  24. #include "intuition_intern.h"
  25. #include <proto/exec.h>
  26. #include <proto/graphics.h>
  27.  
  28. #ifndef DEBUG_CloseScreen
  29. #   define DEBUG_CloseScreen 0
  30. #endif
  31. #if DEBUG_CloseScreen
  32. #   undef DEBUG
  33. #   define DEBUG 1
  34. #endif
  35. #include <aros/debug.h>
  36.  
  37. /*****************************************************************************
  38.  
  39.     NAME */
  40. #include <intuition/screens.h>
  41. #include <proto/intuition.h>
  42.  
  43.     AROS_LH1(BOOL, CloseScreen,
  44.  
  45. /*  SYNOPSIS */
  46.     AROS_LHA(struct Screen *, screen, A0),
  47.  
  48. /*  LOCATION */
  49.     struct IntuitionBase *, IntuitionBase, 11, Intuition)
  50.  
  51. /*  FUNCTION
  52.  
  53.     INPUTS
  54.  
  55.     RESULT
  56.  
  57.     NOTES
  58.  
  59.     EXAMPLE
  60.  
  61.     BUGS
  62.  
  63.     SEE ALSO
  64.  
  65.     INTERNALS
  66.  
  67.     HISTORY
  68.     29-10-95    digulla automatically created from
  69.                 intuition_lib.fd and clib/intuition_protos.h
  70.  
  71. *****************************************************************************/
  72. {
  73.     AROS_LIBFUNC_INIT
  74.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  75.     struct Screen * parent;
  76.  
  77.     D(bug("CloseScreen (%p)\n", screen));
  78.  
  79.     /* Trick: Since NextScreen is the first field of the structure,
  80.     we can use the pointer in the IntuitionBase as a screen with
  81.     the structure-size of one pointer */
  82.     parent = (struct Screen *)&(IntuitionBase->FirstScreen);
  83.  
  84.     /* For all screens... */
  85.     while (parent->NextScreen)
  86.     {
  87.     /* If the screen to close is the next screen... */
  88.     if (parent->NextScreen == screen)
  89.     {
  90.         /* Unlink it */
  91.         parent->NextScreen = screen->NextScreen;
  92.  
  93.         /* Check ActiveScreen */
  94.         if (IntuitionBase->ActiveScreen == screen)
  95.         {
  96.         if (screen->NextScreen)
  97.             IntuitionBase->ActiveScreen = screen->NextScreen;
  98.         else if (IntuitionBase->FirstScreen)
  99.             IntuitionBase->ActiveScreen = parent;
  100.         else
  101.             IntuitionBase->ActiveScreen = NULL;
  102.         }
  103.  
  104.         /* Free the RastPort's contents */
  105.         DeinitRastPort (&screen->RastPort);
  106.  
  107.         /* Free the memory */
  108.         FreeMem (screen, sizeof (struct Screen));
  109.  
  110.         ReturnBool("CloseScreen",TRUE);
  111.     }
  112.     }
  113.  
  114.     ReturnBool("CloseScreen",FALSE);
  115.     AROS_LIBFUNC_EXIT
  116. } /* CloseScreen */
  117.