Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!att!bellcore!jello!aw From: aw@jello.bae.bellcore.com (Andrew Wason) Newsgroups: comp.windows.x Subject: Re: Resource Cvt*To* reoutine problem Message-ID: <1991Apr17.181741.7865@bellcore.bellcore.com> Date: 17 Apr 91 18:17:41 GMT References: <9104162110.AA25496@gothamcity.jsc.nasa.gov> Sender: usenet@bellcore.bellcore.com (Poster of News) Reply-To: aw@bae.bellcore.com Organization: Bell Communications Research Lines: 44 In article <9104162110.AA25496@gothamcity.jsc.nasa.gov>, bill@gothamcity.jsc.nasa.GOV (Bill Shirley [CSC]) writes: > > Q: I am writing a resource conversion routine. How can I call an Xt > conversion routine from my converter? There are, basically, two functions > to call converters with: XtCallConverter (XtDirectConvert in R3), and > XtConvertAndStore (XtConvert in R3). > > XtCallConverter needs the pointer to the function. The Xt Cvt functions, > in Convert.c, are defined statically and thus their pointers aren't > available. You mean Converters.c. > XtConvertAndStore takes a Widget as a parameter. There is not a Widget to > use in my conversion routine. I tried passing a pointer to the core.self > field as a parameter and then casting this into a Widget (it is the first > field of the instance structure of all Widgets). This gave my the lovely > result of a 'Bus error'. I'm not sure what the correct solution is, but take a look at XmuCvtStringToCursor() in lib/Xmu/StrToCurs.c. It needs to invoke the StringToFont converter. It does the following (old style interface): WidgetRec widgetRec; [...] /* widgetRec is stupid; we should just use XtDirectConvert, * but the names in Xt/Converters aren't public. */ widgetRec.core.screen = screen; fromString.addr = source_name; fromString.size = strlen(source_name); XtConvert(&widgetRec, XtRString, &fromString, XtRFont, &toFont); This seems dangerous, but off hand I can't think of another way. Andrew _______________________________________________________________________________ Andrew Wason Bell Communications Research aw@bae.bellcore.com Piscataway, NJ bellcore!bae!aw