/* EGS_Test.c
 *
 */
#include <exec/types.h>
#include <proto/exec.h>
#include <egs/egsintui.h>
#include <egs/proto/egsintui.h>
#include <egs/egsgfx.h>
#include <egs/proto/egsgfx.h>

struct Library *EGSIntuiBase;
struct Library *EGSGfxBase;

int   i;
ULONG color, ocolor;

void main( int argc, char **argv )
{
  static struct EI_NewWindow newWindow = {
    100,50, 400,200,
    0,0, 0,0,
    NULL,
    EI_WINDOWCLOSE | EI_WINDOWBACK | EI_WINDOWDRAG,
    NULL,
    "EGS-Fenster",
    EI_GIMMEZEROZERO | EI_SMART_REFRESH,
    EI_iCLOSEWINDOW,
    NULL,
    {0,0,0,0,0,0,0},
    NULL,
    NULL
    };
  EI_WindowPtr window;

  EGSIntuiBase=OpenLibrary("egsintui.library",0);
  if( EGSIntuiBase ) {
    EGSGfxBase = OpenLibrary("egsgfx.library",0);
    if( EGSGfxBase ) {
      window = EI_OpenWindow( &newWindow );
      if( window ) {
        ocolor = EI_ObtainColor( window->WScreen,
                               0xff, 0x00, 0x00);
        for(i=2;i<398;i+=4) {
          color = (((ULONG)i*3 & 0xff) << 24) |
                  (((ULONG)i*2 & 0xff) << 16) |
                  (((ULONG)i   & 0xff) << 8);
          EG_SetAPen( window->RPort,color);
          EG_RectFill( window->RPort,i,2,4,196);
        }
        EG_SetAPen( window->RPort, ocolor);
        EG_Move( window->RPort, 1, 1);
        EG_Draw( window->RPort, 398, 1);
        EG_Draw( window->RPort, 398, 198);
        EG_Draw( window->RPort, 1, 198);
        EG_Draw( window->RPort, 1, 1);
        WaitPort( window -> UserPort );
        EI_ReleaseColor( window->WScreen, ocolor);
        EI_CloseWindow( window );
      }
      CloseLibrary( EGSGfxBase );
    }
    CloseLibrary( EGSIntuiBase );
  }
}
