/*Copyright (C) 2010 Deveaux Duncan

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 "TextButton.hpp"

TextButton::TextButton()
{
    TextButton("", 100, 50, sf::Color());
}

TextButton::TextButton(const std::string &text, float width, float height, const sf::Color &borderColor) :
Button(width, height, borderColor), m_text(text), m_textField( sf::Text(text) )
{
    centerText();
}

void TextButton::Render(sf::RenderTarget& target, sf::Renderer& renderer) const
{
    Button::Render(target, renderer);
    target.Draw(m_textField);
}

void TextButton::centerText()
{
    m_textField.SetX((m_width - m_textField.GetRect().Width) / 2);
    m_textField.SetY((m_height - m_textField.GetRect().Height) / 2);
}

//Get and set methods
void TextButton::setText(const std::string &text)
{
    m_text = text;
    
    m_textField.SetString(m_text);
    centerText();
}

const std::string &TextButton::getText() const
{
    return m_text;
}

void TextButton::setTextFont(const sf::Font &textFont)
{
    m_textField.SetFont(textFont);
}

const sf::Font &TextButton::getTextFont() const
{
    return m_textField.GetFont();
}

void TextButton::setTextSize(unsigned int textSize)
{
    m_textField.SetCharacterSize(textSize);
}

unsigned int TextButton::getTextSize() const
{
    return m_textField.GetCharacterSize();
}

void TextButton::setTextColor(const sf::Color &textColor)
{
    m_textField.SetColor(textColor);
}

const sf::Color &TextButton::getTextColor() const
{
    return m_textField.GetColor();
}

void TextButton::setTextStyle(unsigned long textStyle)
{
    m_textField.SetStyle(textStyle);
}

unsigned long TextButton::getTextStyle() const
{
    return m_textField.GetStyle();
}