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);
151 void* G4Xt::GetEvent (
157 if(appContext==NULL)
return NULL;
158 if(topWidget==NULL)
return NULL;
159 XtAppNextEvent (appContext, &event);
163 void G4Xt::PutStringInResourceDatabase (
169 if(topWidget==NULL)
return;
170 if(a_string==NULL)
return;
171 Display* dpy = XtDisplay(topWidget);
172 XrmDatabase dbres = XrmGetStringDatabase (a_string);
173 if(dbres==NULL)
return;
174 XrmDatabase database = XrmGetDatabase (dpy);
176 XrmMergeDatabases (dbres,&database);
178 XrmSetDatabase (dpy,dbres);
182 void G4Xt::FlushAndWaitExecution (
187 if(topWidget==NULL)
return;
188 XSync(XtDisplay(topWidget),False);
G4bool(* G4DispatchFunction)(void *)
G4GLOB_DLL std::ostream G4cout
static MCTruthManager * instance
void * malloc(size_t __size)