Helper define


19-02-2008 19:56:16

Just some helper define for adding events handlers
#define ADD_EVENT(Widget_Par,Event_Par,HandlerType_Par,Handler_Par) \
Widget_Par->addEventHandler <HandlerType_Par> (QuickGUI::Widget::Event_Par,&HandlerType_Par::evt##Widget_Par##Event_Par,dynamic_cast<HandlerType_Par*> (Handler_Par));

So instead of:
LeftButton->addEventHandler <DemoListener> (QuickGUI::Widget::EVENT_MOUSE_BUTTON_DOWN,&DemoListener::evtHandlerLeft,dynamic_cast<DemoListener*> (mFrameListener));
you can use:

The macro expects event handlers defined in the respective class like this:
void DemoListener::evtLeftButtonEVENT_MOUSE_BUTTON_DOWN(const QuickGUI::EventArgs& args)

Not a big deal, I just played with it and though that it may be useful. It would have been even nicer if the QuickGUI events had some aesthetic names :wink:


19-02-2008 20:01:21

That does look convenient to use, except that you'd need to memorize all the event names in order to come up with correct handler function names, right?


Also some widgets have unique events with no enumerated type, you have to use the provided interfaces as far as I know.

I thought users would want to define their own meaningful handler names. Instead of evtLeftButton... they would have startGame, exit, etc.


19-02-2008 20:28:54

Sorry, but a big NO! We had a discussion about that already in another thread. Macros are evil. What, if you want to use QuickGUI together with another library, which defines an ADD_EVENT macro, too? And I really don't want to go into details here about the debugging-problems you can get from this stuff.