/* **********************************************************
  Programma Window.c - Dimostrativo apertura di finestra in C
*********************************************************** */

#include <exec/types.h>

#include <intuition/intuition.h>

#define INOM "intuition.library"
#define GNOM "graphics.library"
#define VERS 33L
#define SECRIT 5

struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
struct Window *mywindow;

struct NewWindow NWStruct = {
 101,36,  /* origine XY finestra */
 409,124, /* larghezza ed altezza */
 0,1,     /* Detailpen e BlockPen */
 NULL,    /* flags di IDCMP  */
 WINDOWSIZING + WINDOWDRAG + WINDOWDEPTH + 
 WINDOWCLOSE + ACTIVATE + NOCAREREFRESH, /* flags */
 NULL,    /* primo gadget */
 NULL,    /* immagine CHECKMARK personale */
 (UBYTE *) "MiaFinestra", /* titolo finestra */
 NULL,    /* puntatore schermo custom */
 NULL,    /* puntatore bitmap custom */
 0,0,     /* minima larghezza ed altezza */
 0,0,     /* massima larghezza ed altezza */
 WBENCHSCREEN /* tipo schermo destinazione */
};
void gexit( t )
LONG t;
{
 if ( mywindow ) CloseWindow( mywindow );
 if ( IntuitionBase ) CloseLibrary( IntuitionBase );
 if ( GfxBase ) CloseLibrary( GfxBase );
 exit( t );
}

void main()
{
 GfxBase = (struct GfxBase *) OpenLibrary( GNOM,VERS );
 IntuitionBase = (struct IntuitionBase *)OpenLibrary(INOM,VERS);
 
 if ( GfxBase == NULL || IntuitionBase == NULL )
  gexit( 10L );
 
 mywindow = (struct Window *) OpenWindow( &NWStruct );
 
 if ( mywindow == NULL )
  gexit( 11L );
  
 Delay ( SECRIT * 50L );
 gexit( 0L );
}
