LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::WindowMenu Class Reference

#include "WindowMenu.h"

Public Member Functions

 WindowMenu (TGMenuBar *menubar, TGMainFrame *mf)
 
virtual ~WindowMenu ()
 
void HandleMenu (int menu)
 

Private Member Functions

int NoImpl (const char *m)
 
int No3DViewer ()
 

Private Attributes

TGPopupMenu * fWindowMenu
 
TGLayoutHints * fLayout
 

Detailed Description

Definition at line 19 of file WindowMenu.h.

Constructor & Destructor Documentation

evdb::WindowMenu::WindowMenu ( TGMenuBar *  menubar,
TGMainFrame *  mf 
)

Definition at line 25 of file WindowMenu.cxx.

References fLayout, fWindowMenu, evdb::ListWindow::Names(), and evdb::DisplayWindow::Names().

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  }
TGLayoutHints * fLayout
Definition: WindowMenu.h:35
static const std::vector< std::string > & Names()
Definition: ListWindow.cxx:46
static const std::vector< std::string > & Names()
TGPopupMenu * fWindowMenu
Definition: WindowMenu.h:34
evdb::WindowMenu::~WindowMenu ( )
virtual

Definition at line 58 of file WindowMenu.cxx.

References fLayout, and fWindowMenu.

59  {
60  if (fLayout) { delete fLayout; fLayout = 0; }
61  if (fWindowMenu) { delete fWindowMenu; fWindowMenu = 0; }
62  }
TGLayoutHints * fLayout
Definition: WindowMenu.h:35
TGPopupMenu * fWindowMenu
Definition: WindowMenu.h:34

Member Function Documentation

void evdb::WindowMenu::HandleMenu ( int  menu)

Definition at line 66 of file WindowMenu.cxx.

References evdb::DisplayWindow::Names(), NoImpl(), evdb::DisplayWindow::OpenWindow(), and util::size().

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  }
static int OpenWindow(int type=0)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
int NoImpl(const char *m)
Definition: WindowMenu.cxx:84
static const std::vector< std::string > & Names()
int evdb::WindowMenu::No3DViewer ( )
private

Definition at line 98 of file WindowMenu.cxx.

References evdb::TopWindow().

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  }
const TGWindow * TopWindow()
Definition: evdb.cxx:12
int evdb::WindowMenu::NoImpl ( const char *  m)
private

Definition at line 84 of file WindowMenu.cxx.

References evdb::TopWindow().

Referenced by HandleMenu().

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  }
const TGWindow * TopWindow()
Definition: evdb.cxx:12

Member Data Documentation

TGLayoutHints* evdb::WindowMenu::fLayout
private

Definition at line 35 of file WindowMenu.h.

Referenced by WindowMenu(), and ~WindowMenu().

TGPopupMenu* evdb::WindowMenu::fWindowMenu
private

Definition at line 34 of file WindowMenu.h.

Referenced by WindowMenu(), and ~WindowMenu().


The documentation for this class was generated from the following files: