home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / acm1.lzh / Graphics / Example1.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  121 lines

  1. /* Example1                                                         */
  2. /* This program will open a normal window which is connected to the */
  3. /* Workbench Screen. We will then draw a strange line with help of  */
  4. /* Intuition's Border structure.                                    */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   40,            /* LeftEdge    x position of the window. */
  24.   20,            /* TopEdge     y positio of the window. */
  25.   250,           /* Width       250 pixels wide. */
  26.   40,            /* Height      40 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWDRAG|    /*             Drag gadget. */
  32.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  33.   ACTIVATE,      /*             The window should be Active when opened. */
  34.   NULL,          /* FirstGadget No Custom Gadgets. */
  35.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  36.   "STRANGE LINE",/* Title       Title of the window. */
  37.   NULL,          /* Screen      Connected to the Workbench Screen. */
  38.   NULL,          /* BitMap      No Custom BitMap. */
  39.   0,             /* MinWidth    We do not need to care about these */
  40.   0,             /* MinHeight   since we have not supplied the window */
  41.   0,             /* MaxWidth    with a Sizing Gadget. */
  42.   0,             /* MaxHeight */
  43.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  44. };
  45.  
  46.  
  47.  
  48. /* The coordinates for the lines: */
  49. SHORT my_points[]=
  50. {
  51.   10,10, /* Start at position (10,10) */
  52.   25,10, /* Draw a line to the right to position (25,10) */
  53.   25,14, /* Draw a line down to position (25,14) */
  54.   35,14, /* Draw a line to the right to position (35,14) */
  55.   35,12  /* Finish of by drawing a line up to position (35,12) */ 
  56. };
  57.  
  58.  
  59.  
  60. /* The Border structure: */
  61. struct Border my_border=
  62. {
  63.   0, 0,        /* LeftEdge, TopEdge. */
  64.   3,           /* FrontPen, colour register 3. */
  65.   0,           /* BackPen, for the moment unused. */
  66.   JAM1,        /* DrawMode, draw the lines with colour 3. */
  67.   5,           /* Count, 5 pair of coordinates in the array. */
  68.   my_points,   /* XY, pointer to the array with the coordinates. */
  69.   NULL,        /* NextBorder, no other Border structures are connected. */
  70. };
  71.  
  72.  
  73.  
  74. main()
  75. {
  76.   /* Open the Intuition Library: */
  77.   IntuitionBase = (struct IntuitionBase *)
  78.     OpenLibrary( "intuition.library", 0 );
  79.   
  80.   if( IntuitionBase == NULL )
  81.     exit(); /* Could NOT open the Intuition Library! */
  82.  
  83.  
  84.  
  85.   /* We will now try to open the window: */
  86.   my_window = (struct Window *) OpenWindow( &my_new_window );
  87.   
  88.   /* Have we opened the window succesfully? */
  89.   if(my_window == NULL)
  90.   {
  91.     /* Could NOT open the Window! */
  92.     
  93.     /* Close the Intuition Library since we have opened it: */
  94.     CloseLibrary( IntuitionBase );
  95.  
  96.     exit();  
  97.   }
  98.  
  99.  
  100.  
  101.   /* Tell Intuition to draw a strange line, using my_border structure: */
  102.   DrawBorder( my_window->RPort, &my_border, 10, 12 );
  103.  
  104.  
  105.  
  106.   /* We have opened the window, and everything seems to be OK. */
  107.   /* Wait for 30 seconds: */
  108.   Delay( 50 * 30);
  109.  
  110.  
  111.  
  112.   /* We should always close the windows we have opened before we leave: */
  113.   CloseWindow( my_window );
  114.  
  115.  
  116.   
  117.   /* Close the Intuition Library since we have opened it: */
  118.   CloseLibrary( IntuitionBase );
  119.   
  120.   /* THE END */
  121. }