Line data Source code
1 : /* Copyright (C) 2021 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/CGUISprite.h"
22 : #include "gui/ObjectBases/IGUIObject.h"
23 : #include "gui/ObjectBases/IGUIScrollBarOwner.h"
24 : #include "gui/ObjectBases/IGUITextOwner.h"
25 : #include "gui/SettingTypes/CGUIString.h"
26 :
27 : /**
28 : * Text field that just displays static text.
29 : */
30 : class CText : public IGUIObject, public IGUIScrollBarOwner, public IGUITextOwner
31 : {
32 0 : GUI_OBJECT(CText)
33 : public:
34 : CText(CGUI& pGUI);
35 : virtual ~CText();
36 :
37 : /**
38 : * @see IGUIObject#ResetStates()
39 : */
40 : virtual void ResetStates();
41 :
42 : /**
43 : * @see IGUIObject#UpdateCachedSize()
44 : */
45 : virtual void UpdateCachedSize();
46 :
47 : /**
48 : * @return the object text size.
49 : */
50 : CSize2D GetTextSize();
51 :
52 : virtual const CStrW& GetTooltipText() const;
53 : protected:
54 : /**
55 : * Sets up text, should be called every time changes has been
56 : * made that can change the visual.
57 : */
58 : void SetupText();
59 :
60 : /**
61 : * @see IGUIObject#HandleMessage()
62 : */
63 : virtual void HandleMessage(SGUIMessage& Message);
64 :
65 : /**
66 : * Draws the Text
67 : */
68 : virtual void Draw(CCanvas2D& canvas);
69 :
70 : virtual void CreateJSObject();
71 :
72 : /**
73 : * Placement of text. Ignored when scrollbars are active.
74 : */
75 : CVector2D m_TextPos;
76 :
77 : CGUISimpleSetting<float> m_BufferZone;
78 : CGUISimpleSetting<CGUIString> m_Caption;
79 : CGUISimpleSetting<bool> m_Clip;
80 : CGUISimpleSetting<CStrW> m_Font;
81 : CGUISimpleSetting<bool> m_ScrollBar;
82 : CGUISimpleSetting<CStr> m_ScrollBarStyle;
83 : CGUISimpleSetting<bool> m_ScrollBottom;
84 : CGUISimpleSetting<bool> m_ScrollTop;
85 : CGUISimpleSetting<CGUISpriteInstance> m_Sprite;
86 : CGUISimpleSetting<CGUISpriteInstance> m_SpriteOverlay;
87 : CGUISimpleSetting<CGUIColor> m_TextColor;
88 : CGUISimpleSetting<CGUIColor> m_TextColorDisabled;
89 : };
90 :
91 : #endif // INCLUDED_CTEXT
|