/*  $Id: menu_generic.h,v 1.6 2004/02/20 20:57:12 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_generic
#define header_menu_generic

class CL_Menu;
class CL_MenuNode;

class CL_Menu_Generic
{
//! Construction:
 public:
	CL_Menu_Generic(
		CL_Menu *self,
		bool vertical,
		CL_MenuNode *parent_node );
	
	virtual ~CL_Menu_Generic();

//! Attributes:
 public:
	CL_Menu *get_root_menu();
	
	std::list<CL_MenuNode*> children;
	CL_MenuNode *parent_node;

	bool vertical;
	bool menu_open;
	bool auto_resize;
	bool submenu_open;
	bool click_to_open;
	bool collapse_root;
	
	bool has_mouse_in_submenus();
	bool has_mouse_over();

	CL_Menu *get_menu( std::vector<std::string> path);
	CL_MenuNode *get_node( std::vector<std::string> path );
	CL_Component *get_item( std::vector<std::string> path );

//! Signals:
	CL_Signal_v2<int,int> sig_reposition;

//! Operations:
 public:
	void set_vertical(bool vertical);
	void add_node(CL_MenuNode *node);
	void remove_node(CL_MenuNode *node);
	void set_parent_node( CL_MenuNode *node );

	void open();
	void collapse();
	void collapse_submenus();
	
	int get_items_height();
	int get_items_width();

	CL_Menu *create_menu( std::vector<std::string> path, std::vector<std::string> labels );
	CL_MenuNode *create_node( std::vector<std::string> path, std::vector<std::string> labels );
	CL_MenuNode *create_item( std::vector<std::string> path, std::vector<std::string> labels );
	CL_MenuNode *create_toggle_item( std::vector<std::string> path, std::vector<std::string> labels );

//! Callbacks:
 private:
	void on_mouse_up(const CL_InputEvent &e);
	void on_menu_moved(int old_x, int old_y);
	
//! Implementation:
 private:
	CL_Menu *menu;
	
	CL_SlotContainer slots;
};

#endif
