fw4spl
IActionSrv.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWGUI_IACTIONSRV_HPP__
8 #define __FWGUI_IACTIONSRV_HPP__
9 
10 #include "fwGui/config.hpp"
11 #include "fwGui/registrar/ActionRegistrar.hpp"
12 
13 #include <fwCom/Signals.hpp>
14 #include <fwCom/Slots.hpp>
15 
16 #include <fwServices/IService.hpp>
17 
18 namespace fwGui
19 {
20 
24 class FWGUI_CLASS_API IActionSrv : public ::fwServices::IService
25 {
26 
27 public:
28 
31 
36  typedef ::fwCom::Signal< void ()> EnabledSignalType;
38  static const ::fwCom::Signals::SignalKeyType s_ENABLED_SIG;
39 
41  typedef ::fwCom::Signal< void ()> DisabledSignalType;
42  static const ::fwCom::Signals::SignalKeyType s_DISABLED_SIG;
43 
45  typedef ::fwCom::Signal< void ()> CheckedSignalType;
46  static const ::fwCom::Signals::SignalKeyType s_CHECKED_SIG;
47 
49  typedef ::fwCom::Signal< void ()> UncheckedSignalType;
50  static const ::fwCom::Signals::SignalKeyType s_UNCHECKED_SIG;
59  static const ::fwCom::Slots::SlotKeyType s_SET_VISIBLE_SLOT;
61 
63  static const ::fwCom::Slots::SlotKeyType s_SHOW_SLOT;
64 
66  static const ::fwCom::Slots::SlotKeyType s_HIDE_SLOT;
67 
69  static const ::fwCom::Slots::SlotKeyType s_SET_IS_ACTIVE_SLOT;
70 
72  static const ::fwCom::Slots::SlotKeyType s_ACTIVATE_SLOT;
73 
75  static const ::fwCom::Slots::SlotKeyType s_DEACTIVATE_SLOT;
76 
78  static const ::fwCom::Slots::SlotKeyType s_SET_IS_EXECUTABLE_SLOT;
79 
81  static const ::fwCom::Slots::SlotKeyType s_SET_EXECUTABLE_SLOT;
82 
84  static const ::fwCom::Slots::SlotKeyType s_SET_INEXECUTABLE_SLOT;
89  FWGUI_API void actionServiceStopping();
91 
93  FWGUI_API void actionServiceStarting();
94 
96  FWGUI_API virtual void setIsActive(bool isActive);
97 
99  FWGUI_API virtual void activate();
100 
102  FWGUI_API virtual void deactivate();
103 
105  FWGUI_API bool getIsActive() const;
106 
108  bool getActiveStateValue() const
109  {
110  return m_activeStateValue;
111  }
112 
114  FWGUI_API virtual void setIsExecutable(bool isExecutable);
115 
117  FWGUI_API virtual void setExecutable();
118 
120  FWGUI_API virtual void setInexecutable();
121 
123  FWGUI_API bool getIsExecutable() const;
124 
126  FWGUI_API void setVisible(bool isVisible);
127 
129  FWGUI_API void show();
130 
132  FWGUI_API void hide();
133 
135  FWGUI_API bool isVisible() const;
136 
145  FWGUI_API bool confirmAction();
146 
147 protected:
148 
149  FWGUI_API IActionSrv();
150 
151  FWGUI_API virtual ~IActionSrv();
152 
153  typedef ::fwRuntime::ConfigurationElement::sptr ConfigurationType;
154 
180  FWGUI_API void initialize();
181 
182 private:
183 
184  ::fwGui::registrar::ActionRegistrar::sptr m_registrar;
185 
187  bool m_activeStateValue;
188  bool m_isActive;
189  bool m_isExecutable;
190  bool m_isVisible;
191  bool m_confirmAction;
192  std::string m_confirmMessage;
193  std::string m_defaultButton;
194 
196  EnabledSignalType::sptr m_sigEnabled;
198  DisabledSignalType::sptr m_sigDisabled;
200  CheckedSignalType::sptr m_sigChecked;
202  UncheckedSignalType::sptr m_sigUnchecked;
203 };
204 
205 //-----------------------------------------------------------------------------
206 
208 {
209 public:
210  LockAction(IActionSrv::wptr action) :
211  m_action(action)
212  {
213  m_action.lock()->setIsExecutable(false);
214  }
215  ~LockAction()
216  {
217  m_action.lock()->setIsExecutable(true);
218  }
219 private:
220  IActionSrv::wptr m_action;
221 };
222 
223 //-----------------------------------------------------------------------------
224 
225 } // namespace fwGui
226 
227 #endif /*__FWGUI_IACTIONSRV_HPP__*/
228 
Base class for all services.
Definition: IService.hpp:61
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
static const ::fwCom::Signals::SignalKeyType s_DISABLED_SIG
Signal emitted when action is enabled.
Definition: IActionSrv.hpp:42
static const ::fwCom::Signals::SignalKeyType s_CHECKED_SIG
Signal emitted when action is enabled.
Definition: IActionSrv.hpp:46
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
static const ::fwCom::Slots::SlotKeyType s_SET_INEXECUTABLE_SLOT
Slot to disable the action.
Definition: IActionSrv.hpp:84
static const ::fwCom::Slots::SlotKeyType s_HIDE_SLOT
Slot to disable the action.
Definition: IActionSrv.hpp:66
static const ::fwCom::Slots::SlotKeyType s_SET_EXECUTABLE_SLOT
Slot to enable the action.
Definition: IActionSrv.hpp:81
static const ::fwCom::Slots::SlotKeyType s_SET_IS_ACTIVE_SLOT
Slot to activate/deactivate the action.
Definition: IActionSrv.hpp:69
::fwCom::Signal< void()> CheckedSignalType
Signal emitted when action is checked.
Definition: IActionSrv.hpp:45
bool getActiveStateValue() const
Return true if action &#39;check&#39; feedback is inverted.
Definition: IActionSrv.hpp:108
static const ::fwCom::Signals::SignalKeyType s_UNCHECKED_SIG
Signal emitted when action is enabled.
Definition: IActionSrv.hpp:50
static const ::fwCom::Slots::SlotKeyType s_DEACTIVATE_SLOT
Slot to desactivate the action.
Definition: IActionSrv.hpp:75
#define fwCoreAllowSharedFromThis()
Generate getSptr and getConstSptr methods.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
::fwCom::Signal< void()> DisabledSignalType
Signal emitted when action is disabled.
Definition: IActionSrv.hpp:41
static const ::fwCom::Slots::SlotKeyType s_ACTIVATE_SLOT
Slot to activate the action.
Definition: IActionSrv.hpp:72
static const ::fwCom::Slots::SlotKeyType s_SHOW_SLOT
Slot to disable the action.
Definition: IActionSrv.hpp:63
::fwCom::Signal< void()> UncheckedSignalType
Signal emitted when action is unchecked.
Definition: IActionSrv.hpp:49
static const ::fwCom::Signals::SignalKeyType s_ENABLED_SIG
Signal emitted when action is enabled.
Definition: IActionSrv.hpp:38
static const ::fwCom::Slots::SlotKeyType s_SET_IS_EXECUTABLE_SLOT
Slot to enable/disable the action.
Definition: IActionSrv.hpp:78