Beispiel #1
0
void ShellPool::ShellClosed(const ShellEvent::Pointer& e)
{

  if (e->doit)
  {
    Shell::Pointer s = e->GetSource();
    IShellListener* l =  s->GetExtraShellListener();

    if (l != 0)
    {
      s->SetExtraShellListener(NULL);
      l->ShellClosed(e);

      // The shell can 'cancel' the close by setting
      // the 'doit' to false...if so, do nothing
      if (e->doit)
      {
        availableShells.push_back(s);
        s->SetVisible(false);
      }
      else
      {
        // Restore the listener
        s->SetExtraShellListener(l);
      }
    }
  }
  e->doit = false;
}
Beispiel #2
0
Shell::Pointer Window::GetModalChild(const QList<Shell::Pointer>& toSearch)
{
  int modal = Constants::APPLICATION_MODAL | Constants::SYSTEM_MODAL | Constants::PRIMARY_MODAL;

  int size = toSearch.size();
  for (int i = size - 1; i < size; i--)
  {
    Shell::Pointer shell = toSearch[i];

    // Check if this shell has a modal child
    QList<Shell::Pointer> children = shell->GetShells();
    Shell::Pointer modalChild = GetModalChild(children);
    if (modalChild != 0)
    {
      return modalChild;
    }

    // If not, check if this shell is modal itself
    if (shell->IsVisible() && (shell->GetStyle() & modal) != 0)
    {
      return shell;
    }
  }

  return Shell::Pointer(nullptr);
}
Beispiel #3
0
void ShellPool::ShellClosed(ShellEvent::Pointer e)
{

  if (e->doit)
  {
    Shell::Pointer s = e->GetSource();
    IShellListener::Pointer l =
        s->GetData(CLOSE_LISTENER).Cast<IShellListener> ();

    if (l != 0)
    {
      s->SetData(Object::Pointer(0), CLOSE_LISTENER);
      l->ShellClosed(e);

      // The shell can 'cancel' the close by setting
      // the 'doit' to false...if so, do nothing
      if (e->doit)
      {
        availableShells.push_back(s);
        s->SetVisible(false);
      }
      else
      {
        // Restore the listener
        s->SetData(l, CLOSE_LISTENER);
      }
    }
  }
  e->doit = false;
}
Beispiel #4
0
bool LayoutPart::IsDocked()
{
  Shell::Pointer s = this->GetShell();
  if (s == 0) {
      return false;
  }

  return s->GetData().Cast<IWorkbenchWindow>() != 0;
}
void WorkbenchWindowConfigurer::SetTitle(const std::string& title)
{
  windowTitle = title;
  Shell::Pointer shell = window.Lock()->GetShell();
  if (shell)
  {
    shell->SetText(title);
  }
}
std::string WorkbenchWindowConfigurer::GetTitle()
{
  Shell::Pointer shell = window.Lock()->GetShell();
  if (shell)
  {
    // update the cached title
    windowTitle = shell->GetText();
  }
  return windowTitle;
}
void SwitchToWindowMenu::MenuItemTriggered(int index)
{
  if (index < 0 || index >= windows.size()) return;

  IWorkbenchWindow* window = windows[index];
  Shell::Pointer windowShell = window->GetShell();
  if (windowShell->GetMinimized())
  {
    windowShell->SetMinimized(false);
  }
  windowShell->SetActive();
  windowShell->GetControl()->raise();

}
QList<Shell::Pointer> QtShell::GetShells()
{
  GuiWidgetsTweaklet* widgetTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
  QList<Shell::Pointer> allShells(widgetTweaklet->GetShells());
  QList<Shell::Pointer> descendants;

  for (int i = 0; i < allShells.size(); ++i)
  {
    Shell::Pointer shell = allShells[i];
    if (widgetTweaklet->GetShell(shell->GetControl()) == this)
    {
      descendants.push_back(shell);
    }
  }

  return descendants;
}
Beispiel #9
0
Shell::Pointer ShellPool::AllocateShell(IShellListener* closeListener)
{
  Shell::Pointer result;
  if (!availableShells.empty())
  {
    result = availableShells.front();
    availableShells.pop_front();
  }
  else
  {
    result = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateShell(parentShell.Lock(),
        flags);
    result->AddShellListener(this);
    //result.addDisposeListener(disposeListener);
  }

  result->SetExtraShellListener(closeListener);
  return result;
}
Beispiel #10
0
IWorkbenchWindow::Pointer LayoutPart::GetWorkbenchWindow()
{
  Shell::Pointer s = this->GetShell();
  if (s == 0)
  {
    return IWorkbenchWindow::Pointer(0);
  }
  Object::Pointer data = s->GetData();
  if (data.Cast<IWorkbenchWindow>() != 0)
  {
    return data.Cast<IWorkbenchWindow>();
  }
  else if (data.Cast<DetachedWindow>() != 0)
  {
    return data.Cast<DetachedWindow>()->GetWorkbenchPage()->GetWorkbenchWindow();
  }

  return IWorkbenchWindow::Pointer(0);

}
Beispiel #11
0
Shell::Pointer Window::DefaultModalParent::GetShell() const
{
  Shell::Pointer parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetActiveShell();

  // Make sure we don't pick a parent that has a modal child (this can lock the app)
  if (parent == 0)
  {
    // If this is a top-level window, then there must not be any open modal windows.
    parent = Window::GetModalChild(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShells());
  }
  else
  {
    // If we picked a parent with a modal child, use the modal child instead
    Shell::Pointer modalChild = Window::GetModalChild(parent->GetShells());
    if (modalChild != 0)
    {
      parent = modalChild;
    }
  }

  return parent;
}
Beispiel #12
0
Shell::Pointer Window::CreateShell()
{

  Shell::Pointer newParent = this->GetParentShell();
//  if (newParent != 0 && newParent.isDisposed())
//  {
//    parentShell = new SameShellProvider(null);
//    newParent = getParentShell();//Find a better parent
//  }

  //Create the shell
  Shell::Pointer newShell = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateShell(newParent, this->GetShellStyle());

  //    resizeListener = new Listener() {
  //      public void handleEvent(Event e) {
  //        resizeHasOccurred = true;
  //      }
  //    };

  //newShell.addListener(SWT.Resize, resizeListener);
  newShell->SetData(Object::Pointer(this));

  //Add a listener
  newShell->AddShellListener(this->GetShellListener());

  //Set the layout
  this->ConfigureShell(newShell);

//  //Register for font changes
//  if (fontChangeListener == null)
//  {
//    fontChangeListener = new FontChangeListener();
//  }
//  JFaceResources.getFontRegistry().addListener(fontChangeListener);

  return newShell;
}
Shell::Pointer QtWidgetsTweakletImpl::CreateShell(Shell::Pointer parent, int style)
{
#ifdef __APPLE__
  Qt::WindowFlags qtFlags(0);
#else
  Qt::WindowFlags qtFlags(Qt::CustomizeWindowHint);
#endif

  if (style & Constants::MAX)
    qtFlags |= Qt::WindowMaximizeButtonHint;
  if (style & Constants::MIN)
    qtFlags |= Qt::WindowMinimizeButtonHint;
  if (style & Constants::CLOSE)
  {
    qtFlags |= Qt::WindowSystemMenuHint;
#if QT_VERSION >= 0x040500
    qtFlags |= Qt::WindowCloseButtonHint;
#endif
  }
  if (!(style & Constants::BORDER))
    qtFlags |= Qt::FramelessWindowHint;
  if (style & Constants::TITLE)
    qtFlags |= Qt::WindowTitleHint;
  if (style & Constants::TOOL)
    qtFlags |= Qt::Tool;

  QWidget* parentWidget = nullptr;
  if (parent != 0)
    parentWidget = static_cast<QWidget*>(parent->GetControl());

  auto   qtshell = new QtShell(parentWidget, qtFlags);
  Shell::Pointer shell(qtshell);
  shellList.push_back(shell);

  if ((style & Constants::APPLICATION_MODAL)
      || (style & Constants::SYSTEM_MODAL)) qtshell->GetWidget()->setWindowModality(Qt::ApplicationModal);
  if (style & Constants::PRIMARY_MODAL) qtshell->GetWidget()->setWindowModality(Qt::WindowModal);

  return shell;
}
Beispiel #14
0
void Window::ConfigureShell(Shell::Pointer newShell)
{

  // The single image version of this code had a comment related to bug
  // 46624,
  // and some code that did nothing if the stored image was already
  // disposed.
  // The equivalent in the multi-image version seems to be to remove the
  // disposed images from the array passed to the shell.
  if (defaultImages.size() > 0)
  {
//    ArrayList nonDisposedImages = new ArrayList(defaultImages.length);
//    for (int i = 0; i < defaultImages.length; ++i)
//    {
//      if (defaultImages[i] != null && !defaultImages[i].isDisposed())
//      {
//        nonDisposedImages.add(defaultImages[i]);
//      }
//    }
//
//    if (nonDisposedImages.size() <= 0)
//    {
//      System.err.println("Window.configureShell: images disposed"); //$NON-NLS-1$
//    }
//    else
//    {
//      //Image[] array = new Image[nonDisposedImages.size()];
//      nonDisposedImages.toArray(array);
      newShell->SetImages(defaultImages);
//    }
  }

//  Layout layout = getLayout();
//  if (layout != null)
//  {
//    newShell.setLayout(layout);
//  }
  CreateTrimWidgets(newShell);
}
void QtWidgetsTweakletImpl::DisposeShell(Shell::Pointer shell)
{
  shellList.removeAll(shell);
  shell->SetVisible(false);
}