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

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

silenttree
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Nov 01, 2006 05:59
Contact:

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

Postby silenttree » Wed Nov 08, 2006 09:14

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 !
Last edited by silenttree on Thu Nov 09, 2006 14:20, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Nov 08, 2006 18:48

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.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Wed Nov 08, 2006 23:21

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 :)

silenttree
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Nov 01, 2006 05:59
Contact:

Postby silenttree » Thu Nov 09, 2006 01:18

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!

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Thu Nov 09, 2006 02:24

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.

silenttree
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Nov 01, 2006 05:59
Contact:

Postby silenttree » Thu Nov 09, 2006 04:29

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.
:)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Nov 09, 2006 09:49

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.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Thu Nov 09, 2006 10:32

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");

silenttree
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Nov 01, 2006 05:59
Contact:

Postby silenttree » Thu Nov 09, 2006 14:17

hi spannerman, thx for your advice!

i think your mthod is what i want!


hehe :lol:

silenttree
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Wed Nov 01, 2006 05:59
Contact:

Postby silenttree » Thu Nov 09, 2006 14:19

CrazyEddie wrote:Hi,

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

CE.


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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Nov 13, 2006 09:39

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! :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 15 guests