/Irrlicht/CGUIStaticText.h
C++ Header | 114 lines | 53 code | 34 blank | 27 comment | 0 complexity | 6914c546f4ec74c32e8a77440e919563 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0
1// Copyright (C) 2002-2010 Nikolaus Gebhardt 2// This file is part of the "Irrlicht Engine". 3// For conditions of distribution and use, see copyright notice in irrlicht.h 4 5#ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__ 6#define __C_GUI_STATIC_TEXT_H_INCLUDED__ 7 8#include "IrrCompileConfig.h" 9#ifdef _IRR_COMPILE_WITH_GUI_ 10 11#include "IGUIStaticText.h" 12#include "irrArray.h" 13 14namespace irr 15{ 16namespace gui 17{ 18 class CGUIStaticText : public IGUIStaticText 19 { 20 public: 21 22 //! constructor 23 CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment, 24 IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, 25 bool background = false); 26 27 //! destructor 28 virtual ~CGUIStaticText(); 29 30 //! draws the element and its children 31 virtual void draw(); 32 33 //! Sets another skin independent font. 34 virtual void setOverrideFont(IGUIFont* font=0); 35 36 //! Gets the override font (if any) 37 virtual IGUIFont * getOverrideFont() const; 38 39 //! Sets another color for the text. 40 virtual void setOverrideColor(video::SColor color); 41 42 //! Sets another color for the background. 43 virtual void setBackgroundColor(video::SColor color); 44 45 //! Sets whether to draw the background 46 virtual void setDrawBackground(bool draw); 47 48 //! Sets whether to draw the border 49 virtual void setDrawBorder(bool draw); 50 51 //! Sets alignment mode for text 52 virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); 53 54 //! Gets the override color 55 virtual video::SColor const & getOverrideColor() const; 56 57 //! Sets if the static text should use the overide color or the 58 //! color in the gui skin. 59 virtual void enableOverrideColor(bool enable); 60 61 //! Checks if an override color is enabled 62 virtual bool isOverrideColorEnabled() const; 63 64 //! Enables or disables word wrap for using the static text as 65 //! multiline text control. 66 virtual void setWordWrap(bool enable); 67 68 //! Checks if word wrap is enabled 69 virtual bool isWordWrapEnabled() const; 70 71 //! Sets the new caption of this element. 72 virtual void setText(const wchar_t* text); 73 74 //! Returns the height of the text in pixels when it is drawn. 75 virtual s32 getTextHeight() const; 76 77 //! Returns the width of the current text, in the current font 78 virtual s32 getTextWidth() const; 79 80 //! Updates the absolute position, splits text if word wrap is enabled 81 virtual void updateAbsolutePosition(); 82 83 //! Writes attributes of the element. 84 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; 85 86 //! Reads attributes of the element 87 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); 88 89 private: 90 91 //! Breaks the single text line. 92 void breakText(); 93 94 EGUI_ALIGNMENT HAlign, VAlign; 95 bool Border; 96 bool OverrideColorEnabled; 97 bool OverrideBGColorEnabled; 98 bool WordWrap; 99 bool Background; 100 101 video::SColor OverrideColor, BGColor; 102 gui::IGUIFont* OverrideFont; 103 gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated. 104 105 core::array< core::stringw > BrokenText; 106 }; 107 108} // end namespace gui 109} // end namespace irr 110 111#endif // _IRR_COMPILE_WITH_GUI_ 112 113#endif 114