[comp.windows.x] Athena asciiDisk Widget

pusateri@romeo.cs.duke.edu (Thomas J. Pusateri) (08/22/89)

I've been trying to display multiple columns of data in an athena text widget
(asciiDiskWidgetClass). The lines of data turn out to be longer than the widget
so I set the  scrollVertical | scrollHorizontal as Options. However, no
horizontal scrollbars ever exist and my line just gets chopped off in the
middle.
    When the application writes another line of text to the bottom of the file,
the asciiDiskWidget does not keep up with the file. This is understandable so
I called XtTextDisplay(w) but it still didn't realize more text had been
added. Now I guess I could use XtTextSetLastPos() but why should I have to
keep track of how many characters are in the file? If the file already exists
when I start, I would have to read the entire file when I open it to count
characters and then rewind it so the widget could read it.
    Has anyone else experienced similar problems? What is the best way to
provide a window into a large file? Are there any patches for the Athena
Text Widgets that aren't in the fixes 1-10?

Thanks for any info.

Tom Pusateri

National Biomedical Simulation Resource

pusateri@nbsr.mc.duke.edu

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (08/25/89)

> The lines of data turn out to be longer than the widget
> so I set the  scrollVertical | scrollHorizontal as Options. However, no
> horizontal scrollbars ever exist and my line just gets chopped off in the
> middle.

Scroll Horizontal is not implemented in R3.  For those of you who have been
so patient on this one I have implemented Horizontal scrolling for R4.

>    When the application writes another line of text to the bottom of the file,
> the asciiDiskWidget does not keep up with the file.

This is a bug in the Disk widget.  I have fixed things so that if you do
make a SetValues call with a file name it always loads that file.  Thus you
can reload the current file this will be fixed in R4.  In R3 the only thing
that you can do is destroy the disksource and create a new one.  This will
force a re-read of the file.  

I have done a lot of work with the Text widget, and I think you will find
things much easier to deal with in R4.  The changes are so great the patches
to R3 are not possible.

> Are there any patches for the Athena Text Widgets that aren't in the fixes
> 1-10? 

Nope.

						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

pusateri@macbeth.cs.duke.edu (Thomas J. Pusateri) (12/05/89)

Note: I am resending this since because I don't think it worked the first
time about a week ago.


I thought I finally figured out the Athena Text widgets and so I wrote
this short program which should act like an editor. It uses the
asciiDiskWidgetClass. However, the program will not let me input any
text from the keyboard. It just beeps at me. Its not a problem with
keyboard focus. Any one have any helpful hints?

I have compiled the following program on a sun3 and a sun4 (OS 4.0.3).


Tom Pusateri

pusateri@nbsr.duke.edu


---------------------- Cut Here -------------------------------------
#include <stdio.h>		/* C standard I/O library	   */
#include <X11/Intrinsic.h>	/* X toolkit initrinsics	   */
#include <X11/StringDefs.h>	/* X String definitions		   */
#include <X11/Shell.h>		/* X top level shell definitions   */
#include <X11/Cardinals.h>	/* X type definitions		   */
#include <X11/Form.h>		/* Athena form widget defs	   */
#include <X11/Command.h>	/* Athena command widget defs	   */
#include <X11/AsciiText.h>	/* More Athena text widget defs	   */

#ifndef lint
static char RCSid[]=
"$Id: test.c,v 1.1 89/11/28 17:29:55 pusateri Exp $";
#endif

main(argc, argv)
int argc;
char *argv[];
{
    void quit_callback();	/* quit command button event handler */	

    char Temporary[16];		/* name of temporary text widget file */
    FILE *fp;			/* text widget temporary file */
    unsigned int n;
    Arg arg[20];

    Widget toplevel,
	   form,
	   annot,
	   quit;

    (void) strcpy(Temporary, "tmpfile");

    if ((fp=fopen(Temporary,"w")) == NULL) {
	fprintf(stderr,"%s: unable to open %s\n",argv[0],Temporary);
	exit(1);
    }
    (void) fclose(fp);

 		/* initialize X Display */
    toplevel = XtInitialize(NULL, "testing", NULL, ZERO, &argc, argv);

    n = 0;
    XtSetArg(arg[n], XtNinput, True);			n++;
    XtSetValues(toplevel, arg, n);

    form = XtCreateManagedWidget("form",formWidgetClass,
	toplevel,(Arg *)NULL,0);

    n = 0;		/* display annotation */
    XtSetArg(arg[n], XtNheight, (Dimension) 200);	n++;
    XtSetArg(arg[n], XtNwidth, (Dimension) 500);	n++;
    XtSetArg(arg[n], XtNfile, Temporary);		n++;
    XtSetArg(arg[n], XtNeditType, XttextEdit);		n++;
    XtSetArg(arg[n], XtNtextOptions,
	editable|scrollVertical|wordBreak|scrollOnOverflow);	n++;
    annot = XtCreateManagedWidget("annot", asciiDiskWidgetClass, form, arg, n);

    n = 0;		/* quit command button */
    XtSetArg(arg[n], XtNvertDistance, 20);		n++;
    XtSetArg(arg[n], XtNfromVert, annot);		n++;
    XtSetArg(arg[n], XtNhorizDistance, 250);		n++;
    XtSetArg(arg[n], XtNfromHoriz, NULL);		n++;
    XtSetArg(arg[n], XtNlabel, "Quit");			n++;
    quit=XtCreateManagedWidget("quit", commandWidgetClass, form,arg,n);
    XtAddCallback(quit, XtNcallback, quit_callback,(caddr_t) toplevel);

    XtRealizeWidget(toplevel);

    XtMainLoop();			  /* let X windows process events */

}

void quit_callback(widget, clientData, callData)
Widget widget;                  /* unused */
caddr_t clientData;             /* toplevel */
caddr_t callData;               /* unused */
{
    Widget toplevel = (Widget) clientData;

    XtUnmapWidget(toplevel);
    exit(0);
}

/*
   Thomas Pusateri
   pusateri@nbsr.duke.edu

 */