31 #if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
36 #include <X11/Intrinsic.h>
37 #include <X11/Shell.h>
43 #define NewString(str) \
44 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
54 static char** args = NULL;
55 static XtAppContext appContext = NULL;
56 static Widget topWidget = NULL;
58 G4Xt* G4Xt::getInstance (
63 return G4Xt::getInstance (0,NULL,(
char*)
"Geant4");
66 G4Xt* G4Xt::getInstance (
75 instance =
new G4Xt(a_argn,a_args,a_class);
90 args = (
char**)malloc(a_argn *
sizeof(
char*));
93 for(
int argi=0;argi<a_argn;argi++) {
94 args[argi] = (
char*)
NewString (a_args[argi]);
98 #if XtSpecificationRelease == 4
100 narg = (Cardinal)a_argn;
106 XtSetArg (xargs[0],XtNgeometry,
"100x100");
107 topWidget = XtAppInitialize (&appContext,a_class,
111 if(topWidget==NULL) {
115 if( (a_argn!=0) && (args!=NULL)) {
116 for(
int argi=0;argi<a_argn;argi++) {
118 strcpy(a_args[argi],args[argi]);
124 XtSetMappedWhenManaged (topWidget,False);
125 XtRealizeWidget (topWidget);
128 SetArguments (argn,args);
129 SetMainInteractor (topWidget);
130 AddDispatcher(xt_dispatch_event);
153 void* G4Xt::GetEvent (
159 if(appContext==NULL)
return NULL;
160 if(topWidget==NULL)
return NULL;
161 XtAppNextEvent (appContext, &event);
165 void G4Xt::PutStringInResourceDatabase (
171 if(topWidget==NULL)
return;
172 if(a_string==NULL)
return;
173 Display* dpy = XtDisplay(topWidget);
174 XrmDatabase dbres = XrmGetStringDatabase (a_string);
175 if(dbres==NULL)
return;
176 XrmDatabase database = XrmGetDatabase (dpy);
178 XrmMergeDatabases (dbres,&database);
180 XrmSetDatabase (dpy,dbres);
184 void G4Xt::FlushAndWaitExecution (
189 if(topWidget==NULL)
return;
190 XSync(XtDisplay(topWidget),False);
static MCTruthManager * instance
G4GLOB_DLL std::ostream G4cout