+//! Create a vertical scrollbar
+void intlGUIEditBox::createVScrollBar()
+{
+ s32 fontHeight = 1;
+
+ if (OverrideFont) {
+ fontHeight = OverrideFont->getDimension(L"").Height;
+ } else {
+ if (IGUISkin* skin = Environment->getSkin()) {
+ if (IGUIFont* font = skin->getFont()) {
+ fontHeight = font->getDimension(L"").Height;
+ }
+ }
+ }
+
+ irr::core::rect<s32> scrollbarrect = FrameRect;
+ scrollbarrect.UpperLeftCorner.X += FrameRect.getWidth() - m_scrollbar_width;
+ m_vscrollbar = Environment->addScrollBar(false, scrollbarrect, getParent(), getID());
+ m_vscrollbar->setVisible(false);
+ m_vscrollbar->setSmallStep(3 * fontHeight);
+ m_vscrollbar->setLargeStep(10 * fontHeight);
+}
+
+//! Update the vertical scrollbar (visibilty & scroll position)
+void intlGUIEditBox::updateVScrollBar()
+{
+ if (!m_vscrollbar)
+ return;
+
+ // OnScrollBarChanged(...)
+ if (m_vscrollbar->getPos() != VScrollPos) {
+ s32 deltaScrollY = m_vscrollbar->getPos() - VScrollPos;
+ CurrentTextRect.UpperLeftCorner.Y -= deltaScrollY;
+ CurrentTextRect.LowerRightCorner.Y -= deltaScrollY;
+
+ s32 scrollymax = getTextDimension().Height - FrameRect.getHeight();
+ if (scrollymax != m_vscrollbar->getMax()) {
+ // manage a newline or a deleted line
+ m_vscrollbar->setMax(scrollymax);
+ calculateScrollPos();
+ } else {
+ // manage a newline or a deleted line
+ VScrollPos = m_vscrollbar->getPos();
+ }
+ }
+
+ // check if a vertical scrollbar is needed ?
+ if (getTextDimension().Height > (u32) FrameRect.getHeight()) {
+ s32 scrollymax = getTextDimension().Height - FrameRect.getHeight();
+ if (scrollymax != m_vscrollbar->getMax()) {
+ m_vscrollbar->setMax(scrollymax);
+ }
+
+ if (!m_vscrollbar->isVisible() && MultiLine) {
+ AbsoluteRect.LowerRightCorner.X -= m_scrollbar_width;
+
+ m_vscrollbar->setVisible(true);
+ }
+ } else {
+ if (m_vscrollbar->isVisible()) {
+ AbsoluteRect.LowerRightCorner.X += m_scrollbar_width;
+
+ VScrollPos = 0;
+ m_vscrollbar->setPos(0);
+ m_vscrollbar->setMax(1);
+ m_vscrollbar->setVisible(false);
+ }
+ }
+}
+
+void intlGUIEditBox::setWritable(bool can_write_text)
+{
+ m_writable = can_write_text;
+}
+