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 !
can cegui auto break long string to multiline?[resolved]
Moderators: CEGUI MVP, CEGUI Team
-
- Not too shy to talk
- Posts: 30
- Joined: Wed Nov 01, 2006 05:59
- Contact:
can cegui auto break long string to multiline?[resolved]
Last edited by silenttree on Thu Nov 09, 2006 14:20, edited 1 time in total.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
Assume you're using 0.5.0 and mean in XML, you use the property element as a text node, like this...
HTH
CE.
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.
-
- Not too shy to talk
- Posts: 30
- Joined: Wed Nov 01, 2006 05:59
- Contact:
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
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:
Hope that helps.
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.
-
- Not too shy to talk
- Posts: 30
- Joined: Wed Nov 01, 2006 05:59
- Contact:
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.
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.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
I misunderstood the original questions
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.
I misunderstood the original questions
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.
- spannerman
- Home away from home
- Posts: 330
- Joined: Wed Jan 12, 2005 12:06
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:
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:
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");
-
- Not too shy to talk
- Posts: 30
- Joined: Wed Nov 01, 2006 05:59
- Contact:
-
- Not too shy to talk
- Posts: 30
- Joined: Wed Nov 01, 2006 05:59
- Contact:
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Who is online
Users browsing this forum: No registered users and 19 guests