home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / colourwindow / example.c < prev    next >
C/C++ Source or Header  |  1990-11-24  |  3KB  |  139 lines

  1. /* Name: Example.c
  2.  
  3.    CCC                                W     W
  4.   C   C                               W     W
  5.   C      OOO  L      OOO  U   U RRRR  W     W III N   N DDD    OOO  W     W
  6.   C     O   O L     O   O U   U R   R W     W  I  NN  N D  D  O   O W     W
  7.   C     O   O L     O   O U   U RRRR  W  W  W  I  N N N D   D O   O W  W  W
  8.   C   C O   O L     O   O U   U R  R   W W W   I  N  NN D  D  O   O  W W W
  9.    CCC   OOO  LLLLL  OOO   UUU  R   R   W W   III N   N DDD    OOO    W W
  10.  
  11.  
  12.   COLOUR WINDOW   EXAMPLE   VERSION 1.00   90-07-22
  13.  
  14.   Yet another program dedicated to Sioe-Lin Kwik.
  15.   
  16.  
  17.   COLOUR WINDOW was created by Anders Bjerin, and is distributed as
  18.   public domain with NO RIGHTS RESERVED. That means that you can do
  19.   what ever you want with the program.
  20.   
  21.   You may use COLOUR WINDOW in your own programs, commercial or not,
  22.   and do not even need to mention that you have used it. You may
  23.   alter the source code to fit your needs, and you may spread it to
  24.   anyone.
  25.  
  26.   HAPPY PROGRAMMING,
  27.  
  28.   Anders Bjerin
  29.  
  30. */
  31.  
  32.  
  33.  
  34. /* Include Intuition's and ColourWindow's header file: */
  35. #include <intuition/intuition.h>
  36. #include "ColourWindow.h"
  37.  
  38.  
  39.  
  40. /* ColourWindow needs both the Intuition and Graphics library: */
  41. struct IntuitionBase *IntuitionBase = NULL;
  42. struct GfxBase *GfxBase = NULL;
  43.  
  44.  
  45.  
  46. /* Declare a pointer to a Screen structure: */ 
  47. struct Screen *screen = NULL;
  48.  
  49. /* Declare and initialize a NewScreen structure: */
  50. struct NewScreen screen_data=
  51. {
  52.   0,            /* LeftEdge  Should always be 0. */
  53.   0,            /* TopEdge   Top of the display. */
  54.   640,          /* Width     We are using a high resolution screen. */
  55.   200,          /* Height    Non-Interlaced NTSC (American) display. */
  56.   4,            /* Depth     16 colours. */
  57.   0,            /* DetailPen Text should be drawn with colour reg. 0 */
  58.   1,            /* BlockPen  Blocks should be drawn with colour reg. 1 */
  59.   HIRES,        /* ViewModes High-resolution. (Non-Interlaced) */
  60.   CUSTOMSCREEN, /* Type      A customized screen. */
  61.   NULL,         /* Font      Default font. */
  62.  
  63.   "ColourWindow  V1.00  By Anders Bjerin",  /* Title */
  64.  
  65.   NULL,         /* Gadget    Must for the moment be NULL. */
  66.   NULL          /* BitMap    No special CustomBitMap. */
  67. };
  68.  
  69.  
  70.  
  71. void main();
  72. void CleanUp();
  73.  
  74.  
  75.  
  76. void main()
  77. {
  78.   UBYTE result;
  79.  
  80.  
  81.  
  82.   /* 1. Open the Intuition Library: */
  83.   IntuitionBase = (struct IntuitionBase *)
  84.     OpenLibrary( "intuition.library", 0 );
  85.   if( IntuitionBase == NULL )
  86.     CleanUp( "Could NOT open the Intuition Library!" );
  87.  
  88.  
  89.  
  90.   /* 2. Open the Graphics Library: */
  91.   GfxBase = (struct GfxBase *)
  92.     OpenLibrary( "graphics.library", 0 );
  93.   if( GfxBase == NULL )
  94.     CleanUp( "Could NOT open the Graphics Library!" );
  95.  
  96.  
  97.  
  98.   /* 3. Open the screen: */
  99.   screen = (struct Screen *) OpenScreen( &screen_data );
  100.   if( screen == NULL )
  101.     CleanUp( "Could NOT open the Screen!" );
  102.  
  103.  
  104.  
  105.   result = ColourWindow( screen, "ColourWindow V1.00", 20, 20 );
  106.  
  107.   switch( result )
  108.   {
  109.     case ERROR:  printf("ERROR!\n");  break;
  110.     case OK:     printf("OK!\n");     break;
  111.     case CANCEL: printf("CANCEL!\n"); break;
  112.     case QUIT:   printf("QUIT!\n");   break;
  113.   }
  114.  
  115.  
  116.  
  117.   CleanUp( "THE END" );
  118. }
  119.  
  120.  
  121.  
  122. /* This function will close everything that have been opened: */
  123. void CleanUp( message )
  124. STRPTR message;
  125. {
  126.   if( screen )
  127.     CloseScreen( screen );
  128.   
  129.   if( GfxBase )
  130.     CloseLibrary( GfxBase );
  131.   
  132.   if( IntuitionBase )
  133.     CloseLibrary( IntuitionBase );
  134.  
  135.   printf("%s\n", message );
  136.  
  137.   exit();
  138. }
  139.