[solved] how to access a StaticText ?

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

khayyam
Just popping in
Just popping in
Posts: 13
Joined: Thu Jun 29, 2006 08:22
Location: France

[solved] how to access a StaticText ?

Postby khayyam » Wed Mar 21, 2007 08:34

Hi all

In CEGUI Layout Editor, there is the possibility to add staticText widgets, but how to access them from the code ?
the class CEGUI::StaticText does not exist ...
Maybe I didn't choose correctly the widget I need. I need a widget only displaying a text, that I could could modify from c++ code. What is the best way ?
Last edited by khayyam on Wed Mar 21, 2007 13:50, edited 1 time in total.

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Wed Mar 21, 2007 10:51

To get it from C++ (for 0.4)

Code: Select all

CEGUI::StaticText * myTextEntry = (CEGUI::StaticText*)CEGUI::WindowManager::getSingletonPtr()->getWindow("nameofthewindow");


for 0.5 I think it is

Code: Select all

CEGUI::Static * myTextEntry = (CEGUI::Static*)CEGUI::WindowManager::getSingletonPtr()->getWindow("nameofthewindow");
Image
Image

khayyam
Just popping in
Just popping in
Posts: 13
Joined: Thu Jun 29, 2006 08:22
Location: France

Postby khayyam » Wed Mar 21, 2007 12:19

Levia wrote:for 0.5 I think it is

Code: Select all

CEGUI::Static * myTextEntry = (CEGUI::Static*)CEGUI::WindowManager::getSingletonPtr()->getWindow("nameofthewindow");


CEGUI::Static does not exist ...

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Mar 21, 2007 13:41

Widget Galore shows how to use most types of Cegui windows (which I call widgets). The short answer is to use DefaultWindow.

Then there's this post:

Rackle wrote:Upgraded to v0.5.0.

The v0.4 StaticText code

Code: Select all

StaticText* staticText = static_cast<StaticText*>(winMgr.getWindow((utf8*) "StaticText"));
staticText->setText("Red StaticText");
staticText->setTextColours( colour(1.0f, 0.0f, 0.0f, 1.0f) ); // Red text
staticText->setFormatting(StaticText::HorzCentred, StaticText::VertCentred); // Center the text

was upgraded to v0.5.0 like this

Code: Select all

DefaultWindow* staticText = static_cast<DefaultWindow*>(winMgr.getWindow("StaticText"));
staticText->setText("Red Static Text");
staticText->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");
staticText->setProperty("VertFormatting", "VertCentred");
staticText->setProperty("HorzFormatting", "HorzCentred");


The v0.4 StaticImage code

Code: Select all

ImagesetManager::getSingleton().createImagesetFromImageFile("ImageForStaticImage", "../datafiles/imagesets/GPN-2000-001437.tga");
StaticImage* staticImage = static_cast<StaticImage*>(winMgr.getWindow("StaticImage"));
staticImage->setImage("ImageForStaticImage", "full_image");

was upgraded to v0.5.0 like this

Code: Select all

ImagesetManager::getSingleton().createImagesetFromImageFile("ImageForStaticImage", "GPN-2000-001437.tga");
DefaultWindow* staticImage = static_cast<DefaultWindow*>(winMgr.getWindow("StaticImage"));
staticImage->setProperty("Image", "set:ImageForStaticImage image:full_image");

User avatar
Levia
Quite a regular
Quite a regular
Posts: 83
Joined: Mon May 22, 2006 18:25
Location: Bergen op zoom, The Netherlands
Contact:

Postby Levia » Wed Mar 21, 2007 13:46

Yeah, I know, I need to stop using C-style type casting ;)
Image

Image

khayyam
Just popping in
Just popping in
Posts: 13
Joined: Thu Jun 29, 2006 08:22
Location: France

Postby khayyam » Wed Mar 21, 2007 13:50

DefaultWindow* ok, thanks :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests