/*  $Id: menu_node_generic.h,v 1.4 2003/12/15 19:44:15 harry Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/

#ifndef header_menu_node_generic
#define header_menu_node_generic

#include "API/gui.h"


class CL_MenuNode;
class CL_Menu;
class CL_Menu_Generic;

class CL_MenuNode_Generic
{
 public:
	// construction
	CL_MenuNode_Generic( CL_MenuNode *self, CL_Menu *parent_menu);
	virtual ~CL_MenuNode_Generic();

	// attributes
	CL_Component *data;
	CL_Menu *submenu;
	CL_Menu *parent_menu;
	std::string name;
	bool close_on_click;

	bool mouse_in_submenus();
	bool has_mouse_over();
	bool has_mouse_in_submenus();
	bool has_open_submenu();

	bool child_has_mouse_over(const CL_Component *comp) const;

	// operations
	void set_submenu(CL_Menu *menu);
	void set_parent_menu(CL_Menu *menu);
	void open_submenu();
	void collapse();
	void collapse_submenus();
	void reposition();

	// callbacks
	void on_mouse_down(const CL_InputEvent &e);
	void on_mouse_up(const CL_InputEvent &e);
	void on_mouse_enter();
	void on_child_add(CL_Component *child);

	// signals:
	CL_Signal_v0 sig_reposition;
	CL_Signal_v0 sig_clicked;

 private:
	// implementation
	CL_MenuNode *node;
	bool close_lock;

	CL_SlotContainer slots;

	friend class CL_Menu;
};

#endif
