Beispiel #1
0
bool HierTreeMdl::iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const
{
    bool res = false;
    if (IsIterValid(parent)) {
	Elem* node = (Elem*) parent.gobj()->user_data;
	if (n < node->Comps().size()) {
	    iter.set_stamp(iStamp);
	    iter.gobj()->user_data = node->Comps().at(n);
	    res = true;
	}
    }
    return res;
}
Beispiel #2
0
void HierTreeMdl::OnCompAdding(Elem& aComp)
{
    std::cout << "HierTreeMdl::OnCompAdding: [" << aComp.Name() << "]" << std::endl;
    //UpdateStamp();
    // Nodify view of all the internal components. This is required because there is no
    // notif from internal comps - they are created before element gets inserted to the hier
    iterator iter;
    iter.set_stamp(iStamp);
    iter.gobj()->user_data = &aComp;
    Path path = get_path_vfunc(iter);
    row_inserted(path, iter);
    for (vector<Elem*>::iterator it = aComp.Comps().begin(); it != aComp.Comps().end(); it++) {
	OnCompAdding(*(*it));
    }
}
Beispiel #3
0
Elem* HierTreeMdl::get_next_comp(Elem* aComp) 
{
    Elem* res = NULL;
    Elem* mgr = aComp->GetMan();
    if (mgr != NULL) {
	int ct = 0;
	for (; ct < mgr->Comps().size(); ct++) {
	    if (mgr->Comps().at(ct) == aComp) {
		break;
	    }
	}
	if (ct < mgr->Comps().size() - 1) {
	    res = mgr->Comps().at(++ct);
	}	
    }
    return res;
}
Beispiel #4
0
bool HierTreeMdl::iter_has_child_vfunc(const iterator& iter) const
{
    bool res = false;
    if (IsIterValid(iter)) {
	Elem* node = (Elem*) iter.gobj()->user_data;
	res = (node->Comps().size() > 0);
    }
    return res;
}
Beispiel #5
0
int HierTreeMdl::iter_n_children_vfunc(const iterator& iter) const
{
    int res = 0;
    if (IsIterValid(iter)) {
	Elem* node = (Elem*) iter.gobj()->user_data;
	res = node->Comps().size();
    }
    return res;
}
Beispiel #6
0
Gtk::TreeModel::Path HierTreeMdl::get_path_vfunc(const iterator& iter) const
{
    Path path;
    Elem* mgr = NULL;
    Elem* comp = (Elem*) iter.gobj()->user_data;
    // By depth
    do {
	mgr = comp->GetMan();
	if (mgr == NULL) {
	    break;
	}
	int pos;
	for (pos = 0; pos < mgr->Comps().size(); pos++) {
	    if (mgr->Comps().at(pos) == comp) {
		break;
	    }
	}
	path.prepend_index(pos);
	comp = mgr;
    } while (comp != iRoot);
    return path;
}
Beispiel #7
0
bool HierTreeMdl::get_iter_vfunc(const Path& path, iterator& iter) const
{
    bool res = false;
    Elem* comp = NULL;
    Elem* mgr = iRoot;
    unsigned depth = path.size();
    //Glib::ArrayHandle<int> indc = path.get_indices(); 
    vector<int> indcv = path.get_indices();
    for (int dc = 0; dc < depth; dc++) {
	int ind = indcv.at(dc);
	if (ind >= mgr->Comps().size()) {
	    return false;
	}
	comp = mgr->Comps().at(ind);
	mgr = comp;
    }
    if (comp != NULL) {
	iter.set_stamp(iStamp);
	iter.gobj()->user_data = comp;
	res = true;
    }
    return res;
}