Dynamic window

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

Rakkar
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 15, 2006 02:49

Dynamic window

Postby Rakkar » Sun Aug 20, 2006 15:31

I want to display a window onto which I will display some text. I should only specify the width and coordinates. The height should automatically be scaled to match the height of the text.

I do not know what will be the text of the window in advance.

How do I do this?

User avatar
Duck
Just popping in
Just popping in
Posts: 9
Joined: Sun Apr 30, 2006 17:15

Postby Duck » Sun Aug 27, 2006 22:41

I'm not quite sure of the effect you're after, and what you've tried.

You might turn off the background:

CEGUI::StaticText* pStaticText = (CEGUI::StaticText*)GetWindowManager().getWindow( "blah_name" );
pStaticText->setBackgroundEnabled( false );

Assuming you have some function which allows you to set the string, you could do your resizing/scaling of the parent window in there...

Hope this helps a bit...

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Postby Van » Mon Aug 28, 2006 19:15

Rakkar,

You have to compute this. If the WIDTH is set, then it makes it much easier. First, you need to get the FONT (CEGUI::Font) so you can use it to determine the max width in chars. There are several helper functions in the CEGUI::Font that will help you determine width and heigth. It will give you the width for a given text and will tell you the "height" for a line of text. The part you have to do is figure out how many lines there will be.What makes it even tricker is if the lines could contain some '\n'(CR and/or LF).

I wrote a dialog class which uses a CEGUI::DefaultWindow (StaticText) inside a FrameWindow. What I do is adjust the height/width of the frame window.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 14 guests