net@TUB.BITNET (Oliver Laumann) (01/07/89)
Has somebody already implemented an XtGetConstraintResourceList() function that works like XtGetResourceList() but returns the constraint resource list? If so, are you willing to publish the source code for it? If not, can someone being more familiar with the internals of the Xt intrinsics provide some hints how one would implement such a function? I need this functionality to be able to determine whether or not a given widget class has a resource of a given name and, if so, to obtain the resource's type. Regards, -- Oliver Laumann net@TUB.BITNET net@tub.UUCP
asente@decwrl.dec.com (Paul Asente) (01/07/89)
In article <8901061631.AA14339@tub.UUCP> net@TUB.BITNET (Oliver Laumann) writes: >Has somebody already implemented an XtGetConstraintResourceList() >function that works like XtGetResourceList() but returns the constraint >resource list? Yes, here's one. I'm writing up a proposal at this very minute to add this as a standard part of the intrinsics, but since even if it's accepted it'll probably be months before it makes it out of MIT, and you need it now... Note that by using this you risk having the consortium decide on a different interface. -paul asente asente@decwrl.dec.com decwrl!asente void XtGetResourceList(widget_class, resources, num_resources) WidgetClass widget_class; XtResourceList *resources; Cardinal *num_resources; { GetResourceList(widget_class, resources, num_resources, widget_class->core_class.num_resources, widget_class->core_class.resources); } void XtGetConstraintResourceList(widget_class, resources, num_resources) WidgetClass widget_class; XtResourceList *resources; Cardinal *num_resources; { if (_XtClassIsSubclass(widget_class, constraintWidgetClass)) { ConstraintWidgetClass cwc = (ConstraintWidgetClass) widget_class; GetResourceList(widget_class, resources, num_resources, cwc->constraint_class.num_resources, cwc->constraint_class.resources); } else { *resources = NULL; *num_resources = 0; } } static GetResourceList(widget_class, resources, num_resources, count, r_source) WidgetClass widget_class; XtResourceList *resources; Cardinal *num_resources; Cardinal count; XtResourceList r_source; { int size = count * sizeof(XtResource); register int i, dest = 0; register XtResourceList dlist; register XtResourceList *source; *resources = (XtResourceList) XtMalloc((unsigned) size); if (!widget_class->core_class.class_inited) { /* Easy case */ bcopy((char *) r_source, (char *) *resources, size); *num_resources = count; return; } /* Nope, it's the hard case */ dlist = *resources; source = (XtResourceList *) r_source; for (i = 0; i < count; i++) { if (source[i] != NULL) { dlist[dest].resource_name = (String) XrmQuarkToString((XrmQuark) source[i]->resource_name); dlist[dest].resource_class = (String) XrmQuarkToString((XrmQuark) source[i]->resource_class); dlist[dest].resource_type = (String) XrmQuarkToString((XrmQuark) source[i]->resource_type); dlist[dest].resource_size = source[i]->resource_size; dlist[dest].resource_offset = -(source[i]->resource_offset + 1); dlist[dest].default_type = (String) XrmQuarkToString((XrmQuark) source[i]->default_type); dlist[dest].default_addr = source[i]->default_addr; dest++; } } *num_resources = dest; }