Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CButton.h
Go to the documentation of this file.
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_CBUTTON
19#define INCLUDED_CBUTTON
20
21#include "gui/CGUISprite.h"
27#include "maths/Vector2D.h"
28
29class CButton : public IGUIObject, public IGUITextOwner, public IGUIButtonBehavior
30{
32public:
33 CButton(CGUI& pGUI);
34 virtual ~CButton();
35
36 /**
37 * @see IGUIObject#ResetStates()
38 */
39 virtual void ResetStates();
40
41 /**
42 * @see IGUIObject#UpdateCachedSize()
43 */
44 virtual void UpdateCachedSize();
45
46 /**
47 * @return the object text size.
48 */
50
51 /**
52 * @see IGUIObject#HandleMessage()
53 */
54 virtual void HandleMessage(SGUIMessage& Message);
55
56 /**
57 * Draws the Button
58 */
59 virtual void Draw(CCanvas2D& canvas);
60
61 /**
62 * @see IGUIObject#IsMouseOver()
63 */
64 virtual bool IsMouseOver() const;
65
66protected:
67 /**
68 * Sets up text, should be called every time changes has been
69 * made that can change the visual.
70 */
71 void SetupText();
72
73 /**
74 * Picks the text color depending on current object settings.
75 */
76 const CGUIColor& ChooseColor();
77
78 /**
79 * Placement of text.
80 */
82
83 virtual void CreateJSObject();
84
85 // Settings
98};
99
100#endif // INCLUDED_CBUTTON
#define GUI_OBJECT(obj)
Definition: IGUIObject.h:50
Definition: CButton.h:30
CVector2D m_TextPos
Placement of text.
Definition: CButton.h:81
virtual void HandleMessage(SGUIMessage &Message)
Definition: CButton.cpp:76
virtual void CreateJSObject()
Creates the JS object representing this page upon first use.
virtual ~CButton()
Definition: CButton.cpp:46
CGUISimpleSetting< CStrW > m_Font
Definition: CButton.h:88
virtual bool IsMouseOver() const
Definition: CButton.cpp:93
virtual void Draw(CCanvas2D &canvas)
Draws the Button.
Definition: CButton.cpp:83
CGUISimpleSetting< CGUISpriteInstance > m_Sprite
Definition: CButton.h:89
CGUIMouseEventMask m_MouseEventMask
Definition: CButton.h:97
const CGUIColor & ChooseColor()
Picks the text color depending on current object settings.
Definition: CButton.cpp:102
CGUISimpleSetting< CGUISpriteInstance > m_SpriteOver
Definition: CButton.h:90
virtual void ResetStates()
Definition: CButton.cpp:58
CGUISimpleSetting< CGUIColor > m_TextColorOver
Definition: CButton.h:94
CGUISimpleSetting< float > m_BufferZone
Definition: CButton.h:86
CGUISimpleSetting< CGUIColor > m_TextColor
Definition: CButton.h:93
void SetupText()
Sets up text, should be called every time changes has been made that can change the visual.
Definition: CButton.cpp:50
CGUISimpleSetting< CGUISpriteInstance > m_SpritePressed
Definition: CButton.h:91
CGUISimpleSetting< CGUIColor > m_TextColorPressed
Definition: CButton.h:95
CGUISimpleSetting< CGUIString > m_Caption
Definition: CButton.h:87
virtual void UpdateCachedSize()
Definition: CButton.cpp:64
CSize2D GetTextSize()
Definition: CButton.cpp:70
CGUISimpleSetting< CGUISpriteInstance > m_SpriteDisabled
Definition: CButton.h:92
CGUISimpleSetting< CGUIColor > m_TextColorDisabled
Definition: CButton.h:96
CButton(CGUI &pGUI)
Definition: CButton.cpp:26
Definition: Canvas2D.h:36
A custom shape that changes the object's "over-ability", and thus where one can click on it.
Definition: MouseEventMask.h:42
The main object that represents a whole GUI page.
Definition: CGUI.h:61
Definition: Size2D.h:25
Definition: Vector2D.h:32
Appends button behaviours to the IGUIObject.
Definition: IGUIButtonBehavior.h:40
GUI object such as a button or an input-box.
Definition: IGUIObject.h:60
Framework for handling Output text.
Definition: IGUITextOwner.h:53
Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yel...
Definition: CGUIColor.h:30
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:68