[comp.windows.x] Help with Xaw

bchen@esvax.berkeley.edu (Benjamin Chen) (09/15/89)

I'm mid-way through the transition from X10 to X11.  I'm now at the point
of using the Xt toolkit.  The following program is supposed to just
create an AsciiText Widget (assuming that AsciiDisk widgets is a subclass
of AsciiText widgets).  I get the following warning:

X Toolkit Warning: No type converter registered for 'String' to 'Orientation' co
nversion.

It gets to XtMainLoop() and nothing gets mapped.  (It's possible that none
of the widgets I created is a drawable, but I don't know.)  I looked
at the code to xclipboard, which does essentially what I want, but
I can't find major differences to what it does and what I do to get a
text widget up.

Also, the Athena Widgets manual said something about an "Ascii Text" widget
which would take care of both a source and a sink.  I'm not too clear
about what they mean.  Did I create just a source when I created a
DiskWidget?  If so, what's a valid sink?

Anyways, thanks for your patience.  I'm sure these are pretty novice ?'s.

	BC

BTW:  I'm on a Sun 3/60 running an R3 server (and hopefully using an R3 toolkit
and Xaw) with a cgfour display card.
----------------------------------------------------------------------------

#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/AsciiText.h>
#include <X11/Form.h>
#include <X11/Command.h>
#include <X11/Xresource.h>
#include <X11/Cardinals.h>
#include <X11/Shell.h>
#include <sys/param.h>

#define SAMPLE "foo"
#define SAMPLE_CLASS "sample"

void Activate(w, client_data, call_data)
     Widget w;
     caddr_t client_data;
     caddr_t call_data;
{
    printf("Called\n");
    exit(0);
}

void main(argc, argv)
     unsigned int argc;
     char **argv;
{
    Widget toplevel, sink, form;
    XtAppContext app;
    XrmOptionDescRec *xrmOpts = NULL;
    Cardinal xrmNumOpts = 0;
    Display *displayPtr;
    FILE *f;
    char file[MAXPATHLEN];

    static XtCallbackRec callbacks[]=  {
	{Activate, NULL},
	{NULL, NULL}
    };

    static Arg textArgs[] = {
        {XtNfile, 0},
        {XtNtextOptions, (XtArgVal)scrollVertical },
        {XtNeditType, (XtArgVal)XttextAppend},
        {XtNwidth, 500},
        {XtNheight, 100},
    };

    XtToolkitInitialize();   
    app = XtCreateApplicationContext(); 
    displayPtr = XtOpenDisplay(app, (String) NULL, SAMPLE, SAMPLE,
			       xrmOpts, xrmNumOpts,
			       (Cardinal *) &argc, (String *) &argv);
    toplevel = XtAppCreateShell(SAMPLE, SAMPLE_CLASS, 
				applicationShellWidgetClass,
				displayPtr,  (ArgList *) NULL, 0);
    
    (void)tmpnam(file);
    if ((f = fopen(file, "w")) == NULL) {
        perror( argv[0] );
        exit(1);
    }
    fclose(f);

    textArgs[0].value = (XtArgVal)file;
    textArgs[1].value |= wordBreak;
    form = XtCreateManagedWidget("shell", formWidgetClass, toplevel, NULL, 0);
    XtCreateManagedWidget(SAMPLE, asciiDiskWidgetClass, form, 
			  textArgs, XtNumber(textArgs));
    XtRealizeWidget(toplevel);
    XtMainLoop();
}
Benjamin Chen
Office:   550-A4 Cory Hall, 2-4332
UUCP:     !ucbvax!esvax!bchen               
HEPNET:   LBL::"bchen@esvax.Berkeley.EDU"