00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 #ifndef G4UIXm_h 00030 #define G4UIXm_h 00031 00032 #if defined(G4UI_BUILD_XM_SESSION) || defined(G4UI_USE_XM) 00033 00034 #include <map> 00035 00036 #include <X11/Intrinsic.h> 00037 00038 #include "G4VBasicShell.hh" 00039 #include "G4VInteractiveSession.hh" 00040 00041 class G4UIsession; 00042 00043 // Class description : 00044 // 00045 // G4UIXm : class to handle a Motif interactive session. 00046 // G4UIXm is the Motif version of G4UIterminal. 00047 // 00048 // A command box is at disposal for entering/recalling Geant4 commands. 00049 // A menubar could be customized through the AddMenu, AddButton methods. 00050 // Note that there are corresponding Geant4 commands to add a 00051 // menus in the menubar and add buttons in a menu. 00052 // Ex : 00053 // /gui/addMenu test Test 00054 // /gui/addButton test Init /run/initialize 00055 // /gui/addButton test "Set gun" "/control/execute gun.g4m" 00056 // /gui/addButton test "Run one event" "/run/beamOn 1" 00057 // 00058 // Command completion, by typing "tab" key, is available on the 00059 // command line. 00060 // 00061 // Class description - end : 00062 00063 class G4UIXm : public G4VBasicShell, public G4VInteractiveSession { 00064 public: // With description 00065 G4UIXm(int,char**); 00066 // (argv, argc) or (0, NULL) had to be given. 00067 G4UIsession* SessionStart(); 00068 // To enter interactive X loop ; waiting/executing command,... 00069 void AddMenu(const char*,const char*); 00070 // To add a pulldown menu in the menu bar. 00071 // First argument is the name of the menu. 00072 // Second argument is the label of the cascade button. 00073 // Ex : AddMenu("my_menu","My menu") 00074 void AddButton(const char*,const char*,const char*); 00075 // To add a push button in a pulldown menu. 00076 // First argument is the name of the menu. 00077 // Second argument is the label of the button. 00078 // Third argument is the Geant4 command executed when the button is fired. 00079 // Ex : AddButton("my_menu","Run","/run/beamOn 1"); 00080 public: 00081 ~G4UIXm(); 00082 void Prompt(G4String); 00083 void SessionTerminate(); 00084 virtual void PauseSessionStart(const G4String&); 00085 virtual G4int ReceiveG4cout(const G4String&); 00086 virtual G4int ReceiveG4cerr(const G4String&); 00087 G4String GetCommand(Widget); 00088 private: 00089 void SecondaryLoop(G4String); 00090 G4bool GetHelpChoice(G4int&); 00091 void ExitHelp() const; 00092 private: 00093 Widget form,shell,command,menuBar,text; 00094 std::map<Widget,G4String, std::less<Widget> > commands; 00095 static void CommandEnteredCallback(Widget,XtPointer,XtPointer); 00096 static void keyHandler(Widget,XtPointer,XEvent*,Boolean*); 00097 G4bool fHelp; 00098 G4int fHelpChoice; 00099 static void ButtonCallback(Widget,XtPointer,XtPointer); 00100 }; 00101 00102 #endif 00103 00104 #endif 00105