Page 1 of 1

Static text alignment and properties

Posted: Thu Apr 22, 2010 15:02
by pianoman
Hi, I'm trying to left-align the text in a static text widget. On a static text widget, I tried:

Code: Select all

lblAction->setProperty("HorzLabelFormatting", "HorzLeftAligned");

But got an exception about HorzLabelFormatting not being an available property. I also tried "HorzFormatting" with the same result. Any ideas? Also, is there a reason that these common widget-specific properties are not available as getters/setters on the widget classes themselves? Having to reference string property names in code is very difficult compared to using a method, which is available through an IDE's completion assistance.

I fount the latter in a forum question where someone had a similar problem, and the former i found on the wiki page that lists all the properties for all the widgets (maybe it's not up to date or something).

Re: Static text alignment and properties

Posted: Fri Apr 23, 2010 08:49
by CrazyEddie
The correct property name is "HorzFormatting" and the available settings are as follows:

Code: Select all

"LeftAligned"
"RightAligned"
"HorzCentred"
"HorzJustified"
"WordWrapLeftAligned"
"WordWrapRightAligned"
"WordWrapCentred"
"WordWrapJustified"


The reason there is no member function on the StaticText for these types of setting is because there is no StaticText class, it's implemented via a DefaultWindow and a custom WindowRenderer. In this particular instance, you could actually get access to the WindowRenderer (in this case CEGUI::FalagardStaticText) and use member functions on that class to get/set the formatting (see: http://www.cegui.org.uk/docs/current/cl ... cText.html).

Though note that in some other instances there may not be any code at all to support such options since they are sometimes implemented via properties defined via XML alone.

HTH

CE

Re: Static text alignment and properties

Posted: Fri Apr 23, 2010 13:55
by pianoman
Ah, no "Horz" before "LeftAligned". Thank you. :D Is there a particular place I should be looking to see what values are available for a property? (Instead of wasting your time...) That wikipage I mentioned is a bit out of date apparently; I suppose I could use that same tool to output my own 'documentation'.

Hooray for getters/setters on the Falagard classes. Thanks for pointing that out. I kind of forgot about the Falagard classes :oops: .

Cheers :pint: