Esempio n. 1
0
IconPair::IconPair(const std::string icon1URI, const std::string icon2URI,
		   bool clickIsSwitch, Wt::WContainerWidget *parent)
  : Wt::WCompositeWidget(parent),
    impl_(new Wt::WContainerWidget()),
    icon1_(new Wt::WImage(icon1URI, impl_)),
    icon2_(new Wt::WImage(icon2URI, impl_)),
    icon1Clicked(icon1_->clicked),
    icon2Clicked(icon2_->clicked)
{
  setImplementation(impl_);

  implementStateless(&IconPair::showIcon1, &IconPair::undoShowIcon1);
  implementStateless(&IconPair::showIcon2, &IconPair::undoShowIcon2);

  setInline(true);

  icon2_->hide();

  if (clickIsSwitch) {
    icon1_->clicked.connect(SLOT(icon1_, Wt::WImage::hide));
    icon1_->clicked.connect(SLOT(icon2_, Wt::WImage::show));

    icon2_->clicked.connect(SLOT(icon2_, Wt::WImage::hide));
    icon2_->clicked.connect(SLOT(icon1_, Wt::WImage::show)); //

    decorationStyle().setCursor(Wt::WCssDecorationStyle::Pointer);
  }
} //
Esempio n. 2
0
WTableRow::WTableRow()
  : hidden_(false),
    hiddenChanged_(false)
{ 
  implementStateless(&WTableRow::hide, &WTableRow::undoHide);
  implementStateless(&WTableRow::show, &WTableRow::undoHide);
}
Esempio n. 3
0
WStatelessSlot *WAbstractToggleButton::getStateless(Method method)
{
  void (WAbstractToggleButton::*setC)() = &WAbstractToggleButton::setChecked;

  if (method == static_cast<WObject::Method>(setC))
    return implementStateless(setC, &WAbstractToggleButton::undoSetChecked);
  else if (method == static_cast<WObject::Method>
	   (&WAbstractToggleButton::setUnChecked))
    return implementStateless(&WAbstractToggleButton::setUnChecked,
			      &WAbstractToggleButton::undoSetUnChecked);
  else
    return WFormWidget::getStateless(method);
}
Esempio n. 4
0
WStatelessSlot *WWidget::getStateless(Method method)
{
    if (method == static_cast<WObject::Method>(&WWidget::hide))
        return implementStateless(&WWidget::hide, &WWidget::undoHideShow);
    else if (method == static_cast<WObject::Method>(&WWidget::show))
        return implementStateless(&WWidget::show, &WWidget::undoHideShow);
    else if (method == static_cast<WObject::Method>(&WWidget::enable))
        return implementStateless(&WWidget::enable, &WWidget::undoDisableEnable);
    else if (method == static_cast<WObject::Method>(&WWidget::disable))
        return implementStateless(&WWidget::disable, &WWidget::undoDisableEnable);
    else
        return WObject::getStateless(method);
}
Esempio n. 5
0
void WTreeNode::create()
{
  setImplementation(layout_ = new WTable());

  setStyleClass("Wt-tree");
  layout_->setSelectable(false);

  if (WApplication::instance()->environment().agentIsOpera())
    layout_->setAttributeValue("style", "table-layout: auto");

  implementStateless(&WTreeNode::doExpand, &WTreeNode::undoDoExpand);
  implementStateless(&WTreeNode::doCollapse, &WTreeNode::undoDoCollapse);

  WApplication *app = WApplication::instance();

  expandIcon_
    = new WIconPair(WApplication::resourcesUrl() + "themes/" + app->cssTheme()
		    + "/" + imagePlus_,
		    WApplication::resourcesUrl() + "themes/" + app->cssTheme()
		    + "/" + imageMin_);
  noExpandIcon_ = new WText();
  noExpandIcon_->setStyleClass("Wt-noexpand");

  layout_->rowAt(1)->hide();

  if (labelText_)
    // "treenodelabel" is for backwards compatibility with Wt < 3.1.1
    labelText_->setStyleClass("Wt-label treenodelabel");

  childCountLabel_ = 0;

  layout_->elementAt(0, 0)->setStyleClass("Wt-trunk");
  layout_->elementAt(0, 0)->addWidget(noExpandIcon_);

  if (labelIcon_) {
    layout_->elementAt(0, 1)->addWidget(labelIcon_);
    labelIcon_->setVerticalAlignment(AlignMiddle);
  }

  if (labelText_)
    layout_->elementAt(0, 1)->addWidget(labelText_);

  layout_->elementAt(0, 0)->setContentAlignment(AlignLeft | AlignTop);
  layout_->elementAt(0, 1)->setContentAlignment(AlignLeft | AlignMiddle);

  layout_->rowAt(0)->setStyleClass("Wt-node");

  childrenLoaded_ = false;

  setLoadPolicy(LazyLoading);
}
Esempio n. 6
0
WNavigationBar::WNavigationBar(WContainerWidget *parent)
  : WTemplate(tr("Wt.WNavigationBar.template"), parent)
{
  bindEmpty("collapse-button");
  bindEmpty("expand-button");
  bindEmpty("title-link");
  bindWidget("contents", new NavContainer());

  implementStateless(&WNavigationBar::collapseContents,
		     &WNavigationBar::undoExpandContents);

  implementStateless(&WNavigationBar::expandContents,
		     &WNavigationBar::undoExpandContents);
}
Esempio n. 7
0
void WTreeNode::create()
{
  setImplementation(layout_ = new WTable());

  implementStateless(&WTreeNode::doExpand, &WTreeNode::undoDoExpand);
  implementStateless(&WTreeNode::doCollapse, &WTreeNode::undoDoCollapse);

  expandIcon_ = new WIconPair(imagePlus_[Last], imageMin_[Last]);
  noExpandIcon_ = new WImage(imageLine_[Last]);

  expandedContent_ = new WContainerWidget();
  expandedContent_->hide();

  if (labelText_) {
    labelText_->setStyleClass(L"treenodelabel");
    childCountLabel_ = new WText();
    childCountLabel_->setMargin(WLength(7), Left);
    childCountLabel_->setStyleClass(L"treenodechildcount");
  } else
    childCountLabel_ = 0;

  layout_->elementAt(0, 0)->addWidget(noExpandIcon_);

  if (labelIcon_) {
    layout_->elementAt(0, 1)->addWidget(labelIcon_);
    labelIcon_->setVerticalAlignment(AlignMiddle);
  }

  if (labelText_)
    layout_->elementAt(0, 1)->addWidget(labelText_);

  if (childCountLabel_)
    layout_->elementAt(0, 1)->addWidget(childCountLabel_);

  layout_->elementAt(1, 1)->addWidget(expandedContent_);

  layout_->elementAt(0, 0)->setContentAlignment(AlignTop);
  layout_->elementAt(0, 1)->setContentAlignment(AlignMiddle);

  childrenLoaded_ = false;

  setLoadPolicy(LazyLoading);
}
Esempio n. 8
0
WStatelessSlot *WFormWidget::getStateless(Method method)
{
  typedef void (WFormWidget::*Type)();

  Type focusMethod = &WFormWidget::setFocus;

  if (method == static_cast<WObject::Method>(focusMethod))
    return implementStateless(&WFormWidget::setFocus,
			      &WFormWidget::undoSetFocus);
  else
    return WInteractWidget::getStateless(method);
}
Esempio n. 9
0
void WMenuItem::connectSignals()
{
  if (!signalsConnected_) {
    signalsConnected_ = true;

    if (!contents_ || contentsLoaded())
      implementStateless(&WMenuItem::selectVisual,
			 &WMenuItem::undoSelectVisual);

    WAnchor *a = anchor();

    if (a) {
      SignalBase *as;
      bool selectFromCheckbox = false;

      if (checkBox_ && !checkBox_->clicked().propagationPrevented()) {
	as = &checkBox_->changed();
	/*
	 * Because the checkbox is not a properly exposed form object,
	 * we need to relay its value ourselves
	 */
	checkBox_->checked().connect(this, &WMenuItem::setCheckBox);
	checkBox_->unChecked().connect(this, &WMenuItem::setUnCheckBox);
	selectFromCheckbox = true;
      } else
	as = &a->clicked();

      if (checkBox_)
	a->setLink(WLink());

      if (contentsContainer_ && contentsContainer_->count() == 0)
	as->connect(this, &WMenuItem::selectNotLoaded);
      else {
	as->connect(this, &WMenuItem::selectVisual);
	if (!selectFromCheckbox)
	  as->connect(this, &WMenuItem::select);
      }
    }
  }
}
Esempio n. 10
0
File: WPanel.C Progetto: NovaWova/wt
WPanel::WPanel(WContainerWidget *parent)
  : WCompositeWidget(parent),
    collapseIcon_(0),
    title_(0),
    centralWidget_(0),
    collapsed_(this),
    expanded_(this),
    collapsedSS_(this),
    expandedSS_(this)
{
  const char *TEMPLATE =
    "${titlebar}"
    "${contents}";

  setImplementation(impl_ = new WTemplate(WString::fromUTF8(TEMPLATE)));

  implementStateless(&WPanel::doExpand, &WPanel::undoExpand);
  implementStateless(&WPanel::doCollapse, &WPanel::undoCollapse);

  WApplication *app = WApplication::instance();

  WContainerWidget *centralArea = new WContainerWidget();
  app->theme()->apply(this, centralArea, PanelBodyRole);

  impl_->bindWidget("titlebar", 0);
  impl_->bindWidget("contents", centralArea);

  setJavaScriptMember
    (WT_RESIZE_JS,
     "function(self, w, h, l) {"
     """var defined = h >= 0;"
     """if (defined) {"
     ""  "var mh = " WT_CLASS ".px(self, 'maxHeight');"
     ""  "if (mh > 0) h = Math.min(h, mh);"
     """}"
     """if (" WT_CLASS ".boxSizing(self)) {"
     ""  "h -= " WT_CLASS ".px(self, 'borderTopWidth') + "
     ""       WT_CLASS ".px(self, 'borderBottomWidth');"
     """}"
     """var c = self.lastChild;"
     """var t = c.previousSibling;"
     """if (t)"
     ""  "h -= t.offsetHeight;"
     """h -= 8;" // padding
     """if (defined && h > 0) {"
     ""  "c.lh = l;"
     ""  "c.style.height = h + 'px';"
     // this seems golden, but, JQuery docs say it doesn't work when
     // the panel is indirectly hidden: will this back-fire ?
     ""  "$(c).children().each(function() { "
     ""      "var self = $(this), "
     ""          "padding = self.outerHeight() - self.height();"
     ""      "self.height(h - padding);"
     ""      "this.lh = l;"
     ""  "});"
     """} else {"
     ""  "c.lh = false;"
     ""  "c.style.height = '';"
     ""  "$(c).children().each(function() { "
     ""      "this.style.height = '';"
     ""      "this.lh = false;"
     ""  "});"
     """}"
     "};");

  setJavaScriptMember(WT_GETPS_JS, StdWidgetItemImpl::secondGetPSJS());
}
Esempio n. 11
0
void WTreeNode::create()
{
  setImplementation(layout_ = new WTemplate(tr("Wt.WTreeNode.template")));
  setStyleClass("Wt-tree");
  layout_->setSelectable(false);

  layout_->bindEmpty("cols-row");
  layout_->bindEmpty("trunk-class");

  implementStateless(&WTreeNode::doExpand, &WTreeNode::undoDoExpand);
  implementStateless(&WTreeNode::doCollapse, &WTreeNode::undoDoCollapse);

  WApplication *app = WApplication::instance();

  /*
   * Children
   */
  WContainerWidget *children = new WContainerWidget();
  children->setList(true);
  children->hide();
  layout_->bindWidget("children", children);

  /*
   * Expand icon
   */
  if (WApplication::instance()->layoutDirection() == RightToLeft)
    expandIcon_
      = new WIconPair(app->theme()->resourcesUrl() + imagePlusRtl_,
		      app->theme()->resourcesUrl() + imageMinRtl_);
  else
    expandIcon_
      = new WIconPair(app->theme()->resourcesUrl() + imagePlus_,
		      app->theme()->resourcesUrl() + imageMin_);
  expandIcon_->setStyleClass("Wt-ctrl Wt-expand");
  noExpandIcon_ = new WText();
  noExpandIcon_->setStyleClass("Wt-ctrl Wt-noexpand");
  layout_->bindWidget("expand", noExpandIcon_);
  addStyleClass("Wt-trunk");

  /*
   * Label
   */
  layout_->bindWidget("label-area", new WContainerWidget());

  if (labelText_)
    labelText_->setStyleClass("Wt-label");

  childCountLabel_ = 0;

  if (labelIcon_) {
    labelArea()->addWidget(labelIcon_);
    labelIcon_->setVerticalAlignment(AlignMiddle);
  }

  if (labelText_)
    labelArea()->addWidget(labelText_);

  childrenLoaded_ = false;

  setLoadPolicy(LazyLoading);
}