2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_GUI_STATIC_TEXT_H_INCLUDED
|
|
|
|
#define IRR_C_GUI_STATIC_TEXT_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
|
|
|
#include "IGUIStaticText.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
class CGUIStaticText : public IGUIStaticText
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
|
|
|
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle,
|
|
|
|
bool background = false);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CGUIStaticText();
|
|
|
|
|
|
|
|
//! draws the element and its children
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void draw() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets another skin independent font.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setOverrideFont(IGUIFont* font=0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the override font (if any)
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IGUIFont* getOverrideFont() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Get the font which is used right now for drawing
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IGUIFont* getActiveFont() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets another color for the text.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setOverrideColor(video::SColor color) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets another color for the background.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setBackgroundColor(video::SColor color) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets whether to draw the background
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setDrawBackground(bool draw) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the background color
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SColor getBackgroundColor() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if background drawing is enabled
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isDrawBackgroundEnabled() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets whether to draw the border
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setDrawBorder(bool draw) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if border drawing is enabled
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isDrawBorderEnabled() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets alignment mode for text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the override color
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SColor getOverrideColor() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2020-12-10 15:45:30 +01:00
|
|
|
//! Gets the currently used text color
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual video::SColor getActiveColor() const IRR_OVERRIDE;
|
2020-12-10 15:45:30 +01:00
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
//! Sets if the static text should use the override color or the
|
|
|
|
//! color in the gui skin.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void enableOverrideColor(bool enable) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if an override color is enabled
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isOverrideColorEnabled() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set whether the text in this label should be clipped if it goes outside bounds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setTextRestrainedInside(bool restrainedInside) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if the text in this label should be clipped if it goes outside bounds
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isTextRestrainedInside() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Enables or disables word wrap for using the static text as
|
|
|
|
//! multiline text control.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setWordWrap(bool enable) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if word wrap is enabled
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isWordWrapEnabled() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the new caption of this element.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setText(const wchar_t* text) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the height of the text in pixels when it is drawn.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 getTextHeight() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the width of the current text, in the current font
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual s32 getTextWidth() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Updates the absolute position, splits text if word wrap is enabled
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void updateAbsolutePosition() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set whether the string should be interpreted as right-to-left (RTL) text
|
|
|
|
/** \note This component does not implement the Unicode bidi standard, the
|
|
|
|
text of the component should be already RTL if you call this. The
|
|
|
|
main difference when RTL is enabled is that the linebreaks for multiline
|
|
|
|
elements are performed starting from the end.
|
|
|
|
*/
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setRightToLeft(bool rtl) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Checks if the text should be interpreted as right-to-left text
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isRightToLeft() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Writes attributes of the element.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//! Breaks the single text line.
|
|
|
|
void breakText();
|
|
|
|
|
|
|
|
EGUI_ALIGNMENT HAlign, VAlign;
|
|
|
|
bool Border;
|
|
|
|
bool OverrideColorEnabled;
|
|
|
|
bool OverrideBGColorEnabled;
|
|
|
|
bool WordWrap;
|
|
|
|
bool Background;
|
|
|
|
bool RestrainTextInside;
|
|
|
|
bool RightToLeft;
|
|
|
|
|
|
|
|
video::SColor OverrideColor, BGColor;
|
|
|
|
gui::IGUIFont* OverrideFont;
|
|
|
|
gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated.
|
|
|
|
|
|
|
|
core::array< core::stringw > BrokenText;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif // _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
|
|
|
#endif
|