Page 1 of 3
CGUITextBox, scrolling, static text.
Posted: Mon Aug 15, 2005 9:17 pm
by MasterD
I've searched the engine and forums and, excuse me, if I'm wrong, it came up, that there is no GUI Element for showing plain text, which is scrollable.
This class creates a static Text for displaying text and a scrollbar to change the viewable area on the right of the text.
So I've made a small GUI Class for showing plain text. I would not say, that this is perfect and bug free, but it looked good to me for now.
edit: Fixed some bugs, so this code (which was here before) is no longer up to date.
You can download the Class + an example from
this location.
Hope that this is not worthless,
happy coding anyway!
Matthias
Posted: Tue Aug 16, 2005 6:52 am
by Masdus
nice, should also be a good source for teaching people how to extend the current system to add new GUI elements.
Posted: Tue Aug 16, 2005 5:40 pm
by TheRLG
I like the idea, would love to see an example of its use before I give my final judgement.
CTextBox example
Posted: Wed Aug 17, 2005 10:38 am
by MasterD
Oh, thats an easy one!
Code: Select all
// create a longer text
wchar_t text[] =
L"(21)Lorem ipsum dolor sit amet, consectetuer"\
// add text for your comfort
L"\n(0)Consect adipiscing eli.";
CGUITextBox * textBox = 0;
textBox = new CGUITextBox(pEnv->getBuiltInFont(),text, pEnv,
irr::core::rect<irr::s32>(5, 120, 315,235),
parent);
Than you only have to do your GUIEnvironment->drawAll() in your device->run() loop.
If you like you can
to change the displayed text after creation.
I don't know if it is allso usefull for real _big_ text, since all of the Text is in memory all the time, but this is not intended to be used for License Agreements

(well, the GPL displayed somehow good, except for a little bit to much linefeeds at the end of the text.)
Posted: Sat Aug 20, 2005 11:11 pm
by vgmdev
Is multilane supported?
multilane?
Posted: Mon Aug 22, 2005 6:56 am
by MasterD
I'm sorry, I don't know this "multilane" and after searching the web a bit I was even more confused.
Maybe this helps you out:
The displayed Text in this Text Box has (or should have) the same functionality as the CGUIStaticText except that wordwrap is allways true.
If this was not that, what you asked for, please describe that multilane support a bit more in detail.
Posted: Mon Aug 22, 2005 12:10 pm
by Fred
I think he means "multi-line".
Posted: Mon Aug 22, 2005 1:22 pm
by TheRLG
He's probably after paragraph-style text.
@MasterD: any screenshots available of this in action? Haven't been able to sit down and compile your code.
Posted: Mon Aug 22, 2005 3:37 pm
by MasterD
That's one great Idea!
Here you are:

edit: Maybe this picture also explains the multi-lane / -line question.
The right Picture does not look that well, since I was too lazy to reformat the GPL...
Posted: Mon Aug 22, 2005 6:19 pm
by niko
Nice code, thanks for posting. Would you mind if I took this code for a new tutorial like Masdus suggested?
Posted: Mon Aug 22, 2005 7:10 pm
by MasterD
I'm honored!
I have fixed the bug with the too much linefeeds, thanks to you and your StaticText->getTextHeight() - Method, Niko.
Now it is better to understand and you can also resize the complete Element. (In that case all needed Elements are recreated.)
In addition to that you can now put the Scrollbar left or right of the text and let the Scrollbar scroll "per-line" or "per-pixel", if you understand what I'm saying.
You can download the current Version here:
http://yass.de.md/downloads/TextBox.rar
Wiki Tutorial
Posted: Wed Aug 24, 2005 6:22 pm
by MasterD
I've added a tutorial to the Irrlicht Wiki
http://www.irrforge.org/index.php/CGUITextBox
Which came up being bigger as planned, but I wanted to do everything right

...don't get me wrong...
Posted: Wed Aug 24, 2005 6:32 pm
by MasterD
@niko: this should not keep you from creating a new tutorial, if you want to use the code, you're welcome!
Posted: Sat Aug 27, 2005 11:55 pm
by FlyHigh
Thanks MasterD,
This was just what I needed for a chat window type thing, I'll be sure to put your name in the credits
PS. I also added this to it:
void CGUITextBox::appendText(const wchar_t *text)
{
Text += text;
setText(Text.c_str());
}
and i made it keep to scroll down as new text gets added...
Posted: Mon Sep 12, 2005 2:24 am
by Midnight
RabidLockerGnome wrote:I like the idea, would love to see an example of its use before I give my final judgement.
ok there Judy.