#include <CtrlLib/CtrlLib.h>
#include <stdio.h>


using namespace Upp;

struct MyApp : TopWindow {
	
	//nötig, weil sonst THISBACK nicht aufgelöst wird
	typedef MyApp CLASSNAME;
		
	Button b1,b2,b3,b4,b5,b6,bexit;	
	void Exit();
	virtual void Paint(Draw& w);
	MyApp();

};

	void MyApp::Exit() 
	{
		if (PromptOKCancel("Exit MyApp ?"))
			Break();
	}

	void MyApp::Paint(Draw& w) {
				
		w.DrawRect(GetSize(), SWhite);
			
		w.DrawImage(60, 240, CtrlImg::save());
		w.DrawImage(170, 210, 80, 80, CtrlImg::save());
		w.DrawImage(290, 240, CtrlImg::save(), Blue);
		w.DrawImage(350, 210, 80, 80, CtrlImg::save(), Blue);
				
	}

	typedef MyApp CLASSNAME;
	
	MyApp::MyApp() {
		BackPaint();
		
		b1.SetImage(CtrlImg::save());
		b2.SetImage(CtrlImg::save());
		bexit.Exit();
		Title("GuiTestApplication");
		
		*this << b1.LeftPos(10,80).TopPos(480,40)
			  << b2.SetLabel("Two").LeftPos(100,80).TopPos(480,40)
			  << b3.SetLabel("Three").LeftPos(200,80).TopPos(480,40)
			  << b4.SetLabel("Four").LeftPos(300,80).TopPos(480,40)
			  << b5.SetLabel("Five").LeftPos(400,80).TopPos(480,40)
			  << b6.SetLabel("Six").LeftPos(500,80).TopPos(480,40)
			  << bexit.SetLabel("Exit").LeftPos(600,80).TopPos(480,40);
	
		
		bexit <<= THISBACK(Exit);
	}

GUI_APP_MAIN
{
	MyApp().FullScreen().RunAppModal();
}
