CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <functional>
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  activated.connect(std::bind(&CSGContinuousAction::switchMode, this));
42 }
43 
45  const TGPicture* upPic,
46  const TGPicture* downPic,
47  const TGPicture* disabledPic,
48  const TGPicture* upRunningPic,
49  const TGPicture* downRunningPic,
50  TGLayoutHints* l,
51  Int_t id,
52  GContext_t norm,
53  UInt_t option) {
54  m_upPic = upPic;
55  m_downPic = downPic;
56  m_disabledPic = disabledPic;
57  m_runningUpPic = upRunningPic;
58  m_runningDownPic = downRunningPic;
59  m_button = CSGAction::createCustomIconsButton(p, upPic, downPic, disabledPic, l, id, norm, option);
60 }
61 
63  if (!m_isRunning) {
64  m_isRunning = true;
66  if (getToolBar() && !m_runningImageFileName.empty()) {
67  getToolBar()->ChangeIcon(getToolBarData(), m_runningImageFileName.c_str());
68  }
69  if (nullptr != m_button) {
70  const TGPicture* tUp = m_runningUpPic;
71  const TGPicture* tDown = m_runningDownPic;
72  m_button->swapIcons(tUp, tDown, m_disabledPic);
73  }
74  if (nullptr != getMenu()) {
75  getMenu()->CheckEntry(getMenuEntry());
76  }
77  started_();
78  } else {
79  stop();
80  stopped_();
81  }
82 }
83 
85  m_isRunning = false;
86  if (getToolBar() && !m_imageFileName.empty()) {
87  getToolBar()->ChangeIcon(getToolBarData(), m_imageFileName.c_str());
88  }
89  if (nullptr != m_button) {
90  const TGPicture* tUp = m_upPic;
91  const TGPicture* tDown = m_downPic;
92 
93  m_button->swapIcons(tUp, tDown, m_disabledPic);
94  }
95  if (nullptr != getMenu()) {
96  getMenu()->UnCheckEntry(getMenuEntry());
97  }
98 }
99 
101 
103  if (!m_isRunning) {
105  }
106 }
107 
108 //
109 // const member functions
110 //
111 
112 //
113 // static member functions
114 //
ToolBarData_t * getToolBarData() const
Definition: CSGAction.cc:265
void globalEnable() override
TGPopupMenu * getMenu() const
Definition: CSGAction.cc:257
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)
sigc::signal< void()> stopped_
virtual void globalDisable()
Definition: CSGAction.cc:284
const TGPicture * m_downPic
TGToolBar * getToolBar() const
Definition: CSGAction.cc:267
const TGPicture * m_upPic
CSGContinuousAction(CSGActionSupervisor *sup, const char *name)
int getMenuEntry() const
Definition: CSGAction.cc:259
std::string m_runningImageFileName
void globalDisable() override
const TGPicture * m_runningUpPic
const TGPicture * m_disabledPic
const TGPicture * m_runningDownPic
virtual void globalEnable()
Definition: CSGAction.cc:279
sigc::signal< void()> started_
sigc::signal< void()> activated
Definition: CSGAction.h:100
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:155
void swapIcons(const TGPicture *&iUpIcon, const TGPicture *&iDownIcon, const TGPicture *&iDisabledIcon)