/***************************************
 *                                     *
 * Program : Demonstration Menu-Strip.c*
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb      2/ 3/1988  Menu-Strip      *
 *                                     *
 *                                     *
 ***************************************/


#include <exec/types.h>
#include <intuition/intuition.h>


struct IntuitionBase *IntuitionBase;
struct Screen        *FirstScreen;
struct Window        *FirstWindow;
struct IntuiMessage  *message;


struct TextAttr ScreenFont =
   {
   (STRPTR)"topaz.font",
   TOPAZ_SIXTY,
   FS_NORMAL,
   FPF_ROMFONT
   };

struct NewScreen FirstNewScreen =
   {
   0, 0,                /* LeftEdge, TopEdge   */
   640, 200,            /* Width, Height       */
   3,                   /* Depth               */
   0, 1,                /* DetailPen, BlockPen */
   HIRES,               /* ViewModes           */
   CUSTOMSCREEN,        /* Type                */
   &ScreenFont,         /* Font                */
   (UBYTE *)"Screen Test",
   NULL,                /* Gadgets             */
   NULL,                /* CustomBitMap        */
   };

struct NewWindow FirstNewWindow =
   {
   0, 0,                /* LeftEdge, TopEdge   */
   640, 100,            /* Width, Height       */
   0, 1,                /* DetailPen, BlockPen */
   CLOSEWINDOW,         /* IDCMP Flags         */
   WINDOWDEPTH |        /* Flags               */
   WINDOWSIZING |
   WINDOWDRAG |
   WINDOWCLOSE |
   SMART_REFRESH,
   NULL,                /* First Gadget        */
   NULL,                /* CheckMark           */
   (UBYTE *)"Test Menu-Strip",
   NULL,                /* Screen (kommt noch) */
   NULL,                /* BitMap              */
   100, 50,             /* Min Width, Height   */
   640, 200,            /* Max Width, Height   */
   CUSTOMSCREEN,        /* Type                */
   };




main()
   {
   ULONG MessageClass;
   USHORT code;
   
   struct Message *GetMsg();
   
   Open_All();
   
   FOREVER
      {
      if ((message = (struct IntuiMessage *)
          GetMsg(FirstWindow->UserPort)) == NULL)
         {
         Wait(1L << FirstWindow->UserPort->mp_SigBit);
         continue;
         }
      MessageClass = message->Class;
      code = message->Code;
      
      ReplyMsg(message);
      switch (MessageClass)
            {
            case CLOSEWINDOW : Close_All();
                               exit(TRUE);
                               break;
            }
      }
   }


/***********************************************
 *                                             *
 * Function: Library, Screen and Window open   *
 * =========================================== *
 *                                             *
 * Author: Date:       Comments:               *
 * ------  ----------  ----------              *
 * Wgb     10/16/1987  functions!              *
 *                                             *
 *                                             *
 ***********************************************/

Open_All()
   {
   void          *OpenLibrary();
   struct Window *OpenWindow();
   struct Screen *OpenScreen();
   
   if (!(IntuitionBase = (struct IntuitionBase *)
       OpenLibrary("intuition.library", 0L)))
      {
      printf("Intuition Library not found!\n");
      Close_All();
      exit(FALSE);
      }
   
   if (!(FirstScreen = (struct Screen *)
       OpenScreen(&FirstNewScreen)))
      {
      printf("No screen page!\n");
      Close_All();
      exit(FALSE);
      }
   
   FirstNewWindow.Screen = FirstScreen;
   
   if (!(FirstWindow = (struct Window *)
       OpenWindow(&FirstNewWindow)))
      {
      printf("Window will not open!\n");
      Close_All();
      exit(FALSE);
      }
   
   
   }


/***************************************
 *                                     *
 * Function: Close all                 *
 * =================================== *
 *                                     *
 * Author: Date:        Comments:      *
 * ------  ----------  ----------      *
 * Wgb     16.10.1987  Window, Screen  *
 *                     and Intuition   *
 *                                     *
 ***************************************/

Close_All()
   {
   if (FirstWindow)     CloseWindow(FirstWindow);
   if (FirstScreen)     CloseScreen(FirstScreen);
   if (IntuitionBase)   CloseLibrary(IntuitionBase);
   }

