LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
WindowMenu.cxx
Go to the documentation of this file.
1 #include <cstdlib>
9 #include <string>
10 #include <iostream>
11 #include "TGMsgBox.h"
12 #include "TGMenu.h"
13 #include "TGLayout.h"
14 
20 
21 namespace evdb{
22 
23 //......................................................................
24 
25  WindowMenu::WindowMenu(TGMenuBar* menubar, TGMainFrame* /*mf*/)
26  {
27  fWindowMenu = new TGPopupMenu(gClient->GetRoot());
28  fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
29 
30  // Create the list of functions. Associate each which a command code
31  unsigned int cnt = 2;
32  unsigned int i=0;
33  const std::vector<std::string>& names = DisplayWindow::Names();
34  for (; i<names.size(); ++i) {
35  fWindowMenu->AddEntry(names[i].c_str(), cnt+i);
36  }
37  fWindowMenu->AddSeparator();
38 
39  // Create the list of functions. Associate each which a command code
40  const std::vector<std::string>& lnames = ListWindow::Names();
41  for (unsigned int j=0; j<lnames.size(); ++j) {
42  fWindowMenu->AddEntry(lnames[j].c_str(), cnt+i+j);
43  }
44  fWindowMenu->AddSeparator();
45  fWindowMenu->AddEntry("&Scan Window", 0);
46  fWindowMenu->AddSeparator();
47  //fWindowMenu->AddEntry("&MC Information", -2);
48  fWindowMenu->AddEntry("&ROOT Browser", 1);
49  fWindowMenu->Connect("Activated(Int_t)",
50  "evdb::WindowMenu",this,"HandleMenu(int)");
51 
52  // Attach the menu to the menu bar
53  menubar->AddPopup("&Window",fWindowMenu,fLayout);
54  }
55 
56  //......................................................................
57 
59  {
60  if (fLayout) { delete fLayout; fLayout = 0; }
61  if (fWindowMenu) { delete fWindowMenu; fWindowMenu = 0; }
62  }
63 
64  //......................................................................
65 
66  void WindowMenu::HandleMenu(int menu)
67  {
68  if( menu == 0 ){
69  new ScanWindow();
70  return;
71  }
72  //
73  // Check if the menu has selected one of the named "user" windows
74  //
75  if (menu-2 < (int)DisplayWindow::Names().size()) {
76  int aok = DisplayWindow::OpenWindow(menu-2);
77  if (aok<0) this->NoImpl("Error openning requested window");
78  return;
79  }
80  }
81 
82  //......................................................................
83 
84  int WindowMenu::NoImpl(const char* method)
85  {
86  std::string s;
87  s = "Sorry action '"; s += method; s+= "' is not implemented.\n";
88  // Why isn't this a memory leak? Dunno, but its seems the TG classes
89  // are all managed by TGClient which takes care of deletion
90  new TGMsgBox(evdb::TopWindow(),
92  "No implementation",s.c_str(),kMBIconExclamation);
93  return 0;
94  }
95 
96  //......................................................................
97 
99  {
100  new TGMsgBox(evdb::TopWindow(),
101  evdb::TopWindow(),
102  "Not for this view",
103  "This display does not implement a 3D viewer",
104  kMBIconExclamation);
105  return 0;
106  }
107 
108 } // namespace
Float_t s
Definition: plot.C:23
virtual ~WindowMenu()
Definition: WindowMenu.cxx:58
Pull down menu for launching new windows.
TGLayoutHints * fLayout
Definition: WindowMenu.h:35
Manage all things related to colors for the event display.
WindowMenu(TGMenuBar *menubar, TGMainFrame *mf)
Definition: WindowMenu.cxx:25
static int OpenWindow(int type=0)
A window containing dialog boxes for handscans.
static const std::vector< std::string > & Names()
Definition: ListWindow.cxx:46
int NoImpl(const char *m)
Definition: WindowMenu.cxx:84
void HandleMenu(int menu)
Definition: WindowMenu.cxx:66
A window containing a list of objects.
static const std::vector< std::string > & Names()
const TGWindow * TopWindow()
Definition: evdb.cxx:12
A window containing a display of the detector or one of its components.
TGPopupMenu * fWindowMenu
Definition: WindowMenu.h:34