7 #include "fwGuiQt/layoutManager/CardinalLayoutManager.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwGui/registry/macros.hpp> 14 #include <QDockWidget> 16 #include <QMainWindow> 17 #include <QScrollArea> 20 ::fwGui::layoutManager::CardinalLayoutManagerBase::REGISTRY_KEY );
33 CardinalLayoutManager::~CardinalLayoutManager()
42 m_parentContainer = ::fwGuiQt::container::QtContainer::dynamicCast(parent);
43 SLM_ASSERT(
"dynamicCast fwContainer to QtContainer failed", m_parentContainer);
45 m_qtWindow =
new QMainWindow( );
47 QBoxLayout* layout =
new QBoxLayout(QBoxLayout::LeftToRight);
48 layout->setContentsMargins(0, 0, 0, 0);
49 layout->addWidget( m_qtWindow );
51 m_parentContainer->setLayout(layout);
53 const std::list< ViewInfo>& views = this->getViewsInfo();
55 bool hasCentral =
false;
59 QWidget* insideWidget;
60 QScrollArea* scrollArea;
62 if(viewInfo.m_align == CENTER)
64 if(viewInfo.m_caption.first)
66 QGroupBox* groupbox =
new QGroupBox(m_qtWindow);
67 groupbox->setTitle(QString::fromStdString(viewInfo.m_caption.second));
68 insideWidget = groupbox;
72 insideWidget =
new QWidget(m_qtWindow);
75 QWidget* widget = insideWidget;
76 SLM_ASSERT(
"multiple center views are not managed in Qt version of CardinalLayoutManager",
79 if (viewInfo.m_useScrollBar)
81 scrollArea =
new QScrollArea(m_qtWindow);
82 scrollArea->setWidget(widget);
83 scrollArea->setWidgetResizable(
true );
84 m_qtWindow->setCentralWidget(scrollArea);
88 m_qtWindow->setCentralWidget(widget);
91 insideWidget->setVisible(viewInfo.m_visible);
96 QDockWidget* dockWidget =
new QDockWidget(m_qtWindow);
97 insideWidget =
new QWidget(dockWidget);
98 QDockWidget::DockWidgetFeatures features;
100 features = QDockWidget::DockWidgetMovable;
102 Qt::DockWidgetArea area;
104 if(viewInfo.m_align == RIGHT)
106 area = Qt::RightDockWidgetArea;
108 else if(viewInfo.m_align == LEFT)
110 area = Qt::LeftDockWidgetArea;
112 else if(viewInfo.m_align == BOTTOM)
114 area = Qt::BottomDockWidgetArea;
116 else if(viewInfo.m_align == TOP)
118 area = Qt::TopDockWidgetArea;
121 m_qtWindow->addDockWidget(area, dockWidget);
122 dockWidget->setFeatures(features);
124 if(viewInfo.m_caption.first)
126 dockWidget->setWindowTitle( QString::fromStdString(viewInfo.m_caption.second) );
127 dockWidget->setMinimumSize(0, 0);
135 QHBoxLayout* layout =
new QHBoxLayout;
136 layout->setSpacing(0);
137 layout->setMargin(0);
139 QWidget* widget =
new QWidget;
140 widget->setLayout(layout);
142 dockWidget->setMinimumSize(std::max(viewInfo.m_minSize.first, 0),
143 std::max(viewInfo.m_minSize.second, 0));
144 dockWidget->setTitleBarWidget(widget);
147 if (viewInfo.m_useScrollBar)
149 scrollArea =
new QScrollArea(dockWidget);
150 scrollArea->setWidget(insideWidget);
151 scrollArea->setWidgetResizable(
true);
152 dockWidget->setWidget(scrollArea);
156 dockWidget->setWidget(insideWidget);
159 if(
false == viewInfo.m_visible)
161 dockWidget->setVisible(
false);
165 if(!viewInfo.m_isResizable)
170 if (viewInfo.m_useScrollBar)
172 scrollArea->setMinimumSize(std::max(viewInfo.m_minSize.first, 0), std::max(viewInfo.m_minSize.second, 0));
176 insideWidget->setMinimumSize(std::max(viewInfo.m_minSize.first, 0), std::max(viewInfo.m_minSize.second, 0));
185 ::fwGuiQt::container::QtContainer::sptr subContainer = ::fwGuiQt::container::QtContainer::New();
186 subContainer->setQtContainer(insideWidget);
190 m_qtWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
198 m_parentContainer->clean();
The namespace fwGui contains the base interface for IHM services.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Defines the cardinal layout manager.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
virtual FWGUIQT_API void destroyLayout() 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) ...
std::vector< ::fwGui::container::fwContainer::sptr > m_subViews
All sub containers managed by this layout.
virtual FWGUIQT_API void createLayout(::fwGui::container::fwContainer::sptr parent) override
Instantiate layout with parent container.
virtual FWGUI_API void destroySubViews()
Helper to destroy local sub views.