home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / intuition / windows / example9.c < prev    next >
C/C++ Source or Header  |  1995-02-27  |  5KB  |  149 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:    Example9.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 normal window with all system gadgets      */
  21. /* connected to it. If you activate the window, the pointer will chage */
  22. /* shape into a "nice" arrow.                                          */
  23.  
  24.  
  25.  
  26. /* If your program is using Intuition you should include intuition.h: */
  27. #include <intuition/intuition.h>
  28.  
  29.  
  30.  
  31. struct IntuitionBase *IntuitionBase;
  32.  
  33.  
  34.  
  35. /* Declare a pointer to a Window structure: */ 
  36. struct Window *my_window;
  37.  
  38. /* Declare and initialize your NewWindow structure: */
  39. struct NewWindow my_new_window=
  40. {
  41.   50,            /* LeftEdge    x position of the window. */
  42.   50,            /* TopEdge     y positio of the window. */
  43.   200,           /* Width       200 pixels wide. */
  44.   150,           /* Height      150 lines high. */
  45.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  46.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  47.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  48.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  49.   WINDOWCLOSE|   /*             Close Gadget. */
  50.   WINDOWDRAG|    /*             Drag gadget. */
  51.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  52.   WINDOWSIZING,  /*             Sizing Gadget. */
  53.   NULL,          /* FirstGadget No Custom Gadgets. */
  54.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  55.   "MY WINDOW",   /* Title       Title of the window. */
  56.   NULL,          /* Screen      Connected to the Workbench Screen. */
  57.   NULL,          /* BitMap      No Custom BitMap. */
  58.   80,            /* MinWidth    We will not allow the window to become */
  59.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  60.   300,           /* MaxWidth    than 300 x 200. */
  61.   200,           /* MaxHeight */
  62.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  63. };
  64.  
  65.  
  66.  
  67. /* Declare and initialize Sprite data for the Pointer: */
  68. USHORT chip my_sprite_data[36]=
  69. {
  70.     0x0000, 0x0000, /* Used by Intuition only. */
  71.  
  72.     0x0000, 0x0100,
  73.     0x0000, 0x0300,
  74.     0x0200, 0x0700,
  75.     0x0600, 0x0D00,
  76.     0x0E00, 0x1900,
  77.     0x1E00, 0x31FC,
  78.     0x3FFC, 0x60FE,
  79.     0x7FFE, 0xc003,
  80.     0x3FFE, 0x4001,
  81.     0x1E0E, 0x21F1,
  82.     0x0E0E, 0x1119,
  83.     0x060E, 0x0919,
  84.     0x020E, 0x0519,
  85.     0x000E, 0x0319,
  86.     0x000E, 0x0119,
  87.     0x0000, 0x001F,
  88.  
  89.     0x0000, 0x0000  /* Used by Intuition only. */
  90. };
  91.  
  92.  
  93.  
  94. main()
  95. {
  96.   /* Open the Intuition Library: */
  97.   IntuitionBase = (struct IntuitionBase *)
  98.     OpenLibrary( "intuition.library", 0 );
  99.   
  100.   if( IntuitionBase == NULL )
  101.     exit(); /* Could NOT open the Intuition Library! */
  102.  
  103.  
  104.  
  105.   /* We will now try to open the window: */
  106.   my_window = (struct Window *) OpenWindow( &my_new_window );
  107.   
  108.   /* Have we opened the window succesfully? */
  109.   if(my_window == NULL)
  110.   {
  111.     /* Could NOT open the Window! */
  112.     
  113.     /* Close the Intuition Library since we have opened it: */
  114.     CloseLibrary( IntuitionBase );
  115.  
  116.     exit();  
  117.   }
  118.  
  119.  
  120.  
  121.   /* We will now call the function SetPointer() to change the windows */
  122.   /* default pointer. If you now Activate the window, by clicking */
  123.   /* somewhere inside it, the pointer will change: */
  124.   SetPointer( my_window, my_sprite_data, 16, 16, 0, -7);
  125.  
  126.   /* my_window:       Pointer to the window. */
  127.   /* &my_sprite_data: Pointer to the Sprite Data. */
  128.   /* 16:              Height, 16 lines. */
  129.   /* 16:              Width, 16 pixels. */
  130.   /* 0:               XOffset, left side. (Position of the "Hot Spot") */
  131.   /* -7:              YOffset, 7 lines down.         -"- */
  132.  
  133.  
  134.   /* We have opened the window, and everything seems to be OK. */
  135.   /* Wait for 30 seconds: */
  136.   Delay( 50 * 30);
  137.  
  138.  
  139.  
  140.   /* We should always close the windows we have opened before we leave: */
  141.   CloseWindow( my_window );
  142.  
  143.  
  144.   
  145.   /* Close the Intuition Library since we have opened it: */
  146.   CloseLibrary( IntuitionBase );
  147.   
  148.   /* THE END */
  149. }