/** 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/imagebutton.cpp

*/

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

tUINT32	sgxGUIImageButtonParams::DEFAULT_WIDTH = 48;
tUINT32	sgxGUIImageButtonParams::DEFAULT_HEIGHT = 48;

sgxGUIImageButtonParams::sgxGUIImageButtonParams(const sgxGUISkinnedImageButton::tButtonType type) {
	m_Type = type;
}

sgxGUIImageButton::sgxGUIImageButton(const tINT32 x, const tINT32 y, const sgxGUIImageButtonParams &params) :
	sgxWidget(x,y,CGUIDesignScreen::widgetImageButton), 
	m_SetupParams(params)
{
	m_pSkinParams = CSGXGUI::get()->getCurrentSkin()->getSkinnedImageButton();
	m_pSkinParams->cursorOver = m_isOver;
	m_pSkinParams->m_Type = m_SetupParams.m_Type;
}

void	
sgxGUIImageButton::getArea(sgxRect2i &rc) const {
	rc.left = m_X;
	rc.top = m_Y;
	rc.right = m_X+DEFAULT_WIDTH;
	rc.bottom = m_Y+DEFAULT_HEIGHT;
}

tBOOL sgxGUIImageButton::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+DEFAULT_WIDTH;
	m_pSkinParams->bottomright.y = m_pSkinParams->topleft.y+DEFAULT_HEIGHT;

	m_pSkinParams->focused = isFocused();
	m_pSkinParams->selected = m_DirectedState;
	m_pSkinParams->cursorOver = m_isOver;
	m_pSkinParams->enabled = m_bEnabled;

	m_pSkinParams->draw();
#if 0
	if (m_DirectedState) {
		// "in" state
	}
	if (isFocused()) {
		// dotted lines around it
	}
	
//		drawButton(position, position2, m_DirectedState, isFocused());
#endif

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


	
