| [25140] | 1 | /* Copyright (C) 2021 Wildfire Games.
|
|---|
| [27965] | 2 | * This file is part of 0 A.D.
|
|---|
| [6830] | 3 | *
|
|---|
| [27965] | 4 | * 0 A.D. is free software: you can redistribute it and/or modify
|
|---|
| [6830] | 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 | *
|
|---|
| [27965] | 9 | * 0 A.D. is distributed in the hope that it will be useful,
|
|---|
| [6830] | 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
|
|---|
| [27965] | 15 | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| [6830] | 16 | */
|
|---|
| 17 |
|
|---|
| [5040] | 18 | #ifndef INCLUDED_CBUTTON
|
|---|
| 19 | #define INCLUDED_CBUTTON
|
|---|
| [9] | 20 |
|
|---|
| [23005] | 21 | #include "gui/CGUISprite.h"
|
|---|
| [23028] | 22 | #include "gui/ObjectBases/IGUIButtonBehavior.h"
|
|---|
| 23 | #include "gui/ObjectBases/IGUIObject.h"
|
|---|
| 24 | #include "gui/ObjectBases/IGUITextOwner.h"
|
|---|
| 25 | #include "gui/SettingTypes/CGUIString.h"
|
|---|
| [25408] | 26 | #include "gui/SettingTypes/MouseEventMask.h"
|
|---|
| [25152] | 27 | #include "maths/Vector2D.h"
|
|---|
| [9] | 28 |
|
|---|
| [23020] | 29 | class CButton : public IGUIObject, public IGUITextOwner, public IGUIButtonBehavior
|
|---|
| [9] | 30 | {
|
|---|
| 31 | GUI_OBJECT(CButton)
|
|---|
| 32 | public:
|
|---|
| [22741] | 33 | CButton(CGUI& pGUI);
|
|---|
| [9] | 34 | virtual ~CButton();
|
|---|
| 35 |
|
|---|
| [9340] | 36 | /**
|
|---|
| 37 | * @see IGUIObject#ResetStates()
|
|---|
| 38 | */
|
|---|
| [23020] | 39 | virtual void ResetStates();
|
|---|
| [94] | 40 |
|
|---|
| [66] | 41 | /**
|
|---|
| [23020] | 42 | * @see IGUIObject#UpdateCachedSize()
|
|---|
| 43 | */
|
|---|
| 44 | virtual void UpdateCachedSize();
|
|---|
| 45 |
|
|---|
| 46 | /**
|
|---|
| [25225] | 47 | * @return the object text size.
|
|---|
| 48 | */
|
|---|
| 49 | CSize2D GetTextSize();
|
|---|
| 50 |
|
|---|
| 51 | /**
|
|---|
| [9340] | 52 | * @see IGUIObject#HandleMessage()
|
|---|
| [66] | 53 | */
|
|---|
| [16931] | 54 | virtual void HandleMessage(SGUIMessage& Message);
|
|---|
| [9] | 55 |
|
|---|
| [66] | 56 | /**
|
|---|
| 57 | * Draws the Button
|
|---|
| 58 | */
|
|---|
| [25588] | 59 | virtual void Draw(CCanvas2D& canvas);
|
|---|
| [290] | 60 |
|
|---|
| [25408] | 61 | /**
|
|---|
| 62 | * @see IGUIObject#IsMouseOver()
|
|---|
| 63 | */
|
|---|
| 64 | virtual bool IsMouseOver() const;
|
|---|
| 65 |
|
|---|
| [290] | 66 | protected:
|
|---|
| 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 | /**
|
|---|
| [22969] | 74 | * Picks the text color depending on current object settings.
|
|---|
| 75 | */
|
|---|
| 76 | const CGUIColor& ChooseColor();
|
|---|
| 77 |
|
|---|
| 78 | /**
|
|---|
| [290] | 79 | * Placement of text.
|
|---|
| 80 | */
|
|---|
| [25152] | 81 | CVector2D m_TextPos;
|
|---|
| [23005] | 82 |
|
|---|
| [24378] | 83 | virtual void CreateJSObject();
|
|---|
| 84 |
|
|---|
| [23005] | 85 | // Settings
|
|---|
| [25392] | 86 | CGUISimpleSetting<float> m_BufferZone;
|
|---|
| 87 | CGUISimpleSetting<CGUIString> m_Caption;
|
|---|
| 88 | CGUISimpleSetting<CStrW> m_Font;
|
|---|
| 89 | CGUISimpleSetting<CGUISpriteInstance> m_Sprite;
|
|---|
| 90 | CGUISimpleSetting<CGUISpriteInstance> m_SpriteOver;
|
|---|
| 91 | CGUISimpleSetting<CGUISpriteInstance> m_SpritePressed;
|
|---|
| 92 | CGUISimpleSetting<CGUISpriteInstance> m_SpriteDisabled;
|
|---|
| 93 | CGUISimpleSetting<CGUIColor> m_TextColor;
|
|---|
| 94 | CGUISimpleSetting<CGUIColor> m_TextColorOver;
|
|---|
| 95 | CGUISimpleSetting<CGUIColor> m_TextColorPressed;
|
|---|
| 96 | CGUISimpleSetting<CGUIColor> m_TextColorDisabled;
|
|---|
| [25408] | 97 | CGUIMouseEventMask m_MouseEventMask;
|
|---|
| [9] | 98 | };
|
|---|
| 99 |
|
|---|
| [16931] | 100 | #endif // INCLUDED_CBUTTON
|
|---|