// COPYRIGHT (C) 1990-1999.  All Rights Reserved. - MAIN2.CPP
// Zinc Software Incorporated.  Pleasant Grove, Utah  USA
// May be freely copied, used and distributed.

#include <zaf.hpp>
#include <z_prst.hpp>
#include "bitmap2.hpp"

// Start the application.
int ZafApplication::Main(void)
{
	// This is for compilers that do not look in the library for main.
	LinkMain();

	// Create a pointer to the storage file.
	ZafStorage *storage = new ZafStorage(ZAF_ITEXT("bitmaps.znc"), ZAF_FILE_READ);

	// Check to see if the default storage was allocated.
	if (storage->Error())
	{
		zafErrorSystem->ReportError(ZAF_NULLP(ZafWindowObject),
			ZAF_ITEXT("File Error"), ZAF_DIALOG_OK,
			ZAF_ITEXT("Error: bitmaps.znc could not be found."));
		delete storage;
		return(-1);
	}

	// Use bitmap storage in data persistence.
	if (zafDataPersistence)
		zafDataPersistence->AddFileSystem(storage);
	else
		zafDataPersistence = new ZafDataPersistence(storage, zafDefaultDataConstructor);

	// Create the window and add the support objects.
	ZafWindow *window = new ZafWindow(0, 0, 25, 4);
	window->AddGenericObjects(new ZafStringData("Bitmap Window 2"));

	// Add the bitmap object to the window.
	window->Add(new MyBitmap(1, 1, 10, 3, ZAF_ITEXT("WORLD_6")));

	// Center the window on the screen before adding to the window manager.
	zafWindowManager->Center(window);

	// Add the window to the window manager.
	zafWindowManager->Add(window);

	// Process user responses.
	Control();

	// Cleanup
	zafDataPersistence->SubtractFileSystem(storage);
	delete storage;

	// End the program.
	return(0);
}

