WPaintedWidget::WPaintedWidget(WContainerWidget *parent)
  : WInteractWidget(parent),
    preferredMethod_(HtmlCanvas),
    painter_(0),
    needRepaint_(false),
    sizeChanged_(false),
    areaImageAdded_(false),
    repaintFlags_(0),
    areaImage_(0),
    renderWidth_(0), renderHeight_(0)
{
  if (WApplication::instance()) {
    const WEnvironment& env = WApplication::instance()->environment();

    if (env.agentIsOpera()
	&& env.userAgent().find("Mac OS X") == std::string::npos)
      preferredMethod_ = InlineSvgVml;
  }

  setLayoutSizeAware(true);
  setJavaScriptMember(WT_RESIZE_JS,
		      "function(self, w, h) {"
		      """var u = $(self).find('canvas, img');"
		      """if (w >= 0) "
		      ""  "u.width(w);"
		      """if (h >= 0) "
		      ""  "u.height(h);"
		      "}");
  setInline(false);
}
Exemple #2
0
void WSlider::render(WFlags<RenderFlag> flags)
{
  /*
   * In theory we are a bit late here to decide what we want to become:
   * somebody could already have asked the domElementType()
   */
  if (flags.test(RenderFlag::Full)) {
    bool useNative = nativeControl();

    if (!useNative) {
      if (!paintedSlider_) {
	manageWidget
	  (paintedSlider_,
	   std::unique_ptr<PaintedSlider>(new PaintedSlider(this)));
	paintedSlider_->sliderResized(width(), height());
      }
    } else {
      manageWidget(paintedSlider_, std::unique_ptr<PaintedSlider>());
    }

    setLayoutSizeAware(!useNative);
    setFormObject(useNative);
  }

  WFormWidget::render(flags);
}
Exemple #3
0
void WSlider::render(WFlags<RenderFlag> flags)
{
  /*
   * In theory we are a bit late here to decide what we want to become:
   * somebody could already have asked the domElementType()
   */
  if (flags & RenderFull) {
    bool useNative = nativeControl();

    if (!useNative) {
      if (!paintedSlider_) {
	addChild(paintedSlider_ = new PaintedSlider(this));
	paintedSlider_->sliderResized(width(), height());
      }
    } else {
      delete paintedSlider_;
      paintedSlider_ = 0;
    }

    setLayoutSizeAware(!useNative);
    setFormObject(useNative);
  }

  WFormWidget::render(flags);
}
Exemple #4
0
void WPaintedWidget::resize(const WLength& width, const WLength& height)
{
  if (!width.isAuto() && !height.isAuto()) {
    setLayoutSizeAware(false);
    resizeCanvas(static_cast<int>(width.toPixels()),
		 static_cast<int>(height.toPixels()));
  }

  WInteractWidget::resize(width, height);
}
ProfileList::ProfileList(Ptr<org::esb::core::PluginContext> ctx,WContainerWidget *parent):Wt::WContainerWidget(parent),_ctx(ctx)
{
  //Wt::WHBoxLayout *hbox = new Wt::WHBoxLayout();
  //setLayout(hbox);
  LOGDEBUG("Height:"<<this->height().value());

  Wt::WToolBar *toolBar = new Wt::WToolBar(this);
  Wt::WPushButton * createButton;
  toolBar->addButton(createButton=new Wt::WPushButton("Create"));
  createButton->clicked().connect(this, &ProfileList::createNewProfile);
  /*
  toolBar->addButton(new Wt::WPushButton("Stop"));
  toolBar->addButton(new Wt::WPushButton("Pause"));
  */

  tableView = new Wt::WTableView(this);
  tableView->setModel(new ProfileTableModel(ctx->database, tableView));
  //tableView->setModel(new VirtualModel(10000, 50, tableView));

  tableView->setColumnResizeEnabled(true);
  tableView->setColumnAlignment(0, Wt::AlignCenter);
  tableView->setSortingEnabled(false);
  tableView->setHeaderAlignment(0, Wt::AlignCenter);
  tableView->setAlternatingRowColors(true);
  tableView->setRowHeight(28);
  tableView->setHeaderHeight(28);

  tableView->setSelectionMode(Wt::SingleSelection);
  tableView->setEditTriggers(Wt::WAbstractItemView::NoEditTrigger);

  //hbox->addWidget(tableView,0);
  //hbox->addWidget(new Wt::WText("Item 2"),1);
  /*
   * Configure column widths and matching table width
   */
  const int WIDTH = 120;
  for (int i = 0; i < tableView->model()->columnCount(); ++i)
    tableView->setColumnWidth(i, 420);

  setLayoutSizeAware(true);
  //this->setHeight(300);
  //tableView->setHeight(300);
  tableView->resize(Wt::WLength::Auto,400);
  //this->addWidget(tableView);
  /*
   * 7 pixels are padding/border per column
   * 2 pixels are border of the entire table
   */
  //tableView->setWidth((WIDTH + 7) * tableView->model()->columnCount() + 2);


  tableView->doubleClicked().connect(this,&ProfileList::doubleClicked);

}
void ProfileList::layoutSizeChanged(int width, int height){
  LOGDEBUG("profile layoutSizeChanged w:"<<width<<" h:"<<height);
  setLayoutSizeAware(false);
  tableView->setHeight(height);
  setLayoutSizeAware(true);
}
Exemple #7
0
DomElement *WPaintedWidget::createDomElement(WApplication *app)
{
  if (isInLayout()) {
    setLayoutSizeAware(true);
    setJavaScriptMember(WT_RESIZE_JS,
			"function(self, w, h) {"
			"""var u = $(self).find('canvas, img');"
			"""if (w >= 0) "
			""  "u.width(w);"
			"""if (h >= 0) "
			""  "u.height(h);"
			"}");
  }

  createPainter();

  DomElement *result = DomElement::createNew(domElementType());
  setId(result, app);

  DomElement *wrap = result;

  if (width().isAuto() && height().isAuto()) {
    result->setProperty(PropertyStylePosition, "relative");

    wrap = DomElement::createNew(DomElement_DIV);
    wrap->setProperty(PropertyStylePosition, "absolute");
    wrap->setProperty(PropertyStyleLeft, "0");
    wrap->setProperty(PropertyStyleRight, "0");
  }

  DomElement *canvas = DomElement::createNew(DomElement_DIV);

  if (!app->environment().agentIsSpiderBot())
    canvas->setId('p' + id());

  WPaintDevice *device = painter_->getPaintDevice(false);

  //handle the widget correctly when inline and using VML 
  if (painter_->renderType() == WWidgetPainter::InlineVml && isInline()) {
    result->setProperty(PropertyStyle, "zoom: 1;");
    canvas->setProperty(PropertyStyleDisplay, "inline");
    canvas->setProperty(PropertyStyle, "zoom: 1;");
  }

  if (renderWidth_ != 0 && renderHeight_ != 0) {
    paintEvent(device);

#ifdef WT_TARGET_JAVA
    if (device->painter())
      device->painter()->end();
#endif // WT_TARGET_JAVA
  }

  painter_->createContents(canvas, device);

  needRepaint_ = false;

  wrap->addChild(canvas);
  if (wrap != result)
    result->addChild(wrap);

  updateDom(*result, true);

  return result;
}