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

# G4UIXm.hh

Go to the documentation of this file.

    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: G4UIXm.hh,v 1.13 2006/06/29 19:09:33 gunter Exp $
    00028 // GEANT4 tag $Name: geant4-08-01-patch-01 $
    00029 //
    00030 #ifndef G4UIXm_h
    00031 #define G4UIXm_h
    00032
    00033 #if defined(G4UI_BUILD_XM_SESSION) || defined(G4UI_USE_XM)
    00034
    00035 #include <map>
    00036
    00037 #include <X11/Intrinsic.h>
    00038
    00039 #include "G4VBasicShell.hh"
    00040 #include "G4VInteractiveSession.hh"
    00041
    00042 class G4UIsession;
    00043
    00044 // Class description :
    00045 //
    00046 //  G4UIXm : class to handle a Motif interactive session.
    00047 // G4UIXm is the Motif version of G4UIterminal.
    00048 //
    00049 //  A command box is at disposal for entering/recalling Geant4 commands.
    00050 //  A menubar could be customized through the AddMenu, AddButton methods.
    00051 //  Note that there are corresponding Geant4 commands to add a
    00052 // menus in the menubar and add buttons in a menu.
    00053 //  Ex :
    00054 //    /gui/addMenu   test Test
    00055 //    /gui/addButton test Init /run/initialize
    00056 //    /gui/addButton test "Set gun" "/control/execute gun.g4m"
    00057 //    /gui/addButton test "Run one event" "/run/beamOn 1"
    00058 //
    00059 //  Command completion, by typing "tab" key, is available on the
    00060 // command line.
    00061 //
    00062 // Class description - end :
    00063
    00064 class G4UIXm : public G4VBasicShell, public G4VInteractiveSession {
    00065 public: // With description
    00066   G4UIXm(int,char**);
    00067   // (argv, argc) or (0, NULL) had to be given.
    00068   G4UIsession* SessionStart();
    00069   // To enter interactive X loop ; waiting/executing command,...
    00070   void AddMenu(const char*,const char*);
    00071   // To add a pulldown menu in the menu bar.
    00072   // First argument is the name of the menu.
    00073   // Second argument is the label of the cascade button.
    00074   // Ex : AddMenu("my_menu","My menu")
    00075   void AddButton(const char*,const char*,const char*);
    00076   // To add a push button in a pulldown menu.
    00077   // First argument is the name of the menu.
    00078   // Second argument is the label of the button.
    00079   // Third argument is the Geant4 command executed when the button is fired.
    00080   // Ex : AddButton("my_menu","Run","/run/beamOn 1");
    00081 public:
    00082   ~G4UIXm();
    00083   void Prompt(G4String);
    00084   void SessionTerminate();
    00085   void PauseSessionStart(G4String);
    00086   G4int ReceiveG4cout(G4String);
    00087   G4int ReceiveG4cerr(G4String);
    00088   G4String GetCommand(Widget);
    00089 private:
    00090   void SecondaryLoop(G4String);
    00091   G4bool GetHelpChoice(G4int&);
    00092   void ExitHelp();
    00093 private:
    00094   Widget form,shell,command,menuBar,text;
    00095   std::map<Widget,G4String, std::less<Widget> > commands;
    00096   static void commandEnteredCallback(Widget,XtPointer,XtPointer);
    00097   static void keyHandler(Widget,XtPointer,XEvent*,Boolean*);
    00098   G4bool fHelp;
    00099   G4int fHelpChoice;
    00100   static void ButtonCallback(Widget,XtPointer,XtPointer);
    00101 };
    00102
    00103 #endif
    00104
    00105 #endif
    00106