Page 1 of 1

How to add images "freely" among text.

Posted: Tue Mar 17, 2009 03:49
by yllfever
Hi, all.

Just like in the MSN, we will need to send faces or other larger images,
when chatting.

I'm writing a chatbox, how can I display text mixed with freely placed images? Is it possible just using a ItemListbox with my own ItemEnty?

Any suggestion will be appreciated.

Posted: Tue Mar 17, 2009 11:42
by CrazyEddie

To do it 'freely' is pretty difficult at the moment.

The "best" way is probably to encode all the information in the text string and parse that into a sequence of sub-strings and images that you then render.


Posted: Wed Mar 18, 2009 04:01
by yllfever
Thanks for your reply, CE. You are alwlays patient, and your replies are helpful.

As there is no easy way, I'll have to create a new window type like "RichEditbox".

I've read some of the source files of CEGUI. But I didn't find where to put my window's text and images to the renderer.

How is a CEGUI window get itself rendered?

There is a

Code: Select all

 virtual void populateRenderCache() 

method in the Window class. But none of the derived class override it, like Editbox, MultiLineEditbox, etc.

So, if i want to mentain the content myself, how can I get my content rendered?


Posted: Wed Mar 18, 2009 09:44
by CrazyEddie

The rendering is handled by a separate object called a CEGUI::WindowRenderer (the defaults for these are in the FalagardWRBase module). The idea is that the core functionality of any given widget type should totally independent of it's visual aspect, so in CEGUI we have these two items separate (with varying degrees of success; but hey, it's a work in progress :P).

The default approach we use in the library is for the WindowRenderer for a given widget type to get most of it's basic form via a falagard looknfeel WidgetLook specification. WindowRenderer types are mapped to Window types along with a LookNFeel within the scheme file.

Having said this, the use of the WindowRenderer is not a requrement; certainly not for user project widgets where customisation is less of an issue than it is for us as library providers ;) You can just as easily dispense with WindowRenderer objects and override that populateRenderCache function.

One key thing to understand is that when you 'draw' things in that function (or via the WindowRenderer), you're not actually drawing it immediately; rather you're queueing things to be drawn at a later time. You do this by using the Window objects RenderCache, and add images and text strings to that, which will be drawn later at an appropriate time.

Anyway, take a look in the FalagardWRBase files, since that's where the rendering 'action' takes place.



Posted: Sun Mar 22, 2009 12:36
by Pompei2
Hey, here is a post that might interest you:

but be double-triple-sure to verify the code before you add it to your cegui, I remember there were little memory overflows that make the game crash here and then, if they are not fixed.