/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program 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 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI #include "glgui_button.h" #include "text.h" namespace OrxGui { NewObjectListDefinition(GLGuiButton); /** * standard constructor */ GLGuiButton::GLGuiButton (const std::string& label) { this->init(); this->_label.setText( label ); } /** * standard deconstructor */ GLGuiButton::~GLGuiButton() { /* this does not have to be done, since the Label is a child, * and will be deleted by Element2D's deletion Process * delete this->label; */ } /** * @brief initializes the GUI-element */ void GLGuiButton::init() { this->registerObject(this, GLGuiButton::_objectList); this->setSelectable(true); this->setFocusable(true); this->setClickable(true); this->_label.setFont(this->font()); this->_label.setColor(this->foregroundColor() ); this->_label.setParent2D(this); this->_label.setVisibility(false); } void GLGuiButton::setLabel(const std::string& label) { this->_label.setText(label); this->resize(); } void GLGuiButton::updateFrontColor() { this->_label.setColor(this->foregroundColor()); } void GLGuiButton::clicking(const Vector2D& pos) { GLGuiWidget::clicking(pos); clicked.emit(); } void GLGuiButton::releasing(const Vector2D& pos, bool focused) { GLGuiWidget::releasing(pos, focused); released.emit(); } void GLGuiButton::hiding() { this->_label.setVisibility(false); } void GLGuiButton::showing() { this->_label.setVisibility(true); } bool GLGuiButton::processEvent(const Event& event) { if (event.type == SDLK_SPACE) { if (event.bPressed) clicked.emit(); else released.emit(); return true; } return false; } /** * @brief draws the GLGuiButton */ void GLGuiButton::draw() const { GLGuiWidget::draw(); } }