kwh@sei.cmu.edu (Kurt Hoyt) (05/24/88)
Has anyone else had the X11R2 Xt Toolkit fail to convert String colorname resources into the corresponding Pixel value? I have a line in my XtResourceList which looks like this: {XtNlineColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffset(LineObject, line.color), XtRString, "Black"}, The XGetSubresources call correctly converts "Black" to the right pixel value. However, if an Arg structure like: {XtNlineColor, "Green"}, is passed to XtGetSubresources, "Green" is NOT converted to ANY pixel value. The address of the string "Green" is returned. I expected the value to be converted. Is this an incorrect expectation? -- Kurt Hoyt, Software Engineering Institute -- kwh@sei.cmu.edu "From previous research with rendering systems we have learned that a good dose of gratuitous partial differential equations is needed to meet the paper quota for impressive formulas." SIGGRAPH '87 Proceedings, p. 73
haynes@WSL.DEC.COM (05/24/88)
There is no type conversion (coercion) on parameters passed in the arglist. If you are using an arglist you are expected to pass the argument in the form the callee want's it in. In this case, as a pixel value. We considered having "source type" information in arglists, but decided that it was too expensive, to complicated to explain, and not useful enough. -- Charles
asente@WSL.DEC.COM (05/24/88)
>However, if an Arg structure like: > > {XtNlineColor, "Green"}, > >is passed to XtGetSubresources, "Green" is NOT converted to ANY pixel value. >The address of the string "Green" is returned. I expected the value to be >converted. Is this an incorrect expectation? Yes, it is incorrect. Resource conversions do not take place in arg lists. If you think about it, you'll realize that you never specified anywhere in the arg list that you were passing it a string instead of a pixel value. Whether or not this was the right way to do things is debatable, but at any rate it is the way things are. Values in arg lists must be of the end type (pixel in this case). -paul asente
rlh2@eagle.ukc.ac.uk (R.L.Hesketh) (05/25/88)
In article <8805232258.AA22283@gilroy.dec.com> asente@WSL.DEC.COM writes: >>However, if an Arg structure like: >> >> {XtNlineColor, "Green"}, >> [ question deleted ] >Yes, it is incorrect. Resource conversions do not take place in arg >lists. If you think about it, you'll realize that you never specified >anywhere in the arg list that you were passing it a string instead of a pixel value. > > -paul asente What nobody has mentioned is a method of getting around this and actually produce the right pixel value. From looking through Converters.c and Convert.c, there is a direct CvtStringToPixel routine, however it is static. But it calls XtDirectConvert a non-static ( hence public? ) routine in Convert.c Is it ok to call XtDirectConvert with the type of conversion you wish to make and let it do its stuff? Richard -- Richard Hesketh: rlh2@ukc.ac.uk | --- | Computing Lab., University of Kent at Canterbury, | Canterbury, Kent, CT2 7NF, England. |
asente@WSL.DEC.COM (05/27/88)
It's ok to call XtDirectConvert on your own converters, but XtConvert is the preferred interface. It takes a value, source type, and destination type and looks up the appropriate conversion routine. The names of the internal conversion routines are private. -paul asente