0ad/source/gui/CText.h
elexis 8190293f8b Remove virtual inheritance from the codebase, refs 6b51d71c85, e21ebb37f5 e326ebae46.
Remove workaround in 3d07327837 / D2136, the pointer from IGUIObject to
IGUITextOwner that avoided the dynamic_cast.
Have the GUIObject implementing class take responsibility of calling the
virtual methods in the base classes.
Leaves the code in a clean state that can serve as an example for new
GUI object classes, such as D1346, refs #4683.

Differential Revision: https://code.wildfiregames.com/D2325
Comments By: Vladislav on IRC 2019-07-30, 2019-08-22, 2019-09-20-23
Tested on: clang 8.0.1, Jenkins

This was SVN commit r23020.
2019-09-30 14:08:14 +00:00

103 lines
2.2 KiB
C++

/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_CTEXT
#define INCLUDED_CTEXT
#include "gui/CGUISprite.h"
#include "gui/CGUIString.h"
#include "gui/IGUIScrollBarOwner.h"
#include "gui/IGUITextOwner.h"
/**
* Text field that just displays static text.
*/
class CText : public IGUIObject, public IGUIScrollBarOwner, public IGUITextOwner
{
GUI_OBJECT(CText)
public:
CText(CGUI& pGUI);
virtual ~CText();
/**
* @see IGUIObject#ResetStates()
*/
virtual void ResetStates();
/**
* @see IGUIObject#UpdateCachedSize()
*/
virtual void UpdateCachedSize();
/**
* Test if mouse position is over an icon
*/
virtual bool MouseOverIcon();
protected:
/**
* Sets up text, should be called every time changes has been
* made that can change the visual.
*/
void SetupText();
virtual void RegisterScriptFunctions();
/**
* @see IGUIObject#HandleMessage()
*/
virtual void HandleMessage(SGUIMessage& Message);
/**
* Draws the Text
*/
virtual void Draw();
/**
* Script accessors to this GUI object.
*/
static JSFunctionSpec JSI_methods[];
static bool GetTextSize(JSContext* cx, uint argc, JS::Value* vp);
/**
* Placement of text. Ignored when scrollbars are active.
*/
CPos m_TextPos;
// Settings
float m_BufferZone;
CGUIString m_Caption;
i32 m_CellID;
bool m_Clip;
CStrW m_Font;
bool m_ScrollBar;
CStr m_ScrollBarStyle;
bool m_ScrollBottom;
bool m_ScrollTop;
CGUISpriteInstance m_Sprite;
EAlign m_TextAlign;
EVAlign m_TextVAlign;
CGUIColor m_TextColor;
CGUIColor m_TextColorDisabled;
CStrW m_IconTooltip;
CStr m_IconTooltipStyle;
};
#endif // INCLUDED_CTEXT