MainWindow.hxx

Go to the documentation of this file.
00001 #include <TGMenu.h>
00002 #include <TSystem.h>
00003 #include <TROOT.h>
00004 
00005 class MainWindow: public TGMainFrame {
00006 
00007 private:
00008   TGPopupMenu*          menuFile;
00009   //TGPopupMenu*                menuControls;
00010   TGMenuBar*            menuBar;
00011   TGLayoutHints*        menuBarLayout;
00012   TGLayoutHints*        menuBarItemLayout;
00013   
00014 public:
00015   MainWindow(const TGWindow*w,int s1,int s2);
00016   virtual ~MainWindow(); // Closing the control window closes the whole program
00017   virtual void CloseWindow();
00018   
00019   Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00020 };
00021 
00022 #define M_FILE_EXIT 0
00023 
00024 Bool_t MainWindow::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
00025 {
00026    // printf("GUI Message %d %d %d\n",(int)msg,(int)parm1,(int)parm2);
00027     switch (GET_MSG(msg))
00028       {
00029       default:
00030         break;
00031       case kC_COMMAND:
00032         switch (GET_SUBMSG(msg))
00033           {
00034           default:
00035             break;
00036           case kCM_MENU:
00037             switch (parm1)
00038               {
00039               default:
00040                 break;
00041               case M_FILE_EXIT:
00042                 gSystem->ExitLoop();
00043                 break;
00044               }
00045             break;
00046           }
00047         break;
00048       }
00049 
00050     return kTRUE;
00051 }
00052 
00053 MainWindow::MainWindow(const TGWindow*w,int s1,int s2) // ctor
00054     : TGMainFrame(w,s1,s2)
00055 {
00056    //SetCleanup(kDeepCleanup);
00057    
00058 
00059    SetWindowName("ROOT Analyzer Control");
00060 
00061    // layout the gui
00062    menuFile = new TGPopupMenu(gClient->GetRoot());
00063    menuFile->AddEntry("Exit", M_FILE_EXIT);
00064 
00065    menuBarItemLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
00066 
00067    menuFile->Associate(this);
00068    //menuControls->Associate(this);
00069 
00070    menuBar = new TGMenuBar(this, 1, 1, kRaisedFrame);
00071    menuBar->AddPopup("&File",     menuFile,     menuBarItemLayout);
00072    //menuBar->AddPopup("&Controls", menuControls, menuBarItemLayout);
00073    menuBar->Layout();
00074 
00075    menuBarLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX);
00076    AddFrame(menuBar,menuBarLayout);
00077    
00078    MapSubwindows(); 
00079    Layout();
00080    MapWindow();
00081 
00082 }
00083 
00084 MainWindow::~MainWindow()
00085 {
00086 
00087     delete menuFile;
00088     //delete menuControls;
00089     delete menuBar;
00090     delete menuBarLayout;
00091     delete menuBarItemLayout;
00092 }
00093 
00094 void MainWindow::CloseWindow()
00095 {
00096 
00097     gSystem->ExitLoop();
00098 }

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1