示例#1
0
void WMenuItem::create(const std::string& iconPath, const WString& text,
		       std::unique_ptr<WWidget> contents, ContentLoading policy)
{
  customLink_ = false;

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

  text_ = nullptr;
  icon_ = nullptr;
  checkBox_ = nullptr;
  subMenu_ = nullptr;
  data_ = nullptr;

  setContents(std::move(contents), policy);

  if (!separator_) {
    addWidget(std::unique_ptr<WAnchor>(new WAnchor));
    updateInternalPath();
  }

  signalsConnected_ = false;

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

  if (!separator_)
    setText(text);
}
示例#2
0
文件: WMenuItem.C 项目: chr-thien/wt
void WMenuItem::setMenu(WMenu *menu)
{
  subMenu_ = menu;
  subMenu_->parentItem_ = this;

  Wt::WContainerWidget *sparent
    = dynamic_cast<Wt::WContainerWidget *>(subMenu_->parent());
  if (sparent)
    sparent->removeWidget(subMenu_);

  addWidget(subMenu_);
  if (subMenu_->isPopup() &&
      parentMenu() && parentMenu()->isPopup()) {
    subMenu_->webWidget()->setZIndex(std::max(parentMenu()->zIndex() + 100, subMenu_->zIndex()));
  }

  WPopupMenu *popup = dynamic_cast<WPopupMenu *>(subMenu_);
  if (popup) {
    popup->setJavaScriptMember("wtNoReparent", "true");
    setSelectable(false);
    popup->setButton(anchor());
    updateInternalPath();
    // WPopupMenus are hidden by default, 'show' this WPopupMenu
    // but not really, since the parent is still hidden. This fixes
    // an issue where child widgets would remain unexposed, even
    // though this submenu was open (e.g. in a submenu where items
    // are checkable)
    if (dynamic_cast<WPopupMenu*>(menu_))
      popup->show();
  }
}
示例#3
0
文件: WMenuItem.C 项目: chr-thien/wt
void WMenuItem::setPathComponent(const std::string& path)
{
  customPathComponent_ = true;
  pathComponent_ = path;

  updateInternalPath();
  if (menu_)
    menu_->itemPathChanged(this);
}
示例#4
0
文件: WMenuItem.C 项目: chr-thien/wt
void WMenuItem::setParentMenu(WMenu *menu)
{
  menu_ = menu;

  updateInternalPath();

  if (menu && menu->isPopup() &&
      subMenu_ && subMenu_->isPopup()) {
    subMenu_->webWidget()->setZIndex(std::max(menu->zIndex() + 100, subMenu_->zIndex()));
  }
}
示例#5
0
文件: WMenuItem.C 项目: bend/wt
void WMenuItem::setMenu(WMenu *menu)
{
  subMenu_ = menu;
  subMenu_->parentItem_ = this;

  Wt::WContainerWidget *sparent
    = dynamic_cast<Wt::WContainerWidget *>(subMenu_->parent());
  if (sparent)
    sparent->removeWidget(subMenu_);

  addWidget(subMenu_);

  WPopupMenu *popup = dynamic_cast<WPopupMenu *>(subMenu_);
  if (popup) {
    popup->setJavaScriptMember("wtNoReparent", "true");
    setSelectable(false);
    popup->setButton(anchor());
    updateInternalPath();
  }
}
示例#6
0
文件: WMenuItem.C 项目: chr-thien/wt
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);
}
示例#7
0
文件: WMenuItem.C 项目: chr-thien/wt
void WMenuItem::setInternalPathEnabled(bool enabled)
{
  internalPathEnabled_ = enabled;
  updateInternalPath();
}
示例#8
0
文件: WMenuItem.C 项目: bend/wt
void WMenuItem::setParentMenu(WMenu *menu)
{
  menu_ = menu;

  updateInternalPath();
}