/*  $Id: menu_node.cpp,v 1.5 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
**
*/

#include "precomp.h"
#include "API/GUI/stylemanager.h"
#include "API/GUI/menu_node.h"
#include "API/GUI/menu.h"
#include "menu_node_generic.h"

/////////////////////////////////////////////////////////////////////////////
// Construction:

CL_MenuNode::CL_MenuNode(
	CL_Menu *parent_menu,
	CL_StyleManager *style)
:
	CL_Component( parent_menu, style ),
	impl(0)
{
	impl = new CL_MenuNode_Generic(this, parent_menu);
	parent_menu->add_node(this);
	get_style_manager()->connect_styles("menu_node", this);
}

CL_MenuNode::~CL_MenuNode()
{
	delete impl;
}

/////////////////////////////////////////////////////////////////////////////
// Attributes:

bool CL_MenuNode::has_submenu()
{
	if( impl->submenu )
		return true;

	return false;
}

bool CL_MenuNode::has_open_submenu()
{
	return impl->has_open_submenu();
}

bool CL_MenuNode::has_mouse_over()
{
	return impl->has_mouse_over();
}

bool CL_MenuNode::has_mouse_in_submenus()
{
	return impl->has_mouse_in_submenus();
}

CL_Component *CL_MenuNode::get_data()
{
	return impl->data;
}

CL_Menu *CL_MenuNode::get_parent_menu()
{
	return impl->parent_menu;
}

CL_Menu *CL_MenuNode::get_submenu()
{
	return impl->submenu;
}

std::string CL_MenuNode::get_name()
{
	return impl->name;
}

/////////////////////////////////////////////////////////////////////////////
// Operations:

void CL_MenuNode::collapse()
{
	impl->collapse();
}

void CL_MenuNode::open_submenu()
{
	impl->open_submenu();
}

void CL_MenuNode::set_submenu(CL_Menu *menu)
{
	impl->set_submenu(menu);
}

void CL_MenuNode::set_name(std::string name)
{
	impl->name = name;
}

void CL_MenuNode::set_parent_menu(CL_Menu *menu)
{
	impl->set_parent_menu(menu);
}

void CL_MenuNode::set_close_on_click(bool close)
{
	impl->close_on_click = close;
}

void CL_MenuNode::reposition_submenus()
{
	impl->sig_reposition();
}

/////////////////////////////////////////////////////////////////////////////
// Signals:

CL_Signal_v0 &CL_MenuNode::sig_reposition()
{
	return impl->sig_reposition;
}

CL_Signal_v0 &CL_MenuNode::sig_clicked()
{
	return impl->sig_clicked;
}
