added IGUIEditBox::setAutoScroll, isAutoScrollEnabled and getTextDimension.

added automatic scrolling when dragging text with mouse

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@747 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2007-07-01 06:54:58 +00:00
parent 4701c286f6
commit 4996342b0f
3 changed files with 62 additions and 1 deletions

View File

@ -76,6 +76,18 @@ namespace gui
//! \return true if mult-line is enabled, false otherwise
virtual bool isMultiLineEnabled() = 0;
//! Enables or disables automatic scrolling with cursor position
//! \param enable: If set to true, the text will move around with the cursor position
virtual void setAutoScroll(bool enable) = 0;
//! Checks to see if automatic scrolling is enabled
//! \return true if automatic scrolling is enabled, false if not
virtual bool isAutoScrollEnabled() = 0;
//! Gets the size area of the text in the edit box
//! \return Returns the size in pixels of the text
virtual core::dimension2di getTextDimension() = 0;
//! Sets the maximum amount of characters which may be entered in the box.
/** \param max: Maximum amount of characters. If 0, the character amount is
infinity. */

View File

@ -768,6 +768,39 @@ void CGUIEditBox::setText(const wchar_t* text)
breakText();
}
//! Enables or disables automatic scrolling with cursor position
//! \param enable: If set to true, the text will move around with the cursor position
void CGUIEditBox::setAutoScroll(bool enable)
{
AutoScroll = enable;
}
//! Checks to see if automatic scrolling is enabled
//! \return true if automatic scrolling is enabled, false if not
bool CGUIEditBox::isAutoScrollEnabled()
{
return AutoScroll;
}
//! Gets the area of the text in the edit box
//! \return Returns the size in pixels of the text
core::dimension2di CGUIEditBox::getTextDimension()
{
core::rect<s32> ret;
setTextRect(0);
ret = CurrentTextRect;
for (u32 i=1; i < BrokenText.size(); ++i)
{
setTextRect(i);
ret.addInternalPoint(CurrentTextRect.UpperLeftCorner);
ret.addInternalPoint(CurrentTextRect.LowerRightCorner);
}
return ret.getSize();
}
//! Sets the maximum amount of characters which may be entered in the box.
//! \param max: Maximum amount of characters. If 0, the character amount is
@ -801,6 +834,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
if (MouseMarking)
MarkEnd = CursorPos;
MouseMarking = false;
calculateScrollPos();
return true;
}
break;
@ -810,6 +844,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
{
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
MarkEnd = CursorPos;
calculateScrollPos();
return true;
}
}
@ -824,6 +859,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
MarkBegin = CursorPos;
MarkEnd = CursorPos;
calculateScrollPos();
return true;
}
else
@ -844,6 +880,7 @@ bool CGUIEditBox::processMouse(const SEvent& event)
MouseMarking = true;
MarkEnd = CursorPos;
calculateScrollPos();
return true;
}
}

View File

@ -53,6 +53,18 @@ namespace gui
//! \return true if mult-line is enabled, false otherwise
virtual bool isMultiLineEnabled();
//! Enables or disables automatic scrolling with cursor position
//! \param enable: If set to true, the text will move around with the cursor position
virtual void setAutoScroll(bool enable);
//! Checks to see if automatic scrolling is enabled
//! \return true if automatic scrolling is enabled, false if not
virtual bool isAutoScrollEnabled();
//! Gets the size area of the text in the edit box
//! \return Returns the size in pixels of the text
virtual core::dimension2di getTextDimension();
//! Sets text justification
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);