DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
PopupMenu.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDEVE_POPUPMENU_H
14 #define DDEVE_POPUPMENU_H
15 
16 // Framework include files
17 #include "DD4hep/Callback.h"
18 #include "TGMenu.h"
19 
20 // C/C++ include files
21 #include <string>
22 #include <map>
23 
24 // Forward declarations
25 class TGWindow;
26 
28 namespace dd4hep {
29 
31  /*
32  * \author M.Frank
33  * \version 1.0
34  * \ingroup DD4HEP_EVE
35  */
36  class PopupMenu {
37  public:
38  typedef std::map<int,Callback> Callbacks;
39  protected:
42  TGPopupMenu m_popup;
43  int m_cmd;
44  public:
46  PopupMenu(const TGWindow *parent);
48  virtual ~PopupMenu();
50  void HandleMenu(int id);
51 
53  TGPopupMenu& menu() { return m_popup; }
54 
56  virtual void Build(TGMenuBar* menuBar, int hints=kLHintsNormal);
57 
59  virtual void AddSeparator(TGMenuEntry* before = 0);
61  virtual void AddLabel(const char* label, const TGPicture* p = 0, TGMenuEntry* before = 0);
63  virtual void AddPopup(const char* name, TGPopupMenu* popup, TGMenuEntry* before = 0, const TGPicture* p = 0);
65  virtual int AddEntry(const char* name, Callback cb, void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0);
67  template <typename T>
68  int AddEntry(const char* name, T* ptr, void (T::*pmf)(TGMenuEntry*, void*), void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0) {
69  return AddEntry(name, Callback(ptr).make(pmf), ud, p, before);
70  }
72  void CheckEntry(int id);
74  void UnCheckEntry(int id);
76  bool IsEntryChecked(int id);
77 
79  TGPopupMenu* operator->() { return &m_popup; }
81  operator TGPopupMenu* () { return &m_popup; }
82 
84  };
85 } /* End namespace dd4hep */
86 #endif // DDEVE_POPUPMENU_H
87 
dd4hep::PopupMenu::m_cmd
int m_cmd
Definition: PopupMenu.h:43
dd4hep::PopupMenu::ClassDef
ClassDef(PopupMenu, 0)
dd4hep::PopupMenu::HandleMenu
void HandleMenu(int id)
Handle menu items.
Definition: PopupMenu.cpp:67
dd4hep::PopupMenu::UnCheckEntry
void UnCheckEntry(int id)
Uncheck menu entry.
Definition: PopupMenu.cpp:86
dd4hep::PopupMenu::AddLabel
virtual void AddLabel(const char *label, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu label to the menu.
Definition: PopupMenu.cpp:50
dd4hep::PopupMenu::IsEntryChecked
bool IsEntryChecked(int id)
Get check-value.
Definition: PopupMenu.cpp:91
dd4hep::PopupMenu::operator->
TGPopupMenu * operator->()
Public access to the popup menu using '->'.
Definition: PopupMenu.h:79
Callback.h
dd4hep::PopupMenu::CheckEntry
void CheckEntry(int id)
Check menu entry.
Definition: PopupMenu.cpp:81
dd4hep::Callback
Definition of the generic callback structure for member functions.
Definition: Callback.h:38
dd4hep::PopupMenu::Callbacks
std::map< int, Callback > Callbacks
Definition: PopupMenu.h:38
dd4hep::PopupMenu::~PopupMenu
virtual ~PopupMenu()
Default destructor.
Definition: PopupMenu.cpp:34
dd4hep::PopupMenu::AddEntry
virtual int AddEntry(const char *name, Callback cb, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a new popup menu entry with a callback.
Definition: PopupMenu.cpp:60
dd4hep::PopupMenu::m_calls
Callbacks m_calls
Callback map.
Definition: PopupMenu.h:41
dd4hep::PopupMenu
class PopupMenu PopupMenu.h DDEve/PopupMenu.h
Definition: PopupMenu.h:36
dd4hep::PopupMenu::AddEntry
int AddEntry(const char *name, T *ptr, void(T::*pmf)(TGMenuEntry *, void *), void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a new popup menu entry with a callback.
Definition: PopupMenu.h:68
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::PopupMenu::AddSeparator
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: PopupMenu.cpp:45
dd4hep::PopupMenu::PopupMenu
PopupMenu(const TGWindow *parent)
Standard constructor.
dd4hep::PopupMenu::Build
virtual void Build(TGMenuBar *menuBar, int hints=kLHintsNormal)
Add the menu to the menu bar.
Definition: PopupMenu.cpp:41
dd4hep::PopupMenu::menu
TGPopupMenu & menu()
Access to implementation.
Definition: PopupMenu.h:53
dd4hep::PopupMenu::AddPopup
virtual void AddPopup(const char *name, TGPopupMenu *popup, TGMenuEntry *before=0, const TGPicture *p=0)
Add a (cascading) popup menu to a popup menu.
Definition: PopupMenu.cpp:55
dd4hep::PopupMenu::m_popup
TGPopupMenu m_popup
Definition: PopupMenu.h:42