#ifndef _APPWINDOW_H_
#define _APPWINDOW_H_

#include "../tk/gui/gui.h"
#include "toolbutton.h"

#include <list>

using namespace std;

class ToolButton;
class Designer;

/**
 * \brief Represents window with toolbox and main application menu.
 * 
 * \date 01-29-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class AppWindow:public ButtonPressListener
{
	Designer* designer;
	Ptr<TkTopLevel> window;
	list<Ptr<TkTopLevel> > lstTopLevels;
	Ptr<TclInterp> interp;

	typedef list<Ptr<ToolButton> > t_buttons;
	t_buttons buttons;
	Ptr<ToolButton> activeButton;
	Ptr<ToolButton> butArrow;

	class MyMenuListener:public TkMenuListener
	{
		AppWindow* parent;
	public:
		MyMenuListener(AppWindow* parent):parent(parent)
		{}
		void handleEvent(TkMenu* menu,const string& commandId);
	};
	Ptr<MyMenuListener> menuListener;

	class MyWindowListener;
public:
	static const char* type;
	const char* getType() const
	{
		return type;
	}
	
	/**
	 * \return active tool button
	 */
	Ptr<ToolButton>& getActiveButton()
	{
		return activeButton;
	}


	/**
	 * \brief ctor
	 * \param interp interpret
	 * \param designer designer represents whole application GUI 
	 */
	AppWindow(Ptr<TclInterp>& interp,Designer* designer);

	void onButtonPress(EHeader& header,int button,const string& state,int x,int y,int x_root,int y_root);
	
	/**
	 * \brief handles tool button press
	 * \param button 
	 */
	void toolButtonPressed(TkBase* button);


	/**
	 * \brief sets tool "arrow" to be active
	 */
	void setArrowToolActive();
	
	/**
	 * \brief insert new toplevel into editation list
	 * \param topLevel top level widget
	 */
	void enlistWindow(TkTopLevel* topLevel);

	/**
	 * \brief make window visible/hidden
	 * \param value visiblity
	 */
	void setVisible(bool value);
};

#endif/*_APPWINDOW_H_*/
