/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: src/sgx/gui/radio_button.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/graphics/graphics.hpp"
#include "sgx/gui/gui.hpp"

#ifdef SGX_PLATFORM_NDS
tUINT32	sgxGUIRadioButtonParams::DEFAULT_WIDTH = 32;
tUINT32	sgxGUIRadioButtonParams::DEFAULT_HEIGHT = 32;
#else
tUINT32	sgxGUIRadioButtonParams::DEFAULT_WIDTH = 48;
tUINT32	sgxGUIRadioButtonParams::DEFAULT_HEIGHT = 48;
#endif

sgxGUIRadioButtonParams::sgxGUIRadioButtonParams(const sgxString &text, sgxWidgetGroup *pGroup, tBOOL initState) {
	m_bInitialState = initState;
	m_pGroup = pGroup;
	m_bTextOnRight = TRUE;
	m_Text = text;
	//
	m_Width = m_Height = 32;
}

sgxGUIRadioButton::sgxGUIRadioButton(const tINT32 x, const tINT32 y, const sgxGUIRadioButtonParams &params):
	sgxWidget(x,y, CGUIDesignScreen::widgetRadioButton), 
	m_SetupParams(params)
{
	m_pSkinParams = CSGXGUI::get()->getCurrentSkin()->getSkinnedRadioButton();
	m_bState = params.m_bInitialState;
}

void	
sgxGUIRadioButton::getArea(sgxRect2i &rc) const {
	rc.left = m_X;
	rc.top = m_Y;
	rc.right = m_X+m_SetupParams.m_Width;
	rc.bottom = m_Y+m_SetupParams.m_Height;
}


tBOOL sgxGUIRadioButton::onPressed(const sgxVector2 &position) {
	SGX_UNUSED(position);
// scan group
// HOW? Add widget to group vector also?
// Add removeWidget
	return TRUE;
}

tBOOL sgxGUIRadioButton::draw(const tINT32 offsetX, const tINT32 offsetY) const {
	m_pSkinParams->topleft.x = m_X+offsetX;
	m_pSkinParams->topleft.y = m_Y+offsetY;
	m_pSkinParams->bottomright.x = m_pSkinParams->topleft.x+m_SetupParams.m_Width;
	m_pSkinParams->bottomright.y = m_pSkinParams->topleft.y+m_SetupParams.m_Height;

	//m_pSkinParams->focused = isFocused();
	m_pSkinParams->selected = m_bState;
	m_pSkinParams->cursorOver = m_isOver;

	m_pSkinParams->draw();
	return sgxWidget::draw(m_pSkinParams->topleft.x, m_pSkinParams->topleft.y);
}