home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / c / cmanual / intuition / windows / example10.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  7KB  |  218 lines

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