Making a new widget...

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

LennyH
Quite a regular
Quite a regular
Posts: 92
Joined: Thu Nov 30, 2006 20:50

Making a new widget...

Postby LennyH » Fri Dec 15, 2006 20:30

Let's say I have created a new widget in the looknfeel file, and I now wish to use it in my code. This is something the tutorial stops short on; for existing widgets, it is obvious that for a WindowsLook/Button you would create a CEGUI::PushButton. But what do you do if you have a new widget - UberCoolWidget? Everything is derived from CEGUI::Window, I think, so would I cast it to that while calling createWindow( "WindowsLook/UberCoolWidget", ... )?

But naturally that results in a runtime error for me, which I wholly expected. I can understand more complex controls not being usable without creating a back-end class to match, but can you not create a simple, new widget in the looknfeel file that will render and respond to the basic state changes and other events?

LennyH
Quite a regular
Quite a regular
Posts: 92
Joined: Thu Nov 30, 2006 20:50

Postby LennyH » Tue Dec 19, 2006 15:58

Surely there is somebody that can answer what the proper course of action is for creating a new widget :)?

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Postby martignasse » Wed Dec 20, 2006 11:28

hello LennyH,

for an example of making new widget, you can look at the source code of the CEImagesetEditor.

it use some new widget like "ElasticBox", like that you can see all the stuff needed for adding a new widget.

PS : there is several place where you have to add some class (looknfeel, properties, falagard....) but i don't remenber exactly.

Hope it help

LennyH
Quite a regular
Quite a regular
Posts: 92
Joined: Thu Nov 30, 2006 20:50

Postby LennyH » Wed Dec 20, 2006 16:18

Indeed; I guess I was hoping for a bit much to think you could create new, generic widgets with just the looknfeel.

Perhaps a feature request ;)

But, to the topic at hand, I figured a simple approach to work up from would simply to get a widget to compile from my own test application, much how ElasticBox appears to be compiled into the CEGUIImagesetEditor [as opposed to getting shoved into the CEGUI dll files].

I simply copied over the CEGUICheckbox.h/.cpp files, along with the appropriate Properties files.

Do a find and replace for Checkbox and rename it. Boom, "new" widget.

Aside that it doesn't work :) First thing I figured I would need is a factory. I read that somewhere on these forums and kept it in the back of my mind. Well, ElasticBox has a factory, so I followed its example, since my goal is just to get something to compile and run :p

So we have a factory, identical to ElasticBox, save that it references my own 'new' widget class.

But now, unfortunately, when it tries to compile the factory, it says it cannot instantiate an abstract class of my 'new' widget.

I am working with this from VS2005, which is a constraint that cannot change. Would it be an error caused by that? I know there is code breaking change in regards to abstract classes that VS2005 causes, however, reading up on these does not indicate that being the case.

I am curious if anybody else has used CEGUI 0.4.1 to create a new widget from VS2005?


edit: Indeed, it is because of VS2005 being more strict. ButtonBase defines drawNormal( float z ) as pure virtual; checkbox did not define this function at all. Hence, the error.

Now to figure out why it doesn't show up :) But progress is progress :)

If I had to venture, it's not showing up because I'm not sure what to do with drawNormal.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 28 guests