home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 420.lha / winformat_v1.0 / samplewin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-02  |  2.8 KB  |  97 lines

  1. /* INCLUDES ********************************************************** */
  2.  
  3. #include "exec/types.h"
  4. #include "exec/io.h"
  5. #include "exec/memory.h"
  6. #include "libraries/dos.h"
  7. #include "intuition/intuition.h"
  8.  
  9.         USHORT quit_flag = FALSE;
  10.  
  11. /* This is for the event handler */
  12. void quit(object)
  13. APTR object;
  14. {
  15.         quit_flag = TRUE;
  16. }
  17.  
  18.         long IntuitionBase=0;
  19.         long GfxBase=0;
  20.  
  21. struct Window *OpenWindow();
  22. struct Screen *OpenScreen();
  23.  
  24. struct NewWindow NewWindowStructure1 = {
  25.         0,0,    /* window XY origin relative to TopLeft of screen */
  26.         640,200,        /* window width and height */
  27.         0,1,    /* detail and block pens */
  28.         CLOSEWINDOW,    /* IDCMP flags */
  29.         WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH, /* other window flags */
  30.         NULL,   /* first gadget in gadget list */
  31.         NULL,   /* custom CHECKMARK imagery */
  32.         "Click on the Close Gadget to Quit",    /* window title */
  33.         NULL,   /* custom screen pointer */
  34.         NULL,   /* custom bitmap */
  35.         5,5,    /* minimum width and height */
  36.         -1,-1,  /* maximum width and height */
  37.         WBENCHSCREEN    /* destination screen type */
  38. };
  39.  
  40.  
  41. #include "textfile.c"
  42.  
  43. main()
  44. {
  45.         UWORD code;
  46.         ULONG class;
  47.         APTR object;
  48.  
  49.         struct Window *wG;      /* we fetch the RastPort pointer from here */
  50.         struct RastPort *rpG;
  51.         struct IntuiMessage *message;   /* the message the IDCMP sends us */
  52.  
  53.         IntuitionBase = OpenLibrary("intuition.library", 0);
  54.         if (IntuitionBase == NULL)
  55.         {
  56.                 printf("intuition is not here.  where are we?\n");
  57.                 goto cleanup1;
  58.         }
  59.         GfxBase = OpenLibrary("graphics.library", 0);
  60.  
  61.  
  62.         wG = OpenWindow(&NewWindowStructure1);  /* open the window */
  63.         if ( wG == NULL )
  64.         {
  65.                 printf ("open window failed\n");
  66.                 goto cleanup1;
  67.         }
  68.  
  69.         rpG = wG->RPort;        /* get a rastport pointer for the window */
  70.  
  71.         PrintIText(rpG,&IntuiTextList1,0,0);    /* Print the text */
  72.  
  73.  
  74.         do
  75.         {
  76.                 WaitPort(wG->UserPort);
  77.                         while( (message = (struct IntuiMessage *)
  78.                                 GetMsg(wG->UserPort) ) != NULL)
  79.                         {
  80.                                 code = message->Code;  /* MENUNUM */
  81.                                 object = message->IAddress;  /* Gadget */
  82.                                 class = message->Class;
  83.                                 ReplyMsg(message);
  84.                                 if ( class == CLOSEWINDOW ) (quit_flag = TRUE);
  85.                         }
  86.         } while (quit_flag == FALSE);
  87.  
  88. cleanup3:
  89.         CloseWindow(wG);
  90.  
  91. cleanup1:
  92.         if (GfxBase != NULL) CloseLibrary(GfxBase);
  93.         if (IntuitionBase != NULL) CloseLibrary(IntuitionBase);
  94.         return(0);
  95.  
  96. }
  97.