Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

G4UIXm Class Reference

#include <G4UIXm.hh>

Inheritance diagram for G4UIXm:

Inheritance graph
[legend]
Collaboration diagram for G4UIXm:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 G4UIXm (int, char **)
G4UIsession * SessionStart ()
void AddMenu (const char *, const char *)
void AddButton (const char *, const char *, const char *)
 ~G4UIXm ()
void Prompt (G4String)
void SessionTerminate ()
void PauseSessionStart (G4String)
G4int ReceiveG4cout (G4String)
G4int ReceiveG4cerr (G4String)
G4String GetCommand (Widget)

Private Member Functions

void SecondaryLoop (G4String)
G4bool GetHelpChoice (G4int &)
void ExitHelp ()

Static Private Member Functions

void commandEnteredCallback (Widget, XtPointer, XtPointer)
void keyHandler (Widget, XtPointer, XEvent *, Boolean *)
void ButtonCallback (Widget, XtPointer, XtPointer)

Private Attributes

Widget form
Widget shell
Widget command
Widget menuBar
Widget text
std::map< Widget, G4String,
std::less< Widget > > 
commands
G4bool fHelp
G4int fHelpChoice

Constructor & Destructor Documentation

G4UIXm::G4UIXm int  argc,
char **  argv
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 74 of file G4UIXm.cc.

References clearButtonCallback(), command, commandEnteredCallback(), form, G4Xt::getInstance(), G4VInteractorManager::GetMainInteractor(), keyHandler(), menuBar, shell, and text.

00078 :shell(NULL)
00079 ,command(NULL)
00080 ,menuBar(NULL)
00081 ,text(NULL)
00082 ,fHelp(false)
00083 ,fHelpChoice(0)
00084 /***************************************************************************/
00086 {
00087   G4UImanager* UI = G4UImanager::GetUIpointer();
00088   if(UI!=NULL) UI->SetSession(this);
00089 
00090   G4Xt* interactorManager = G4Xt::getInstance (argc,argv,(char*)"Xm");
00091 
00092   Widget top = (Widget)interactorManager->GetMainInteractor();
00093 
00094   if(getenv("XENVIRONMENT")==NULL) {
00095     XrmDatabase database = XrmGetDatabase(XtDisplay(top));
00096     if(database!=NULL) {
00097       XrmPutLineResource(&database,"*topShadowColor:white");
00098       XrmPutLineResource(&database,"*bottomShadowColor:black");
00099       XrmPutLineResource(&database,"*foreground:black");
00100       XrmPutLineResource(&database,"*background:lightgrey");
00101       XrmPutLineResource(&database,"*borderColor:lightgrey");
00102       XrmPutLineResource(&database,"*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1");
00103       XrmPutLineResource(&database,"*text.background:white");
00104       XrmPutLineResource(&database,"*text.fontList:*courier*-r-*--14-*");
00105       XrmPutLineResource(&database,"*text.maxLength:8000");
00106     }
00107   }
00108 
00109   Arg args[9];
00110   XtSetArg(args[0],XmNkeyboardFocusPolicy,XmPOINTER); // For completion.
00111   shell = XtAppCreateShell ("G4UIXm","G4UIXm",
00112                             topLevelShellWidgetClass,XtDisplay(top),
00113                             args,1); 
00114   form = XmCreateForm (shell,(char*)"form",NULL,0);
00115   XtManageChild (form);
00116 
00117   XtSetArg(args[0],XmNtopAttachment   ,XmATTACH_FORM);
00118   XtSetArg(args[1],XmNleftAttachment  ,XmATTACH_FORM);
00119   XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
00120   menuBar = XmCreateMenuBar (form,(char*)"menuBar",args,3);
00121 
00122   XtSetArg(args[0],XmNtopAttachment      ,XmATTACH_NONE);
00123   XtSetArg(args[1],XmNleftAttachment     ,XmATTACH_FORM);
00124   XtSetArg(args[2],XmNrightAttachment    ,XmATTACH_FORM);
00125   XtSetArg(args[3],XmNbottomAttachment   ,XmATTACH_FORM);
00126   command = XmCreateCommand (form,(char*)"command",args,4);
00127   XtManageChild (command);
00128 
00129   XtSetArg(args[0],XmNtopAttachment   ,XmATTACH_NONE);
00130   XtSetArg(args[1],XmNleftAttachment  ,XmATTACH_FORM);
00131   XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
00132   XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET);
00133   XtSetArg(args[4],XmNbottomWidget    ,command);
00134   XmString cps = XmStringLtoRCreate((char*)"Clear",XmSTRING_DEFAULT_CHARSET);
00135   XtSetArg (args[5],XmNlabelString,cps);
00136   Widget clearButton = XmCreatePushButton(form,(char*)"clearButton",args,6);
00137   XmStringFree (cps);
00138   XtManageChild (clearButton);
00139 
00140   XtSetArg(args[0],XmNtopAttachment   ,XmATTACH_WIDGET);
00141   XtSetArg(args[1],XmNtopWidget       ,menuBar);
00142   XtSetArg(args[2],XmNleftAttachment  ,XmATTACH_FORM);
00143   XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM);
00144   XtSetArg(args[4],XmNbottomAttachment,XmATTACH_WIDGET);
00145   XtSetArg(args[5],XmNbottomWidget    ,clearButton);
00146   XtSetArg(args[6],XmNeditMode        ,XmMULTI_LINE_EDIT);
00147   XtSetArg(args[7],XmNrows            ,12);
00148   XtSetArg(args[8],XmNcolumns         ,80);
00149   text = XmCreateScrolledText (form,(char*)"text",args,9);
00150   XtManageChild (text);
00151 
00152   XtAddCallback(clearButton,XmNactivateCallback,
00153                 clearButtonCallback,(XtPointer)text);
00154   XtAddCallback(command,XmNcommandEnteredCallback,
00155                 commandEnteredCallback,(XtPointer)this);
00156 
00157   Widget commandText = XmCommandGetChild(command,XmDIALOG_COMMAND_TEXT);
00158   XtAddEventHandler(commandText,KeyPressMask,False,keyHandler,(XtPointer)this);
00159 
00160   XtRealizeWidget(shell);
00161   XtMapWidget(shell);
00162 
00163   if(UI!=NULL) UI->SetCoutDestination(this);
00164 }

Here is the call graph for this function:

G4UIXm::~G4UIXm  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 166 of file G4UIXm.cc.

References shell.

00170 { 
00171   G4UImanager* UI = G4UImanager::GetUIpointer();
00172   if(UI!=NULL) {
00173     UI->SetSession(NULL);
00174     UI->SetCoutDestination(NULL);
00175   }
00176   XtDestroyWidget(shell);
00177 }


Member Function Documentation

void G4UIXm::AddButton const char *  a_menu,
const char *  a_label,
const char *  a_command
[virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 329 of file G4UIXm.cc.

References ButtonCallback(), commands, and G4VInteractiveSession::GetInteractor().

00336 {
00337   if(a_menu==NULL) return;
00338   if(a_label==NULL) return;
00339   if(a_command==NULL) return;
00340   Widget parent = (Widget)GetInteractor(a_menu);
00341   if(parent==NULL) return;
00342   Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0);
00343   XtManageChild (widget);
00344   XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this);
00345   commands[widget] = a_command;
00346 }

Here is the call graph for this function:

void G4UIXm::AddMenu const char *  a_name,
const char *  a_label
[virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 303 of file G4UIXm.cc.

References G4VInteractiveSession::AddInteractor(), ExecuteChangeSizeFunction(), form, G4Interactor, and menuBar.

00309 {
00310   if(menuBar==NULL) return;
00311   if(a_name==NULL) return;
00312   if(a_label==NULL) return;
00313   XtManageChild (menuBar);
00314   // Pulldown menu :
00315   Widget widget;
00316   widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0);
00317   AddInteractor (a_name,(G4Interactor)widget);
00318   // Cascade button :
00319   Arg args[2];
00320   XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET);
00321   XtSetArg (args[0],XmNlabelString,cps);
00322   XtSetArg (args[1],XmNsubMenuId,widget);
00323   widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2);
00324   XmStringFree (cps);
00325   XtManageChild (widget);
00326   ExecuteChangeSizeFunction(form);
00327 }

Here is the call graph for this function:

void G4UIXm::ButtonCallback Widget  a_widget,
XtPointer  a_tag,
XtPointer 
[static, private]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 416 of file G4UIXm.cc.

References G4VBasicShell::ApplyShellCommand(), exitPause, exitSession, fHelp, and GetCommand().

Referenced by AddButton().

00423 {
00424   G4UIXm* This = (G4UIXm*)a_tag;
00425   if(This->fHelp==true) return; // Disabled when in help.
00426   G4String ss = This->GetCommand (a_widget);
00427   //printf ("debug : execute:\n%s\n",ss.data());
00428   This->ApplyShellCommand(ss,exitSession,exitPause);
00429 }

Here is the call graph for this function:

void G4UIXm::commandEnteredCallback Widget  a_widget,
XtPointer  a_tag,
XtPointer  a_data
[static, private]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 359 of file G4UIXm.cc.

References G4VBasicShell::ApplyShellCommand(), command, ConvertStringToInt(), exitHelp, exitPause, exitSession, fHelp, fHelpChoice, and XmConvertCompoundStringToString().

Referenced by G4UIXm().

00366 {
00367   G4UIXm*  This = (G4UIXm*)a_tag;
00368 
00369   XmString cps  = ((XmCommandCallbackStruct*)a_data)->value;
00370   char*    ss = XmConvertCompoundStringToString(cps,0);
00371   G4String command (ss);
00372   XtFree   (ss);
00373 
00374   if(This->fHelp==true) {
00375     exitHelp = true;
00376     This->fHelp = ConvertStringToInt(command.data(),This->fHelpChoice);
00377   } else {
00378     This->ApplyShellCommand (command,exitSession,exitPause);
00379   }
00380 
00381   a_widget = NULL;
00382   a_tag    = NULL;
00383 }

Here is the call graph for this function:

void G4UIXm::ExitHelp  )  [private, virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 296 of file G4UIXm.cc.

00300 {
00301 }

G4String G4UIXm::GetCommand Widget  a_widget  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 348 of file G4UIXm.cc.

References commands.

Referenced by ButtonCallback().

00353 {
00354   return commands[a_widget];
00355 }

G4bool G4UIXm::GetHelpChoice G4int &  aInt  )  [private, virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 272 of file G4UIXm.cc.

References G4VInteractorManager::DispatchEvent(), exitHelp, fHelp, fHelpChoice, G4Xt::GetEvent(), G4Xt::getInstance(), and Prompt().

00277 {
00278   fHelp = true;
00279   // SecondaryLoop :
00280   G4Xt* interactorManager = G4Xt::getInstance ();
00281   Prompt("Help");
00282   exitHelp = false;
00283   void* event;
00284   while((event = interactorManager->GetEvent())!=NULL) { 
00285     interactorManager->DispatchEvent(event);
00286     if(exitHelp==true) break;
00287   }
00288   Prompt("session");
00289   //
00290   if(fHelp==false) return false;
00291   aInt = fHelpChoice;
00292   fHelp = false;
00293   return true;
00294 }

Here is the call graph for this function:

void G4UIXm::keyHandler Widget  a_widget,
XtPointer  a_tag,
XEvent *  a_event,
Boolean * 
[static, private]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 385 of file G4UIXm.cc.

References G4VBasicShell::Complete().

Referenced by G4UIXm().

00393 {
00394   KeySym keySym;
00395   XLookupString(&(a_event->xkey),NULL,0,&keySym,NULL);
00396   if(keySym!=XK_Tab) return;
00397   G4UIXm* This = (G4UIXm*)a_tag;
00398   char* s = XmTextGetString(a_widget);
00399   G4String ss = This->Complete(s);
00400   XmTextSetString(a_widget,(char*)ss.data());
00401   XtFree(s);
00402   XmTextSetInsertionPosition(a_widget,XmTextGetLastPosition(a_widget));
00403 }

Here is the call graph for this function:

void G4UIXm::PauseSessionStart G4String  a_state  )  [virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 219 of file G4UIXm.cc.

References SecondaryLoop().

00224 {
00225   if(a_state=="G4_pause> ") { 
00226     SecondaryLoop ("Pause, type continue to exit this state");
00227   }
00228 
00229   if(a_state=="EndOfEvent") {
00230     // Picking with feed back in event data Done here !!!
00231     SecondaryLoop ("End of event, type continue to exit this state");
00232   }
00233 }

Here is the call graph for this function:

void G4UIXm::Prompt G4String  aPrompt  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 197 of file G4UIXm.cc.

References command.

Referenced by GetHelpChoice(), SecondaryLoop(), and SessionStart().

00202 {
00203   Arg args[1];
00204   char* str = (char*)XtNewString(aPrompt.data());
00205   XmString cps = XmStringLtoRCreate(str,XmSTRING_DEFAULT_CHARSET);
00206   XtFree(str);
00207   XtSetArg(args[0],XmNpromptString,cps);
00208   XtSetValues(command,args,1);
00209   XmStringFree(cps);
00210 }

G4int G4UIXm::ReceiveG4cerr G4String  a_string  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 262 of file G4UIXm.cc.

References text, and XmTextAppendString().

00267 {
00268   XmTextAppendString(text,(char*)a_string.data());
00269   return 0;
00270 }

Here is the call graph for this function:

G4int G4UIXm::ReceiveG4cout G4String  a_string  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 252 of file G4UIXm.cc.

References text, and XmTextAppendString().

00257 {
00258   XmTextAppendString(text,(char*)a_string.data());
00259   return 0;
00260 }

Here is the call graph for this function:

void G4UIXm::SecondaryLoop G4String  a_prompt  )  [private]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 235 of file G4UIXm.cc.

References G4VInteractorManager::DispatchEvent(), exitPause, G4Xt::GetEvent(), G4Xt::getInstance(), and Prompt().

Referenced by PauseSessionStart().

00240 {
00241   G4Xt* interactorManager = G4Xt::getInstance ();
00242   Prompt(a_prompt);
00243   exitPause = false;
00244   void* event;
00245   while((event = interactorManager->GetEvent())!=NULL) { 
00246     interactorManager->DispatchEvent(event);
00247     if(exitPause==true) break;
00248   }
00249   Prompt("session");
00250 }

Here is the call graph for this function:

G4UIsession * G4UIXm::SessionStart  )  [virtual]
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 179 of file G4UIXm.cc.

References G4VInteractorManager::DisableSecondaryLoop(), G4VInteractorManager::DispatchEvent(), G4VInteractorManager::EnableSecondaryLoop(), exitSession, G4Xt::GetEvent(), G4Xt::getInstance(), and Prompt().

00183 {
00184   G4Xt* interactorManager = G4Xt::getInstance ();
00185   Prompt("session");
00186   exitSession = false;
00187   interactorManager->DisableSecondaryLoop ();
00188   void* event;
00189   while((event = interactorManager->GetEvent())!=NULL) { 
00190     interactorManager->DispatchEvent(event);
00191     if(exitSession==true) break;
00192   }
00193   interactorManager->EnableSecondaryLoop ();
00194   return this;
00195 }

Here is the call graph for this function:

void G4UIXm::SessionTerminate  ) 
 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 212 of file G4UIXm.cc.

00216 {
00217 }


Member Data Documentation

Widget G4UIXm::command [private]
 

Definition at line 94 of file G4UIXm.hh.

Referenced by commandEnteredCallback(), G4UIXm(), and Prompt().

std::map<Widget,G4String, std::less<Widget> > G4UIXm::commands [private]
 

Definition at line 95 of file G4UIXm.hh.

Referenced by AddButton(), and GetCommand().

G4bool G4UIXm::fHelp [private]
 

Definition at line 98 of file G4UIXm.hh.

Referenced by ButtonCallback(), commandEnteredCallback(), and GetHelpChoice().

G4int G4UIXm::fHelpChoice [private]
 

Definition at line 99 of file G4UIXm.hh.

Referenced by commandEnteredCallback(), and GetHelpChoice().

Widget G4UIXm::form [private]
 

Definition at line 94 of file G4UIXm.hh.

Referenced by AddMenu(), and G4UIXm().

Widget G4UIXm::menuBar [private]
 

Definition at line 94 of file G4UIXm.hh.

Referenced by AddMenu(), and G4UIXm().

Widget G4UIXm::shell [private]
 

Definition at line 94 of file G4UIXm.hh.

Referenced by G4UIXm(), and ~G4UIXm().

Widget G4UIXm::text [private]
 

Definition at line 94 of file G4UIXm.hh.

Referenced by G4UIXm(), ReceiveG4cerr(), and ReceiveG4cout().


The documentation for this class was generated from the following files:
Generated on Fri Jun 22 11:07:54 2007 by doxygen 1.3.4