Page 1 of 1

[solved]How to load a image to a StaticImage or button

Posted: Tue Jul 08, 2008 01:54
by erwinxu
I have searched and read some topics about loading a image to a staticImage object, especially this one:
http://www.cegui.org.uk/phpBB2/viewtopi ... +jpg+image


I followed this page and implemented my function like this:

CEGUI::ImagesetManager::getSingleton().createImageset("mj.imageset");
guiWnd= WindowManager::getSingleton().getWindow("logo");
guiWnd->setImage("mjset", "ogretext");

"logo" is the name of a StaticImage object, defined as:
<Window Type="TaharezLook/StaticImage" Name="logo">
<Property Name="FrameEnabled" Value="False" />
<Property Name="BackgroundEnabled" Value="False" />
<Property Name="UnifiedPosition" Value="{{0,0},{0,0}}" />
<Property Name="UnifiedSize" Value="{{1,0},{1,0}}" />
<Property Name="Alpha" Value="0.8" />
<Property Name="InheritsAlpha" Value="False" />
<Property Name="NormalImage" Value="set:mjset image:ogretext" />
</Window>

After compiling, my codeblocks shows this message:
error: 'class CEGUI::Window' has no member named 'setImage'


I looked up the CEGUI reference, and found that setImage is not a member function of StaticImage class, In fact I can not even find a StaticImage class, I don't know how to fix it.

I also want to load a image to a button, if it is possible? and how? thanks

Posted: Tue Jul 08, 2008 07:44
by scriptkid
Hi and welcome :)

StaticImage and StaticText are mapped to the DefaultWindow, and can only be accessed by using properties, except for the common methods. To set your image, use:

Code: Select all

guiWnd->setProperty("Image", "set:mjset image:ogretext");


For your second question, you also need to call properties, for example:

Code: Select all

button->setProperty("NormalImage", "set:mjset image:ogretext" )


There's also HoverImage, PushedImage and DisabledImage.

For a full property reference, please see this thread: http://www.cegui.org.uk/phpBB2/viewtopic.php?t=2555

HTH.

Posted: Thu Jul 10, 2008 16:24
by rogerdv
Is there any way to directly load the image to the StaticImage, without using an imageset? I need to display a picture in a window that changes depending on the character selected, so I will have several portraits to display in the same widget.

Posted: Fri Jul 11, 2008 08:29
by CrazyEddie
Hi,

All images displayed by CEGUI currently have to be part of an imageset.

CE.

it works

Posted: Fri Jul 11, 2008 14:46
by erwinxu
thank you, scriptkid and eddie, it works