int tree_view(int fdin, u_int rootdir) { AVT_ELEM elem; // one element if ((lseek(fdin, rootdir, SEEK_SET) != rootdir) || (read(fdin, &elem, sizeof(AVT_ELEM)) != 40)) { return(1); } print_elem(fdin, elem); if (elem.bits.fdir && elem.tree) tree_view(fdin, elem.tree); if (elem.left) tree_view(fdin, elem.left); if (elem.right) tree_view(fdin, elem.right); return(0); };
main(int argc, char *argv[]) { int fdin; // file desk struct stat fdstat; // stat file AVT_HEAD head; // head of AVT file AVT_IPHYSTAPE *iphystape; // list iphystape if (argc < 2) { fprintf(stderr, "Usage: %s <file.avt>\n", argv[0]); return(0); } // пробуем открыть fdin = open(argv[1], O_RDONLY, 0); if (fdin < 0) { fprintf(stderr, "Can't open file '%s'\n", argv[1]); return(0); } // статистика по файлу для проверок if (fstat(fdin, &fdstat) < 0) { fprintf(stderr, "Can't stat file '%s'\n", argv[1]); close(fdin); return(0); } // загрузим заголовок if (read(fdin, &head, sizeof(AVT_HEAD)) != 40) { fprintf(stderr, "Error read HEAD from file '%s'.\n", argv[1]); close(fdin); return(0); } print_head(head); // проверим версию if (head.avtformat != 1) { fprintf(stderr, "Format '%d' not supported.\n", head.avtformat); close(fdin); return(0); } iphystape = new AVT_IPHYSTAPE; if ((lseek(fdin, head.iphystape, SEEK_SET) != head.iphystape) || (read(fdin, iphystape, sizeof(AVT_IPHYSTAPE)) != 40)) { fprintf(stderr, "Error read from file '%s'!\n", argv[1]); delete iphystape; close(fdin); return(0); } print_iphystape(iphystape); if (tree_view(fdin, head.rootdir)) { fprintf(stderr, "Error read from file '%s'!\n", argv[1]); delete iphystape; close(fdin); } delete iphystape; close(fdin); };
ttree_view_node& ttree_view_node::add_child( const std::string& id , const std::map<std::string /* widget id */, string_map>& data , const int index) { boost::ptr_vector<ttree_view_node>::iterator itor = children_.end(); if(static_cast<size_t>(index) < children_.size()) { itor = children_.begin() + index; } itor = children_.insert(itor, new ttree_view_node( id , node_definitions_ , this , tree_view() , data)); if(is_folded() || is_root_node()) { return *itor; } if(tree_view().get_size() == tpoint(0, 0)) { return *itor; } assert(tree_view().content_grid()); const int current_width = tree_view().content_grid()->get_width(); // Calculate width modification. tpoint best_size = itor->get_best_size(); best_size.x += get_indention_level() * tree_view().indention_step_size_; const unsigned width_modification = best_size.x > current_width ? best_size.x - current_width : 0; // Calculate height modification. const int height_modification = best_size.y; assert(height_modification > 0); // Request new size. tree_view().resize_content(width_modification, height_modification); return *itor; }
VOID edit_box(LONG tree, WORD sobj) { LONG obspec; WORD where, type, exitobj, ok, nilok; BYTE name[9], text[2], bxchar; GRECT p; if (rcs_state != ALRT_STATE) { get_fields(tree, sobj, &type, &obspec, &p); ini_tree(&tree, BOXDIAL); where = set_obname(tree, BOXNAME, name, ad_view, sobj); if ( where != NIL && tree_view() && tree_kind( get_kind(where)) ) nilok = FALSE; else nilok = TRUE; bxchar = LHIBT(LHIWD(LLGET(obspec))); set_text(tree, OCHRITEM, (LONG)ADDR(&text[0]), 2); text[0] = bxchar? bxchar: '@'; text[1] = '\0'; do { exitobj = hndl_dial(tree, OCHRITEM, &p); desel_obj(tree, exitobj); ok = DEFAULT & GET_FLAGS(tree, exitobj); } while (ok && !name_ok(name, where, nilok)); if (ok) { rcs_edited = TRUE; get_obname(name, ad_view, sobj); bxchar = (text[0] == '@')? '\0': text[0]; LLSET(obspec, (LLGET(obspec) & 0xffffffL) | ((LONG) ((UWORD) bxchar) << 24)); } } }
ttree_view_node::~ttree_view_node() { if(/*tree_view() &&*/ tree_view().selected_item_ == this) { tree_view().selected_item_ = NULL; } }