Exemplo n.º 1
0
void WTreeTable::setTree(std::unique_ptr<WTree> root, const WString& h)
{
  WContainerWidget *parent = dynamic_cast<WContainerWidget *>(tree_->parent());
  parent->removeWidget(tree_);
  tree_ = root.get();
  parent->addWidget(std::move(root));

  header(0)->setText(h);
  tree_->resize(WLength(100, LengthUnit::Percentage), WLength::Auto);

  treeRoot()->setTable(this);
}
Exemplo n.º 2
0
Arquivo: WMenu.C Projeto: LifeGo/wt
void WMenu::removeItem(WMenuItem *item)
{
  WContainerWidget *items = ul();

  if (item->parent() == items) {
    int itemIndex = items->indexOf(item);
    items->removeWidget(item);

    if (contentsStack_ && item->contents())
      contentsStack_->removeWidget(item->contents());

    item->setParentMenu(0);

    if (itemIndex <= current_ && current_ >= 0)
      --current_;

    select(current_, true);
  }
}
Exemplo n.º 3
0
void WMenuItem::create(const std::string& iconPath, const WString& text,
		       WWidget *contents, LoadPolicy policy)
{
  customLink_ = false;
  contentsContainer_ = 0;
  contents_ = 0;

  menu_ = 0;
  customPathComponent_ = false;
  internalPathEnabled_ = true;
  closeable_ = false;
  selectable_ = true;

  text_ = 0;
  icon_ = 0;
  checkBox_ = 0;
  subMenu_ = 0;
  data_ = 0;

  if (contents && contents->parent()) {
    WContainerWidget *cw = dynamic_cast<WContainerWidget *>(contents->parent());
    if (cw)
      cw->removeWidget(contents);
  }

  setContents(contents, policy);

  if (!separator_) {
    new WAnchor(this);
    updateInternalPath();
  }

  signalsConnected_ = false;

  if (!iconPath.empty())
    setIcon(iconPath);

  if (!separator_)
    setText(text);
}
Exemplo n.º 4
0
IndexCheckBox *WItemDelegate::checkBox(WidgetRef& w, const WModelIndex& index,
				      bool autoCreate, bool triState)
{
  IndexCheckBox *checkBox = dynamic_cast<IndexCheckBox *>(w.w->find("c"));

  if (!checkBox) {
    if (autoCreate) {
      IndexCheckBox * const result = checkBox = new IndexCheckBox(index);

      checkBox->setObjectName("c");
      checkBox->clicked().preventPropagation();

      WContainerWidget *wc = dynamic_cast<WContainerWidget *>(w.w->find("o"));
      if (!wc) {
	wc = new WContainerWidget();
	wc->setObjectName("o");
	w.w->setInline(true);
	w.w->setStyleClass(WString::Empty);

	/* We first remove to avoid reparenting warnings */
	WContainerWidget *p = dynamic_cast<WContainerWidget *>(w.w->parent());
	if (p)
	  p->removeWidget(w.w);

	wc->addWidget(w.w);
	w.w = wc;
      }
      
      wc->insertWidget(0, checkBox);
      checkBox->changed().connect
	(boost::bind(&WItemDelegate::onCheckedChange, this, result));
    } else
      return 0;
  }

  checkBox->setTristate(triState);

  return checkBox;
}
Exemplo n.º 5
0
WAnchor *WItemDelegate::anchorWidget(WidgetRef& w)
{
  WAnchor *anchor = dynamic_cast<WAnchor *>(w.w->find("a"));
  if (anchor)
    return anchor;

  anchor = new WAnchor();
  anchor->setObjectName("a");

  WContainerWidget *wc = dynamic_cast<WContainerWidget *>(w.w->find("o"));
  if (wc) {
    /*
     * Convert (2) -> (4)
     */
    int firstToMove = 0;

    WCheckBox *cb = dynamic_cast<WCheckBox *>(wc->widget(0));
    if (cb)
      firstToMove = 1;

    wc->insertWidget(firstToMove, anchor);

    while (wc->count() > firstToMove + 1) { 
      WWidget *c = wc->widget(firstToMove + 1);
      wc->removeWidget(c);
      anchor->addWidget(c);
    }
  } else {
    /*
     * Convert (1) -> (3)
     */
    anchor->addWidget(w.w);
    w.w = anchor;
  }

  return anchor;
}