Parent document is top of "Motif FAQ (Part 9 of 9)"
Previous document is "299) How can I implement "bubble help" or "tool tips" with Motif?"
Next document is "301) Why are only some of my translations are being installed? I"
300) Can I specify a widget in a resource file?
Answer: This answer, which uses the Xmu library, is due to David Elliott. If
the converter is added, then the name of a widget (a string) can be used in
resource files, and will be converted to the appropriate widget.
This code, which was basically stolen from the Athena Form widget, adds a
String to Widget converter. I wrote it as a general routine that I call at
the beginning of all of my programs, and made it so I could add other
converters as needed (like String to Unit Type ;-).
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <X11/Xmu/Converters.h>
#include <X11/IntrinsicP.h>
#include <X11/CoreP.h>
void
setupConverters()
{
static XtConvertArgRec parentCvtArgs[] = {
{XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
sizeof(Widget)}
};
XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
parentCvtArgs, XtNumber(parentCvtArgs));
}
Parent document is top of "Motif FAQ (Part 9 of 9)"
Previous document is "299) How can I implement "bubble help" or "tool tips" with Motif?"
Next document is "301) Why are only some of my translations are being installed? I"