Page 1 of 1

can cegui auto break long string to multiline?[resolved]

Posted: Wed Nov 08, 2006 09:14
by silenttree
i know that the editbox can do this well.

my question is, can StaticText do this also?

if could, what property(or something else) can make this happen!


thank you all !

Posted: Wed Nov 08, 2006 18:48
by CrazyEddie
Hi,

Assume you're using 0.5.0 and mean in XML, you use the property element as a text node, like this...

Code: Select all

<Property Name="Text">This is line 1
This is line 2
This is line 3.</Property>


HTH

CE.

Posted: Wed Nov 08, 2006 23:21
by Pompei2
I think he means that CEGUI automatically decides where to begin a new line. IIRC this was posssible but I'm not able to find the property that was doing this anymore :? or am I just confused and mixing a few things :)

Posted: Thu Nov 09, 2006 01:18
by silenttree
thank you all!

i mean sometimes a long string cant display in one line for the window-size reason.

how can i make it auto-break-line to display this long string in multiline.

thx again!

Posted: Thu Nov 09, 2006 02:24
by spannerman
Do you mean inserting a linebreak in the text? Try using "\n".

For example if you have a StaticText window, you can define how the text is wrapped like this:

Code: Select all

stLabel->setProperty("HorzFormatting", "WordWrapLeftAligned");
stLabel->setText("This is a line.\nAnd this is a new line.");


Hope that helps.

Posted: Thu Nov 09, 2006 04:29
by silenttree
thx, spannerman!

your method can work well!

let me show you my problem again:

a string, maybe like this
A_Long_Text_Goes_Here_And_More_Text_Go_On!

but my window( such as a Static Text), because of its size, can not hold so long string in one line, i must break it in mulitiline manual.

my question is:
is there exist a method, can auto break this string with a given size window.
:)

Posted: Thu Nov 09, 2006 09:49
by CrazyEddie
Hi,

I misunderstood the original questions :oops:

The word-wrapping support is basic at the moment, and is also not Unicode aware. What this means is that unless your string contains the basic space character (ASCII 32), then the system does not know where to break - so at the moment does nothing.

Obviously, depending on the script in use, appropriate places to break lines will not be limited to the western space character. I accept this will be an issue for some, though it is something that "one day" I intend to have implemented fully (that is, full Unicode support).

I think that the moment, manually breaking the line, while certainly not ideal, may have to suffice :?

CE.

Posted: Thu Nov 09, 2006 10:32
by spannerman
Edit: Sorry, missed Eddies post ^

Oh, I think I understand now what it is you want. Unfortunately, (Im not sure) but I doubt that there is anything in Cegui that would automatically break up a string like that for you. I think you will have to do that yourself with standard String splitting functions.

You might be able to use Font functions to detect whether your string is going to be too long for the StaticText area:

Code: Select all

float getTextExtent (const String &text, float x_scale=1.0f)
  Return the pixel width of the specified text if rendered with this Font.

float getFormattedTextExtent (const String &text, const Rect &format_area, TextFormatting fmt, float x_scale=1.0f)
  Return the horizontal pixel extent given text would be formatted to. 


Then if your string is too long, you could split it.

Or...what I would do is forget all that and just put a horizontal scrollbar on the StaticText, then you dont care how long your strings are:

Code: Select all

stLabel->setProperty("HorzScrollbar", "True");

Posted: Thu Nov 09, 2006 14:17
by silenttree
hi spannerman, thx for your advice!

i think your mthod is what i want!


hehe :lol:

Posted: Thu Nov 09, 2006 14:19
by silenttree
CrazyEddie wrote:Hi,

I misunderstood the original questions :oops:
.........

CE.


I must say "im so sorry" for my poor english :?

Posted: Mon Nov 13, 2006 09:39
by CrazyEddie
silenttree wrote:I must say "im so sorry" for my poor english :?

No need for apologies; since English is not your first language, you do great! :)