CGUITextBox, scrolling, static text.

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

Is this usefull?

Add it to the Wiki!
24
89%
Nope
3
11%
 
Total votes: 27

MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

CGUITextBox, scrolling, static text.

Post 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
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
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

nice, should also be a good source for teaching people how to extend the current system to add new GUI elements.
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post by TheRLG »

I like the idea, would love to see an example of its use before I give my final judgement.
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

CTextBox example

Post 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

Code: Select all

textBox->setText(newText);
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 :D (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
vgmdev
Posts: 57
Joined: Sun Jan 09, 2005 7:32 pm
Location: USA, MI

Post by vgmdev »

Is multilane supported?
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

multilane?

Post 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.
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
Fred

Post by Fred »

I think he means "multi-line".
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post 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.
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Post by MasterD »

That's one great Idea!
Here you are:
Image
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
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Nice code, thanks for posting. Would you mind if I took this code for a new tutorial like Masdus suggested?
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Post 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
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Wiki Tutorial

Post 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 :roll:
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

...don't get me wrong...

Post by MasterD »

@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
FlyHigh
Posts: 111
Joined: Wed Mar 23, 2005 12:05 am

Post 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 :wink:

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...
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post 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.
Post Reply