Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

nci/suif/suif2b/suifbrowser/visual/binding.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  * binding.h
00003  *
00004  * A "binding" is a function callback that is attached to a user event.
00005  * It can be attached to a menu item, user selection, invocation, etc.
00006  *
00007  * The callback function can be in several forms - tcl/tk command,
00008  * "bfun" or "bfun2" functions (defined in binding.h). The function
00009  * parameters are a "event" object, and one or two client data. The
00010  * "event" object contains context information of the event that invoked
00011  * the binding.
00012  *
00013  */
00014 
00015 #ifndef BINDING_H
00016 #define BINDING_H
00017 
00018 #include "event.h"
00019 //#include <sty.h>
00020 #include "common/suif_list.h"
00021 
00022 class vnode;
00023 
00024 typedef void (*bfun)(const event &e, void *client_data);
00025 typedef void (*bfun2)(const event &e, void *client_data1, void *client_data2);
00026 
00027 class binding {
00028 private:
00029   char *tcl_command;
00030   bfun function;
00031 
00032   int num_client_data;
00033   void *client_data1;
00034   void *client_data2;
00035 
00036 public:
00037   binding(void);
00038   binding(bfun f, void *data = 0);
00039   binding(bfun2 f, void *data1, void *data2);
00040 
00041   ~binding(void);
00042 
00043   void set_tcl_command(char *s, void *data = 0) {
00044     tcl_command = s;
00045     client_data1 = data;
00046     num_client_data = 1;
00047   }
00048   void set_tcl_command(char *s, void *data1, void *data2) {
00049     tcl_command = s;
00050     client_data1 = data1;
00051     client_data2 = data2;
00052     num_client_data = 2;
00053   }
00054   void set_function(bfun f, void *data = 0) { 
00055     function = f;
00056     client_data1 = data;
00057     num_client_data = 1;
00058   };
00059   void set_function(bfun2 f, void *data1, void *data2) { 
00060     function = (bfun) f;
00061     client_data1 = data1;
00062     client_data2 = data2;
00063     num_client_data = 2;
00064   };
00065 
00066   /* invoke */
00067   void invoke(const event &e);
00068 };
00069 
00070 
00071 //typedef slist_tos<binding*> binding_list;
00072 typedef list<binding*> binding_list;
00073 
00074 void delete_bindings(binding_list *bindings);
00075 
00076 #endif

Generated at Mon Jul 31 13:42:33 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000