[comp.windows.x] Motif DrawingArea to OL Intrinsics?

bschoen@well.sf.ca.us (Brook Schoenfield) (06/10/91)

I'm porting an application from Motif to the Open Look Intrinsics.  
In the Motif program, I used a drawingArea widget to give me input 
and expose events.  However, under Open Look, I do not see an
analogous widget.  There seems to be no widget whose purpose is to
give an input/drawing basis.

One thought I had to this problem, is to use the Text widget and not
use any of its drawing/text capabilities, but rather, take its
input/expose call backs and draw into the widget as an X window
(which is what I do with the drawingArea widget under Motif, anyway).

Any help with this problem would be greatly appreciated.

-- 
Brook Schoenfield: bschoen@well.sf.ca.us
or D6428@applelink.apple.com
"How can technology be used to create a peaceful, well fed world?"
-- 
Brook Schoenfield: bschoen@well.sf.ca.us
or D6428@applelink.apple.com
"How can technology be used to create a peaceful, well fed world?"

Amy.Moore@corp.sun.COM (Amy) (06/11/91)

>>
>>I'm porting an application from Motif to the Open Look Intrinsics.  
>>In the Motif program, I used a drawingArea widget to give me input 
>>and expose events.  However, under Open Look, I do not see an
>>analogous widget.  There seems to be no widget whose purpose is to
>>give an input/drawing basis.

You should be using the Stub widget (strange name, I know).  THis
widget provides hooks to the various widget methods such as Expose.
It is very easy to use, all you do is create the Stub the size
you want and then set the XtNexpose resource to be the routine
which will do the rendering....see code below.

Hope this helps,
Regards,
Amy Moore
aim@sun.com

--------------------------------------------------------------------
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xol/OpenLook.h>
#include <Xol/Stub.h>

/*************************************************************************
 * exposeHandler: routine called on Exposure events on the Canvas(Stub).
 ************************************************************************/
void exposeHandler(w, xevent, region)
Widget w;
XEvent *xevent;
Region region;
{
	Display *display;
	static GC gc;
	XGCValues gc_values;
	Window paint_win;
	
	display = XtDisplay(w);
	paint_win = XtWindow(w);

	/* All xlib drawing routines would go here....*/
}
/**********************************************************************/


main(argc, argv)
int argc;
char **argv;
{
	Widget toplevel, canvas;
	Arg arg;

	toplevel = OlInitialize(argv[0], "Test", NULL,
						0, &argc, argv);

	/* 
	 * Create canvas (Stub) and set its expose Method 
	 */
	canvas = XtVaCreateManagedWidget("canvas",
				stubWidgetClass,
				toplevel,
				XtNexpose,	(XtArgVal)exposeHandler,
				XtNwidth,	100,
				XtNheight,	100,
				NULL);

	XtRealizeWidget(toplevel);
	XtMainLoop();

}
/*******************************END EXAMPLE***************************/

mjf@mjm.mjm.com (Mark Fresolone) (06/11/91)

>I'm porting an application from Motif to the Open Look Intrinsics.  
>In the Motif program, I used a drawingArea widget to give me input 
>and expose events.  However, under Open Look, I do not see an
>analogous widget.  There seems to be no widget whose purpose is to
>give an input/drawing basis.

The OLIT Stub widget is a skeletal widget class which can be used as
a drawing area.  In addition to callbacks, you can add an event handler
to it for Exposure, allowing your client to take advantage of event
compression.

The Stub widget is scantilly documented in the Programmer's Guide,
but it gets the usual treatment in the Reference Section, and is used
in tutorial code such as s_sampler.c.

>One thought I had to this problem, is to use the Text widget and not
>use any of its drawing/text capabilities, but rather, take its
>input/expose call backs and draw into the widget as an X window
>(which is what I do with the drawingArea widget under Motif, anyway).

Having the Stub widget around, I wouldn't fool with Text.  (By the way,
if you have a later version of USL 2.0/Sun 2.3, you may have the newer
TextEdit widget.  If so, I would abandon Text immediately - USL is!)

Mark Fresolone					 mjf@mjm.com, rutgers!mjm!mjf
Melillo Consulting/MJM Software			908-873-0620/Fax 908-873-2250

jmk@mahler.Eng.Sun.COM (Myself) (06/12/91)

	The next release of OLIT (OLIT 3.0 from Sun) due to be released soon, will
feature a DrawingArea widget which would be functionally similar  to the Motif 
DrawArea widget. It also supports multiple visuals - you could draw in a different 
visual other than that the rest of your app has, ofcourse provided your h/w supports
multiple visuals ....