File indexing completed on 2025-01-18 09:14:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDEve/PopupMenu.h>
0016 #include <DD4hep/Printout.h>
0017 #include <DD4hep/InstanceCount.h>
0018
0019
0020
0021
0022
0023 using namespace dd4hep;
0024
0025 ClassImp(PopupMenu)
0026
0027
0028 PopupMenu::PopupMenu(const TGWindow *parent) : m_popup(parent), m_cmd(0) {
0029 m_popup.Connect("Activated(int)", "dd4hep::PopupMenu", this, "HandleMenu(int)");
0030 InstanceCount::increment(this);
0031 }
0032
0033
0034 PopupMenu::~PopupMenu() {
0035 m_popup.Disconnect("Activated(int)", this, "HandleMenu(int)");
0036 m_calls.clear();
0037 InstanceCount::decrement(this);
0038 }
0039
0040
0041 void PopupMenu::Build(TGMenuBar* , int ) {
0042 }
0043
0044
0045 void PopupMenu::AddSeparator(TGMenuEntry* before) {
0046 m_popup.AddSeparator(before);
0047 }
0048
0049
0050 void PopupMenu::AddLabel(const char* s, const TGPicture* p, TGMenuEntry* before) {
0051 m_popup.AddLabel(s,p,before);
0052 }
0053
0054
0055 void PopupMenu::AddPopup(const char* s, TGPopupMenu* popup, TGMenuEntry* before, const TGPicture* p) {
0056 m_popup.AddPopup(s,popup,before,p);
0057 }
0058
0059
0060 int PopupMenu::AddEntry(const char* name, Callback cb, void* ud, const TGPicture* p, TGMenuEntry* before) {
0061 m_calls[++m_cmd] = cb;
0062 m_popup.AddEntry(name, m_cmd, ud, p, before);
0063 return m_cmd;
0064 }
0065
0066
0067 void PopupMenu::HandleMenu(int id) {
0068 Callbacks::const_iterator i = m_calls.find(id);
0069 if ( i != m_calls.end() ) {
0070 TGMenuEntry* e = m_popup.GetEntry(id);
0071 void* ud = e->GetUserData();
0072 const void* args[2] = {&e, ud};
0073 printout(INFO,"PopupMenu","+++ HandleMenu: executing callback with ID=%d Arg=%p [%p]",id,ud,&ud);
0074 (*i).second.execute(args);
0075 return;
0076 }
0077 printout(INFO,"PopupMenu","+++ HandleMenu: unhandled callback with ID=%d",id);
0078 }
0079
0080
0081 void PopupMenu::CheckEntry(int id) {
0082 m_popup.CheckEntry(id);
0083 }
0084
0085
0086 void PopupMenu::UnCheckEntry(int id) {
0087 m_popup.UnCheckEntry(id);
0088 }
0089
0090
0091 bool PopupMenu::IsEntryChecked(int id) {
0092 return m_popup.IsEntryChecked(id);
0093 }
0094
0095