1 // SuperTuxKart - a fun racing game with go-kart 2 // Copyright (C) 2009-2015 Marianne Gagnon 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 3 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 19 20 #ifndef HEADER_CHECKBOX_HPP 21 #define HEADER_CHECKBOX_HPP 22 23 #include "guiengine/widget.hpp" 24 #include "utils/leak_check.hpp" 25 #include "utils/ptr_vector.hpp" 26 27 namespace GUIEngine 28 { 29 /** 30 * \brief A checkbox widget. 31 * \ingroup widgetsgroup 32 */ 33 class CheckBoxWidget : public Widget 34 { 35 bool m_state; 36 EventPropagation transmitEvent(Widget* w, 37 const std::string& originator, 38 const int playerID); 39 40 public: 41 42 LEAK_CHECK() 43 44 CheckBoxWidget(); ~CheckBoxWidget()45 virtual ~CheckBoxWidget() {} 46 47 /** \brief Implement callback from parent class Widget */ 48 void add(); 49 50 /** Get whether the checkbox is checked */ getState() const51 bool getState() const { return m_state; } 52 53 /** Set whether the checkbox is checked */ setState(const bool checked)54 void setState(const bool checked) { m_state = checked; } 55 56 57 /** When inferring widget size from its label length, this method will be called to 58 * if/how much space must be added to the raw label's size for the widget to be large enough */ getHeightNeededAroundLabel() const59 virtual int getHeightNeededAroundLabel() const { return 10; } 60 }; 61 } 62 63 #endif 64