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

#include <zaf.hpp>

int ZafApplication::Main(void)
{
	LinkMain();

	// Create the scrolled window.
	ZafScrolledWindow *scrollWindow = new ZafScrolledWindow(0, 0, 60, 6, 100, 15);

	// Convert the coordinates so that SetScrollWidth() and 
	// SetScrollHeight() will use pixel values.
	scrollWindow->ConvertCoordinates(ZAF_PIXEL);
	scrollWindow->SetCoordinateType(ZAF_PIXEL);

	// Add the generic children.
	scrollWindow->AddGenericObjects(new ZafStringData("ZafScrolledWindow"));

	// Add the scroll bars.
	scrollWindow->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData), ZAF_CORNER_SCROLL));
	scrollWindow->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData), ZAF_VERTICAL_SCROLL));
	scrollWindow->Add(new ZafScrollBar(0, 0, 0, 0, ZAF_NULLP(ZafScrollData), ZAF_HORIZONTAL_SCROLL));

	// Add an auto sizing image object.
	ZafImage *image = new ZafImage(0, 0, 0, 0, ZAF_ITEXT("image1"));
	image->SetAutoSize(true);
	scrollWindow->Add(image);

	// Set visible false so that changes can be made before it is shown
	// on the screen.
	scrollWindow->SetVisible(false);

	// Adding to the window manager causes the image object to compute
	// its region.
	zafWindowManager->Center(scrollWindow);
	zafWindowManager->Add(scrollWindow);

	// Use the image objects region to set the scroll region.
	scrollWindow->SetScrollWidth(image->zafRegion.Width());
	scrollWindow->SetScrollHeight(image->zafRegion.Height());

	// Show the window on the screen.
	scrollWindow->SetVisible(true);

	// Process events.
	Control();

	return (0);
}

