sam@ccvs3.uucp (Sam Moore) (05/23/89)
Can someone send me, or point me in the direction of, help or a simple example of how to change sources with a Text Widget. I have tried changing the XtNstring and XtNfile values with XtSetValues and XtTextSetValues. I am sure I am missing the obvious. My application needs to be able to view different files. It works great for the first file using a AsciiStringWidget or an AsciiDiskWidget. I just can't change the source unless I destroy the widget and start over. I assume this is not necessary. Sam
treese@CRL.DEC.COM (Win Treese) (05/27/89)
> > Can someone send me, or point me in the direction of, help or a simple > example of how to change sources with a Text Widget. I have tried changing > the XtNstring and XtNfile values with XtSetValues and XtTextSetValues. I > am sure I am missing the obvious. SetValues isn't the way to go here. Here's a short function that does the job: /* Function: SetTextFile() sets the text file of the specified widget. * Arguments: w: Widget to set. * filename: Name of filename. * Returns: Nothing. * Notes: */ void SetTextFile(w, filename) Widget w; char *filename; { Arg args[10]; Cardinal arg_cnt; XtTextSource new_src; XtTextSource old_src; old_src = XtTextGetSource(w); arg_cnt = 0; XtSetArg(args[arg_cnt], XtNfile, filename); arg_cnt++; new_src = XtDiskSourceCreate(w, args, arg_cnt); XtTextSetSource(w, new_src, (XtTextPosition) 0); XtDiskSourceDestroy(old_src); } Happy hacking. Win Treese Cambridge Research Lab treese@crl.dec.com Digital Equipment Corp.