7 #include "fwGuiQt/builder/ToolBarBuilder.hpp" 8 #include "fwGuiQt/container/QtContainer.hpp" 9 #include "fwGuiQt/container/QtToolBarContainer.hpp" 11 #include <fwGui/registry/macros.hpp> 13 #include <QHBoxLayout> 14 #include <QMainWindow> 34 ToolBarBuilder::~ToolBarBuilder()
42 m_parent = ::fwGuiQt::container::QtContainer::dynamicCast(parent);
43 SLM_ASSERT(
"The parent container is not a QtContainer", m_parent);
44 QMainWindow *window = qobject_cast<QMainWindow*> ( m_parent->getQtContainer() );
46 QToolBar *toolBar =
new QToolBar(QObject::tr(
"ToolBar"));
47 toolBar->setIconSize( QSize(m_toolBitmapSize.first, m_toolBitmapSize.second) );
48 toolBar->setFloatable(
false);
50 ::fwGuiQt::container::QtToolBarContainer::sptr toolBarContainer = ::fwGuiQt::container::QtToolBarContainer::New();
53 bool visible = window->isVisible();
59 area = Qt::TopToolBarArea;
62 area = Qt::BottomToolBarArea;
65 area = Qt::RightToolBarArea;
68 area = Qt::LeftToolBarArea;
71 window->addToolBar( area, toolBar );
74 window->setVisible(visible);
78 QWidget * widget = m_parent->getQtContainer();
79 SLM_ASSERT(
"Parent container must have a layout", widget->layout());
80 QBoxLayout * layout = qobject_cast<QBoxLayout*> ( widget->layout() );
84 layout->setDirection(QBoxLayout::TopToBottom);
85 toolBar->setOrientation(Qt::Horizontal);
88 layout->setDirection(QBoxLayout::BottomToTop);
89 toolBar->setOrientation(Qt::Horizontal);
92 layout->setDirection(QBoxLayout::RightToLeft);
93 toolBar->setOrientation(Qt::Vertical);
96 layout->setDirection(QBoxLayout::LeftToRight);
97 toolBar->setOrientation(Qt::Vertical);
100 SLM_ASSERT(
"Parent container layout must have be a QVBoxLayout", layout);
101 layout->insertWidget(0, toolBar, 0);
104 toolBarContainer->setQtToolBar(toolBar);
114 SLM_ASSERT(
"The parent's container is not a QtContainer", m_parent);
115 QMainWindow *window = qobject_cast<QMainWindow*> ( m_parent->getQtContainer() );
119 ::fwGuiQt::container::QtToolBarContainer::sptr qtToolBar =
120 ::fwGuiQt::container::QtToolBarContainer::dynamicCast(
m_toolBar);
121 QToolBar * toolbar = qtToolBar->getQtToolBar();
122 window->removeToolBar( toolbar );
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.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...