Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:07

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     CSGContinuousAction
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Jul 29 10:21:18 EDT 2008
0011 //
0012 
0013 // system include files
0014 #include <functional>
0015 #include "TGMenu.h"
0016 
0017 // user include files
0018 #include "Fireworks/Core/interface/CSGContinuousAction.h"
0019 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
0020 
0021 //
0022 // constants, enums and typedefs
0023 //
0024 
0025 //
0026 // static data member definitions
0027 //
0028 
0029 //
0030 // constructors and destructor
0031 //
0032 CSGContinuousAction::CSGContinuousAction(CSGActionSupervisor* iSupervisor, const char* iName)
0033     : CSGAction(iSupervisor, iName),
0034       m_upPic(nullptr),
0035       m_downPic(nullptr),
0036       m_disabledPic(nullptr),
0037       m_runningUpPic(nullptr),
0038       m_runningDownPic(nullptr),
0039       m_button(nullptr),
0040       m_isRunning(false) {
0041   activated.connect(std::bind(&CSGContinuousAction::switchMode, this));
0042 }
0043 
0044 void CSGContinuousAction::createCustomIconsButton(TGCompositeFrame* p,
0045                                                   const TGPicture* upPic,
0046                                                   const TGPicture* downPic,
0047                                                   const TGPicture* disabledPic,
0048                                                   const TGPicture* upRunningPic,
0049                                                   const TGPicture* downRunningPic,
0050                                                   TGLayoutHints* l,
0051                                                   Int_t id,
0052                                                   GContext_t norm,
0053                                                   UInt_t option) {
0054   m_upPic = upPic;
0055   m_downPic = downPic;
0056   m_disabledPic = disabledPic;
0057   m_runningUpPic = upRunningPic;
0058   m_runningDownPic = downRunningPic;
0059   m_button = CSGAction::createCustomIconsButton(p, upPic, downPic, disabledPic, l, id, norm, option);
0060 }
0061 
0062 void CSGContinuousAction::switchMode() {
0063   if (!m_isRunning) {
0064     m_isRunning = true;
0065     CSGAction::globalEnable();
0066     if (getToolBar() && !m_runningImageFileName.empty()) {
0067       getToolBar()->ChangeIcon(getToolBarData(), m_runningImageFileName.c_str());
0068     }
0069     if (nullptr != m_button) {
0070       const TGPicture* tUp = m_runningUpPic;
0071       const TGPicture* tDown = m_runningDownPic;
0072       m_button->swapIcons(tUp, tDown, m_disabledPic);
0073     }
0074     if (nullptr != getMenu()) {
0075       getMenu()->CheckEntry(getMenuEntry());
0076     }
0077     started_();
0078   } else {
0079     stop();
0080     stopped_();
0081   }
0082 }
0083 
0084 void CSGContinuousAction::stop() {
0085   m_isRunning = false;
0086   if (getToolBar() && !m_imageFileName.empty()) {
0087     getToolBar()->ChangeIcon(getToolBarData(), m_imageFileName.c_str());
0088   }
0089   if (nullptr != m_button) {
0090     const TGPicture* tUp = m_upPic;
0091     const TGPicture* tDown = m_downPic;
0092 
0093     m_button->swapIcons(tUp, tDown, m_disabledPic);
0094   }
0095   if (nullptr != getMenu()) {
0096     getMenu()->UnCheckEntry(getMenuEntry());
0097   }
0098 }
0099 
0100 void CSGContinuousAction::globalEnable() { CSGAction::globalEnable(); }
0101 
0102 void CSGContinuousAction::globalDisable() {
0103   if (!m_isRunning) {
0104     CSGAction::globalDisable();
0105   }
0106 }
0107 
0108 //
0109 // const member functions
0110 //
0111 
0112 //
0113 // static member functions
0114 //