Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EditMenu.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "EventDisplayBase/EditMenu.h"
00009 #include <cstdlib>
00010 #include <string>
00011 #include <iostream>
00012 #include "TGMsgBox.h"
00013 #include "TGMenu.h"
00014 #include "TGLayout.h"
00015 #include "TThread.h"
00016 #include "Config/Table.h"
00017 #include "Config/Config.h"
00018 #include "EventDisplayBase/evdb.h"
00019 #include "EventDisplayBase/CfgEdit.h"
00020 using namespace evdb;
00021 
00022 static cfg::Config* gsConfig[1024];
00023 
00024 //......................................................................
00025 
00026 EditMenu::EditMenu(TGMenuBar* menubar, TGMainFrame* mf) :
00027   fMainFrame(mf)
00028 {
00029   fEditMenu = new TGPopupMenu(gClient->GetRoot());
00030   fLayout   = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
00031   
00032   // Create the list of functions. Associate each which a command code
00033   
00034   int icfg = 0;
00035   cfg::Table::ConfigList& cfglist = cfg::Table::Instance().GetList();
00036   cfg::Table::ConfigList::iterator itr   (cfglist.begin());
00037   cfg::Table::ConfigList::iterator itrEnd(cfglist.end());
00038   for (; itr!=itrEnd; ++itr) {
00039     fEditMenu->AddEntry((*itr)->GetName(), icfg);
00040     gsConfig[icfg] = (*itr);
00041     ++icfg;
00042   }
00043   
00044   fEditMenu->Connect("Activated(Int_t)",
00045                      "evdb::EditMenu",this,"HandleMenu(int)");
00046   
00047   // Attach the menu to the menu bar
00048   menubar->AddPopup("&Edit",fEditMenu,fLayout);
00049 }
00050 
00051 //......................................................................
00052 
00053 EditMenu::~EditMenu() 
00054 {
00055   if (fLayout)   { delete fLayout;   fLayout   = 0; }
00056   if (fEditMenu) { delete fEditMenu; fEditMenu = 0; }
00057 }
00058 
00059 //......................................................................
00060 
00061 void EditMenu::HandleMenu(int i) 
00062 {
00063   new CfgEdit(gsConfig[i], fMainFrame); 
00064 }
00065 
00066 //......................................................................
00067 
00068 int EditMenu::Preferences() 
00069 {
00070   this->NoImpl("Preferences");
00071   return 0;
00072 }
00073 
00074 //......................................................................
00075 
00076 int EditMenu::NoImpl(const char* method) 
00077 {
00078   std::string s;
00079   s = "Sorry action '"; s += method; s+= "' is not implemented.\n";
00080   // Why isn't this a memory leak? Dunno, but its seems the TG classes
00081   // are all managed by TGClient which takes care of deletion
00082   new TGMsgBox(evdb::TopWindow(), fMainFrame,
00083                "No implementation",s.c_str(),kMBIconExclamation);
00084   return 0;
00085 }
00086 

Generated on Wed Oct 15 02:35:25 2008 for NOvA Offline by  doxygen 1.3.9.1