2020-01-03 20:05:16 +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
|
|
|
|
|
|
|
|
#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__
|
|
|
|
#define __C_GUI_STATIC_TEXT_H_INCLUDED__
|
|
|
|
|
|
|
|
#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
|
2022-10-09 20:57:28 +02:00
|
|
|
void draw() override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets another skin independent font.
|
2022-10-09 20:57:28 +02:00
|
|
|
void setOverrideFont(IGUIFont* font=0) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Gets the override font (if any)
|
2022-10-09 20:57:28 +02:00
|
|
|
IGUIFont* getOverrideFont() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Get the font which is used right now for drawing
|
2022-10-09 20:57:28 +02:00
|
|
|
IGUIFont* getActiveFont() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets another color for the text.
|
2022-10-09 20:57:28 +02:00
|
|
|
void setOverrideColor(video::SColor color) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets another color for the background.
|
2022-10-09 20:57:28 +02:00
|
|
|
void setBackgroundColor(video::SColor color) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets whether to draw the background
|
2022-10-09 20:57:28 +02:00
|
|
|
void setDrawBackground(bool draw) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Gets the background color
|
2022-10-09 20:57:28 +02:00
|
|
|
video::SColor getBackgroundColor() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if background drawing is enabled
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isDrawBackgroundEnabled() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets whether to draw the border
|
2022-10-09 20:57:28 +02:00
|
|
|
void setDrawBorder(bool draw) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if border drawing is enabled
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isDrawBorderEnabled() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets alignment mode for text
|
2022-10-09 20:57:28 +02:00
|
|
|
void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Gets the override color
|
2022-10-09 20:57:28 +02:00
|
|
|
video::SColor getOverrideColor() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
2020-12-19 16:03:11 +01:00
|
|
|
//! Gets the currently used text color
|
2022-10-09 20:57:28 +02:00
|
|
|
video::SColor getActiveColor() const override;
|
2020-12-19 16:03:11 +01:00
|
|
|
|
2020-01-03 20:05:16 +01:00
|
|
|
//! Sets if the static text should use the override color or the
|
|
|
|
//! color in the gui skin.
|
2022-10-09 20:57:28 +02:00
|
|
|
void enableOverrideColor(bool enable) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if an override color is enabled
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isOverrideColorEnabled() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Set whether the text in this label should be clipped if it goes outside bounds
|
2022-10-09 20:57:28 +02:00
|
|
|
void setTextRestrainedInside(bool restrainedInside) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if the text in this label should be clipped if it goes outside bounds
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isTextRestrainedInside() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Enables or disables word wrap for using the static text as
|
|
|
|
//! multiline text control.
|
2022-10-09 20:57:28 +02:00
|
|
|
void setWordWrap(bool enable) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if word wrap is enabled
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isWordWrapEnabled() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Sets the new caption of this element.
|
2022-10-09 20:57:28 +02:00
|
|
|
void setText(const wchar_t* text) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the height of the text in pixels when it is drawn.
|
2022-10-09 20:57:28 +02:00
|
|
|
s32 getTextHeight() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the width of the current text, in the current font
|
2022-10-09 20:57:28 +02:00
|
|
|
s32 getTextWidth() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Updates the absolute position, splits text if word wrap is enabled
|
2022-10-09 20:57:28 +02:00
|
|
|
void updateAbsolutePosition() override;
|
2020-01-03 20:05:16 +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.
|
|
|
|
*/
|
2022-10-09 20:57:28 +02:00
|
|
|
void setRightToLeft(bool rtl) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Checks if the text should be interpreted as right-to-left text
|
2022-10-09 20:57:28 +02:00
|
|
|
bool isRightToLeft() const override;
|
2020-01-03 20:05:16 +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
|