[comp.windows.x] Drawing Graphics in a Widget

DCOOPER%ESDSDF.DECnet@CRDGW1.GE.COM (08/17/89)

Steve Buck writes:

>   I also have the problem that when I try to add the procedure draw_graphics
> to the translation table it comes back with the error 'X Toolkit Warning:
> 		Actions not found: draw_graphics.  Here is how I'm changing
> the translation table:
>
>	XtTranslations  DisplayTrans;
>	static char	DisplayTransTable[]=
>				"<ConfigureNotify>: draw_graphics() \n\
>				 <Expose>: draw_graphics()";
>		.
>		.
>		.
>
> Any ideas as to what is wrong would be appreciated.
>


You need to add an action for your routine, i.e.:


        static XtActionsRec actionsList[] =
        {
                { "draw_graphics", DrawGraphics },
        };

	...

        XtAddActions(actionsList, 1);


I added the action before Realizing the toplevel widget, and my
DrawGraphics() routine gets called when a ConfigureNotify or
Expose event occurs.

I have constructed a simple example of using X graphics calls with
a widget if you or anyone else is interested.  It is small and isolates
the toolkit eXpert from having to use a lot of Xlib calls.


Dwight Cooper
GE Electronic Systems
dcooper%esdsdf.decnet@crd.ge.com

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

>         XtAddActions(actionsList, 1);

The advice is fine, except using XtAppAddActions is a more portable interface,
as XtAddActions will fail if you are not using XtInitialize().

When coding new programs please use XtApp* in favor of the non-app functions.
This will allow a more portable interface.  If you do not have an app-context
handy then just use XtWidgetToApplicationContext.


						Chris D. Peterson     
						MIT X Consortium 

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