2
0

IGUIEditBox.h 5.8 KB

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