G4UIWin32.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$
00028 //
00029 #ifndef G4UIWin32_h
00030 #define G4UIWin32_h 
00031 
00032 #if defined(G4UI_BUILD_WIN32_SESSION) || defined(G4UI_USE_WIN32)
00033 
00034 #include <map>
00035 #include <vector>
00036 
00037 #include "G4VBasicShell.hh"
00038 #include "G4VInteractiveSession.hh"
00039 
00040 #include "G4Win32.hh"
00041 
00042 class G4VInteractorManager;
00043 
00044 // Class description :
00045 //
00046 //  G4UIWin32 : class to handle a Windows interactive session.
00047 // G4UIWin32 is the Windows 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 G4UIWin32 : public G4VBasicShell, public G4VInteractiveSession {
00065 public: // With description
00066   G4UIWin32();
00067   // The WinMain arguments have to be given.
00068   G4UIsession* SessionStart      ();
00069   // To enter interactive Win32 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   ~G4UIWin32 ();
00083   void Prompt (const G4String&);
00084   void SessionTerminate ();
00085   void PauseSessionStart (const G4String&);
00086   G4int ReceiveG4cout(const G4String&);
00087   G4int ReceiveG4cerr(const G4String&);
00088   G4String GetCommand (int);
00089   void TextAppendString(char*);
00090 private:
00091   void SecondaryLoop (const G4String&);
00092   G4bool GetHelpChoice(G4int&);
00093   void ExitHelp() const;
00094 private:
00095   G4VInteractorManager* interactorManager;
00096   HWND mainWindow;
00097   HWND textWindow,editWindow;
00098   HMENU menuBar,defaultMenu;
00099   std::map<int,G4String, std::less<int> > commands;
00100   void* textBuffer;
00101   int textRows,textCols;
00102   static LRESULT CALLBACK MainWindowProc(HWND,UINT,WPARAM,LPARAM);
00103   static LRESULT CALLBACK TextWindowProc(HWND,UINT,WPARAM,LPARAM);
00104   static LRESULT CALLBACK EditWindowProc(HWND,UINT,WPARAM,LPARAM);
00105   G4bool fHelp;
00106   G4int fHelpChoice;
00107   std::vector<G4String> fHistory;
00108   int fHistoryPos;
00109 };
00110 
00111 #endif
00112 
00113 #endif
00114 

Generated on Mon May 27 17:50:07 2013 for Geant4 by  doxygen 1.4.7