示例#1
0
  void handleFinish(DialogCode result)
  {
    if (result == WDialog::Accepted) {
      /*
       * Update the model with data from the edit widgets.
       *
       * You will want to do some validation here...
       *
       * Note that we directly update the source model to avoid
       * problems caused by the dynamic sorting of the proxy model,
       * which reorders row numbers, and would cause us to switch to editing
       * the wrong data.
       */
      WAbstractItemModel *m = model_;
      int modelRow = item_.row();

      WAbstractProxyModel *proxyModel = dynamic_cast<WAbstractProxyModel *>(m);
      if (proxyModel) {
	m = proxyModel->sourceModel();
	modelRow = proxyModel->mapToSource(item_).row();
      }

      m->setData(modelRow, 1, boost::any(nameEdit_->text()));
      m->setData(modelRow, 2, boost::any(typeEdit_->currentText()));
      m->setData(modelRow, 3, boost::any(boost::lexical_cast<int>
					 (sizeEdit_->text().toUTF8())));
      m->setData(modelRow, 4, boost::any(createdPicker_->date()));
      m->setData(modelRow, 5, boost::any(modifiedPicker_->date()));
    }

    delete this;
  }
示例#2
0
void HelloApplication::run_alg()
{
    sim_params params;
    params.pop_size = WLocale::currentLocale().toInt(pop_size_edit->text());
    params.num_epochs = WLocale::currentLocale().toInt(num_epochs_edit->text());

    enableUpdates(true);	// TODO: Right place? And where to disable?
    ga_thread.swap(boost::shared_ptr< boost::thread >(new boost::thread(run_fn, this, db_cp, params)));//sessionId())));
}
示例#3
0
void MyApp::enterdata()
{
{
    dbo::Transaction transaction(session);
   
    Ball *blog = new Ball();
    blog->username = usernameedit->text().toUTF8();
    blog->password = passwordedit->text().toUTF8();

    dbo::ptr<Ball> blogPtr = session.add(blog); 

   transaction.commit();
  }}
示例#4
0
  /*! \brief Change repository and/or revision
   */
  void loadGitModel() {
    sourceView_->setIndex(WModelIndex());
    repositoryError_->setText("");
    revisionError_->setText("");
    try {
      gitModel_->setRepositoryPath(repositoryEdit_->text().toUTF8());
      try {
	gitModel_->loadRevision(revisionEdit_->text().toUTF8());
      } catch (const Git::Exception& e) {
	revisionError_->setText(e.what());
      }
    } catch (const Git::Exception& e) {
      repositoryError_->setText(e.what());
    }
  }
示例#5
0
void HelloApplication::greet()
{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}
示例#6
0
void DensityApp::reportEdit() {
    cmd_ = codeEdit_->text().toUTF8();	// get text written in box, as UTF-8, assigned to string
    std::string rng = "y <- " + cmd_ + ";";
    R_.parseEvalQ(rng);			// evaluates expression, assigns to 'y'
    Yvec_ = R_["y"];			// cache the y vector
    plot();
}
示例#7
0
boost::any WItemDelegate::editState(WWidget *editor) const
{
  WContainerWidget *w = dynamic_cast<WContainerWidget *>(editor);
  WLineEdit *lineEdit = dynamic_cast<WLineEdit *>(w->widget(0));

  return boost::any(lineEdit->text());
}
示例#8
0
文件: lesson11.cpp 项目: ReWeb3D/wt
void WebGLDemo::eventKeyWentUp(const WKeyEvent& event){
    lightColor.assign(getVal(lightColR->text().toUTF8()),
                      getVal(lightColG->text().toUTF8()),
                      getVal(lightColB->text().toUTF8()) );
    lightDirection.assign(getVal(lightDirX->text().toUTF8()),
                          getVal(lightDirY->text().toUTF8()),
                          getVal(lightDirZ->text().toUTF8()) );
    ambientColor.assign(getVal(ambLightColR->text().toUTF8()),
                        getVal(ambLightColG->text().toUTF8()),
                        getVal(ambLightColB->text().toUTF8()) );

    drawGLWidget_->updateLights(ambientColor,lightDirection,lightColor);
    drawGLWidget_->repaintGL(DrawGLWidget::PAINT_GL);

}
示例#9
0
void AdsEditor::novoAnuncio() {
  AdsApplication *app = AdsApplication::adsApplication();
  cppdb::session &db = app->db_;
    
  Wt::WDialog dialog("novo Anuncio");
  Wt::WPushButton *ok = new WPushButton("Ok");
  ok->setStyleClass("btn btn-primary");
  ok->clicked().connect(&dialog, &Wt::WDialog::accept);
  Wt::WPushButton *cancel = new WPushButton("Cancela");
  cancel->setStyleClass("btn");
  cancel->clicked().connect(&dialog, &Wt::WDialog::reject);

  WLineEdit *lTitulo = new WLineEdit();
  WLineEdit *lURL = new WLineEdit();
  WLineEdit *lTexto = new WLineEdit();

  WTemplate *t = new WTemplate(dialog.contents());
  t->setTemplateText("<form>"
		     " <fieldset>"
		     "  <legend>Dados do anuncio</legend>"
		     "  <table border=0>"
		     "   <tr><td>Titulo</td> <td>${titulo}</td></tr>"
		     "   <tr><td>URL</td>    <td>${url}</td></tr>"
		     "   <tr><td>Texto</td>  <td>${texto}</td></tr>"
		     "  </table>"
		     "  </fieldset>"
		     "  ${ok}${cancel}"			       
		     "</form>"
		     , XHTMLUnsafeText);
  t->bindWidget("titulo", lTitulo);
  t->bindWidget("url", lURL);
  t->bindWidget("texto", lTexto);
  t->bindWidget("ok", ok);
  t->bindWidget("cancel", cancel);
  if (dialog.exec() == Wt::WDialog::Accepted) {
    db << "insert into anuncio (id, titulo, url, texto, imagem) values "
      "(NULL, ?,?,?, '/img/cabure.png')" 
       << lTitulo->text().narrow() << lURL->text().narrow()
       << lTexto->text().narrow() << cppdb::exec;
  }
  renderUI();
}
示例#10
0
文件: Tabs.C 项目: DTidd/wt
ChartSettings::ChartSettings(WCartesian3DChart *chart,
			     WContainerWidget * parent)
  : WContainerWidget(parent),
    chart_(chart)
{
  WTemplate* template_ = new WTemplate(Wt::WString::tr("chartconfig-template"), this);

  WCheckBox *autoRangeX_ = new WCheckBox(this);
  template_->bindWidget("xAuto", autoRangeX_);
  autoRangeX_->setCheckState(Wt::Checked);
  chart_->initLayout();
  WLineEdit *xMin_ = new WLineEdit
    (Wt::asString(chart_->axis(XAxis_3D).minimum()), this);
  template_->bindWidget("xAxisMin", xMin_);
  xMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  xMin_->setEnabled(false);
  WLineEdit *xMax_ = new WLineEdit
    (Wt::asString(chart_->axis(XAxis_3D).maximum()), this);
  template_->bindWidget("xAxisMax", xMax_);
  xMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  xMax_->setEnabled(false);

  WCheckBox *autoRangeY_ = new WCheckBox(this);
  template_->bindWidget("yAuto", autoRangeY_);
  autoRangeY_->setCheckState(Wt::Checked);
  WLineEdit *yMin_ = new WLineEdit
    (Wt::asString(chart_->axis(YAxis_3D).minimum()), this);
  template_->bindWidget("yAxisMin", yMin_);
  yMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  yMin_->setEnabled(false);
  WLineEdit *yMax_ = new WLineEdit
    (Wt::asString(chart_->axis(YAxis_3D).maximum()), this);
  template_->bindWidget("yAxisMax", yMax_);
  yMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  yMax_->setEnabled(false);

  WCheckBox *autoRangeZ_ = new WCheckBox(this);
  template_->bindWidget("zAuto", autoRangeZ_);
  autoRangeZ_->setCheckState(Wt::Checked);
  WLineEdit *zMin_ = new WLineEdit
    (Wt::asString(chart_->axis(ZAxis_3D).minimum()), this);
  template_->bindWidget("zAxisMin", zMin_);
  zMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  zMin_->setEnabled(false);
  WLineEdit *zMax_ = new WLineEdit
    (Wt::asString(chart_->axis(ZAxis_3D).maximum()), this);
  template_->bindWidget("zAxisMax", zMax_);
  zMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
  zMax_->setEnabled(false);

  WLineEdit *title = new WLineEdit(this);
  template_->bindWidget("chartTitle", title);
  WCheckBox *enableLegend = new WCheckBox(this);
  template_->bindWidget("chartLegend", enableLegend);
  WComboBox *legendSide = new WComboBox(this);
  legendSide->addItem("Left");
  legendSide->addItem("Right");
  legendSide->addItem("Top");
  legendSide->addItem("Bottom");
  template_->bindWidget("legendside", legendSide);
  switch (chart_->legendSide()) {
  case Left:
    legendSide->setCurrentIndex(0); break;
  case Right:
    legendSide->setCurrentIndex(1); break;
  case Top:
    legendSide->setCurrentIndex(2); break;
  case Bottom:
    legendSide->setCurrentIndex(3); break;
  default:
    break;
  }
  WComboBox *legendAlignment = new WComboBox(this);
  legendAlignment->addItem("Left");
  legendAlignment->addItem("Center");
  legendAlignment->addItem("Right");
  legendAlignment->addItem("Top");
  legendAlignment->addItem("Middle");
  legendAlignment->addItem("Bottom");
  template_->bindWidget("legendalignment", legendAlignment);
  switch (chart_->legendAlignment()) {
  case AlignLeft:
    legendAlignment->setCurrentIndex(0); break;
  case AlignCenter:
    legendAlignment->setCurrentIndex(1); break;
  case AlignRight:
    legendAlignment->setCurrentIndex(2); break;
  case AlignTop:
    legendAlignment->setCurrentIndex(3); break;
  case AlignMiddle:
    legendAlignment->setCurrentIndex(4); break;
  case AlignBottom:
    legendAlignment->setCurrentIndex(5); break;
  default:
    break;
  }
  WCheckBox *enableGridLines = new WCheckBox(this);
  template_->bindWidget("gridlines", enableGridLines);
  WLineEdit *widgetWidth = new WLineEdit(Wt::asString(chart_->width().value()), this);
  widgetWidth->setValidator(new Wt::WIntValidator(1, 2000));
  WLineEdit *widgetHeight = new WLineEdit(Wt::asString(chart_->height().value()), this);
  widgetHeight->setValidator(new Wt::WIntValidator(1, 2000));
  template_->bindWidget("width", widgetWidth);
  template_->bindWidget("height", widgetHeight);

  WLineEdit *xAxisTitle = new WLineEdit(chart_->axis(XAxis_3D).title(), this);
  WLineEdit *yAxisTitle = new WLineEdit(chart_->axis(YAxis_3D).title(), this);
  WLineEdit *zAxisTitle = new WLineEdit(chart_->axis(ZAxis_3D).title(), this);
  template_->bindWidget("xTitle", xAxisTitle);
  template_->bindWidget("yTitle", yAxisTitle);
  template_->bindWidget("zTitle", zAxisTitle);
    

  // hook it up
  autoRangeX_->checked().connect(std::bind([=] () {
	chart_->axis(XAxis_3D).setAutoLimits(Chart::MinimumValue 
					     | Chart::MaximumValue);
	xMin_->setEnabled(false); xMax_->setEnabled(false);
      }));
  autoRangeX_->unChecked().connect(std::bind([=] () {
	xMin_->setEnabled(true); xMax_->setEnabled(true);
	chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()),
					Wt::asNumber(xMax_->text()));
      }));
  autoRangeY_->checked().connect(std::bind([=] () {
	chart_->axis(YAxis_3D).setAutoLimits(Chart::MinimumValue 
					     | Chart::MaximumValue);
	yMin_->setEnabled(false); yMax_->setEnabled(false);
      }));
  autoRangeY_->unChecked().connect(std::bind([=] () {
	yMin_->setEnabled(true); yMax_->setEnabled(true);
	chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()),
					  Wt::asNumber(yMax_->text()));
      }));
  autoRangeZ_->checked().connect(std::bind([=] () {
	chart_->axis(ZAxis_3D).setAutoLimits(Chart::MinimumValue 
					     | Chart::MaximumValue);
	zMin_->setEnabled(false); zMax_->setEnabled(false);
      }));
  autoRangeZ_->unChecked().connect(std::bind([=] () {
	zMin_->setEnabled(true); zMax_->setEnabled(true);
	chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()),
					Wt::asNumber(zMax_->text()));
      }));

  xMin_->changed().connect(std::bind([=] () {
	chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()),
					Wt::asNumber(xMax_->text()));
      }));
  xMax_->changed().connect(std::bind([=] () {
	chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()),
					Wt::asNumber(xMax_->text()));
      }));
  yMin_->changed().connect(std::bind([=] () {
	chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()),
					  Wt::asNumber(yMax_->text()));
      }));
  yMax_->changed().connect(std::bind([=] () {
	chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()),
					  Wt::asNumber(yMax_->text()));
      }));
  zMin_->changed().connect(std::bind([=] () {
	chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()),
					  Wt::asNumber(zMax_->text()));
      }));
  zMax_->changed().connect(std::bind([=] () {
	chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()),
					  Wt::asNumber(zMax_->text()));
      }));

  enableGridLines->checked().connect(std::bind([=]() {
	chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::XAxis_3D, true);
	chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::YAxis_3D, true);
	chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::XAxis_3D, true);
	chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::ZAxis_3D, true);
	chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::YAxis_3D, true);
	chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::ZAxis_3D, true);
      }));
  enableGridLines->unChecked().connect(std::bind([=]() {
	chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::XAxis_3D, false);
	chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::YAxis_3D, false);
	chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::XAxis_3D, false);
	chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::ZAxis_3D, false);
	chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::YAxis_3D, false);
	chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::ZAxis_3D, false);
      }));

  enableLegend->checked().connect(std::bind([=]() {
	chart_->setLegendEnabled(true);
      }));
  enableLegend->unChecked().connect(std::bind([=]() {
	chart_->setLegendEnabled(false);
      }));

  legendSide->changed().connect(std::bind([=]() {
	switch (legendSide->currentIndex()) {
	case 0:
	  chart_->setLegendLocation(Left, chart_->legendAlignment()); break;
	case 1:
	  chart_->setLegendLocation(Right, chart_->legendAlignment()); break;
	case 2:
	  chart_->setLegendLocation(Top, chart_->legendAlignment()); break;
	case 3:
	  chart_->setLegendLocation(Bottom, chart_->legendAlignment()); break;
	}
      }));
  legendAlignment->changed().connect(std::bind([=]() {
	switch (legendAlignment->currentIndex()) {
	case 0:
	  chart_->setLegendLocation(chart_->legendSide(), AlignLeft); break;
	case 1:
	  chart_->setLegendLocation(chart_->legendSide(), AlignCenter); break;
	case 2:
	  chart_->setLegendLocation(chart_->legendSide(), AlignRight); break;
	case 3:
	  chart_->setLegendLocation(chart_->legendSide(), AlignTop); break;
	case 4:
	  chart_->setLegendLocation(chart_->legendSide(), AlignMiddle); break;
	case 5:
	  chart_->setLegendLocation(chart_->legendSide(), AlignBottom); break;
	}
      }));

  title->changed().connect(std::bind([=] () {
	chart_->setTitle(Wt::asString(title->text()));
      }));

  widgetWidth->changed().connect(std::bind([=] () {
	chart_->resize(Wt::asNumber(widgetWidth->text()),
		       Wt::asNumber(widgetHeight->text()));
      }));
  widgetHeight->changed().connect(std::bind([=] () {
	chart_->resize(Wt::asNumber(widgetWidth->text()),
		       Wt::asNumber(widgetHeight->text()));
      }));

  xAxisTitle->changed().connect(std::bind([=]() {
	chart_->axis(XAxis_3D).setTitle(xAxisTitle->text());
      }));
  yAxisTitle->changed().connect(std::bind([=]() {
	chart_->axis(YAxis_3D).setTitle(yAxisTitle->text());
      }));
  zAxisTitle->changed().connect(std::bind([=]() {
	chart_->axis(ZAxis_3D).setTitle(zAxisTitle->text());
      }));
  
}
示例#11
0
void Example::set_pan_to() {
    double x = boost::lexical_cast<double>(edit_of_pan_to_lat_->text());
    double y = boost::lexical_cast<double>(edit_of_pan_to_lng_->text());
    mv_->pan_to(Coordinate(x, y));
}
示例#12
0
void Example::set_zoom_to() {
    mv_->zoom_to(boost::lexical_cast<int>(edit_of_zoom_to_->text()));
}