00001 #ifndef EVENT_H 00002 #define EVENT_H 00003 00004 /* 00005 * The visual system is an event-driven environment. An "event" object 00006 * contains the current event context - the event kind, the vnode object, 00007 * the source widget. 00008 * 00009 * There is a global event binding list. Whenever an event occurs, 00010 * event bindings in this global list are invoked. The "add_event_binding" 00011 * function adds a binding to this list; the "remove_event_binding" removes 00012 * a binding from the list. The "post_event" method posts a global event, 00013 * and invokes the corresponding event bindings; 00014 */ 00015 00016 //#include <sty.h> 00017 00018 enum event_kind { 00019 NULL_EVENT = 0, 00020 00021 VNODE_CREATE = 1024, 00022 VNODE_DESTROY, 00023 00024 WINDOW_CREATE = 2048, 00025 WINDOW_CLOSE, 00026 PROP_CREATE, // New property 00027 PROP_CHANGE, // Property changed 00028 PROP_DESTROY, // Property removed 00029 00030 SELECTION = 4096, 00031 INVOCATION, 00032 OK_BUTTON, 00033 CANCEL_BUTTON, 00034 00035 VISUAL_USER_EVENT = 8192 00036 }; 00037 00038 /* event masks */ 00039 #define ALL_EVENTS (-1L) 00040 #define VNODE_EVENTS 1024L 00041 #define VISUAL_EVENTS 2048L 00042 #define X_EVENTS 4096L 00043 #define VISUAL_USER_EVENTS (VISUAL_USER_EVENT) 00044 00045 00046 class event { 00047 private: 00048 int e_kind; 00049 class vnode *vn; 00050 class vwidget *source_obj; 00051 void *event_param; 00052 00053 public: 00054 event() { e_kind = NULL_EVENT; } 00055 event(vnode *obj, int k, vwidget *source = 0, void *param = 0 ) { 00056 vn = obj; 00057 e_kind = k; 00058 source_obj = source; 00059 event_param = param; 00060 } 00061 ~event() {} 00062 00063 int kind(void) const { return e_kind; } 00064 vnode *get_object(void) const { return vn; } 00065 vwidget *get_source(void) const { return source_obj; } 00066 void *get_param(void) const { return event_param; } 00067 }; 00068 00069 00070 void init_eman(void); 00071 void exit_eman(void); 00072 void post_event(const event &e); 00073 void add_event_binding(class binding *b, int event_mask); 00074 void remove_event_binding(binding *b); 00075 void set_event_mask(binding *b, int event_mask); 00076 00077 #endif