void iupTreeSelectLastCollapsedBranch(Ihandle* ih, int *last_id) { /* if last selected item is a branch, then select its children */ if (iupStrEqual(IupTreeGetAttribute(ih, "KIND", *last_id), "BRANCH") && iupStrEqual(IupTreeGetAttribute(ih, "STATE", *last_id), "COLLAPSED")) { int childcount = IupTreeGetInt(ih, "CHILDCOUNT", *last_id); if (childcount > 0) { int start = *last_id + 1; int end = *last_id + childcount; IupSetfAttribute(ih, "MARK", "%d-%d", start, end); *last_id = *last_id + childcount; } } }
VALUE rb_IupTreeGetAttribute(VALUE node,VALUE v_a,VALUE v_id) { const char* a = RSTRING_PTR(v_a); int id = NUM2INT(v_id); char* v; VALUE v_ih = rb_iv_get(node,"@ihandle"); v = IupTreeGetAttribute((Ihandle*)NUM2ULONG(v_ih),a,id); return rb_str_new2(v); }
static int togglestate(void) { char *value; Ihandle* tree = IupGetHandle("tree"); int id = IupGetInt(tree, "VALUE"); value = IupTreeGetAttribute(tree, "STATE", id); if (value) { if (strcmp(value, "EXPANDED")==0) IupTreeSetAttribute(tree, "STATE", id, "COLLAPSED"); else IupTreeSetAttribute(tree, "STATE", id, "EXPANDED"); } return IUP_DEFAULT; }