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