[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
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));
}
Send corrections/additions to the FAQ Maintainer:
Last Update May 13 2007 @ 00:23 AM