M> AFAIK, you are mentioning events in the sense that there are passing =
M>
thru the regular GUI event loop.
Just for the record, normal events in wxWindows *are* synchronous.
Hi,
apart from the whole discussion yet, I have written a general
wxWidgets application that uses my system for managing or
connecting events to handlers.
In the wxWidgets app I have one hardcoded eventhandler (macros),
that can handle exit, about and similar standard events.
Is the event ID not in that #defined EV_ID_XX1... it calls an
event dispatcher, wich knows about other ID's - that in my way
are ID's > 5000.
The dispatcher then looks up the matching event handler for that
ID by using a skiplist and forwards the event to the registered event
handler. This then handles it and returns.
The registration of a new handler is done by calling a function from
my event manager. This class registers a symbolic event name and
returns an increased event ID.
If these ID's are registered, I can register it's handlers. Either by
using again the symbolic event names or by prior retrieved and stored
ID's.
These event handlers may or may not located in a wxWidget based
application module.
To issue an event I need to add a menu entry on the wx side.
I use my registered event handler (in the wx GUI - since I need
access to wx functionality) to build up a menu entry from non wx
modules.
Now the wx GUI user can issue a dynamically registered event from the
GUI that goes to a module unknown by the wx application.
I hope this will give another ideas for managing signals and slots.
This currently works with wxWigrets, but may also interconnect to
the signals and slot approach.
-- non wx
|
wx -| my approach (like COM with interfaces) -- signals and slot
|
-- other
Regards,
Lothar
Here is the sample code, I have extracted from my project:
(I need to think about more macros to simplify the code :-)
wx loads a module 'metaapplication' and initializes it:
(Calling this member)
lbErrCodes LB_STDCALL lb_MetaApplication::Initialize() {
// Variables that should be defined in the class decls.
int getBasicApplicationInfo;
int getMainModuleInfo;
int testPressed;
// I get my event manager by the interface name
lb_I_Module* m =3D *&manager;
REQUEST(m, lb_I_EventManager, eman)
// I register my event names and get the ID's
eman->registerEvent("getBasicApplicationInfo",
getBasicApplicationInfo);
eman->registerEvent("getMainModuleInfo", getMainModuleInfo);
eman->registerEvent("Button Test pressed", testPressed);
// I get my dispatcher
REQUEST(m, lb_I_Dispatcher, disp)
dis->setEventManager(eman.getPtr());
// I register my handlers to the given dispatcher
lbErrCodes LB_STDCALL
lb_MetaApplication::registerEventHandler(lb_I_Dispatcher* disp) {
disp->addEventHandlerFn(this, (lbEvHandler)
&lb_MetaApplication::lbEvHandler1, "getBasicApplicationInfo");
disp->addEventHandlerFn(this, (lbEvHandler)
&lb_MetaApplication::lbEvHandler2, "getMainModuleInfo");
disp->addEventHandlerFn(this, (lbEvHandler)
&lb_MetaApplication::lbButtonTestHandler, "Button Test pressed");
}
/* These has interconnected the event handler - now the menu */
addMenuBar("Edit");
loadApplication(); // let subsequent modules initialize their menu
addMenuBar("Help");
// Add some menu entries and buttons that do something
addMenuEntry("Help", "MainModuleInfo", "getMainModuleInfo", "");
addButton("Press me for test", "Button Test pressed", 10, 30, 100,
20);
int hight =3D 60;
int n =3D 1;
addLabel("Label", 115, 30, 100, 20);
addTextField("TextField", 220, 30, 100, 20);
addButton("|<", "Button Test pressed", 10, hight+n*20+n*5, 100, 20);
addButton("<<", "Button Test pressed", 115, hight+n*20+n*5, 100, 20);
addButton(">>", "Button Test pressed", 220, hight+n*20+n*5, 100, 20);
addButton(">|", "Button Test pressed", 325, hight+n*20+n*5, 100, 20);
n++;
addButton("|<", "Button Test pressed", 10, hight+n*20+n*5, 100, 20);
addButton("<<", "Button Test pressed", 115, hight+n*20+n*5, 100, 20);
addButton(">>", "Button Test pressed", 220, hight+n*20+n*5, 100, 20);
addButton(">|", "Button Test pressed", 325, hight+n*20+n*5, 100, 20);
---- My home: www.lollisoft.de -----------------------------
Lothar Behrens | Independent: ***@gmx.de
Rosmarinstr 3 | My public project:
40235 D=FCsseldorf | http://sourceforge.net/projects/lbdmf
| -> Need comments, please visit :-)