Hi,
I am having trouble porting an XWindows app and cannot get even a simple
xwin program to run. The one listed below gives a whole slew of
Warnings followed by an Error that crashes it.
Any ideas???
Simon
Warning: translation table syntax error: Unknown keysym name: osfHelp
Warning: … found while parsing ’ :osfHelp: Help()’
Error: attempt to add non-widget child “DropSiteManager” to parent
“./xtest” which supports only widgets
Makefile for Xwindows App
LDFLAGS= -L/usr/lib -L/usr/X11R6/lib -lm -lphexlib -lICE -lX11 -lXt -lXm
-lSM -lsocket
CFLAGS= -c -I…/include -I. -I/usr/X11R6/include -g -DQNX
xtest: xtest.o
gcc -o xtest xtest.o $(LDFLAGS)
xtest.o: xtest.c
gcc xtest.c $(CFLAGS)
////////////////// xtest.c
#include <stdio.h>
#include <Xm/Xm.h> /* Motif Toolkit */
void helloworld_activate(Widget widget, char *tag,
XmAnyCallbackStruct *callback_data);
Display *display;
XtAppContext app_context;
/*
- Main program
*/
int main(unsigned int argc, char *argv)
{
/ - Declare the variables to contain the two widget ids
*/
Widget toplevel, helloworldmain, helloworld = NULL;
Arg arglist[1] ;
int n;
XtToolkitInitialize();
app_context = XtCreateApplicationContext();
display = XtOpenDisplay(app_context, NULL, argv[0],
“helloworldclass”,
NULL, 0, &argc, argv);
if (display == NULL)
{
fprintf(stderr, “%s: Can’t open display\n”, argv[0]);
exit(1);
}
n = 0;
XtSetArg(arglist[n], XmNallowShellResize, True); n++;
toplevel = XtAppCreateShell(argv[0], NULL,
applicationShellWidgetClass,
display, arglist, n);
helloworldmain = XmCreateMainWindow(toplevel, “Mainw”, arglist,
0);
helloworld = XmCreatePushButton(helloworldmain, “Hello World”,
arglist, 0);
XtAddCallback(helloworld, XmNactivateCallback, helloworld_activate,
NULL);
XtManageChild(helloworld);
/*
- Register our callback routines so that the resource manager can
- resolve them at widget-creation time.
*/
/*
- Make the toplevel widget “manage” the main window (or whatever
the - the uil defines as the topmost widget). This will
- cause it to be “realized” when the toplevel widget is “realized”
*/
XtManageChild(helloworldmain);
/*
- Realize the toplevel widget. This will cause the entire
“managed” - widget hierarchy to be displayed
*/
XtRealizeWidget(toplevel);
/*
- Loop and process events
*/
XtAppMainLoop(app_context);
/* UNREACHABLE */
return (0);
}
void helloworld_activate(Widget widget, char *tag,
XmAnyCallbackStruct *callback_data)
{
Arg arglist[2];
static int call_count = 0;
call_count += 1 ;
switch ( call_count )
{
case 1:
XtSetArg( arglist[0], XmNlabelString,
XmStringLtoRCreate(“Goodbye\nWorld!”,""));
XtSetArg( arglist[1], XmNx, 11 );
XtSetValues( widget, arglist, 2 );
break ;
case 2:
exit(1);
break ;
}
}
Simon Wakley