DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PopupMenu.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 #ifndef DD4HEP_DDEVE_POPUPMENU_H
15 #define DD4HEP_DDEVE_POPUPMENU_H
16 
17 // Framework include files
18 #include "DD4hep/Callback.h"
19 #include "TGMenu.h"
20 
21 // C/C++ include files
22 #include <string>
23 #include <map>
24 
25 // Forward declarations
26 class TGWindow;
27 
29 namespace DD4hep {
30 
32  /*
33  * \author M.Frank
34  * \version 1.0
35  * \ingroup DD4HEP_EVE
36  */
37  class PopupMenu {
38  public:
39  typedef std::map<int,Callback> Callbacks;
40  protected:
43  TGPopupMenu m_popup;
44  int m_cmd;
45  public:
47  PopupMenu(const TGWindow *parent);
49  virtual ~PopupMenu();
51  void HandleMenu(int id);
52 
54  TGPopupMenu& menu() { return m_popup; }
55 
57  virtual void Build(TGMenuBar* bar, int hints=kLHintsNormal);
58 
60  virtual void AddSeparator(TGMenuEntry* before = 0);
62  virtual void AddLabel(const char* s, const TGPicture* p = 0, TGMenuEntry* before = 0);
64  virtual void AddPopup(const char* s, TGPopupMenu* popup, TGMenuEntry* before = 0, const TGPicture* p = 0);
66  virtual int AddEntry(const char* name, Callback cb, void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0);
68  template <typename T>
69  int AddEntry(const char* name, T* ptr, void (T::*pmf)(TGMenuEntry*, void*), void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0) {
70  return AddEntry(name, Callback(ptr).make(pmf), ud, p, before);
71  }
73  void CheckEntry(int id);
75  void UnCheckEntry(int id);
77  bool IsEntryChecked(int id);
78 
80  TGPopupMenu* operator->() { return &m_popup; }
82  operator TGPopupMenu* () { return &m_popup; }
83 
85  };
86 
87 
88 } /* End namespace DD4hep */
89 
90 
91 #endif /* DD4HEP_DDEVE_POPUPMENU_H */
92 
void CheckEntry(int id)
Check menu entry.
Definition: PopupMenu.cpp:82
virtual void AddLabel(const char *s, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu label to the menu.
Definition: PopupMenu.cpp:51
virtual ~PopupMenu()
Default destructor.
Definition: PopupMenu.cpp:35
void HandleMenu(int id)
Handle menu items.
Definition: PopupMenu.cpp:68
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:69
TGPopupMenu m_popup
Definition: PopupMenu.h:43
Callbacks m_calls
Callback map.
Definition: PopupMenu.h:42
virtual void AddPopup(const char *s, TGPopupMenu *popup, TGMenuEntry *before=0, const TGPicture *p=0)
Add a (cascading) popup menu to a popup menu.
Definition: PopupMenu.cpp:56
TGeoShape * s
Definition: Volumes.cpp:294
void UnCheckEntry(int id)
Uncheck menu entry.
Definition: PopupMenu.cpp:87
TGPopupMenu & menu()
Access to implementation.
Definition: PopupMenu.h:54
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: PopupMenu.cpp:46
ClassDef(PopupMenu, 0)
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:61
Definition of the generic callback structure for member functions.
Definition: Callback.h:38
bool IsEntryChecked(int id)
Get check-value.
Definition: PopupMenu.cpp:92
TGPopupMenu * operator->()
Public access to the popup menu using '->'.
Definition: PopupMenu.h:80
class PopupMenu PopupMenu.h DDEve/PopupMenu.h
Definition: PopupMenu.h:37
static const double bar
Definition: DD4hepUnits.h:180
std::map< int, Callback > Callbacks
Definition: PopupMenu.h:39
PopupMenu(const TGWindow *parent)
Standard constructor.
virtual void Build(TGMenuBar *bar, int hints=kLHintsNormal)
Add the menu to the menu bar.
Definition: PopupMenu.cpp:42