7 #include "fwGuiQt/builder/ContainerBuilder.hpp" 9 #include "fwGuiQt/container/QtContainer.hpp" 11 #include <fwGui/registry/macros.hpp> 13 #include <QMainWindow> 14 #include <QVBoxLayout> 32 ContainerBuilder::~ContainerBuilder()
40 m_parent = ::fwGuiQt::container::QtContainer::dynamicCast(parent);
41 SLM_ASSERT(
"The parent container is not a QtContainer", m_parent);
43 ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::New();
44 QWidget* widget =
new QWidget();
45 qtContainer->setQtContainer(widget);
47 QVBoxLayout* layout =
new QVBoxLayout();
48 layout->setContentsMargins(0, 0, 0, 0);
49 layout->addWidget(widget);
51 m_parent->setLayout(layout);
61 SLM_ASSERT(
"The parent container is not a QtContainer", m_parent);
71 ::fwGuiQt::container::QtContainer::sptr parentContainer = ::fwGuiQt::container::QtContainer::dynamicCast(parent);
72 SLM_ASSERT(
"dynamicCast fwContainer to QtContainer failed", parentContainer);
73 ::fwGuiQt::container::QtContainer::sptr container = ::fwGuiQt::container::QtContainer::dynamicCast(
m_container);
74 SLM_ASSERT(
"dynamicCast fwContainer to QtContainer failed", container);
76 QWidget* qtContainer = container->getQtContainer();
77 SLM_ASSERT(
"The QtContainer is not yet initialized", qtContainer);
78 QWidget* qtParent = parentContainer->getQtContainer();
79 SLM_ASSERT(
"The parent's QtContainer is not yet initialized", qtParent);
81 if(qtParent != m_parent->getQtContainer() )
83 if(!qtParent->layout())
85 SLM_TRACE(
"New parent container hasn't layout");
86 QBoxLayout* layout =
new QBoxLayout(QBoxLayout::TopToBottom);
87 layout->setContentsMargins(0, 0, 0, 0);
88 qtParent->setLayout(layout);
90 qtParent->layout()->addWidget(qtContainer);
91 qtContainer->update();
93 m_parent = parentContainer;
virtual FWGUIQT_API void createContainer(::fwGui::container::fwContainer::sptr parent) override
Instantiate layout with parent container.
The namespace fwGui contains the base interface for IHM services.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
virtual FWGUIQT_API void setParent(::fwGui::container::fwContainer::sptr parent) override
Replace parent container.
virtual FWGUIQT_API void destroyContainer() override
Destroy local layout with sub containers.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Defines the generic layout manager for IHM.
#define SLM_TRACE(message)
::fwGui::container::fwContainer::sptr m_container
Container.