CMS 3D CMS Logo

CSGContinuousAction.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : CSGContinuousAction
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Jul 29 10:21:18 EDT 2008
11 //
12 
13 // system include files
14 #include <boost/bind.hpp>
15 #include "TGMenu.h"
16 
17 // user include files
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33  CSGAction(iSupervisor,iName),
34  m_upPic(nullptr),
35  m_downPic(nullptr),
36  m_disabledPic(nullptr),
37  m_runningUpPic(nullptr),
38  m_runningDownPic(nullptr),
39  m_button(nullptr),
40  m_isRunning(false)
41 {
42  activated.connect(boost::bind(&CSGContinuousAction::switchMode, this));
43 }
44 
45 void
47  const TGPicture* upPic,
48  const TGPicture* downPic,
49  const TGPicture* disabledPic,
50  const TGPicture* upRunningPic,
51  const TGPicture* downRunningPic,
52  TGLayoutHints* l,
53  Int_t id,
54  GContext_t norm,
55  UInt_t option)
56 {
57  m_upPic=upPic;
58  m_downPic=downPic;
59  m_disabledPic=disabledPic;
60  m_runningUpPic=upRunningPic;
61  m_runningDownPic=downRunningPic;
62  m_button =
63  CSGAction::createCustomIconsButton(p,upPic,downPic,disabledPic,l,id,norm,option);
64 }
65 
66 void
68 {
69  if(!m_isRunning) {
70  m_isRunning = true;
72  if(getToolBar() && !m_runningImageFileName.empty()) {
73  getToolBar()->ChangeIcon(getToolBarData(),m_runningImageFileName.c_str());
74  }
75  if(nullptr!=m_button) {
76  const TGPicture* tUp = m_runningUpPic;
77  const TGPicture* tDown = m_runningDownPic;
78  m_button->swapIcons(tUp,tDown,m_disabledPic);
79  }
80  if(nullptr!=getMenu()) {
81  getMenu()->CheckEntry(getMenuEntry());
82  }
83  started_();
84  } else {
85  stop();
86  stopped_();
87  }
88 }
89 
90 void
92 {
93  m_isRunning=false;
94  if(getToolBar() && !m_imageFileName.empty()) {
95  getToolBar()->ChangeIcon(getToolBarData(),m_imageFileName.c_str());
96  }
97  if(nullptr!=m_button) {
98  const TGPicture* tUp = m_upPic;
99  const TGPicture* tDown = m_downPic;
100 
101  m_button->swapIcons(tUp,tDown,m_disabledPic);
102  }
103  if(nullptr!=getMenu()) {
104  getMenu()->UnCheckEntry(getMenuEntry());
105  }
106 
107 }
108 
109 
110 void
112 {
114 }
115 
116 void
118 {
119  if(!m_isRunning) {
121  }
122 }
123 
124 //
125 // const member functions
126 //
127 
128 //
129 // static member functions
130 //
ToolBarData_t * getToolBarData() const
Definition: CSGAction.cc:276
void globalEnable() override
TGPopupMenu * getMenu() const
Definition: CSGAction.cc:260
sigc::signal< void > activated
Definition: CSGAction.h:88
#define nullptr
FWCustomIconsButton * m_button
void createCustomIconsButton(TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, const TGPicture *upRunningPic, const TGPicture *downRunningPic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
virtual void globalDisable()
Definition: CSGAction.cc:302
const TGPicture * m_downPic
TGToolBar * getToolBar() const
Definition: CSGAction.cc:280
const TGPicture * m_upPic
sigc::signal< void > started_
CSGContinuousAction(CSGActionSupervisor *sup, const char *name)
int getMenuEntry() const
Definition: CSGAction.cc:264
std::string m_runningImageFileName
sigc::signal< void > stopped_
void globalDisable() override
const TGPicture * m_runningUpPic
const TGPicture * m_disabledPic
const TGPicture * m_runningDownPic
virtual void globalEnable()
Definition: CSGAction.cc:295
FWCustomIconsButton * createCustomIconsButton(TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
Definition: CSGAction.cc:162
void swapIcons(const TGPicture *&iUpIcon, const TGPicture *&iDownIcon, const TGPicture *&iDisabledIcon)