See XSysEventSource for more information.
These copy constructors allow on to copy XSysEvents
Returns the group to which this event belongs. The SysEvent::Group is just an enumeration of the possible event types.
Returns the type this event. The type is a string which represents the type of the event.
Returns the type of the event in X-speak.
Dispatches this event to the event target parameter.
Dispatches this event to the event target parameter, and carries along an extra event source in case it is needed. This might be needed if a GUI application wanted to post Glish events as buttons are pressed.
Return the underlying data structure
Return a copy of this event.
If the event driven interface to these event sources is used, there is no more overhead than the typical X event loop, shown below. Using the procedural interface, however, incurs a performance penalty due to polling
This class is most useful when both Glish and X Windows events are used.
Example
This is an example of how these classes might be used. It demonstrates
how Glish and X Windows events can be cleanly combined into one event
stream. The Glish event stream can also be used by itself in this manner
as well (see the event driven
example in the GlishEvent header file).
#include <Xm/Xm.h> // --+ #include <Xm/Form.h> // | #include <Xm/PushB.h> // +-> 1 #include <iostream> // --+ #include <aips/Glish.h> // 2 #include <aips/Glish/XSysEvent.h> // 3 // --+ Bool helloCallback(GlishSysEvent &e, void *) { // | GlishSysEventSource *src = e.glishSource(); // | (*src).postEvent("hello_got",e.type()); // | return True; // | } // +-> 4 // | Bool defaultCallback(GlishSysEvent &e, void *) { // | GlishSysEventSource *src = e.glishSource(); // | (*src).postEvent("default_got",e.type()); // | return True; // | } // --+ // Bool otherCallback(SysEvent &e, void *) { // --+ if ( e.group() == SysEvent::GlishGroup ) { // | GlishSysEvent &ge = (GlishSysEvent &) e; // | GlishSysEventSource *src = ge.glishSource(); // | (*src).postEvent("other_got",ge.type()); // +-> 5 return True; // | } // | return False; // | } // --+ // static void DoXSetup(XSysEventSource &); // 6 main(int argc, char **argv) { // 7 XSysEventSource xStream(argc,argv); // 8 GlishSysEventSource glishStream(argc, argv); // 9 // 10 glishStream.setDefault(defaultCallback); // --+ glishStream.addTarget(helloCallback,".*hello"); // +-> 11 glishStream.addTarget(otherCallback,"[a-z]+"); // --+ // xStream.combine(glishStream); // 12 // DoXSetup(xStream); // 13 // XtRealizeWidget(xStream.toplevel()); // 14 // xStream.loop(); // 15 } void QuitCB (Widget, XtPointer,XtPointer) { cout << "Outttaaa here..." << endl; exit(0); } void DoCB (Widget, XtPointer,XtPointer) { cout << "Do'in it..." << endl; } static void DoXSetup(XSysEventSource &xStream) { Widget outerContainer, quitButton, doButton; outerContainer = XtVaCreateManagedWidget ("OuterForm", xmFormWidgetClass, xStream.toplevel(), NULL); quitButton = XtVaCreateManagedWidget ("QUIT", xmPushButtonWidgetClass, outerContainer, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0, NULL); doButton = XtVaCreateManagedWidget ("DO", xmPushButtonWidgetClass, outerContainer, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 25, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0, NULL); XtAddCallback(quitButton,XmNactivateCallback,QuitCB,(XtPointer) 0); XtAddCallback(doButton,XmNactivateCallback,DoCB,(XtPointer) 0); }
This initializes the event source. It takes the command line parameters, argc and argv, and the name if any of the source. This will do all of the X initialization. From here on, the XSysEventSource::toplevel() member function should be used to access the top level widget.
The parameter options should be a pointer to the X structure XrmOptionDescRec. It is void here to avoid inclusion of X header files.
This initializes the event source. It takes the command line parameters, argc and argv, and the name if any of the source. This will do all of the X initialization. From here on, the XSysEventSource::toplevel() member function should be used to access the top level widget.
Returns the group of the event source. SysEvent::Group is just an enumeration which lists all of the possible types of Events.
Returns the actual X context for use.
Returns the actual X top level widget for use.
Get the next waiting X event (blocks).
Check to see if any X events are queued up.
Indicates if the source is still connected to the event stream or not.
Used to check to see if the other SysEventSource can be combined with this XSysEventSource.
This is used to combine another event source, other. The SysEventSource, other, must persist as long as objects of this class persist, its address will be used.
Invoke the target whenever the event matches the regular expression. These do not currently add targets, but rather they always return False indicating that the target couldn't be added.
Specifies the default action which should be applied when no other targets are applicable. These do not currently add targets, but rather they always return False indicating that the target couldn't be added.
loop and deliver events to targets as they arrive. The process will be blocked until an event arrives.
This is for internal use, and is invoked when an event may be available for processing on this event source.
This default XSysEventTarget simply dispatches the XEvent using the typical X mechanics.
See XSysEventSource for more information.
Get the group of this X event target.
Pass the XSysEvent along to the handler parameter. This typically simply involved dispatching the event to the underlying X dispatch mechanism.
Pass the XSysEvent along to the event handler, but carry along the extra event source. This is useful when handlers of one SysEvent::Group need to post events to a different Group, i.e. X handlers posting Glish events.
This class is used as a container of information for sources which have been combined with XSysEventSource. It facilitates invoking targets based on regular expressions.
This class is not intended for external use.
We would have liked to put this definition in the source (.cc) file, but the compiler SunOS Cfront doesn't seem to deal with it. Instead this class had to be put into this header file, and the X Windows specific information was put into the structure XSysEventSourceInfo_XGUTS to avoid exposing users of XSysEvent.h to X11 header files.