コード例 #1
0
ファイル: WTreeNode.C プロジェクト: chr-thien/wt
void WTreeNode::update()
{
  bool isLast = isLastChildNode();

  if (!visible_) {
    layout_->bindString("selected", "Wt-root");
    childContainer()->addStyleClass("Wt-root");
  } else {
    if (tree()) {
      const WTree::WTreeNodeSet &s = tree()->selectedNodes();
      if (s.find(this) != s.end())
        layout_->bindString("selected", WApplication::instance()->theme()->activeClass());
      else
        layout_->bindEmpty("selected");
    } else
      layout_->bindEmpty("selected");
    childContainer()->removeStyleClass("Wt-root");
  }

  WTreeNode *parent = parentNode();
  if (parent && !parent->childrenDecorated_) {
    // FIXME
  }

  if (expandIcon_->state() != (isExpanded() ? 1 : 0))
    expandIcon_->setState(isExpanded() ? 1 : 0);
  if (childContainer()->isHidden() != !isExpanded())
    childContainer()->setHidden(!isExpanded());
  if (labelIcon_ && (labelIcon_->state() != (isExpanded() ? 1 : 0)))
    labelIcon_->setState(isExpanded() ? 1 : 0);

  toggleStyleClass("Wt-trunk", !isLast);
  layout_->bindString("trunk-class", isLast ? "Wt-end" : "Wt-trunk");

  if (!parentNode() || parentNode()->isExpanded()) {
    if (childCountPolicy_ == Enabled && !populated_)
      doPopulate();

    if (!expandable()) {
      if (noExpandIcon_->parent() == 0) {
	layout_->takeWidget("expand");
	layout_->bindWidget("expand", noExpandIcon_);
      }
    } else {
      if (expandIcon_->parent() == 0) {
	layout_->takeWidget("expand");
	layout_->bindWidget("expand", expandIcon_);
      }
    }
  }

  if (childCountPolicy_ != Disabled && populated_ && childCountLabel_) {
    int n = displayedChildCount();
    if (n)
      childCountLabel_->setText
	(WString::fromUTF8("(" + boost::lexical_cast<std::string>(n) + ")"));
    else
      childCountLabel_->setText(WString());
  }
}
コード例 #2
0
void WTreeNode::update()
{
  ImageIndex index = isLastChildNode() ? Last : Middle;
  
  if (expandIcon_->state() != (expanded() ? 1 : 0))
    expandIcon_->setState(expanded() ? 1 : 0);
  if (expandedContent_->isHidden() != !expanded())
    expandedContent_->setHidden(!expanded());
  if (labelIcon_ && (labelIcon_->state() != (expanded() ? 1 : 0)))
    labelIcon_->setState(expanded() ? 1 : 0);

  if (expandIcon_->icon1()->imageRef() != imagePack() + imagePlus_[index])
    expandIcon_->icon1()->setImageRef(imagePack() + imagePlus_[index]);
  if (expandIcon_->icon2()->imageRef() != imagePack() + imageMin_[index])
    expandIcon_->icon2()->setImageRef(imagePack() + imageMin_[index]);
  if (noExpandIcon_->imageRef() != imagePack() + imageLine_[index])
    noExpandIcon_->setImageRef(imagePack() + imageLine_[index]);

  if (index == Last) {
    layout_->elementAt(0, 0)
      ->decorationStyle().setBackgroundImage("");
    layout_->elementAt(1, 0)
      ->decorationStyle().setBackgroundImage("");
  } else {
    layout_->elementAt(0, 0)
      ->decorationStyle().setBackgroundImage(imagePack() + "line-trunk.gif",
					     WCssDecorationStyle::RepeatY);
    layout_->elementAt(1, 0)
      ->decorationStyle().setBackgroundImage(imagePack() + "line-trunk.gif",
					     WCssDecorationStyle::RepeatY);
  }

  if (childNodes_.empty()) {
    if (noExpandIcon_->parent() == 0) {
      layout_->elementAt(0, 0)->addWidget(noExpandIcon_);
      layout_->elementAt(0, 0)->removeWidget(expandIcon_);
    }
  } else {
    if (expandIcon_->parent() == 0) {
      layout_->elementAt(0, 0)->addWidget(expandIcon_);
      layout_->elementAt(0, 0)->removeWidget(noExpandIcon_);
    }
  }
}
コード例 #3
0
static int getParagraphContext(DocPara *p,bool &isFirst,bool &isLast)
{
  int t=0;
  isFirst=FALSE;
  isLast=FALSE;
  if (p && p->parent())
  {
    switch (p->parent()->kind()) 
    {
      case DocNode::Kind_AutoListItem:
        isFirst=TRUE;
        isLast =TRUE;
        t=1; // not used
        break;
      case DocNode::Kind_SimpleListItem:
        isFirst=TRUE;
        isLast =TRUE;
        t=1; // not used
        break;
      case DocNode::Kind_ParamList:
        isFirst=TRUE;
        isLast =TRUE;
        t=1; // not used
        break;
      case DocNode::Kind_HtmlListItem:
        isFirst=isFirstChildNode((DocHtmlListItem*)p->parent(),p);
        isLast =isLastChildNode ((DocHtmlListItem*)p->parent(),p);
        if (isFirst) t=1;
        if (isLast)  t=3;
        break;
      case DocNode::Kind_SecRefItem:
        isFirst=isFirstChildNode((DocSecRefItem*)p->parent(),p);
        isLast =isLastChildNode ((DocSecRefItem*)p->parent(),p);
        if (isFirst) t=1;
        if (isLast)  t=3;
        break;
      case DocNode::Kind_HtmlDescData:
        isFirst=isFirstChildNode((DocHtmlDescData*)p->parent(),p);
        isLast =isLastChildNode ((DocHtmlDescData*)p->parent(),p);
        if (isFirst) t=2;
        if (isLast)  t=4;
        break;
      case DocNode::Kind_XRefItem:
        isFirst=isFirstChildNode((DocXRefItem*)p->parent(),p);
        isLast =isLastChildNode ((DocXRefItem*)p->parent(),p);
        if (isFirst) t=2;
        if (isLast)  t=4;
        break;
      case DocNode::Kind_HtmlCell:
        isFirst=isFirstChildNode((DocHtmlCell*)p->parent(),p);
        isLast =isLastChildNode ((DocHtmlCell*)p->parent(),p);
        if (isFirst) t=5;
        if (isLast)  t=6;
        break;
      case DocNode::Kind_SimpleSect:
        isFirst=isFirstChildNode((DocSimpleSect*)p->parent(),p);
        isLast =isLastChildNode ((DocSimpleSect*)p->parent(),p);
        if (isFirst) t=2;
        if (isLast)  t=4;
        if (isSeparatedParagraph((DocSimpleSect*)p->parent(),p))
          // if the paragraph is enclosed with separators it will
          // be included in <dd>..</dd> so avoid addition paragraph
          // markers
        {
          isFirst=isLast=TRUE;
        }
        break;
      default:
        break;
    }
    //printf("para=%p parent()->kind=%d isFirst=%d isLast=%d t=%d\n",
    //    p,p->parent()->kind(),isFirst,isLast,t);
  }
  return t;
}
コード例 #4
0
ファイル: WTreeNode.C プロジェクト: bvanhauwaert/wt
void WTreeNode::update()
{
  bool isLast = isLastChildNode();

  if (!visible_) {
    layout_->rowAt(0)->hide();
    expandIcon_->hide();
    layout_->elementAt(0, 0)->resize(0, WLength::Auto);
    layout_->elementAt(1, 0)->resize(0, WLength::Auto);
  } else {
    layout_->rowAt(0)->show();
    expandIcon_->show();
    layout_->elementAt(0, 0)->resize(WLength::Auto, WLength::Auto);
    layout_->elementAt(1, 0)->resize(WLength::Auto, WLength::Auto);
  }

  WTreeNode *parent = parentNode();
  if (parent && !parent->childrenDecorated_) {
    layout_->elementAt(0, 0)->hide();
    layout_->elementAt(1, 0)->hide();
  }

  if (expandIcon_->state() != (isExpanded() ? 1 : 0))
    expandIcon_->setState(isExpanded() ? 1 : 0);
  if (layout_->rowAt(1)->isHidden() != !isExpanded())
    layout_->rowAt(1)->setHidden(!isExpanded());
  if (labelIcon_ && (labelIcon_->state() != (isExpanded() ? 1 : 0)))
    labelIcon_->setState(isExpanded() ? 1 : 0);

  if (isLast) {
    layout_->elementAt(0, 0)->setStyleClass("Wt-end");
    layout_->elementAt(1, 0)->setStyleClass("");
  } else {
    layout_->elementAt(0, 0)->setStyleClass("Wt-trunk");
    layout_->elementAt(1, 0)->setStyleClass("Wt-trunk");
  }

  if (!parentNode() || parentNode()->isExpanded()) {
    if (childCountPolicy_ == Enabled && !populated_)
      doPopulate();

    if (!expandable()) {
      if (noExpandIcon_->parent() == 0) {
	layout_->elementAt(0, 0)->addWidget(noExpandIcon_);
	layout_->elementAt(0, 0)->removeWidget(expandIcon_);
      }
    } else {
      if (expandIcon_->parent() == 0) {
	layout_->elementAt(0, 0)->addWidget(expandIcon_);
	layout_->elementAt(0, 0)->removeWidget(noExpandIcon_);
      }
    }
  }

  if (childCountPolicy_ != Disabled && populated_ && childCountLabel_) {
    int n = displayedChildCount();
    if (n)
      childCountLabel_->setText
	(WString::fromUTF8("(" + boost::lexical_cast<std::string>(n) + ")"));
    else
      childCountLabel_->setText(WString());
  }
}