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

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: G4UIWin32.hh,v 1.14 2006/06/29 19:09:29 gunter Exp $
00028 // GEANT4 tag $Name: geant4-08-01-patch-01 $
00029 //
00030 #ifndef G4UIWin32_h
00031 #define G4UIWin32_h 
00032 
00033 #if defined(G4UI_BUILD_WIN32_SESSION) || defined(G4UI_USE_WIN32)
00034 
00035 #include <map>
00036 #include <vector>
00037 
00038 #include "G4VBasicShell.hh"
00039 #include "G4VInteractiveSession.hh"
00040 
00041 #include "G4Win32.hh"
00042 
00043 class G4VInteractorManager;
00044 
00045 // Class description :
00046 //
00047 //  G4UIWin32 : class to handle a Windows interactive session.
00048 // G4UIWin32 is the Windows version of G4UIterminal.
00049 //
00050 //  A command box is at disposal for entering/recalling Geant4 commands.
00051 //  A menubar could be customized through the AddMenu, AddButton methods.
00052 //  Note that there are corresponding Geant4 commands to add a 
00053 // menus in the menubar and add buttons in a menu.
00054 //  Ex : 
00055 //    /gui/addMenu   test Test
00056 //    /gui/addButton test Init /run/initialize
00057 //    /gui/addButton test "Set gun" "/control/execute gun.g4m"
00058 //    /gui/addButton test "Run one event" "/run/beamOn 1"
00059 //
00060 //  Command completion, by typing "tab" key, is available on the 
00061 // command line.
00062 //
00063 // Class description - end :
00064 
00065 class G4UIWin32 : public G4VBasicShell, public G4VInteractiveSession {
00066 public: // With description
00067   G4UIWin32();
00068   // The WinMain arguments have to be given.
00069   G4UIsession* SessionStart      ();
00070   // To enter interactive Win32 loop ; waiting/executing command,...
00071   void AddMenu (const char*,const char*);
00072   // To add a pulldown menu in the menu bar. 
00073   // First argument is the name of the menu.
00074   // Second argument is the label of the cascade button.
00075   // Ex : AddMenu("my_menu","My menu")
00076   void AddButton (const char*,const char*,const char*);
00077   // To add a push button in a pulldown menu.
00078   // First argument is the name of the menu.
00079   // Second argument is the label of the button.
00080   // Third argument is the Geant4 command executed when the button is fired.
00081   // Ex : AddButton("my_menu","Run","/run/beamOn 1"); 
00082 public:
00083   ~G4UIWin32 ();
00084   void Prompt (G4String);
00085   void SessionTerminate ();
00086   void PauseSessionStart (G4String);
00087   G4int ReceiveG4cout(G4String);
00088   G4int ReceiveG4cerr(G4String);
00089   G4String GetCommand (int);
00090   void TextAppendString(char*);
00091 private:
00092   void SecondaryLoop (G4String);
00093   G4bool GetHelpChoice(G4int&);
00094   void ExitHelp();
00095 private:
00096   G4VInteractorManager* interactorManager;
00097   HWND mainWindow;
00098   HWND textWindow,editWindow;
00099   HMENU menuBar,defaultMenu;
00100   std::map<int,G4String, std::less<int> > commands;
00101   void* textBuffer;
00102   int textRows,textCols;
00103   static LRESULT CALLBACK MainWindowProc(HWND,UINT,WPARAM,LPARAM);
00104   static LRESULT CALLBACK TextWindowProc(HWND,UINT,WPARAM,LPARAM);
00105   static LRESULT CALLBACK EditWindowProc(HWND,UINT,WPARAM,LPARAM);
00106   G4bool fHelp;
00107   G4int fHelpChoice;
00108   std::vector<G4String> fHistory;
00109   int fHistoryPos;
00110 };
00111 
00112 #endif
00113 
00114 #endif
00115 

Generated on Fri Jun 22 11:07:02 2007 by doxygen 1.3.4