Page 1 of 1

Window Constructor really do ???

Posted: Wed Sep 03, 2008 10:23
by traibuidoi
at first , please look at this very simple code :


Code: Select all

CEGUI::Window* t = new CEGUI::Window("WindowsLook/StaticImage","test");
CEGUI::ImagesetManager::getSingleton().createImagesetFromImageFile("ImgOne","imgOne.PNG");   
myRoot->addChildWindow(t); //myRoot is Rootsheet
t->setProperty("Image","set:ImgOne image:full_image");


when app run it gets error in CEGUI.log : (Error) CEGUI::UnknownObjectException in file ..\..\..\src\CEGUIPropertySet.cpp(124) : There is no Property named 'Image' available in the set.


And the second code :

Code: Select all

CEGUI::Window* t = winMgr->createWindow("WindowsLook/StaticImage","test");
CEGUI::ImagesetManager::getSingleton().createImagesetFromImageFile("ImgOne","imgOne.PNG");
myRoot->addChildWindow(t);
t->setProperty("Image","set:ImgOne image:full_image");



It works fine !!!!

So could anyone tell me : what do the window contrustor really do ? And what's difference beetween createWindow() function and window constructor ?

In my game , i must inherit CEGUI::Window class to my own Window ( ex flashing image ...) but i don't know its constructor exactly do .

Please help me

Posted: Wed Sep 03, 2008 12:39
by scriptkid
Hi,

Cegui uses a factory system to create instances. So when you call "createWindow", a different constructor gets called (StaticImage one), so that your "t" points to a StaticImage instead of a base Window (your first line). You must not create windows through the window class directly, but always through the manager. (I am now also thinking why then it is possible to do otherwise).

If you are creating you own widget with C++ implementation, you might want to check out this page:
http://www.cegui.org.uk/wiki/index.php/ ... istboxItem

However this requires recompiling, you can't use the SDK then...

HTH.