[comp.windows.x] widgets and uwm

garton@cunixa.cc.columbia.edu (Bradford Garton) (11/21/88)

I'm posting the following for one of my colleagues with
limited net access at this point -- please reply to the
addresses listed below

---------------------------------------------------------------

I am attempting to create a sound display/editor using as many predefined
widgets as possible, but to actually display the waveforms, etc., I am using
the various lib functions to draw my lines.  My problem is that under uwm, I
have been unable to get anything to show up inside the widget I have
specified to be the screen. All the widgets themselves seem to appear in the
right places, and the application DOES work from the unmanaged login
window.

This attempt has been made using X11R2, which is all we've had until today,
running on a Sun-3/280 using SunOS 3.2. 

The following is the code in question, and the question is: is this just a
mistake on my part or is there some problem with accessing the proper
display, drawable, GC...  Has anyone else had problems with graphics
under uwm?

#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/StringDefs.h>
#include <X11/Label.h>
#include <stdio.h>

static Arg screenarglist[] = {
{XtNheight, (XtArgVal) 512},
{XtNwidth, (XtArgVal) 1024},
{XtNlabel, (XtArgVal) ""},
{NULL,NULL}
};

Display *dpy;
Window screen_w, window;
GC default_gc, screen_gc;
XGCValues values;
Widget shell, screen;

int main(argc, argv)
	unsigned int argc;
	char **argv;
{
unsigned long fg,bg;
static Arg tempargs[3];
	shell = XtInitialize("main", "Main", NULL, 0, &argc, argv);
	screen = XtCreateManagedWidget("screen", labelWidgetClass, shell,
				screenarglist, XtNumber(screenarglist));
	XtRealizeWidget(shell);
	dpy = XtDisplay(screen);    
	screen_w = XtWindow(screen);
	XtSetArg(tempargs[0], XtNbackground, &bg);
	XtSetArg(tempargs[1], XtNforeground, &fg);
	XtGetValues(screen,tempargs,2);   /* Access values for fg & bg */
	screen_gc = XDefaultGC(dpy,DefaultScreen(dpy));
	XSetState(dpy,screen_gc,fg,bg,GXcopy,AllPlanes);
	XSetLineAttributes(dpy,screen_gc,1,LineSolid,CapButt,JoinMiter);
	XDrawLine(dpy, screen_w, screen_gc, 4, 4, 4, 25);
	XtMainLoop();
}

I would very much appreciate any comments.  I am fairly new to X.  I have
been told that working with widgets is something that I will get over once
I learn more, but for now...

Please respond to:

doug@woof.columbia.edu -or-
... !columbia!woof!doug

Thanks!

Doug Scott

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (11/21/88)

Your problem has nothing to do with widgets, it has to do
with the fact that you are attempting to draw into a window
before it actually gets mapped.  You should really be waiting
for an exposure event before drawing.