7 #include "fwGui/IMenuBarSrv.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwServices/macros.hpp> 12 #include <fwServices/registry/ActiveWorkers.hpp> 14 #include <fwThread/Worker.hpp> 15 #include <fwThread/Worker.hxx> 17 #include <fwTools/fwID.hpp> 22 IMenuBarSrv::IMenuBarSrv() :
29 IMenuBarSrv::~IMenuBarSrv()
38 m_registrar = ::fwGui::registrar::MenuBarRegistrar::New(this->getID());
40 std::vector < ConfigurationType > vectRegistrar = m_configuration->find(
"registry");
41 SLM_ASSERT(
"Registry section is mandatory.", !vectRegistrar.empty() );
43 if(!vectRegistrar.empty())
45 m_registrarConfig = vectRegistrar.at(0);
46 m_registrar->initialize(m_registrarConfig);
50 std::vector < ConfigurationType > vectGui = m_configuration->find(
"gui");
51 SLM_ASSERT(
"Gui section is mandatory.", !vectGui.empty() );
56 std::vector < ConfigurationType > vectLayoutMng = vectGui.at(0)->find(
"layout");
57 SLM_ASSERT(
"layout section is mandatory.", !vectLayoutMng.empty() );
58 if(!vectLayoutMng.empty())
60 m_layoutConfig = vectLayoutMng.at(0);
61 this->initializeLayoutManager(m_layoutConfig);
70 ::fwGui::container::fwMenuBar::sptr menuBar = m_registrar->getParent();
71 SLM_ASSERT(
"Parent menuBar is unknown.", menuBar);
75 m_layoutManager->createLayout(menuBar);
78 m_registrar->manage(m_layoutManager->getMenus());
85 m_registrar->unmanage();
89 m_layoutManager->destroyLayout();
97 ::fwGui::container::fwMenu::sptr menu = m_registrar->getFwMenu(menuSrvSID, m_layoutManager->getMenus());
103 m_layoutManager->menuIsVisible(menu,
false);
110 m_layoutManager->menuIsEnabled(menu,
false);
119 ::fwGui::container::fwMenu::sptr menu = m_registrar->getFwMenu(menuSrvSID, m_layoutManager->getMenus());
125 m_layoutManager->menuIsVisible(menu,
true);
132 m_layoutManager->menuIsEnabled(menu,
true);
139 void IMenuBarSrv::initializeLayoutManager(ConfigurationType layoutConfig)
141 OSLM_ASSERT(
"Bad configuration name "<<layoutConfig->getName()<<
", must be layout",
142 layoutConfig->getName() ==
"layout");
144 ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(
145 ::fwGui::layoutManager::IMenuBarLayoutManager::REGISTRY_KEY);
146 m_layoutManager = ::fwGui::layoutManager::IMenuBarLayoutManager::dynamicCast(guiObj);
147 OSLM_ASSERT(
"ClassFactoryRegistry failed for class "<< ::fwGui::layoutManager::IMenuBarLayoutManager::REGISTRY_KEY,
150 m_layoutManager->initialize(layoutConfig);
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
The namespace fwGui contains the base interface for IHM services.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWSERVICES_API::fwThread::Worker::sptr getDefaultWorker()
Get the default registered worker.