/*Copyright (C) 2010-2012 Duncan Deveaux

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "Button.hpp"

Button::Button() : Widget()
{
    
}

Button::Button(const Sprite &background, const Box &contentBox) :
Widget(), m_background(background), m_contentBox(contentBox)
{
    
}

void Button::draw()
{
    //Update matrix
    Drawable::pushMatrix();
    Drawable::updateMatrix();
    
    m_background.draw();
    
    Drawable::popMatrix();
}

bool Button::mouseClick(const Vector &mouseCoords)
{
    return Widget::contains( Widget::localCoords(mouseCoords) );
}

bool Button::mouseMove(const Vector &mouseCoords)
{
    return Widget::contains( Widget::localCoords(mouseCoords) );
}

void Button::setBackground(const Sprite &background)
{
    m_background = background;
}

const Sprite &Button::getBackground() const
{
    return m_background;
}

void Button::setContentBox(const Box &contentBox)
{
    m_contentBox = contentBox;
}

const Box &Button::getContentBox() const
{
    return m_contentBox;
}

float Button::getWidth() const
{
    return m_background.getWidth() * m_background.getXScale();
}

float Button::getHeight() const
{
    return m_background.getHeight() * m_background.getYScale();
}
