/*  $Id: setupgui.cpp,v 1.39 2004/03/13 23:04:13 mbn 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/setupgui.h"
#include "API/GUI/component_manager.h"
#include "default_component_types.h"

static int ref_count = 0;

CL_SetupGUI::CL_SetupGUI(bool register_resources_only)
{
	CL_SetupGUI::init(register_resources_only);
}

CL_SetupGUI::~CL_SetupGUI()
{
	CL_SetupGUI::deinit();
}

void CL_SetupGUI::init(bool register_resources_only)
{
	ref_count++;
	if (ref_count != 1) return;

	if (register_resources_only) return;

	CL_ComponentType::component_types["button"] = new CL_ComponentType_Button;
	CL_ComponentType::component_types["checkbox"] = new CL_ComponentType_CheckBox;
	CL_ComponentType::component_types["filedialog"] = new CL_ComponentType_FileDialog;
	CL_ComponentType::component_types["frame"] = new CL_ComponentType_Frame;
	CL_ComponentType::component_types["image"] = new CL_ComponentType_Image;
	CL_ComponentType::component_types["inputbox"] = new CL_ComponentType_InputBox;
	CL_ComponentType::component_types["label"] = new CL_ComponentType_Label;
	CL_ComponentType::component_types["listbox"] = new CL_ComponentType_ListBox;
	CL_ComponentType::component_types["progressbar"] = new CL_ComponentType_ProgressBar;
	CL_ComponentType::component_types["radiobutton"] = new CL_ComponentType_RadioButton;
	CL_ComponentType::component_types["scrollbar"] = new CL_ComponentType_ScrollBar;
	CL_ComponentType::component_types["window"] = new CL_ComponentType_Window;
}

void CL_SetupGUI::deinit()
{
	ref_count--;
	if (ref_count != 0) return;

	delete CL_ComponentType::component_types["button"];
	delete CL_ComponentType::component_types["checkbox"];
	delete CL_ComponentType::component_types["filedialog"];
	delete CL_ComponentType::component_types["frame"];
	delete CL_ComponentType::component_types["image"];
	delete CL_ComponentType::component_types["inputbox"];
	delete CL_ComponentType::component_types["label"];
	delete CL_ComponentType::component_types["listbox"];
	delete CL_ComponentType::component_types["progressbar"];
	delete CL_ComponentType::component_types["radiobutton"];
	delete CL_ComponentType::component_types["scrollbar"];
	delete CL_ComponentType::component_types["window"];
}
