wchar_t new line?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

bitplane wrote: using guiStaticText->setText(L"Some\nNewline") works fine for me, how were you using it JP?
Yeah that's how i've been using it, and it just treats the \n as a space basically :?
Image Image Image
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

This:
Image

...is what I get when I do:

Code: Select all

lstLoginStatus->addItem(L"Logging in \n to the server...");
Now granted that's a listbox (dunno how those work with linefeeds) but it's the same thing that happens to the staticText's.
Last edited by Rytz on Tue Oct 31, 2006 10:37 pm, edited 1 time in total.
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

List boxes don't work with line feeds. I don't think I've ever seen a listbox that did. For the static text to work, the wordWrap flag has to be set. At least on vc7 it does...

BTW, the static text appears to have a bug in that it doesn't split words/strings when they are wider than the width of the static text area.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Excellent, word wrap seems to make it work now :D
Image Image Image
Rytz
Posts: 249
Joined: Wed Oct 25, 2006 6:05 am
Location: IL, USA
Contact:

Post by Rytz »

JP wrote:Excellent, word wrap seems to make it work now :D
Awesome, I'll have to give it a shot later today.

Thanks, Vitek ;).
Image
gavicus
Posts: 16
Joined: Fri Aug 25, 2006 2:19 pm

Post by gavicus »

wchar_t is generally a pain to work with for me. Let me add a question to this line. This is just C++ (maybe C) and not Irrlicht

I'd like to tell the gui static text to display a varying number (say camera location or something)

I can tell it to set text to L"camera location" but how can I stick a number on it? I could do this with a std::string but how do you convert from string to wchar_t?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

you can do something along the lines of this:

wchar_t wStr[255];
swprintf(wStr, 255, L"%f %f %f", camX, camY, camZ);
text->setText(wStr);

Or you can use Irrlicht's built in Strings, stringw and stringc.

stringw str;
str += camX;
//etc.
text->setText(str.c_str());
Image Image Image
Post Reply