home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / windows / example10.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  6KB  |  200 lines

  1. /* Example10                                                             */
  2. /* This program will open a two normal windows with all system gadgets   */
  3. /* connected to them. If the first window is Activated, the pointer will */
  4. /* chage shapes into a Zzz symbol, if the second window is activated,    */
  5. /* the pointer will look like a pistol.                                  */
  6.  
  7.  
  8.  
  9. /* If your program is using Intuition you should include intuition.h: */
  10. #include <intuition/intuition.h>
  11.  
  12.  
  13.  
  14. struct IntuitionBase *IntuitionBase;
  15.  
  16.  
  17.  
  18. /* Declare a pointer to the first Window structure: */ 
  19. struct Window *my_window1;
  20.  
  21. /* Declare and initialize your first NewWindow structure: */
  22. struct NewWindow my_new_window1=
  23. {
  24.   50,            /* LeftEdge    x position of the window. */
  25.   25,            /* TopEdge     y positio of the window. */
  26.   200,           /* Width       200 pixels wide. */
  27.   150,           /* Height      150 lines high. */
  28.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  29.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  30.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  31.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  32.   WINDOWCLOSE|   /*             Close Gadget. */
  33.   WINDOWDRAG|    /*             Drag gadget. */
  34.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  35.   WINDOWSIZING,  /*             Sizing Gadget. */
  36.   NULL,          /* FirstGadget No Custom Gadgets. */
  37.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  38.   "Zzz",         /* Title       Title of the window. */
  39.   NULL,          /* Screen      Connected to the Workbench Screen. */
  40.   NULL,          /* BitMap      No Custom BitMap. */
  41.   80,            /* MinWidth    We will not allow the window to become */
  42.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  43.   300,           /* MaxWidth    than 300 x 200. */
  44.   200,           /* MaxHeight */
  45.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  46. };
  47.  
  48.  
  49.  
  50. /* Declare a pointer to the second Window structure: */ 
  51. struct Window *my_window2;
  52.  
  53. /* Declare and initialize your second NewWindow structure: */
  54. struct NewWindow my_new_window2=
  55. {
  56.   300,           /* LeftEdge    x position of the window. */
  57.   25,            /* TopEdge     y positio of the window. */
  58.   200,           /* Width       200 pixels wide. */
  59.   150,           /* Height      150 lines high. */
  60.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  61.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  62.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  63.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  64.   WINDOWCLOSE|   /*             Close Gadget. */
  65.   WINDOWDRAG|    /*             Drag gadget. */
  66.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  67.   WINDOWSIZING,  /*             Sizing Gadget. */
  68.   NULL,          /* FirstGadget No Custom Gadgets. */
  69.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  70.   "BANG!",       /* Title       Title of the window. */
  71.   NULL,          /* Screen      Connected to the Workbench Screen. */
  72.   NULL,          /* BitMap      No Custom BitMap. */
  73.   80,            /* MinWidth    We will not allow the window to become */
  74.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  75.   300,           /* MaxWidth    than 300 x 200. */
  76.   200,           /* MaxHeight */
  77.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  78. };
  79.  
  80.  
  81.  
  82. /* Declare and initialize Sprite data for the Pointers: */
  83.  
  84. /* Zzz: (16 x 16  pixels) */
  85. USHORT chip sprite_data_Zzz[36]=
  86. {
  87.     0x0000, 0x0000,  /* Used by Intuition only. */
  88.  
  89.     0x0300, 0x0000,
  90.     0x1F9C, 0x0300,
  91.     0x3FFE, 0x1F9C,
  92.     0x63E3, 0x3FFE,
  93.     0x7A3B, 0x3FFE,
  94.     0xF7B7, 0x7FFE,
  95.     0xEF63, 0x7FFE,
  96.     0xE23F, 0x7FFE,
  97.     0x7FFE, 0x3FC0,
  98.     0x3fC0, 0x0F80,
  99.     0x0FB0, 0x0000,
  100.     0x0078, 0x0030,
  101.     0x0030, 0x0000,
  102.     0x0004, 0x0000,
  103.     0x000E, 0x0004,
  104.     0x0004, 0x0000,
  105.  
  106.     0x0000, 0x0000  /* Used by Intuition only. */
  107. };
  108.  
  109. /* Pistol: (16 x 11  pixels) */
  110. USHORT chip sprite_data_Pistol[26]=
  111. {
  112.     0x0000, 0x0000,  /* Used by Intuition only. */
  113.  
  114.     0x0000, 0x4010,
  115.     0x0000, 0xFFF8,
  116.     0x01E0, 0xFE18,
  117.     0x00E0, 0x071C,
  118.     0x0000, 0x03FC,
  119.     0x001C, 0x027E,
  120.     0x001C, 0x02BF,
  121.     0x001E, 0x01FF,
  122.     0x001E, 0x003F,
  123.     0x000E, 0x001F,
  124.     0x0000, 0x001F,
  125.  
  126.     0x0000, 0x0000  /* Used by Intuition only. */
  127. };
  128.  
  129.  
  130.  
  131. main()
  132. {
  133.   /* Open the Intuition Library: */
  134.   IntuitionBase = (struct IntuitionBase *)
  135.     OpenLibrary( "intuition.library", 0 );
  136.   
  137.   if( IntuitionBase == NULL )
  138.     exit(); /* Could NOT open the Intuition Library! */
  139.  
  140.  
  141.  
  142.   /* We will now try to open the first window: */
  143.   my_window1 = (struct Window *) OpenWindow( &my_new_window1 );
  144.   
  145.   /* Have we opened the first window succesfully? */
  146.   if(my_window1 == NULL)
  147.   {
  148.     /* Could NOT open the first Window! */
  149.     
  150.     /* Close the Intuition Library since we have opened it: */
  151.     CloseLibrary( IntuitionBase );
  152.  
  153.     exit();  
  154.   }
  155.  
  156.  
  157.  
  158.   /* We will now try to open the second window: */
  159.   my_window2 = (struct Window *) OpenWindow( &my_new_window2 );
  160.  
  161.   /* Have we opened the second window succesfully? */
  162.   if(my_window2 == NULL)
  163.   {
  164.     /* Could NOT open the second Window! */
  165.     
  166.     /* Close the first window: */
  167.     CloseWindow( my_window1 );
  168.     
  169.     /* Close the Intuition Library since we have opened it: */
  170.     CloseLibrary( IntuitionBase );
  171.  
  172.     exit();  
  173.   }
  174.  
  175.  
  176.  
  177.   /* We will now call the function SetPointer() to change the windows */
  178.   /* default pointer: */
  179.   SetPointer( my_window1, sprite_data_Zzz, 16, 16, 0, 0);
  180.   SetPointer( my_window2, sprite_data_Pistol, 11, 16, 0, -1);
  181.  
  182.  
  183.  
  184.   /* We have opened the windows, and everything seems to be OK. */
  185.   /* Wait for 30 seconds: */
  186.   Delay( 50 * 30);
  187.  
  188.  
  189.  
  190.   /* We should always close the windows we have opened before we leave: */
  191.   CloseWindow( my_window2 );
  192.   CloseWindow( my_window1 );
  193.  
  194.  
  195.   
  196.   /* Close the Intuition Library since we have opened it: */
  197.   CloseLibrary( IntuitionBase );
  198.   
  199.   /* THE END */
  200. }