Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:35

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     CSGActionSupervisor
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Alja Mrak-Tadel
0010 //         Created:  Aug 2009
0011 //
0012 #include <sigc++/sigc++.h>
0013 
0014 #include "Fireworks/Core/interface/CSGActionSupervisor.h"
0015 #include "Fireworks/Core/interface/CSGAction.h"
0016 #include "Fireworks/Core/interface/fwLog.h"
0017 
0018 // constructors and destructor
0019 //
0020 CSGActionSupervisor::CSGActionSupervisor() : m_tooltipDelay(3) {}
0021 
0022 CSGActionSupervisor::~CSGActionSupervisor() {
0023   for (std::vector<CSGAction*>::iterator it = m_actionList.begin(), itEnd = m_actionList.end(); it != itEnd; ++it) {
0024     delete *it;
0025   }
0026 }
0027 
0028 CSGAction* CSGActionSupervisor::getAction(const std::string& name) {
0029   std::vector<CSGAction*>::iterator it_act;
0030   for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
0031     if ((*it_act)->getName() == name)
0032       return *it_act;
0033   }
0034   fwLog(fwlog::kWarning) << "No action is found with name " << name.c_str() << std::endl;
0035   return nullptr;
0036 }
0037 
0038 void CSGActionSupervisor::addToActionMap(CSGAction* action) { m_actionList.push_back(action); }
0039 
0040 const std::vector<CSGAction*>& CSGActionSupervisor::getListOfActions() const { return m_actionList; }
0041 
0042 void CSGActionSupervisor::defaultAction() { fwLog(fwlog::kInfo) << "Default action.\n"; }
0043 
0044 void CSGActionSupervisor::enableActions(bool enable) {
0045   std::vector<CSGAction*>::iterator it_act;
0046   for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
0047     if (enable)
0048       (*it_act)->globalEnable();
0049     else
0050       (*it_act)->globalDisable();
0051   }
0052 }
0053 
0054 Bool_t CSGActionSupervisor::activateMenuEntry(int entry) {
0055   std::vector<CSGAction*>::iterator it_act;
0056   for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
0057     if (entry == (*it_act)->getMenuEntry()) {
0058       (*it_act)->activated.emit();
0059       return kTRUE;
0060     }
0061   }
0062   return kFALSE;
0063 }
0064 
0065 Bool_t CSGActionSupervisor::activateToolBarEntry(int entry) {
0066   std::vector<CSGAction*>::iterator it_act;
0067   for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
0068     if ((*it_act)->getToolBarData() && (*it_act)->getToolBarData()->fId == entry) {
0069       (*it_act)->activated.emit();
0070       return kTRUE;
0071     }
0072   }
0073   return kFALSE;
0074 }
0075 
0076 void CSGActionSupervisor::HandleMenu(int id) {}
0077 
0078 void CSGActionSupervisor::resizeMenu(TGPopupMenu* menu) {
0079   std::vector<CSGAction*>::iterator it_act;
0080   for (it_act = m_actionList.begin(); it_act != m_actionList.end(); ++it_act) {
0081     if ((*it_act)->getMenu() == menu && (*it_act)->getKeycode() != 0) {
0082       (*it_act)->resizeMenuEntry();
0083     }
0084   }
0085 }
0086 
0087 Long_t CSGActionSupervisor::getToolTipDelay() const { return m_tooltipDelay; }