Exemplo n.º 1
0
bool WWidget::containsExposed(WWidget *w) const
{
    if (w == this)
        return true;

    for (WWidget *p = w; p; p = p->parent())
        if (p == this)
            return true;

    return false;
}
Exemplo n.º 2
0
std::unique_ptr<WWidget> WMenuItem::removeContents()
{
  auto contents = oContents_.get();
  oContents_.reset();

  WWidget *c = contentsInStack();

  if (c) {
    /* Remove from stack */
    std::unique_ptr<WWidget> w = c->parent()->removeWidget(c);

    if (oContentsContainer_)
      return oContentsContainer_->removeWidget(contents);
    else
      return w;
  } else
    return std::move(uContents_);
}
Exemplo n.º 3
0
bool WPopupMenu::isExposed(WWidget *w)
{
  /*
   * w is the popupmenu or contained by the popup menu
   */
  if (WCompositeWidget::isExposed(w))
    return true;

  if (w == WApplication::instance()->root())
    return true;

  /*
   * w is the location at which the popup was positioned, we ignore
   * events on this widget without closing the popup
   */
  if (w == location_)
    return false;

  /*
   * w is a contained popup menu or contained by a sub-popup menu
   */
  for (int i = 0; i < count(); ++i) {
    WPopupMenuItem *item = itemAt(i);
    if (item->popupMenu())
      if (item->popupMenu()->isExposed(w))
	return true;
  }

  // Signal outside of the menu:
  //  - signal of a widget that is an ancestor of location_: ignore it
  //  - otherwise: close the menu and let it be handled.
  if (location_) {
    for (WWidget *p = location_->parent(); p; p = p->parent())
      if (w == p)
	return false;
  }

  if (!parentItem_) {
    done();
    return true;
  } else
    return false;
}