25 #include <QMainWindow>
38 Window::WindowShellListener::WindowShellListener(Window* wnd)
47 if (window->CanHandleShellCloseEvent())
49 window->HandleShellCloseEvent();
53 void Window::DefaultExceptionHandler::HandleException(
const std::exception& t)
56 std::cerr << t.what();
72 Shell::Pointer modalChild = Window::GetModalChild(parent->GetShells());
82 Shell::Pointer Window::GetModalChild(
const QList<Shell::Pointer>& toSearch)
86 int size = toSearch.size();
87 for (
int i = size - 1; i < size; i--)
92 QList<Shell::Pointer> children = shell->GetShells();
100 if (shell->IsVisible() && (shell->GetStyle() & modal) != 0)
147 poco_assert(shellProvider != 0);
148 this->parentShell = shellProvider;
160 this->returnCode =
OK;
224 return parent->GetControl();
274 QPoint centerPoint(0,0);
275 QRect parentBounds(0,0,0,0);
276 if (parent !=
nullptr)
279 centerPoint.setX(parentBounds.x() + parentBounds.width()/2);
280 centerPoint.setY(parentBounds.y() - parentBounds.height()/2);
286 centerPoint.setX(parentBounds.width()/2);
287 centerPoint.setY(parentBounds.height()/2);
290 return QPoint(centerPoint.x() - (initialSize.x() / 2),
291 std::max<int>(parentBounds.y(),
292 std::min<int>(centerPoint.y() - (initialSize.y() * 2 / 3),
293 parentBounds.y() + parentBounds.height() - initialSize.y())));
312 parent = defaultModalParent->GetShell();
321 if (windowShellListener.isNull())
322 windowShellListener.reset(
new WindowShellListener(
this));
324 return windowShellListener.data();
356 QRect result(preferredSize);
362 if (result.height() > bounds.height()) {
363 result.setHeight(bounds.height());
366 if (result.width() > bounds.width()) {
367 result.setWidth(bounds.width());
370 result.moveLeft( std::max<int>(bounds.x(), std::min<int>(result.x(), bounds.x()
371 + bounds.width() - result.width())));
372 result.moveTop(std::max<int>(bounds.y(), std::min<int>(result.y(), bounds.y()
373 + bounds.height() - result.height())));
380 poco_assert(shell == 0);
391 shellStyle = newShellStyle;
396 if (
GetShell().IsNull() && menuBarManager.IsNull())
410 if (menuBarManager.IsNotNull())
412 QMainWindow* mw = qobject_cast<QMainWindow*>(shell->GetControl());
415 mw->setMenuBar(menuBarManager->CreateMenuBar(shell->GetControl()));
416 menuBarManager->UpdateAll(
true);
442 if (windowManager !=
nullptr)
445 windowManager =
nullptr;
498 return windowManager;
503 return menuBarManager.GetPointer();
548 windowManager = manager;
552 if (manager !=
nullptr)
554 QList<Window::Pointer> windows = manager->GetWindows();
555 for (
int i = 0; i < windows.size(); i++)
557 if (windows[i] ==
this)
568 if (exceptionHandler == 0)
576 defaultModalParent = provider;
static MsgHandler handler
void SetParentShell(Shell::Pointer newParentShell)
itk::SmartPointer< Self > Pointer
virtual SmartPointer< MenuManager > CreateMenuManager()
void SetReturnCode(int code)
virtual void ConfigureShell(Shell::Pointer newShell)
void SetWindowManager(WindowManager *manager)
virtual IShellListener * GetShellListener()
virtual bool CanHandleShellCloseEvent()
MenuManager * GetMenuBarManager() const
WindowManager * GetWindowManager()
static QIcon GetDefaultImage()
virtual void CreateTrimWidgets(SmartPointer< Shell > shell)
Shell::Pointer GetParentShell()
static const int SHELL_TRIM
static void SetDefaultModalParent(IShellProvider::Pointer provider)
static void SetDefaultImage(const QIcon &image)
Shell::Pointer GetShell() const override
virtual void InitializeBounds()
void SetShellStyle(int newShellStyle)
QRect GetConstrainedShellBounds(const QRect &preferredSize)
berry::SmartPointer< Self > Pointer
virtual void HandleShellCloseEvent()
static const int SYSTEM_MODAL
virtual QWidget * CreateContents(Shell::Pointer parent)
virtual QPoint GetInitialLocation(const QPoint &initialSize)
Window(Shell::Pointer parentShell)
virtual QPoint GetInitialSize()
static const int PRIMARY_MODAL
static QList< QIcon > GetDefaultImages()
static QList< QIcon > defaultImages
virtual Shell::Pointer CreateShell()
void SetBlockOnOpen(bool shouldBlock)
static const int APPLICATION_MODAL
section MAP_FRAME_Mapper_Settings Mapper settings For the mapping of corrected images
virtual QWidget * GetContents()
static void SetDefaultImages(const QList< QIcon > &images)
static void SetExceptionHandler(IExceptionHandler::Pointer handler)