Back to home page

EIC code displayed by LXR

 
 

    


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

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 #ifndef DDEVE_POPUPMENU_H
0014 #define DDEVE_POPUPMENU_H
0015 
0016 // Framework include files
0017 #include "DD4hep/Callback.h"
0018 #include "TGMenu.h"
0019 
0020 // C/C++ include files
0021 #include <string>
0022 #include <map>
0023 
0024 // Forward declarations
0025 class TGWindow;
0026 
0027 /// Namespace for the AIDA detector description toolkit
0028 namespace dd4hep {
0029 
0030   /// class PopupMenu  PopupMenu.h DDEve/PopupMenu.h
0031   /*
0032    *  \author  M.Frank
0033    *  \version 1.0
0034    *  \ingroup DD4HEP_EVE
0035    */
0036   class PopupMenu  {
0037   public:
0038     typedef std::map<int,Callback> Callbacks;
0039   protected:
0040     /// Callback map
0041     Callbacks m_calls;
0042     TGPopupMenu m_popup;
0043     int m_cmd;
0044   public:
0045     /// Standard constructor
0046     PopupMenu(const TGWindow *parent);
0047     /// Default destructor
0048     virtual ~PopupMenu();
0049     /// Handle menu items.
0050     void HandleMenu(int id);
0051 
0052     /// Access to implementation
0053     TGPopupMenu& menu()  {  return m_popup; }
0054 
0055     /// Add the menu to the menu bar
0056     virtual void Build(TGMenuBar* menuBar, int hints=kLHintsNormal);
0057 
0058     /// Add a menu separator to the menu.
0059     virtual void AddSeparator(TGMenuEntry* before = 0);
0060     /// Add a menu label to the menu.
0061     virtual void AddLabel(const char* label, const TGPicture* p = 0, TGMenuEntry* before = 0);
0062     /// Add a (cascading) popup menu to a popup menu.
0063     virtual void AddPopup(const char* name, TGPopupMenu* popup, TGMenuEntry* before = 0, const TGPicture* p = 0);
0064     /// Add a new popup menu entry with a callback
0065     virtual int AddEntry(const char* name, Callback cb, void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0);
0066     /// Add a new popup menu entry with a callback
0067     template <typename T>
0068     int AddEntry(const char* name, T* ptr, void (T::*pmf)(TGMenuEntry*, void*), void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0)  {
0069       return AddEntry(name, Callback(ptr).make(pmf), ud, p, before);
0070     }
0071     /// Check menu entry
0072     void CheckEntry(int id);
0073     /// Uncheck menu entry
0074     void UnCheckEntry(int id);
0075     /// Get check-value
0076     bool IsEntryChecked(int id);
0077 
0078     /// Public access to the popup menu using '->'
0079     TGPopupMenu* operator->() { return &m_popup; }
0080     /// Public access to the popup menu using '->'
0081     operator TGPopupMenu* ()  { return &m_popup; }
0082 
0083     ClassDef(PopupMenu,0);
0084   };
0085 }      /* End namespace dd4hep     */
0086 #endif // DDEVE_POPUPMENU_H
0087