Line data Source code
1 : /* Copyright (C) 2026 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #ifndef INCLUDED_CTEXT 19 : #define INCLUDED_CTEXT 20 : 21 : #include "gui/CGUISetting.h" 22 : #include "gui/CGUISprite.h" 23 : #include "gui/ObjectBases/IGUIObject.h" 24 : #include "gui/ObjectBases/IGUIScrollBarOwner.h" 25 : #include "gui/ObjectBases/IGUITextOwner.h" 26 : #include "gui/SettingTypes/CGUIColor.h" 27 : #include "gui/SettingTypes/CGUIString.h" 28 : #include "maths/Vector2D.h" 29 : #include "ps/CStr.h" 30 : 31 : class CGUI; 32 : class CSize2D; 33 : 34 : /** 35 : * Text field that just displays static text. 36 : */ 37 : class CText : public IGUIObject, public IGUIScrollBarOwner, public IGUITextOwner 38 : { 39 0 : GUI_OBJECT(CText) 40 : public: 41 : CText(CGUI& pGUI); 42 : 43 : /** 44 : * @see IGUIObject#ResetStates() 45 : */ 46 : virtual void ResetStates(); 47 : 48 : /** 49 : * @see IGUIObject#HandleSizeChanged() 50 : */ 51 : virtual void HandleSizeChanged(); 52 : 53 : /** 54 : * @return the object text size. 55 : */ 56 : CSize2D GetTextSize(); 57 : 58 : CSize2D GetPreferredTextSize(); 59 : 60 : virtual const CStrW& GetTooltipText() const; 61 : protected: 62 : /** 63 : * Sets up text, should be called every time changes has been 64 : * made that can change the visual. 65 : */ 66 : void SetupText(); 67 : 68 : /** 69 : * @see IGUIObject#HandleMessage() 70 : */ 71 : virtual void HandleMessage(SGUIMessage& Message); 72 : 73 : /** 74 : * Draws the Text 75 : */ 76 : virtual void Draw(CCanvas2D& canvas); 77 : 78 : virtual void CreateJSObject(); 79 : 80 : /** 81 : * Placement of text. Ignored when scrollbars are active. 82 : */ 83 : CVector2D m_TextPos; 84 : 85 : CGUISimpleSetting<float> m_BufferZone; 86 : CGUISimpleSetting<CGUIString> m_Caption; 87 : CGUISimpleSetting<bool> m_Clip; 88 : CGUISimpleSetting<CStrW> m_Font; 89 : CGUISimpleSetting<bool> m_ScrollBar; 90 : CGUISimpleSetting<CStr> m_ScrollBarStyle; 91 : CGUISimpleSetting<bool> m_ScrollBottom; 92 : CGUISimpleSetting<bool> m_ScrollTop; 93 : CGUISimpleSetting<CGUISpriteInstance> m_Sprite; 94 : CGUISimpleSetting<CGUISpriteInstance> m_SpriteOverlay; 95 : CGUISimpleSetting<CGUIColor> m_TextColor; 96 : CGUISimpleSetting<CGUIColor> m_TextColorDisabled; 97 : }; 98 : 99 : #endif // INCLUDED_CTEXT