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

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

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  * vman.h
00003  *
00004  * The visual_manager class manages all the internals of the visual system.
00005  * it is responsible for starting and exiting the visual system,
00006  * keep track of the vnodes, window classes, window instances,
00007  * external modules, visual properties.
00008  *
00009  * There should only be one instance (vman) of the visual_manager class.
00010  *
00011  */
00012 
00013 #ifndef VMAN_H
00014 #define VMAN_H
00015 
00016 #include "vnode.h"
00017 #include "vprop.h"
00018 #include "window.h"
00019 #include "vmodule.h"
00020 
00021 class binding;
00022 
00023 void init_vman(void);
00024 void exit_vman(void);
00025 
00026 /* If you change the hash table parameters, you should change the hash
00027  * function also.
00028  */
00029 #define VN_HASH_SIZE 256
00030 #define VN_HASH_MASK 255
00031 
00032 
00033 /*----------------------------------------------------------------------
00034  * window
00035  */
00036 struct window_instance {
00037   window *instance;
00038   window_class *wclass;
00039   
00040   window_instance(void) {
00041     instance = 0;
00042     wclass = 0;
00043   }
00044 };
00045 
00046 typedef list<window_instance*> window_instance_list;
00047 
00048 /*----------------------------------------------------------------------
00049  * Visual Manager
00050  *
00051  * There should only be one instance of this class
00052  */
00053 class visual_manager {
00054 private:
00055   binding *event_binding;
00056 
00057   /* toplevel management */
00058   int toplevel_num;
00059 
00060   /* vnodes management */
00061   vnode_list hashed_list[VN_HASH_SIZE];
00062   vnode_list *vn_history;
00063 
00064   void add_vnode(vnode *vn);
00065   void remove_vnode(vnode *vn);
00066 
00067   /* window class management */
00068   window_class_list *wclasses;
00069 
00070   /* window management */
00071   window_instance_list *current_windows;
00072 
00073   /* properties */
00074   vprop_list *props;
00075 
00076   /* modules */
00077   module_list *modules;
00078 
00079 
00080   static void event_handler(event &e, visual_manager *v);
00081 
00082 public:
00083   visual_manager(void);
00084   ~visual_manager(void);
00085   void init(void);
00086 
00087   /* toplevel path management */
00088   void new_toplevel_path(char *path);
00089 
00090   /* vnodes management */
00091   vnode *find_vnode(const void *obj);
00092   void remove_all_vnodes(void);
00093 
00094   /* selection */
00095   vnode *get_selection(void) const;
00096   vnode_list *get_selection_history(void) const { return vn_history; }
00097   void go_back(void);
00098 
00099   /* window class management */
00100   window_class_list *get_window_classes(void) const { return wclasses; }
00101   void register_window_class(char *class_name, window_cons_fn fn);
00102   window_class *find_window_class(char *name);
00103 
00104   /* window management */
00105   window *create_window_instance(window_class *);
00106   void new_window_instance(window *win, char *class_name);
00107   void remove_window_instance(window *win);
00108   void get_current_windows(window_list &win_list);
00109 
00110   window *find_window_instance(window_class *wclass);
00111   bool find_window_instance(window *win);
00112   window *show_window(window_class *wclass);
00113   window *show_window(char *class_name);
00114 
00115   /* modules */
00116   void register_module(char *name, module *(*constructor_fn)(void));
00117   void add_module(module *m);
00118   module_list *get_module_list(void) { return modules; }
00119 
00120   /* props */
00121   vprop_list *get_prop_list(void) { return props; }
00122 };
00123 
00124 extern visual_manager *vman;
00125 
00126 /*----------------------------------------------------------------------
00127  * Macros
00128  *
00129  */
00130 
00131 #define REGISTER_MODULE(name, constructor_function) \
00132 { \
00133   vman->register_module(name, constructor_function); \
00134 }
00135 
00136 #define REGISTER_WINDOW_CLASS(name, constructor_function) \
00137 { \
00138   vman->register_window_class(name, constructor_function); \
00139 }
00140 
00141 #endif

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