net@TUB.BITNET (Oliver Laumann) (12/06/88)
I'm currently writing a Scheme interface for Xt which allows Scheme
programmers to make use of existing widget sets. This involves
the conversion from Scheme types to resource types and vice versa.
In doing this several questions came up (I'm new to Xt, so maybe
the answers to these questions are obvious to some of you):
1) I need to switch over a resource type. Since resource types
are represented as strings, the code looks like this:
if (strcmp (t, XtRCursor) == 0) $
...
else if (strcmp (t, XtRDisplay) == 0) $
...
else if ... [etc.]
Is there a more efficient and/or elegant way to program
this using quarks? If so, how do I obtain the quark for
a given resource type?
2) According to the `X Toolkit Intrinsics' manual the C-type
for the resource type XtRColor is XColor. This cannot be
right since XColor is a structure; it wouldn't fit into an
XtArgVal. Should this read `XColor *'?
3) XtSetValues() does not signal an error if the ArgList
contains an element with an undefined name field.
Shouldn't XtSetValues() compare the argument names with
the resource names in the widget class's resource list?
3a) Is the following statement true?
It is considered an error to set an argument with a
name that is different from all resource_name fields
in the resource list obtained by a call to
XtGetResourceList() with the widget's class as the
first argument?
4) Resource converters are called automatically when a resource
is fetched from the database or when a resource's default
value must be converted.
However, when application programmers are setting resources by
means of XtSetValues() they are required to provide values of the
`correct' type, e.g. when a resource of the type `XtRFont' is to
be set, the corresponding XtArgVal must contain a `Font', not a
string (the name of a font).
Is it right that in this case application programmers can
call the resource converter explicitly? Is there a way to
find out if there exists a converter for a given source/destination
type other than calling XtConvert() and inspecting the result?
4a) Is the following statement true?
A resource type T1 can be converted to the type T2
by a call to XtConvert(w,...) iff there exists an
entry in the resource list of XtClass(w) with a
resource_type of T2 and a default_type of T1.
--
Regards,
Oliver Laumann, Technical University of Berlin, Germany.
...!pyramid!tub!net or net@TUB.BITNET