CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Core/src/CSGContinuousAction.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     CSGContinuousAction
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Jul 29 10:21:18 EDT 2008
00011 // $Id: CSGContinuousAction.cc,v 1.6 2009/08/26 18:59:20 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include <boost/bind.hpp>
00016 #include "TGMenu.h"
00017 
00018 // user include files
00019 #include "Fireworks/Core/interface/CSGContinuousAction.h"
00020 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
00021 
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 CSGContinuousAction::CSGContinuousAction(CSGActionSupervisor *iSupervisor, const char *iName) :
00034    CSGAction(iSupervisor,iName),
00035    m_upPic(0),
00036    m_downPic(0),
00037    m_disabledPic(0),
00038    m_runningUpPic(0),
00039    m_runningDownPic(0),
00040    m_button(0),
00041    m_isRunning(false)
00042 {
00043    activated.connect(boost::bind(&CSGContinuousAction::switchMode, this));
00044 }
00045 
00046 void
00047 CSGContinuousAction::createCustomIconsButton(TGCompositeFrame* p,
00048                                              const TGPicture* upPic,
00049                                              const TGPicture* downPic,
00050                                              const TGPicture* disabledPic,
00051                                              const TGPicture* upRunningPic,
00052                                              const TGPicture* downRunningPic,
00053                                              TGLayoutHints* l,
00054                                              Int_t id,
00055                                              GContext_t norm,
00056                                              UInt_t option)
00057 {
00058    m_upPic=upPic;
00059    m_downPic=downPic;
00060    m_disabledPic=disabledPic;
00061    m_runningUpPic=upRunningPic;
00062    m_runningDownPic=downRunningPic;
00063    m_button =
00064       CSGAction::createCustomIconsButton(p,upPic,downPic,disabledPic,l,id,norm,option);
00065 }
00066 
00067 void
00068 CSGContinuousAction::switchMode()
00069 {
00070    if(!m_isRunning) {
00071       m_isRunning = true;
00072       CSGAction::globalEnable();
00073       if(getToolBar() && m_runningImageFileName.size()) {
00074          getToolBar()->ChangeIcon(getToolBarData(),m_runningImageFileName.c_str());
00075       }
00076       if(0!=m_button) {
00077          const TGPicture* tUp = m_runningUpPic;
00078          const TGPicture* tDown = m_runningDownPic;
00079          m_button->swapIcons(tUp,tDown,m_disabledPic);
00080       }
00081       if(0!=getMenu()) {
00082          getMenu()->CheckEntry(getMenuEntry());
00083       }
00084       started_();
00085    } else {
00086       stop();
00087       stopped_();
00088    }
00089 }
00090 
00091 void
00092 CSGContinuousAction::stop()
00093 {
00094    m_isRunning=false;
00095    if(getToolBar() && m_imageFileName.size()) {
00096       getToolBar()->ChangeIcon(getToolBarData(),m_imageFileName.c_str());
00097    }
00098    if(0!=m_button) {
00099       const TGPicture* tUp = m_upPic;
00100       const TGPicture* tDown = m_downPic;
00101 
00102       m_button->swapIcons(tUp,tDown,m_disabledPic);
00103    }
00104    if(0!=getMenu()) {
00105       getMenu()->UnCheckEntry(getMenuEntry());
00106    }
00107    
00108 }
00109 
00110 
00111 void
00112 CSGContinuousAction::globalEnable()
00113 {
00114    CSGAction::globalEnable();
00115 }
00116 
00117 void
00118 CSGContinuousAction::globalDisable()
00119 {
00120    if(!m_isRunning) {
00121       CSGAction::globalDisable();
00122    }
00123 }
00124 
00125 //
00126 // const member functions
00127 //
00128 
00129 //
00130 // static member functions
00131 //