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

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

erwinxu
Just popping in
Just popping in
Posts: 5
Joined: Mon Jul 07, 2008 09:59

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

Postby erwinxu » Tue Jul 08, 2008 01:54

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
Last edited by erwinxu on Fri Jul 11, 2008 14:48, edited 2 times in total.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Tue Jul 08, 2008 07:44

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.
Check out my released snake game using Cegui!

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Postby rogerdv » Thu Jul 10, 2008 16:24

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Jul 11, 2008 08:29

Hi,

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

CE.

erwinxu
Just popping in
Just popping in
Posts: 5
Joined: Mon Jul 07, 2008 09:59

it works

Postby erwinxu » Fri Jul 11, 2008 14:46

thank you, scriptkid and eddie, it works


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 21 guests