+//******************************************************
+void XGUI_MainWindow::createSubWindow()
+{
+ viewer()->createView();
+}
+
+//******************************************************
+void XGUI_MainWindow::cascadeWindows()
+{
+ QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
+ QList<QMdiSubWindow*> aWindows = aMdiArea->subWindowList();
+
+ QSize aSize = aMdiArea->size();
+ QRect aRect = aMdiArea->geometry();
+ const int aOffset = 30;
+ int i = 0, j = 0;
+ int x, y;
+ int w = aSize.width() / 2;
+ int h = aSize.height() / 2;
+ QMdiSubWindow* aLastWnd;
+ foreach(QMdiSubWindow* aWnd, aWindows) {
+ aWnd->showNormal();
+ aWnd->raise();
+ x = aOffset * i;
+ if ((x + w) > aSize.width()) {
+ x = 0;
+ i = 0;
+ }
+ y = aOffset * j;
+ if ((y + h) > aSize.height()) {
+ y = 0;
+ j = 0;
+ }
+ aWnd->setGeometry(QStyle::visualRect(aWnd->layoutDirection(), aRect,
+ QRect(x, y, w, h)));
+ i++;
+ j++;
+ viewer()->onWindowActivated(aWnd);
+ aLastWnd = aWnd;
+ QApplication::processEvents();
+ }
+ aLastWnd->setFocus();
+}
+
+void XGUI_MainWindow::onViewCreated(XGUI_ViewWindow* theWindow)
+{
+ QWidget* aSubWindow = theWindow->parentWidget();
+ QWidget* aMDIWidget = centralWidget();
+
+ QAction* aAction = new QAction(aSubWindow->windowTitle(), aMDIWidget);
+ aAction->setCheckable(true);
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(activateView()));
+ aMDIWidget->addAction(aAction);
+
+ QList<QAction*> aActions = aMDIWidget->actions();
+ foreach(QAction* aAct, aActions) {
+ if (aAct->isCheckable())
+ aAct->setChecked(false);
+ }
+ aAction->setChecked(true);
+}
+
+void XGUI_MainWindow::onDeleteView(XGUI_ViewWindow* theWindow)
+{
+ QWidget* aSubWindow = theWindow->parentWidget();
+ QString aTitle = aSubWindow->windowTitle();
+ QWidget* aMDIWidget = centralWidget();
+ QList<QAction*> aActions = aMDIWidget->actions();
+
+ QAction* aDelAct = 0;
+ foreach(QAction* aAct, aActions) {
+ if (aAct->text() == aTitle) {
+ aDelAct = aAct;
+ break;
+ }
+ }
+ aMDIWidget->removeAction(aDelAct);
+}