CGUITextBox, scrolling, static text.
CGUITextBox, scrolling, static text.
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
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
Last edited by MasterD on Mon Aug 22, 2005 7:01 pm, edited 1 time in total.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
CTextBox example
Oh, thats an easy one!
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.)
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);
If you like you can
Code: Select all
textBox->setText(newText);
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.)
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
multilane?
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.
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.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
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...
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...
Last edited by MasterD on Fri Oct 13, 2006 8:09 am, edited 1 time in total.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
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
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
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
Wiki Tutorial
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
http://www.irrforge.org/index.php/CGUITextBox
Which came up being bigger as planned, but I wanted to do everything right
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de
...don't get me wrong...
@niko: this should not keep you from creating a new tutorial, if you want to use the code, you're welcome!
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
under Devolpment, see http://yass-engine.de