ROOTANA
MainWindow.hxx
Go to the documentation of this file.
1 #include <TGMenu.h>
2 #include <TSystem.h>
3 #include <TROOT.h>
4 
5 class MainWindow: public TGMainFrame {
6 
7 private:
8  TGPopupMenu* menuFile;
9  //TGPopupMenu* menuControls;
10  TGMenuBar* menuBar;
11  TGLayoutHints* menuBarLayout;
12  TGLayoutHints* menuBarItemLayout;
13 
14 public:
15  MainWindow(const TGWindow*w,int s1,int s2);
16  virtual ~MainWindow(); // Closing the control window closes the whole program
17  virtual void CloseWindow();
18 
19  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
20 };
21 
22 #define M_FILE_EXIT 0
23 
24 Bool_t MainWindow::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
25 {
26  // printf("GUI Message %d %d %d\n",(int)msg,(int)parm1,(int)parm2);
27  switch (GET_MSG(msg))
28  {
29  default:
30  break;
31  case kC_COMMAND:
32  switch (GET_SUBMSG(msg))
33  {
34  default:
35  break;
36  case kCM_MENU:
37  switch (parm1)
38  {
39  default:
40  break;
41  case M_FILE_EXIT:
42  gSystem->ExitLoop();
43  break;
44  }
45  break;
46  }
47  break;
48  }
49 
50  return kTRUE;
51 }
52 
53 MainWindow::MainWindow(const TGWindow*w,int s1,int s2) // ctor
54  : TGMainFrame(w,s1,s2)
55 {
56  //SetCleanup(kDeepCleanup);
57 
58 
59  SetWindowName("ROOT Analyzer Control");
60 
61  // layout the gui
62  menuFile = new TGPopupMenu(gClient->GetRoot());
63  menuFile->AddEntry("Exit", M_FILE_EXIT);
64 
65  menuBarItemLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
66 
67  menuFile->Associate(this);
68  //menuControls->Associate(this);
69 
70  menuBar = new TGMenuBar(this, 1, 1, kRaisedFrame);
71  menuBar->AddPopup("&File", menuFile, menuBarItemLayout);
72  //menuBar->AddPopup("&Controls", menuControls, menuBarItemLayout);
73  menuBar->Layout();
74 
75  menuBarLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX);
76  AddFrame(menuBar,menuBarLayout);
77 
78  MapSubwindows();
79  Layout();
80  MapWindow();
81 
82 }
83 
85 {
86 
87  delete menuFile;
88  //delete menuControls;
89  delete menuBar;
90  delete menuBarLayout;
91  delete menuBarItemLayout;
92 }
93 
95 {
96 
97  gSystem->ExitLoop();
98 }
#define M_FILE_EXIT
Definition: MainWindow.hxx:22
virtual void CloseWindow()
Definition: MainWindow.hxx:94
TGLayoutHints * menuBarItemLayout
Definition: MainWindow.hxx:12
TGLayoutHints * menuBarLayout
Definition: MainWindow.hxx:11
TGPopupMenu * menuFile
Definition: MainWindow.hxx:8
TGMenuBar * menuBar
Definition: MainWindow.hxx:10
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Definition: MainWindow.hxx:24
virtual ~MainWindow()
Definition: MainWindow.hxx:84
MainWindow(const TGWindow *w, int s1, int s2)
Definition: MainWindow.hxx:53