Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!emory!gatech!mcnc!rti!dg-rtp!dg-rtp!brennan From: brennan@rtp.dg.com (Dave Brennan) Newsgroups: comp.windows.x.motif Subject: Re: Multi-line labels Message-ID: Date: 11 Oct 90 02:46:43 GMT References: <1990Aug21.000632.25880@elroy.jpl.nasa.gov> <9596@jpl-devvax.JPL.NASA.GOV> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Organization: Data General, RTP, NC Lines: 68 In-Reply-To: david@jpl-devvax.JPL.NASA.GOV's message of 20 Sep 90 23:27:46 GMT david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) writes: ems@socrates.jpl.nasa.gov writes: > Is it possible to create multi-line labels >through the resource file? Write a string to XmString converter which looks for \n. Use the same name that Motif uses, and make sure the linker sees your converter before it sees the Motif converter, and you are golden. Do a name search on your motf library to figure out the name you should export. Actually, you don't have to go to all that trouble. The following code replaces the String to XmString converter so you can use \n in resources. Just call MuInstallStringToXmStringConverter (yea, it's a long name, so sue me! :-) before you create your first Motif widget. (After you create the toplevel shell would be a good time.) /* * by David Brennan (brennan@dg-rtp.dg.com) * * This code is provided without warranty. */ #include static void mu_cvt_string_to_xmstring ( XrmValuePtr args, Cardinal *num_args, XrmValue *from, XrmValue *to ) { static char *new_string; if ( from->addr == NULL ) return; new_string = XmStringCreateLtoR ( from->addr, XmSTRING_DEFAULT_CHARSET ); if ( new_string == NULL ) { to->addr = NULL; to->size = 0; XtStringConversionWarning ( from->addr, XmRXmString ); } else { to->addr = (caddr_t) &new_string; to->size = sizeof (caddr_t); } } void MuInstallStringToXmStringConverter (void) { /* first register Motif converters so that this ours don't get overridden */ XmRegisterConverters (); /* now registers ours and override Motif's */ XtAddConverter ( XmRString, XmRXmString, mu_cvt_string_to_xmstring, NULL, 0 ); } |\ Dave Brennan | \____oo_ brennan@rtp.dg.com =========================================((__| /___> ...rti!dg-rtp!brennan User Interfaces, Data General | // daveb@rpitsmts.bitnet Research Triangle Park, NC |// Phone: (919) 248-6330