Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!rochester!uhura.cc.rochester.edu!ub!csn!ccncsu!purdue!decwrl!ucbvax!hplabs!mayer From: mayer@hplabs.hpl.hp.com (Niels Mayer) Newsgroups: comp.windows.x.motif Subject: Re: Question about Motif resource converters Message-ID: <6965@hplabsz.hplabs.hpl.hp.com> Date: 4 Jun 91 02:53:21 GMT References: <188@atesysv.UUCP> Reply-To: mayer@hplabs.hp.com (Niels Mayer) Organization: Hewlett-Packard Labs, Software & Systems Lab, Palo Alto, CA. Lines: 90 In article <188@atesysv.UUCP> lanzo@wgate.wgate.com (Mark Lanzo) writes: > What is the correct way to get all of the Motif resource type > converters registered when my application starts up? I do it this way: ... /* * Initialize the toolkit */ XtToolkitInitialize(); /* * Initialize Resource converters: normally, these functions are called * from XtCreateWidget(), XtCreateManagedWidget(), XtCreatePopupShell(), and * XtAppCreateShell(); they only get called the first time you create a * widget of class Primitive or Manager because they're called from the * ClassInitialize() procedure. With the way WINTERP's automatic resource * converters work, you can end up asking for a resource conversion to occur * before any ClassInitialize() procs are called, and that would cause errors * like "X Toolkit Warning: No type converter registered for 'String' to ..." */ XmRegisterConverters(); /* from Xm/ResConvert.c -- used in Manager, Primitive and Vendor ClassInitialize() */ _XmRegisterPixmapConverters(); /* from Xm/Visual.c -- used in Manager and Primitive */ ... XtMainLoop(); /* or equivalent event loop */ This works on Motif 1.0 (at least on HPUX 7.0) and works on every vendor's Motif 1.1 other than Motif 1.1 for Ultrix (see below). Thus, I ask the following side-question for those in-the-know at DEC: I just received a problem report from someone using DEC's version of Motif 1.1 on a DEC Station. (I didn't even know DEC had released Motif 1.1 yet, but that's another story). This person claims that _XmRegisterPixmapConverters() isn't defined in his version of Motif 1.1, and the lack of external definition results in a link-time error. I know that _XmRegisterPixmapConverters() is defined in the Motif 1.1.0 and 1.1.1 sources from OSF, so I'm wondering whether DEC altered the compiled Motif libs distributed with Ultrix in order to prevent access to such internal functions??? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Someone from DEC please answer this!!! You may question the need for calling the aforementioned initialization functions, but some applications may actually need to invoke a resource converter before the first primitive widget is created. Creating a primitive widget invokes the ClassInitialize() proc which in turn invokes XmRegisterConverters() and _XmRegisterPixmapConverters(). NOT invoking those procedures can leave you open to obscure bugs which will only occur the first time a widget is created. The workaround, of course, is to force the creation of a primitive widget before invoking a resource converter: create a shell widget and put a primitive widget inside that shell (e.g. a pushbutton), then XtUnmap() the shell so that the user doesn't have to see it... Disgusting? I know, but I've had to hack around stupider limitations in the past, so I'm used to it. >This works fine; however, I am uncomfortable using a function which >I would never know existed had I not looked for it in the source code >for the Motif toolkit. It works fine, however, if you try to port your code to platforms where gratuitous and uncecessary changes to the Motif source have been made by the vendor supplying the library, then you're hosed. In my experiences in making a portable Motif package (WINTERP), IBM has been the worst culprit at doing this with Motif 1.0. It looks like DEC is following in their footsteps. At least the Motif 1.1 released by HP has an API that seems consistent with OSF's Motif 1.1 API, despite major differences/improvements in implementation. >So: is there a more "proper" way to do this? I'd like to hear about a proper way to do this. Better yet, I'd like to propose that (1) XmRegisterConverters() and _XmRegisterPixmapConverters() become part of Motif's AES, such that vendors can no longer take liberties with the source.... or... (2) That XmRegisterConverters() and _XmRegisterPixmapConverters() and perhaps even _XmInitializeExtensions() become available in a procedure (e.g. XmInitilize()) which is part of the Motif AES. ------------------------------------------------------------------------------- Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com (... I work for, but don't speak for ...) Human-Computer Interaction Department Hewlett-Packard Laboratories Palo Alto, CA. *