IGUIStaticText.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright (C) 2002-2012 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 IRR_I_GUI_STATIC_TEXT_H_INCLUDED
  5. #define IRR_I_GUI_STATIC_TEXT_H_INCLUDED
  6. #include "IGUIElement.h"
  7. #include "SColor.h"
  8. namespace irr
  9. {
  10. namespace gui
  11. {
  12. class IGUIFont;
  13. //! Multi or single line text label.
  14. class IGUIStaticText : public IGUIElement
  15. {
  16. public:
  17. //! constructor
  18. IGUIStaticText(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
  19. : IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {}
  20. //! Sets another skin independent font.
  21. /** If this is set to zero, the button uses the font of the skin.
  22. \param font: New font to set. */
  23. virtual void setOverrideFont(IGUIFont* font=0) = 0;
  24. //! Gets the override font (if any)
  25. /** \return The override font (may be 0) */
  26. virtual IGUIFont* getOverrideFont(void) const = 0;
  27. //! Get the font which is used right now for drawing
  28. /** Currently this is the override font when one is set and the
  29. font of the active skin otherwise */
  30. virtual IGUIFont* getActiveFont() const = 0;
  31. //! Sets another color for the text.
  32. /** If set, the static text does not use the EGDC_BUTTON_TEXT color defined
  33. in the skin, but the set color instead. You don't need to call
  34. IGUIStaticText::enableOverrrideColor(true) after this, this is done
  35. by this function.
  36. If you set a color, and you want the text displayed with the color
  37. of the skin again, call IGUIStaticText::enableOverrideColor(false);
  38. \param color: New color of the text. */
  39. virtual void setOverrideColor(video::SColor color) = 0;
  40. //! Gets the override color
  41. /** \return: The override color */
  42. virtual video::SColor getOverrideColor(void) const = 0;
  43. //! Gets the currently used text color
  44. /** Either a skin-color for the current state or the override color */
  45. virtual video::SColor getActiveColor() const = 0;
  46. //! Sets if the static text should use the override color or the color in the gui skin.
  47. /** \param enable: If set to true, the override color, which can be set
  48. with IGUIStaticText::setOverrideColor is used, otherwise the
  49. EGDC_BUTTON_TEXT color of the skin. */
  50. virtual void enableOverrideColor(bool enable) = 0;
  51. //! Checks if an override color is enabled
  52. /** \return true if the override color is enabled, false otherwise */
  53. virtual bool isOverrideColorEnabled(void) const = 0;
  54. //! Sets another color for the background.
  55. virtual void setBackgroundColor(video::SColor color) = 0;
  56. //! Sets whether to draw the background
  57. virtual void setDrawBackground(bool draw) = 0;
  58. //! Checks if background drawing is enabled
  59. /** \return true if background drawing is enabled, false otherwise */
  60. virtual bool isDrawBackgroundEnabled() const = 0;
  61. //! Gets the background color
  62. /** \return: The background color */
  63. virtual video::SColor getBackgroundColor() const = 0;
  64. //! Sets whether to draw the border
  65. virtual void setDrawBorder(bool draw) = 0;
  66. //! Checks if border drawing is enabled
  67. /** \return true if border drawing is enabled, false otherwise */
  68. virtual bool isDrawBorderEnabled() const = 0;
  69. //! Sets text justification mode
  70. /** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
  71. EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
  72. \param vertical: EGUIA_UPPERLEFT to align with top edge (default),
  73. EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */
  74. virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
  75. //! Enables or disables word wrap for using the static text as multiline text control.
  76. /** \param enable: If set to true, words going over one line are
  77. broken on to the next line. */
  78. virtual void setWordWrap(bool enable) = 0;
  79. //! Checks if word wrap is enabled
  80. /** \return true if word wrap is enabled, false otherwise */
  81. virtual bool isWordWrapEnabled(void) const = 0;
  82. //! Returns the height of the text in pixels when it is drawn.
  83. /** This is useful for adjusting the layout of gui elements based on the height
  84. of the multiline text in this element.
  85. \return Height of text in pixels. */
  86. virtual s32 getTextHeight() const = 0;
  87. //! Returns the width of the current text, in the current font
  88. /** If the text is broken, this returns the width of the widest line
  89. \return The width of the text, or the widest broken line. */
  90. virtual s32 getTextWidth(void) const = 0;
  91. //! Set whether the text in this label should be clipped if it goes outside bounds
  92. virtual void setTextRestrainedInside(bool restrainedInside) = 0;
  93. //! Checks if the text in this label should be clipped if it goes outside bounds
  94. virtual bool isTextRestrainedInside() const = 0;
  95. //! Set whether the string should be interpreted as right-to-left (RTL) text
  96. /** \note This component does not implement the Unicode bidi standard, the
  97. text of the component should be already RTL if you call this. The
  98. main difference when RTL is enabled is that the linebreaks for multiline
  99. elements are performed starting from the end.
  100. */
  101. virtual void setRightToLeft(bool rtl) = 0;
  102. //! Checks whether the text in this element should be interpreted as right-to-left
  103. virtual bool isRightToLeft() const = 0;
  104. };
  105. } // end namespace gui
  106. } // end namespace irr
  107. #endif