/****************************************************************************
*
* $RCSfile: Zoomer.c $
* $Revision: 1.4 $
* $Date: 1997/03/23 11:44:05 $
* $Author: ssolie $
*
*****************************************************************************
*
* Copyright (c) 1997 Software Evolution.  All Rights Reserved.
*
*****************************************************************************
*
* Zoomer.c -- Main entry point for "Zoomer"
*
* This program can load and display DR2D closed polygons in a window.  The
* user can move and zoom the drawing in real-time.
*
* The DR2D drawing is expected to be "PROGDIR:drawing.dr2d" or the
* program will fail.
*/
#include <classact.h>
#include <classes/window.h>
#include <dos/dos.h>
#include <exec/types.h>
#include <utility/tagitem.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/iffparse.h>
#include <proto/intuition.h>
#include <proto/layers.h>
#include <proto/mathieeesingbas.h>

#include "LibraryObject.h"
#include "ZoomerWindow.h"


/*** Global variables ***/
struct IntuitionBase	*IntuitionBase		 = NULL;
struct GfxBase			*GfxBase			 = NULL;
struct Library			*LayersBase			 = NULL;
struct ClassLibrary		*WindowBase			 = NULL;
struct Library			*MathIeeeSingBasBase = NULL;
struct Library			*IFFParseBase		 = NULL;


/*** Local function prototypes ***/
VOID main(VOID);


/*
 * main -- Main entry point
 *
 * The main entry point handles starting the application and allocating
 * required resources.  Returns when the user has chosen to quit or when
 * an error has occured.
 */
VOID main(VOID)
{
	struct TagItem lib_tags[] = {
		{LIB_LibVersion, (ULONG)39},
		{LIB_Intuition, (ULONG)&IntuitionBase},
		{LIB_Graphics, (ULONG)&GfxBase},
		{LIB_LibName, (ULONG)"layers.library"},
		{LIB_LibBase, (ULONG)&LayersBase},
		{LIB_LibName, (ULONG)"SYS:classes/window.class"},
		{LIB_LibBase, (ULONG)&WindowBase},
		{LIB_LibName, (ULONG)"iffparse.library"},
		{LIB_LibBase, (ULONG)&IFFParseBase},
		{LIB_LibVersion, (ULONG)37},
		{LIB_LibName, (ULONG)"mathieeesingbas.library"},
		{LIB_LibBase, (ULONG)&MathIeeeSingBasBase},
		{TAG_DONE}
	};
	struct Screen *screen;
	LibraryObject lib_obj;
	ZoomerWindow zoomer_window;

	lib_obj = openLibraries(lib_tags);
	if ( lib_obj == NULL )
		Printf("cannot open libraries\n");
	else  {
		screen = LockPubScreen(NULL);
		if ( screen == NULL )
			Printf("cannot lock default public screen\n");
		else  {
			zoomer_window = newZoomerWindow(screen);
			if ( zoomer_window == NULL )
				Printf("cannot create ZoomerWindow object\n");
			else  {
				handleZoomerWindow(zoomer_window);
				deleteZoomerWindow(zoomer_window);
			}

			UnlockPubScreen(NULL, screen);
		}

		closeLibraries(lib_obj);
	}
}
