1 // SuperTuxKart - a fun racing game with go-kart 2 // Copyright (C) 2010-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 #ifndef __BUBBLE_WIDGET_HPP__ 19 #define __BUBBLE_WIDGET_HPP__ 20 21 #include <rect.h> 22 #include <irrString.h> 23 24 #include "guiengine/widget.hpp" 25 #include "utils/leak_check.hpp" 26 27 namespace GUIEngine 28 { 29 const int BUBBLE_MARGIN_ON_RIGHT = 15; 30 31 /** 32 * A text widget that can expand when focused 33 * \ingroup widgetsgroup 34 */ 35 class BubbleWidget : public Widget 36 { 37 friend class Skin; 38 39 /** shrinked size of this widget (size allowed in layout; internal text may be bigger than that). 40 * If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size. 41 */ 42 irr::core::rect<irr::s32> m_shrinked_size; 43 44 /** Expanded size of this widget (size to see all text inside the bubble). 45 * If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size. 46 */ 47 irr::core::rect<irr::s32> m_expanded_size; 48 49 /** Text shrinked to fit into the allowed layout space (will be same as m_text if all text fits) */ 50 irr::core::stringw m_shrinked_text; 51 52 /** For the skin to create the zooming effect */ 53 float m_zoom; 54 55 /** Will add/replace text in the bubble. If it doesn't fit, the text will get shrinked. **/ 56 void replaceText(); 57 58 public: 59 60 LEAK_CHECK() 61 62 BubbleWidget(); 63 64 virtual void add(); 65 66 virtual EventPropagation focused(const int playerID); 67 68 void updateSize(); 69 70 void setText(const irr::core::stringw &s); 71 getHeightNeededAroundLabel() const72 virtual int getHeightNeededAroundLabel() const { return 10; } 73 }; 74 75 } 76 77 #endif 78