Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <boost/bind.hpp>
00016 #include "TGMenu.h"
00017
00018
00019 #include "Fireworks/Core/interface/CSGContinuousAction.h"
00020 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
00127
00128
00129
00130
00131