1
0

IGUIStaticText.h 5.1 KB

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