GUI Image problem and question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

GUI Image problem and question

Post by saigumi »

I'm working on a tutorial for rolling you own GUI Elements and stumbled into somthing I think isn't right. In CGUIEnvironment, when the image element is constructed, a call to setText is performed.

Code: Select all

 //! adds an image. The returned pointer must not be dropped.
IGUIImage* CGUIEnvironment::addImage(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text)
{
	IGUIImage* img = new CGUIImage(this, parent ? parent : this,
		id, rectangle);

	if (text)
		img->setText(text);

	img->drop();
	return img;
}
But IGUIImage's don't have a setText function. They do have a setImage one. So, should this instead be?

Code: Select all

//! adds an image. The returned pointer must not be dropped.
IGUIImage* CGUIEnvironment::addImage(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const video::ITexture* image)
{
	IGUIImage* img = new CGUIImage(this, parent ? parent : this,
		id, rectangle);

	if (image)
		img->setImage(image);

	img->drop();
	return img;
}
Now for the fun question, when you roll your own control seperate from the Irrlicht Engine. (Not a direct part) Would you have to do anything special to handle events, like making your on OnEvent and PostEvent functions to simulate what IGUIEnvironment does?
Crud, how do I do this again?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Every GUIElement has a setText method, but you are right, the text is never drawed in the Image. But maybe this is a feature to add. :)

And for question two: If you want to react to events, just implement a OnEvent method and return 'true' if you procecced the event and don't want any other element to get this event. Do a "return IGUIElement::OnEvent(event);" in all other cases.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Gotcha. That makes sense then.

I'm not near a compiler, so I'm going on assumption that this won't play havok with any parent-child relationships of the handrolled elements playing with Irrlicht Standard ones.

The tutorial I'm writing is to make an Image Button Control with text similiar to Visual Basics button control. Of course, it could be integrated into the Irrlicht Engine itself as a different way of button controls. I'm just thinking it's a good way to showcase making personal Gui elements. It's not difficult since I've already been working with a control scheme similiar to this when making plugins for Decal(http://decaldev.sourceforge.net). My plugin is at http://navi3.sourceforge.net
Crud, how do I do this again?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

I came around your navi3 site some time ago, didn't know that it has been made by you. Cool work. :) And I am looking forward for your tutorial. ;)
Post Reply