00001 /*-------------------------------------------------------------------- 00002 * vprop.h 00003 * 00004 * The vprop class allows a visual properties to be defined on 00005 * vnodes. Each vprop object contains a list of the vnodes that have 00006 * that particular property. The vprop object defines the visual 00007 * attributes such as foreground, background colors. The vnodes also 00008 * contain back-pointers to the vprop objects. 00009 * 00010 * The "add_node" and "remove_node" methods modify the vnode list. 00011 * The "update" method must be called to update the visual attributes. 00012 * This method post a global PROP_CHANGE event, so that all widgets 00013 * can update the display. 00014 * 00015 */ 00016 00017 #ifndef VPROP_H 00018 #define VPROP_H 00019 00020 #include "vnode.h" 00021 #include "common/suif_list.h" 00022 00023 #define DEFAULT_FOREGROUND "black" 00024 #define DEFAULT_BACKGROUND "#F0C0C0" 00025 00026 00027 class vwidget; 00028 class vprop; 00029 typedef list<vprop*> vprop_list; 00030 00031 class vprop { 00032 private: 00033 friend class vwidget; 00034 friend class vnode; 00035 00036 char *nm; 00037 char *desc; 00038 00039 /* display attributes */ 00040 char *foreground; 00041 char *background; 00042 00043 /* misc information */ 00044 vnode_list *nodes; // the nodes that has this property 00045 void *client_data; 00046 00047 public: 00048 vprop(char *name = "no-name", void *data = 0); 00049 ~vprop(void); 00050 00051 void set_description(char *s) { desc = s; } 00052 00053 char *name(void) { return nm; } 00054 char *description(void) { return desc; } 00055 00056 /* display attributes */ 00057 char *get_foreground(void) { return foreground; } 00058 char *get_background(void) { return background; } 00059 00060 void set_foreground(char *color) { foreground = color; } 00061 void set_background(char *color) { background = color; } 00062 00063 /* node list */ 00064 vnode_list *get_node_list(void) { return nodes; } 00065 00066 /* add/remove nodes */ 00067 void erase(void); 00068 void add_node(vnode *vn); 00069 void remove_node(vnode *vn); 00070 00071 /* update */ 00072 void update(void); 00073 00074 /* get client data */ 00075 void set_client_data(void *dat) { client_data = dat; }; 00076 void *get_client_data(void) { return client_data; }; 00077 }; 00078 00079 00080 00081 #endif