basti@orthogo.UUCP (Sebastian Wangnick) (05/09/90)
How do I write a multiline Motif XmString within my
resource file? The manual claims:
``Specifying a string in a defaults file is the same
as creating the string using XmStringCreateLtoR with
the default character set XmSTRING_DEFAULT_CHARSET.''
But it seems that the String-to-XmString-Converter gobbles
all my newlines, whereas XmStringCreateLtoR correctly
replaces newlines with seperators.
Here's nlxmstr.c:
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
#include <Xm/RowColumn.h>
#define CHARSET (XmStringCharSet) XmSTRING_DEFAULT_CHARSET
Arg args[20]; Cardinal n;
#define HEAD(name,value) XtSetArg(args[n=0],name,value); n++
#define NEXT(name,value) XtSetArg(args[n],name,value); n++
#define LIST args,n
#define NOLIST NULL,0
void main (argc, argv) unsigned int argc; char **argv;
{Widget nlxmstr = XtInitialize("nlxmstr","Test",NOLIST,&argc,argv);
Widget container = XmCreateRowColumn(nlxmstr,"container",NOLIST);
static XtResource resources[] =
{ {"teststring",XmCUserData,XmRString,sizeof(char*),
0,XmRString,"default"},
};
char * teststring;
XtGetApplicationResources(nlxmstr,&teststring,
resources,XtNumber(resources),NOLIST);
XtManageChild(container);
XtManageChild(XmCreateMessageBox(container,"messagebox1",NOLIST));
HEAD(XmNmessageString,XmStringCreateLtoR(teststring,CHARSET));
XtManageChild(XmCreateMessageBox(container,"messagebox2",LIST));
printf("teststring: \"%s\"\n",teststring);
XtRealizeWidget(nlxmstr);
XtMainLoop();
}
And this is my nlxmstr.xrdb:
nlxmstr.teststring: Line 1\nLine 2\n\nLine 4
nlxmstr.container.messagebox1.messageString: Line 1\nLine 2\n\nLine 4
The incorrect behaviour shows up on both an Apollo and a Unix-PC.
Who can help?
Sebastian Wangnick (basti@orthogo.uucp)