00001 /*-------------------------------------------------------------------- 00002 * vtext.h 00003 * 00004 */ 00005 00006 #ifndef VTEXT_H 00007 #define VTEXT_H 00008 00009 #include "tcltk_calling_convention.h" 00010 #include "vwidget.h" 00011 #include "event.h" 00012 #include "vtcl.h" 00013 #include "vtagman.h" 00014 #include "vtty.h" 00015 #include "vprop.h" 00016 00017 class vnode; 00018 class binding; 00019 class vprop; 00020 00021 typedef int column_id; 00022 00023 /*---------------------------------------------------------------------- 00024 * text widget 00025 */ 00026 00027 class vtext : public vtty { 00028 00029 private: 00030 vtagman *tagman; // tags mananger 00031 00032 vnode *current_sel; // currently selected object 00033 tag_node *current_tag; // currently selected tag 00034 00035 void add_indicator(int row, int col, bool on); 00036 00037 void expand_node_helper(tag_node *tag); 00038 void collapse_node_helper(tag_node *tag); 00039 00040 /* misc */ 00041 char *read_text(text_coord &begin, text_coord &end); 00042 void delete_text(tag_node *node, text_coord &begin, text_coord &end); 00043 void insert_text(tag_node *root, bool overwrite); // insert text 00044 00045 void preselect_node_at(int row, int col); 00046 00047 public: 00048 vtext(vwidget *par); 00049 ~vtext(void); 00050 void destroy(void); 00051 virtual int kind(void) { return WIDGET_TEXT; } 00052 00053 /* configure */ 00054 void set_text_wrap(bool wrap); 00055 00056 /* additional columns */ 00057 column_id add_column(int width); 00058 void remove_column(column_id); 00059 void set_column_text(column_id col, int line_num, char *text); 00060 00061 /* text I/O */ 00062 int insert_file(char *filename, bool add_line_num = false); 00063 virtual void update(void); 00064 virtual void clear(void); 00065 00066 /* attributes */ 00067 virtual void tag_style(text_style style); 00068 00069 /* vnode tags */ 00070 virtual void *tag_begin(vnode *obj); 00071 virtual void *tag_begin(vnode *obj, print_fn fn, int d, 00072 void *client_data); 00073 virtual void tag_end(vnode *obj); 00074 tag_node *root_tag(void) { return tagman->get_root(); } 00075 tag_node *find_tag(vnode *obj); 00076 tag_node_list *find_tags(vnode *obj); 00077 00078 /* properties */ 00079 void update_props(void); 00080 void update_prop(vprop *p); 00081 00082 /* viewing */ 00083 void view(int row, int col); 00084 void view(tag_node *tag); 00085 void view(vnode *vn); 00086 int get_top_row(void); 00087 00088 /* selection */ 00089 virtual vnode *get_selection(void) { return current_sel; } 00090 00091 void select_clear(void); 00092 void select_node_at(int row, int col, int scope = 0); 00093 void select_line(int row); 00094 void select(tag_node *node, bool add = false); 00095 void select(vnode *vn, bool add = false); 00096 void select_expand(void); 00097 00098 /* toggle nodes */ 00099 void expand_node(tag_node *node); 00100 void collapse_node(tag_node *node); 00101 void collapse_all(void); 00102 void expand_all(void); 00103 00104 /* interface with tcl/tk */ 00105 static int TCLTK_CALLING_CONVENTION vtext_cmd(ClientData clientData, Tcl_Interp *interp, int argc, 00106 char *argv[]); 00107 00108 }; 00109 00110 #endif