30 #if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
35 #include <X11/Intrinsic.h>
36 #include <X11/Shell.h>
42 #define NewString(str) \
43 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
53 static char** args = NULL;
54 static XtAppContext appContext = NULL;
55 static Widget topWidget = NULL;
57 G4Xt* G4Xt::getInstance (
62 return G4Xt::getInstance (0,NULL,(
char*)
"Geant4");
65 G4Xt* G4Xt::getInstance (
74 instance =
new G4Xt(a_argn,a_args,a_class);
89 args = (
char**)malloc(a_argn *
sizeof(
char*));
92 for(
int argi=0;argi<a_argn;argi++) {
93 args[argi] = (
char*)
NewString (a_args[argi]);
97 #if XtSpecificationRelease == 4
99 narg = (Cardinal)a_argn;
105 XtSetArg (xargs[0],XtNgeometry,
"100x100");
106 topWidget = XtAppInitialize (&appContext,a_class,
110 if(topWidget==NULL) {
114 if( (a_argn!=0) && (args!=NULL)) {
115 for(
int argi=0;argi<a_argn;argi++) {
117 strcpy(a_args[argi],args[argi]);
123 XtSetMappedWhenManaged (topWidget,False);
124 XtRealizeWidget (topWidget);
127 SetArguments (argn,args);
128 SetMainInteractor (topWidget);
129 AddDispatcher(xt_dispatch_event);
152 void* G4Xt::GetEvent (
158 if(appContext==NULL)
return NULL;
159 if(topWidget==NULL)
return NULL;
160 XtAppNextEvent (appContext, &event);
164 void G4Xt::PutStringInResourceDatabase (
170 if(topWidget==NULL)
return;
171 if(a_string==NULL)
return;
172 Display* dpy = XtDisplay(topWidget);
173 XrmDatabase dbres = XrmGetStringDatabase (a_string);
174 if(dbres==NULL)
return;
175 XrmDatabase database = XrmGetDatabase (dpy);
177 XrmMergeDatabases (dbres,&database);
179 XrmSetDatabase (dpy,dbres);
183 void G4Xt::FlushAndWaitExecution (
188 if(topWidget==NULL)
return;
189 XSync(XtDisplay(topWidget),False);