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
ContextMenu.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_CONTEXTMENU_H
15 #define DD4HEP_DDEVE_CONTEXTMENU_H
16 
17 // Framework include files
18 #include "DD4hep/Callback.h"
19 
20 // ROOT include files
21 #include "TClass.h"
22 
23 // C/C++ include files
24 #include <string>
25 
26 /*
27  * DD4hep namespace declaration
28  */
29 namespace DD4hep {
30 
36  class ContextMenuHandler : public TObject {
37  protected:
41  void* m_param;
42  public:
46  virtual ~ContextMenuHandler();
48  void *param() const { return m_param; }
50  void Context(TObject* target);
53  };
54 
55 
61  class ContextMenu {
62  typedef std::vector<ContextMenuHandler*> Handlers;
66  TClass* m_class;
67 
69  ContextMenu(TClass* cl);
71  virtual ~ContextMenu();
73  ContextMenu& Add(const std::string& title, Callback cb, void* ud);
74  public:
76  static ContextMenu& instance(TClass* cl);
78  ContextMenu& Clear();
82  template <typename Q,typename T>
83  ContextMenu& Add(const std::string& title, Q* ptr, void (T::*pmf)(TObject*, void* ud), void* ud=0) {
84  return Add(title, Callback(ptr).make(pmf), ud);
85  }
88  };
89 
90 
91 } /* End namespace DD4hep */
92 
93 
94 #endif /* DD4HEP_DDEVE_CONTEXTMENU_H */
static ContextMenu & instance(TClass *cl)
Instantiator.
Definition: ContextMenu.cpp:68
TClass * m_class
List of menu entries.
Definition: ContextMenu.h:66
ContextMenu & Add(const std::string &title, Q *ptr, void(T::*pmf)(TObject *, void *ud), void *ud=0)
Add a user item to the menu.
Definition: ContextMenu.h:83
void * param() const
User parameter hook.
Definition: ContextMenu.h:48
virtual ~ContextMenuHandler()
Default destructor.
Definition: ContextMenu.cpp:44
ClassDef(ContextMenuHandler, 0)
Root implementation macro.
void Context(TObject *target)
Callback.
Definition: ContextMenu.cpp:48
virtual ~ContextMenu()
Default destructor.
Definition: ContextMenu.cpp:64
void * m_param
User parameter.
Definition: ContextMenu.h:41
Callback m_call
User callback.
Definition: ContextMenu.h:39
ContextMenu & AddSeparator()
Add a separator.
Definition: ContextMenu.cpp:85
std::vector< ContextMenuHandler * > Handlers
Definition: ContextMenu.h:62
Handlers m_calls
Callback map.
Definition: ContextMenu.h:64
ContextMenu & Clear()
Clear all existing items.
Definition: ContextMenu.cpp:77
Definition of the generic callback structure for member functions.
Definition: Callback.h:38
ContextMenu & Add(const std::string &title, Callback cb, void *ud)
Add user callback.
Definition: ContextMenu.cpp:93
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:38
ContextMenu(TClass *cl)
Initializing constructor.
ClassDef(ContextMenu, 0)
Root implementation macro.
ContextMenuHandler(Callback cb, void *param)
Initializing constructor.