Page 1 of 1

[solved] how to access a StaticText ?

Posted: Wed Mar 21, 2007 08:34
by khayyam
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 ?

Posted: Wed Mar 21, 2007 10:51
by Levia
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");

Posted: Wed Mar 21, 2007 12:19
by khayyam
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 ...

Posted: Wed Mar 21, 2007 13:41
by Rackle
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");

Posted: Wed Mar 21, 2007 13:46
by Levia
Yeah, I know, I need to stop using C-style type casting ;)

Posted: Wed Mar 21, 2007 13:50
by khayyam
DefaultWindow* ok, thanks :)