2009-01-14 04:37:51 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// 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__
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
#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
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual ~CGUIStaticText();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! draws the element and its children
|
|
|
|
virtual void draw();
|
|
|
|
|
|
|
|
//! Sets another skin independent font.
|
|
|
|
virtual void setOverrideFont(IGUIFont* font=0);
|
|
|
|
|
|
|
|
//! Gets the override font (if any)
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual IGUIFont * getOverrideFont() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets another color for the text.
|
|
|
|
virtual void setOverrideColor(video::SColor color);
|
|
|
|
|
2007-06-08 18:07:21 -07:00
|
|
|
//! Sets another color for the background.
|
|
|
|
virtual void setBackgroundColor(video::SColor color);
|
|
|
|
|
|
|
|
//! Sets whether to draw the background
|
|
|
|
virtual void setDrawBackground(bool draw);
|
|
|
|
|
2007-06-30 16:30:40 -07:00
|
|
|
//! Sets whether to draw the border
|
|
|
|
virtual void setDrawBorder(bool draw);
|
|
|
|
|
|
|
|
//! Sets alignment mode for text
|
|
|
|
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Gets the override color
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual video::SColor const & getOverrideColor() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets if the static text should use the overide color or the
|
|
|
|
//! color in the gui skin.
|
|
|
|
virtual void enableOverrideColor(bool enable);
|
|
|
|
|
|
|
|
//! Checks if an override color is enabled
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual bool isOverrideColorEnabled() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Enables or disables word wrap for using the static text as
|
|
|
|
//! multiline text control.
|
|
|
|
virtual void setWordWrap(bool enable);
|
|
|
|
|
|
|
|
//! Checks if word wrap is enabled
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual bool isWordWrapEnabled() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets the new caption of this element.
|
|
|
|
virtual void setText(const wchar_t* text);
|
|
|
|
|
|
|
|
//! Returns the height of the text in pixels when it is drawn.
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getTextHeight() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Returns the width of the current text, in the current font
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getTextWidth() const;
|
2007-06-30 16:30:40 -07:00
|
|
|
|
|
|
|
//! Updates the absolute position, splits text if word wrap is enabled
|
|
|
|
virtual void updateAbsolutePosition();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Writes attributes of the element.
|
2007-09-14 15:25:59 -07:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//! Breaks the single text line.
|
|
|
|
void breakText();
|
|
|
|
|
2007-06-30 16:30:40 -07:00
|
|
|
EGUI_ALIGNMENT HAlign, VAlign;
|
2009-01-22 04:40:06 -08:00
|
|
|
bool Border;
|
2007-05-20 11:03:49 -07:00
|
|
|
bool OverrideColorEnabled;
|
|
|
|
bool WordWrap;
|
|
|
|
bool Background;
|
|
|
|
|
2007-06-08 18:07:21 -07:00
|
|
|
video::SColor OverrideColor, BGColor;
|
2007-05-20 11:03:49 -07:00
|
|
|
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
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#endif // _IRR_COMPILE_WITH_GUI_
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#endif
|
2007-09-15 17:18:13 -07:00
|
|
|
|