#include "split3.hpp"

// Create a basic window class to add the splitters.
SplitterWindow::SplitterWindow(int left, int top, int width, int height) : 
	ZafWindow(left, top, width, height)
{
	// Add the normal support objects.
	AddGenericObjects(new ZafStringData("Splitter Window"));

	// Create a new ZafSplitter object and add it to the window.
	// The first splitter must have ZAF_AVAILABLE_REGION set while
	// any subsequent splitters must NOT have this set.

	// This is the vertical splitter which will split the entire window.
	ZafSplitter *splitter = new ZafSplitter(ZAF_VERTICAL_SPLITTER, 25);
	splitter->SetRegionType(ZAF_AVAILABLE_REGION);
	Add(splitter);

	// Create a simple vertical list to be one of the splitter's pane objects.
	ZafVtList *list = new ZafVtList(0, 0, 0, 0);
	list->SetBordered(true);
	list->Add(new ZafScrollBar(ZAF_VERTICAL_SCROLL));
	for (int i = 0; i < 15; i++)
	{
		ZafIChar buff[50];
		sprintf(buff, ZAF_ITEXT("String %i"), i + 1);
		list->Add(new ZafString(0, 0, 0, new ZafStringData(buff)));
	}
	splitter->SetPreviousPaneObject(list);
	Add(list);

	// Create a scrolled window to be one of the splitter's pane objects.
	ZafWindow *pane = new ZafScrolledWindow(0, 0, 0, 0, 50, 50);
	pane->SetBordered(true);

	// Add the scroll bars to the scrolled window.
	ZafStringData *data = new ZafStringData("This is a string.");
	pane->Add(new ZafScrollBar(ZAF_CORNER_SCROLL));
	pane->Add(new ZafScrollBar(ZAF_VERTICAL_SCROLL));
	pane->Add(new ZafScrollBar(ZAF_HORIZONTAL_SCROLL));
	pane->Add(new ZafString(2, 2, 20, data));
	pane->Add(new ZafString(28, 47, 20, data));
	splitter->SetNextPaneObject(pane);
	Add(pane);

	// Center the application window.
	zafWindowManager->Center(this);
}

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

	SplitterWindow *split = new SplitterWindow(0, 0, 60, 10);

	zafWindowManager->Add(split);

	Control();

	return (0);
}
