template "CtrlLib application with main window" main;

id     "Main window class name" classname = PACKAGE;
select("No layouts", "Generate layout file", "Main window has layout", "Main window has OK/Cancel")
       "Layout" lay = 2;
option "Imagelist file"         iml;
option "Multithreaded"          mt;

@@<:PACKAGE:>.h
#ifndef _<:PACKAGE:>_<:PACKAGE:>_h
#define _<:PACKAGE:>_<:PACKAGE:>_h

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

<:?lay:>#define LAYOUTFILE <<:PACKAGE:>/<:PACKAGE:>.lay>
#include <CtrlCore/lay.h><:.:>

<:?iml:>#define IMAGEFILE <<:PACKAGE:>/<:PACKAGE:>.iml>
#include <Draw/iml_header.h><:.:>

class <:classname:> : public <:lay > 1 ? "With" + classname + "Layout<TopWindow>" : "TopWindow":> {
public:
	typedef <:classname:> CLASSNAME;
	<:classname:>();
};

#endif

@@main.cpp
#include "<:PACKAGE:>.h"

<:?iml:>#define IMAGEFILE <<:PACKAGE:>/<:PACKAGE:>.iml>
#include <Draw/iml_source.h><:.:>

<:classname:>::<:classname:>()
{
	<:?lay > 1:>CtrlLayout<:(lay == 3 ? "OKCancel" : ""):>(*this, "Window title");<:.:>
}

GUI_APP_MAIN
{
	<:classname:>().Run();
}

@@<:PACKAGE:>.lay
??lay

LAYOUT(<:classname:>Layout, 200, 100)
	<:?lay == 3:>ITEM(Button, ok, SetLabel("OK").RightPosZ(90, 80).BottomPosZ(4, 22))
	ITEM(Button, cancel, SetLabel("Cancel").RightPosZ(4, 80).BottomPosZ(4, 22))<:.:>
END_LAYOUT

@@<:PACKAGE:>.iml
??iml

@@<:PACKAGE:>.upp
uses
	CtrlLib;

file
	"<:PACKAGE:>.h"
	, main.cpp
	<:?lay:>, "<:PACKAGE:>.lay"<:.:>
	<:?iml:>, "<:PACKAGE:>.iml"<:.:>
;

mainconfig
	"" = <:?mt:>"GUI MT"<:/:>"GUI"<:.:>;
