/Irrlicht/CGUIStaticText.h

http://myjeh.googlecode.com/ · C++ Header · 114 lines · 53 code · 34 blank · 27 comment · 0 complexity · 6914c546f4ec74c32e8a77440e919563 MD5 · raw file

  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. #ifndef __C_GUI_STATIC_TEXT_H_INCLUDED__
  5. #define __C_GUI_STATIC_TEXT_H_INCLUDED__
  6. #include "IrrCompileConfig.h"
  7. #ifdef _IRR_COMPILE_WITH_GUI_
  8. #include "IGUIStaticText.h"
  9. #include "irrArray.h"
  10. namespace irr
  11. {
  12. namespace gui
  13. {
  14. class CGUIStaticText : public IGUIStaticText
  15. {
  16. public:
  17. //! constructor
  18. CGUIStaticText(const wchar_t* text, bool border, IGUIEnvironment* environment,
  19. IGUIElement* parent, s32 id, const core::rect<s32>& rectangle,
  20. bool background = false);
  21. //! destructor
  22. virtual ~CGUIStaticText();
  23. //! draws the element and its children
  24. virtual void draw();
  25. //! Sets another skin independent font.
  26. virtual void setOverrideFont(IGUIFont* font=0);
  27. //! Gets the override font (if any)
  28. virtual IGUIFont * getOverrideFont() const;
  29. //! Sets another color for the text.
  30. virtual void setOverrideColor(video::SColor color);
  31. //! Sets another color for the background.
  32. virtual void setBackgroundColor(video::SColor color);
  33. //! Sets whether to draw the background
  34. virtual void setDrawBackground(bool draw);
  35. //! Sets whether to draw the border
  36. virtual void setDrawBorder(bool draw);
  37. //! Sets alignment mode for text
  38. virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
  39. //! Gets the override color
  40. virtual video::SColor const & getOverrideColor() const;
  41. //! Sets if the static text should use the overide color or the
  42. //! color in the gui skin.
  43. virtual void enableOverrideColor(bool enable);
  44. //! Checks if an override color is enabled
  45. virtual bool isOverrideColorEnabled() const;
  46. //! Enables or disables word wrap for using the static text as
  47. //! multiline text control.
  48. virtual void setWordWrap(bool enable);
  49. //! Checks if word wrap is enabled
  50. virtual bool isWordWrapEnabled() const;
  51. //! Sets the new caption of this element.
  52. virtual void setText(const wchar_t* text);
  53. //! Returns the height of the text in pixels when it is drawn.
  54. virtual s32 getTextHeight() const;
  55. //! Returns the width of the current text, in the current font
  56. virtual s32 getTextWidth() const;
  57. //! Updates the absolute position, splits text if word wrap is enabled
  58. virtual void updateAbsolutePosition();
  59. //! Writes attributes of the element.
  60. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
  61. //! Reads attributes of the element
  62. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
  63. private:
  64. //! Breaks the single text line.
  65. void breakText();
  66. EGUI_ALIGNMENT HAlign, VAlign;
  67. bool Border;
  68. bool OverrideColorEnabled;
  69. bool OverrideBGColorEnabled;
  70. bool WordWrap;
  71. bool Background;
  72. video::SColor OverrideColor, BGColor;
  73. gui::IGUIFont* OverrideFont;
  74. gui::IGUIFont* LastBreakFont; // stored because: if skin changes, line break must be recalculated.
  75. core::array< core::stringw > BrokenText;
  76. };
  77. } // end namespace gui
  78. } // end namespace irr
  79. #endif // _IRR_COMPILE_WITH_GUI_
  80. #endif