IGUIEditBox.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 __I_GUI_EDIT_BOX_H_INCLUDED__
  5. #define __I_GUI_EDIT_BOX_H_INCLUDED__
  6. #include "IGUIElement.h"
  7. #include "SColor.h"
  8. namespace irr
  9. {
  10. namespace gui
  11. {
  12. class IGUIFont;
  13. //! Single line edit box for editing simple text.
  14. /** \par This element can create the following events of type EGUI_EVENT_TYPE:
  15. \li EGET_EDITBOX_ENTER
  16. \li EGET_EDITBOX_CHANGED
  17. \li EGET_EDITBOX_MARKING_CHANGED
  18. */
  19. class IGUIEditBox : public IGUIElement
  20. {
  21. public:
  22. //! constructor
  23. IGUIEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
  24. : IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {}
  25. //! Sets another skin independent font.
  26. /** If this is set to zero, the button uses the font of the skin.
  27. \param font: New font to set. */
  28. virtual void setOverrideFont(IGUIFont* font=0) = 0;
  29. //! Gets the override font (if any)
  30. /** \return The override font (may be 0) */
  31. virtual IGUIFont* getOverrideFont() const = 0;
  32. //! Get the font which is used right now for drawing
  33. /** Currently this is the override font when one is set and the
  34. font of the active skin otherwise */
  35. virtual IGUIFont* getActiveFont() const = 0;
  36. //! Sets another color for the text.
  37. /** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined
  38. in the skin, but the set color instead. You don't need to call
  39. IGUIEditBox::enableOverrrideColor(true) after this, this is done
  40. by this function.
  41. If you set a color, and you want the text displayed with the color
  42. of the skin again, call IGUIEditBox::enableOverrideColor(false);
  43. \param color: New color of the text. */
  44. virtual void setOverrideColor(video::SColor color) = 0;
  45. //! Gets the override color
  46. virtual video::SColor getOverrideColor() const = 0;
  47. //! Sets if the text should use the override color or the color in the gui skin.
  48. /** \param enable: If set to true, the override color, which can be set
  49. with IGUIEditBox::setOverrideColor is used, otherwise the
  50. EGDC_BUTTON_TEXT color of the skin. */
  51. virtual void enableOverrideColor(bool enable) = 0;
  52. //! Checks if an override color is enabled
  53. /** \return true if the override color is enabled, false otherwise */
  54. virtual bool isOverrideColorEnabled(void) const = 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. //! Turns the border on or off
  61. /** \param border: true if you want the border to be drawn, false if not */
  62. virtual void setDrawBorder(bool border) = 0;
  63. //! Checks if border drawing is enabled
  64. /** \return true if border drawing is enabled, false otherwise */
  65. virtual bool isDrawBorderEnabled() const = 0;
  66. //! Sets text justification mode
  67. /** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
  68. EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
  69. \param vertical: EGUIA_UPPERLEFT to align with top edge,
  70. EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
  71. virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
  72. //! Enables or disables word wrap.
  73. /** \param enable: If set to true, words going over one line are
  74. broken to the next line. */
  75. virtual void setWordWrap(bool enable) = 0;
  76. //! Checks if word wrap is enabled
  77. /** \return true if word wrap is enabled, false otherwise */
  78. virtual bool isWordWrapEnabled() const = 0;
  79. //! Enables or disables newlines.
  80. /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
  81. instead a newline character will be inserted. */
  82. virtual void setMultiLine(bool enable) = 0;
  83. //! Checks if multi line editing is enabled
  84. /** \return true if multi-line is enabled, false otherwise */
  85. virtual bool isMultiLineEnabled() const = 0;
  86. //! Enables or disables automatic scrolling with cursor position
  87. /** \param enable: If set to true, the text will move around with the cursor position */
  88. virtual void setAutoScroll(bool enable) = 0;
  89. //! Checks to see if automatic scrolling is enabled
  90. /** \return true if automatic scrolling is enabled, false if not */
  91. virtual bool isAutoScrollEnabled() const = 0;
  92. //! Sets whether the edit box is a password box. Setting this to true will
  93. /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
  94. \param passwordBox: true to enable password, false to disable
  95. \param passwordChar: the character that is displayed instead of letters */
  96. virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*') = 0;
  97. //! Returns true if the edit box is currently a password box.
  98. virtual bool isPasswordBox() const = 0;
  99. //! Gets the size area of the text in the edit box
  100. /** \return The size in pixels of the text */
  101. virtual core::dimension2du getTextDimension() = 0;
  102. //! Sets the maximum amount of characters which may be entered in the box.
  103. /** \param max: Maximum amount of characters. If 0, the character amount is
  104. infinity. */
  105. virtual void setMax(u32 max) = 0;
  106. //! Returns maximum amount of characters, previously set by setMax();
  107. virtual u32 getMax() const = 0;
  108. //! Set the character used for the cursor.
  109. /** By default it's "_" */
  110. virtual void setCursorChar(const wchar_t cursorChar) = 0;
  111. //! Get the character used for the cursor.
  112. virtual wchar_t getCursorChar() const = 0;
  113. //! Set the blinktime for the cursor. 2x blinktime is one full cycle.
  114. //** \param timeMs Blinktime in milliseconds. When set to 0 the cursor is constantly on without blinking */
  115. virtual void setCursorBlinkTime(irr::u32 timeMs) = 0;
  116. //! Get the cursor blinktime
  117. virtual irr::u32 getCursorBlinkTime() const = 0;
  118. };
  119. } // end namespace gui
  120. } // end namespace irr
  121. #endif