#include #include #include class MainWindow: public TGMainFrame { private: TGPopupMenu* menuFile; //TGPopupMenu* menuControls; TGMenuBar* menuBar; TGLayoutHints* menuBarLayout; TGLayoutHints* menuBarItemLayout; public: MainWindow(const TGWindow*w,int s1,int s2); virtual ~MainWindow(); // Closing the control window closes the whole program virtual void CloseWindow(); Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); }; #define M_FILE_EXIT 0 Bool_t MainWindow::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) { // printf("GUI Message %d %d %d\n",(int)msg,(int)parm1,(int)parm2); switch (GET_MSG(msg)) { default: break; case kC_COMMAND: switch (GET_SUBMSG(msg)) { default: break; case kCM_MENU: switch (parm1) { default: break; case M_FILE_EXIT: gSystem->ExitLoop(); break; } break; } break; } return kTRUE; } MainWindow::MainWindow(const TGWindow*w,int s1,int s2) // ctor : TGMainFrame(w,s1,s2) { //SetCleanup(kDeepCleanup); SetWindowName("ROOT Analyzer Control"); // layout the gui menuFile = new TGPopupMenu(gClient->GetRoot()); menuFile->AddEntry("Exit", M_FILE_EXIT); menuBarItemLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0); menuFile->Associate(this); //menuControls->Associate(this); menuBar = new TGMenuBar(this, 1, 1, kRaisedFrame); menuBar->AddPopup("&File", menuFile, menuBarItemLayout); //menuBar->AddPopup("&Controls", menuControls, menuBarItemLayout); menuBar->Layout(); menuBarLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX); AddFrame(menuBar,menuBarLayout); MapSubwindows(); Layout(); MapWindow(); } MainWindow::~MainWindow() { delete menuFile; //delete menuControls; delete menuBar; delete menuBarLayout; delete menuBarItemLayout; } void MainWindow::CloseWindow() { gSystem->ExitLoop(); }