File indexing completed on 2025-01-18 09:14:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDEVE_POPUPMENU_H
0014 #define DDEVE_POPUPMENU_H
0015
0016
0017 #include "DD4hep/Callback.h"
0018 #include "TGMenu.h"
0019
0020
0021 #include <string>
0022 #include <map>
0023
0024
0025 class TGWindow;
0026
0027
0028 namespace dd4hep {
0029
0030
0031
0032
0033
0034
0035
0036 class PopupMenu {
0037 public:
0038 typedef std::map<int,Callback> Callbacks;
0039 protected:
0040
0041 Callbacks m_calls;
0042 TGPopupMenu m_popup;
0043 int m_cmd;
0044 public:
0045
0046 PopupMenu(const TGWindow *parent);
0047
0048 virtual ~PopupMenu();
0049
0050 void HandleMenu(int id);
0051
0052
0053 TGPopupMenu& menu() { return m_popup; }
0054
0055
0056 virtual void Build(TGMenuBar* menuBar, int hints=kLHintsNormal);
0057
0058
0059 virtual void AddSeparator(TGMenuEntry* before = 0);
0060
0061 virtual void AddLabel(const char* label, const TGPicture* p = 0, TGMenuEntry* before = 0);
0062
0063 virtual void AddPopup(const char* name, TGPopupMenu* popup, TGMenuEntry* before = 0, const TGPicture* p = 0);
0064
0065 virtual int AddEntry(const char* name, Callback cb, void* ud=0, const TGPicture* p=0, TGMenuEntry* before=0);
0066
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
0072 void CheckEntry(int id);
0073
0074 void UnCheckEntry(int id);
0075
0076 bool IsEntryChecked(int id);
0077
0078
0079 TGPopupMenu* operator->() { return &m_popup; }
0080
0081 operator TGPopupMenu* () { return &m_popup; }
0082
0083 ClassDef(PopupMenu,0);
0084 };
0085 }
0086 #endif
0087