/*  $Id: progressbar.cpp,v 1.11 2003/09/18 17:53:29 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/progressbar.h"
#include "API/GUI/stylemanager.h"
#include "API/Core/XML/dom_element.h"
#include "progressbar_generic.h"

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

CL_ProgressBar::CL_ProgressBar(
	CL_Component *parent,
	CL_StyleManager *style)
: CL_Component(parent, style), impl(NULL)
{
	impl = new CL_ProgressBar_Generic(this, 0);
	get_style_manager()->connect_styles("progressbar", this);
	find_preferred_size();
}

CL_ProgressBar::CL_ProgressBar(
	int steps,
	CL_Component *parent,
	CL_StyleManager *style)
: CL_Component(parent, style), impl(NULL)
{
	impl = new CL_ProgressBar_Generic(this, steps);
	get_style_manager()->connect_styles("progressbar", this);
	find_preferred_size();
}

CL_ProgressBar::CL_ProgressBar(
	const CL_Rect &pos,
	int steps,
	CL_Component *parent,
	CL_StyleManager *style)
: CL_Component(pos, parent, style), impl(NULL)
{
	impl = new CL_ProgressBar_Generic(this, steps);
	get_style_manager()->connect_styles("progressbar", this);
}

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

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

int CL_ProgressBar::get_progress() const
{
	return impl->progress;
}

int CL_ProgressBar::get_steps() const
{
	return impl->steps;
}

float CL_ProgressBar::get_percentage() const
{
	return impl->get_percentage();
}

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

void CL_ProgressBar::set_steps(int total_steps)
{
	impl->set_steps(total_steps);
}

void CL_ProgressBar::set_progress(int progress)
{
	impl->set_progress(progress);
}

void CL_ProgressBar::increase(int steps)
{
	impl->increase(steps);
}

void CL_ProgressBar::reset()
{
	impl->reset();
}
