Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:12

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DDEve/PopupMenu.h>
0016 #include <DD4hep/Printout.h>
0017 #include <DD4hep/InstanceCount.h>
0018 
0019 // C/C++ include files
0020 
0021 // Forward declarations
0022 
0023 using namespace dd4hep;
0024 
0025 ClassImp(PopupMenu)
0026 
0027 /// Standard constructor
0028 PopupMenu::PopupMenu(const TGWindow *parent) : m_popup(parent), m_cmd(0)  {
0029   m_popup.Connect("Activated(int)", "dd4hep::PopupMenu", this, "HandleMenu(int)");
0030   InstanceCount::increment(this);
0031 }
0032 
0033 /// Default destructor
0034 PopupMenu::~PopupMenu()  {
0035   m_popup.Disconnect("Activated(int)", this, "HandleMenu(int)");
0036   m_calls.clear();
0037   InstanceCount::decrement(this);
0038 }
0039 
0040 /// Add the menu to the menu bar
0041 void PopupMenu::Build(TGMenuBar* /* bar */, int /* hints */)    {
0042 }
0043 
0044 /// Add a menu separator to the menu.
0045 void PopupMenu::AddSeparator(TGMenuEntry* before)  {
0046   m_popup.AddSeparator(before);
0047 }
0048 
0049 /// Add a menu label to the menu.
0050 void PopupMenu::AddLabel(const char* s, const TGPicture* p, TGMenuEntry* before)  {
0051   m_popup.AddLabel(s,p,before);
0052 }
0053 
0054 /// Add a (cascading) popup menu to a popup menu.
0055 void PopupMenu::AddPopup(const char* s, TGPopupMenu* popup, TGMenuEntry* before, const TGPicture* p)  {
0056   m_popup.AddPopup(s,popup,before,p);
0057 }
0058 
0059 /// Add a new popup menu entry with a callback
0060 int PopupMenu::AddEntry(const char* name, Callback cb, void* ud, const TGPicture* p, TGMenuEntry* before)   {
0061   m_calls[++m_cmd] = cb;
0062   m_popup.AddEntry(name, m_cmd, ud, p, before);
0063   return m_cmd;
0064 }
0065 
0066 /// Handle menu items.
0067 void PopupMenu::HandleMenu(int id)   {
0068   Callbacks::const_iterator i = m_calls.find(id);
0069   if ( i != m_calls.end() )  {
0070     TGMenuEntry* e = m_popup.GetEntry(id);
0071     void* ud = e->GetUserData();
0072     const void* args[2] = {&e, ud}; 
0073     printout(INFO,"PopupMenu","+++ HandleMenu: executing callback with ID=%d Arg=%p [%p]",id,ud,&ud);
0074     (*i).second.execute(args);
0075     return;
0076   }
0077   printout(INFO,"PopupMenu","+++ HandleMenu: unhandled callback with ID=%d",id);
0078 }
0079 
0080 /// Check menu entry
0081 void PopupMenu::CheckEntry(int id)  {
0082   m_popup.CheckEntry(id);
0083 }
0084 
0085 /// Uncheck menu entry
0086 void PopupMenu::UnCheckEntry(int id)   {
0087   m_popup.UnCheckEntry(id);
0088 }
0089 
0090 /// Get check-value
0091 bool PopupMenu::IsEntryChecked(int id)  {
0092   return m_popup.IsEntryChecked(id);
0093 }
0094 
0095