home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / vmem.lzh / openscrn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-19  |  2.6 KB  |  113 lines

  1. /*
  2. ** OPENSCRN - open a screen and window, return window ptr
  3. **
  4. ** Version 1.0 ⌐1990 by Edward Hutchins
  5. ** Authors:
  6. **
  7. **    Edward Hutchins: eah1@cec1.wustl.edu
  8. **
  9. ** Revisions:
  10. ** 12/19/91 code released as freeware under the GNU general public license - Ed.
  11. **
  12. **    This program is free software; you can redistribute it and/or modify
  13. **    it under the terms of the GNU General Public License as published by
  14. **    the Free Software Foundation; either version 1, or (at your option)
  15. **    any later version.
  16. **
  17. **    This program is distributed in the hope that it will be useful,
  18. **    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. **    GNU General Public License for more details.
  21. **
  22. **    You should have received a copy of the GNU General Public License
  23. **    along with this program; if not, write to the Free Software
  24. **    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26.  
  27. #include    <exec/types.h>
  28. #include    <exec/memory.h>
  29. #include    <intuition/intuition.h>
  30. #include    <proto/intuition.h>
  31.  
  32. /*
  33. ** external stuff
  34. */
  35.  
  36. extern struct IntuitionBase *IntuitionBase;
  37.  
  38. /*
  39. ** default parameters
  40. */
  41.  
  42. #define DEFDEPTH        3
  43. #define DEFWIDTH        320
  44. #define DEFHEIGHT        32
  45. #define DEFIDCMP        0
  46. #define DEFFLAGS        (SMART_REFRESH|ACTIVATE)
  47.  
  48. static struct NewScreen new_screen =
  49. {
  50.     0, 0, DEFWIDTH, DEFHEIGHT + 1, DEFDEPTH,
  51.     0, 0,
  52.     NULL,
  53.     CUSTOMSCREEN | SCREENQUIET | SCREENBEHIND,
  54.     NULL, NULL
  55. };
  56.  
  57. static struct NewWindow new_window =
  58. {
  59.     0, 1, DEFWIDTH, DEFHEIGHT,
  60.     (1<<DEFDEPTH) - 1, 0,
  61.     DEFIDCMP, DEFFLAGS,
  62.     NULL, NULL,
  63.     NULL,
  64.     NULL, NULL,
  65.     64, 40, 0, 0,
  66.     CUSTOMSCREEN
  67. };
  68.  
  69. /*
  70. ** OpenScrn - open a screen and window in intuition, return window ptr
  71. */
  72.  
  73. struct Window *OpenScrn( WORD w, WORD h, WORD d, ULONG IDCMP, ULONG Flags )
  74. {
  75.     struct Window        *window;
  76.  
  77.     /* Set up the graphics */
  78.  
  79.     if (w) new_screen.Width = new_window.Width = w;
  80.     if (h) new_screen.Height = ((new_window.Height = h) + 1);
  81.     if (d) new_screen.Depth = d, new_window.DetailPen = (1<<d) - 1;
  82.     if (IDCMP) new_window.IDCMPFlags = IDCMP;
  83.     if (Flags) new_window.Flags = Flags;
  84.  
  85.     new_window.Screen = OpenScreen( &new_screen );
  86.     if (new_window.Screen == NULL) exit(20);
  87.  
  88.     window = OpenWindow( &new_window );
  89.     if (window == NULL)
  90.     {
  91.         CloseScreen( new_window.Screen );
  92.         exit(20);
  93.     }
  94.  
  95.     return( window );
  96. }
  97.  
  98. /*
  99. ** CloseScrn - close a screen that we opened, using a window ptr
  100. */
  101.  
  102. void CloseScrn( struct Window *window )
  103. {
  104.     struct Screen    *screen;
  105.  
  106.     /* extract the screen address from the window pointer */
  107.  
  108.     screen = window->WScreen;
  109.  
  110.     CloseWindow( window );
  111.     CloseScreen( screen );
  112. }
  113.