7 #include "fwGuiQt/layoutManager/FrameLayoutManager.hpp" 9 #include "fwGuiQt/QtMainFrame.hpp" 11 #include <fwCore/base.hpp> 13 #include <fwGui/registry/macros.hpp> 15 #include <boost/lambda/lambda.hpp> 17 #include <QApplication> 18 #include <QDesktopWidget> 21 #include <QMainWindow> 36 FrameLayoutManager::~FrameLayoutManager()
48 m_qtWindow = mainframe;
50 ::fwGuiQt::QtMainFrame::CloseCallback fct = std::bind( &::fwGui::FrameLayoutManager::onCloseFrame,
this);
51 mainframe->setCloseCallback(fct);
53 m_qtWindow->setWindowTitle(QString::fromStdString(frameInfo.
m_name));
54 m_qtWindow->setMinimumSize(std::max(frameInfo.
m_minSize.first, 0), std::max(frameInfo.
m_minSize.second, 0));
58 QIcon icon(QString::fromStdString(frameInfo.
m_iconPath.string()));
59 OSLM_ASSERT(
"Unable to create an icon instance from " << frameInfo.
m_iconPath.string(), !icon.isNull());
60 m_qtWindow->setWindowIcon(icon);
62 if(!qApp->activeWindow())
64 qApp->setActiveWindow(m_qtWindow);
66 if (frameInfo.
m_style == ::fwGui::layoutManager::IFrameLayoutManager::STAY_ON_TOP)
68 m_qtWindow->setWindowFlags(Qt::WindowStaysOnTopHint);
70 else if(frameInfo.
m_style == ::fwGui::layoutManager::IFrameLayoutManager::MODAL)
72 m_qtWindow->setWindowModality(Qt::ApplicationModal);
75 int sizeX = (frameInfo.
m_size.first > 0) ? frameInfo.
m_size.first : m_qtWindow->size().width();
76 int sizeY = (frameInfo.
m_size.second > 0) ? frameInfo.
m_size.second : m_qtWindow->size().height();
80 QPoint pos(posX, posY);
81 if(!this->isOnScreen(pos))
83 QRect frect(0, 0, sizeX, sizeY);
84 frect.moveCenter(QDesktopWidget().screenGeometry().center());
85 pos = frect.topLeft();
87 m_qtWindow->setGeometry(pos.x(), pos.y(), sizeX, sizeY);
89 this->setState(frameInfo.
m_state);
91 QWidget* qwidget =
new QWidget(m_qtWindow);
92 m_qtWindow->setCentralWidget(qwidget);
94 QObject::connect(m_qtWindow, SIGNAL(destroyed(QObject*)),
this, SLOT(onCloseFrame()));
96 ::fwGuiQt::container::QtContainer::sptr container = ::fwGuiQt::container::QtContainer::New();
97 container->setQtContainer(qwidget);
98 m_container = container;
100 ::fwGuiQt::container::QtContainer::sptr frameContainer = ::fwGuiQt::container::QtContainer::New();
101 frameContainer->setQtContainer(m_qtWindow);
102 m_frame = frameContainer;
117 QObject::disconnect(m_qtWindow, SIGNAL(destroyed(QObject*)),
this, SLOT(onCloseFrame()));
119 m_container->destroyContainer();
122 m_frame->destroyContainer();
127 void FrameLayoutManager::onCloseFrame()
130 this->m_closeCallback();
135 void FrameLayoutManager::setState(
FrameState state )
141 m_qtWindow->showMinimized();
145 m_qtWindow->showMaximized();
149 m_qtWindow->showFullScreen();
152 m_qtWindow->showNormal();
162 if( m_qtWindow->isMinimized() )
166 else if( m_qtWindow->isMaximized() )
170 else if( m_qtWindow->isFullScreen() )
179 bool FrameLayoutManager::isOnScreen(
const QPoint& pos)
181 bool isVisible =
false;
182 for(
int i = 0; i < QDesktopWidget().screenCount() && !isVisible; ++i)
184 isVisible = QDesktopWidget().screenGeometry(i).contains(pos,
false);
const FrameInfo & getFrameInfo() const
Configuration definition.
virtual FWGUIQT_API void createFrame() override
Instantiate frame.
#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_TRACE_FUNC()
Trace contextual function signature.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Style m_style
Frame style.
std::string m_name
Frame name.
Defines the frame manager.
std::pair< int, int > m_minSize
Frame minimum size (min width and min height)
A qt panel used to control a VTK 2D Negatoscope view.
virtual FWGUIQT_API void destroyFrame() override
Destroy local frame with sub containers.
std::pair< int, int > m_position
Frame position.
::boost::filesystem::path m_iconPath
Frame icon.
std::pair< int, int > m_size
Frame size.
FrameState m_state
Frame state (maximize, minized, full screen)