31#if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
36#include <X11/Intrinsic.h>
43#define NewString(str) \
44 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
50G4Xt* G4Xt::instance = NULL;
54static char** args = NULL;
55static XtAppContext appContext = NULL;
56static Widget topWidget = NULL;
58G4Xt* G4Xt::getInstance (
63 return G4Xt::getInstance (0,NULL,(
char*)
"Geant4");
66G4Xt* 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);
151void* G4Xt::GetEvent (
157 if(appContext==NULL)
return NULL;
158 if(topWidget==NULL)
return NULL;
159 XtAppNextEvent (appContext, &event);
163void 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);
182void G4Xt::FlushAndWaitExecution (
187 if(topWidget==NULL)
return;
188 XSync(XtDisplay(topWidget),False);
G4bool(* G4DispatchFunction)(void *)
G4DLLIMPORT std::ostream G4cout