Пример #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
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());
}
Пример #3
0
void WItemDelegate::setEditState(WWidget *editor, const boost::any& value) const
{
  WContainerWidget *w = dynamic_cast<WContainerWidget *>(editor);
  WLineEdit *lineEdit = dynamic_cast<WLineEdit *>(w->widget(0));

  lineEdit->setText(boost::any_cast<WT_USTRING>(value));
}
Пример #4
0
WWidget *FormWidgets::wSuggestionPopup()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WSuggestionPopup", result);
  addText(tr("formwidgets-WSuggestionPopup"), result);

  // options for email address suggestions
  WSuggestionPopup::Options contactOptions;
  contactOptions.highlightBeginTag = "<span class=\"highlight\">";
  contactOptions.highlightEndTag = "</span>";
  contactOptions.listSeparator = ',';
  contactOptions.whitespace = " \\n";
  contactOptions.wordSeparators = "-., \"@\\n;";
  contactOptions.appendReplacedText = ", ";

  WSuggestionPopup *sp =
    new WSuggestionPopup(WSuggestionPopup::generateMatcherJS(contactOptions),
			 WSuggestionPopup::generateReplacerJS(contactOptions),
			 result);
  WLineEdit *le = new WLineEdit(result);
  le->setTextSize(50);
  le->setInline(false);
  sp->forEdit(le);
  sp->addSuggestion("John Tech <*****@*****.**>",
		    "John Tech <*****@*****.**>");
  sp->addSuggestion("Johnny Cash <*****@*****.**>", 
		    "Johnny Cash <*****@*****.**>");
  sp->addSuggestion("John Rambo <*****@*****.**>",
		    "John Rambo <*****@*****.**>");
  sp->addSuggestion("Johanna Tree <*****@*****.**>",
		    "Johanna Tree <*****@*****.**>");

  return result;
}
Пример #5
0
 GravatarApp(const WEnvironment& env):
     WApplication(env) {
     GravatarImage* gravatar = new GravatarImage("*****@*****.**", root());
     new WBreak(root());
     WLineEdit* email = new WLineEdit(root());
     email->changed().connect(boost::bind(set_email, gravatar, email));
     email->setText("*****@*****.**");
     new WBreak(root());
     WSlider* size = new WSlider(root());
     size->setRange(1, 512);
     size->setValue(80);
     size->valueChanged().connect(boost::bind(set_size, gravatar, size));
     new WBreak(root());
     WButtonGroup* builtin = new WButtonGroup(this);
     builtin->addButton(new WRadioButton("default", root()),
                        GravatarImage::DEFAULT);
     builtin->addButton(new WRadioButton("404", root()),
                        GravatarImage::RETURN_404);
     builtin->addButton(new WRadioButton("mm", root()),
                        GravatarImage::MM);
     builtin->addButton(new WRadioButton("identicon", root()),
                        GravatarImage::IDENTICON);
     builtin->addButton(new WRadioButton("monsterid", root()),
                        GravatarImage::MONSTERID);
     builtin->addButton(new WRadioButton("wavatar", root()),
                        GravatarImage::WAVATAR);
     builtin->addButton(new WRadioButton("retro", root()),
                        GravatarImage::RETRO);
     builtin->addButton(new WRadioButton("custom url", root()),
                        9000);
     WLineEdit* custom_url = new WLineEdit(root());
     custom_url->setText("https://www.google.com/favicon.ico");
     builtin->setCheckedButton(builtin->button(GravatarImage::DEFAULT));
     builtin->checkedChanged().connect(boost::bind(set_default,
                                       gravatar, builtin, custom_url));
     new WBreak(root());
     WButtonGroup* rating = new WButtonGroup(this);
     rating->addButton(new WRadioButton("G", root()), GravatarImage::G);
     rating->addButton(new WRadioButton("PG", root()), GravatarImage::PG);
     rating->addButton(new WRadioButton("R", root()), GravatarImage::R);
     rating->addButton(new WRadioButton("X", root()), GravatarImage::X);
     rating->setCheckedButton(rating->button(GravatarImage::G));
     rating->checkedChanged().connect(boost::bind(set_rating,
                                      gravatar, rating));
     new WBreak(root());
     WCheckBox* fd = new WCheckBox("Force default", root());
     fd->checked().connect(boost::bind(&GravatarImage::set_force_default,
                                       gravatar, true));
     fd->unChecked().connect(boost::bind(&GravatarImage::set_force_default,
                                         gravatar, false));
     new WBreak(root());
     WCheckBox* sr = new WCheckBox("Use https", root());
     sr->setTristate();
     sr->setCheckState(PartiallyChecked);
     sr->checked().connect(boost::bind(&GravatarImage::set_secure_requests,
                                       gravatar, GravatarImage::ALWAYS));
     sr->unChecked().connect(boost::bind(&GravatarImage::set_secure_requests,
                                         gravatar, GravatarImage::NEVER));
 }
Пример #6
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())));
}
Пример #7
0
WLineEdit *StyleExample::createColorLineEdit(int value)
{
  WLineEdit *le = new WLineEdit(boost::lexical_cast<std::wstring>(value),
				this);
  le->setTextSize(3);
  le->setValidator(new WIntValidator(0, 255));

  return le;
}
Пример #8
0
WWidget *EventsDemo::wKeyEvent()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WKeyEvent", result);
  addText(tr("events-WKeyEvent-1"), result);
  WLineEdit *l = new WLineEdit(result);
  l->setTextSize(50);
  l->keyWentUp().connect(this, &EventsDemo::showKeyWentUp);
  l->keyWentDown().connect(this, &EventsDemo::showKeyWentDown);
  
  addText(tr("events-WKeyEvent-2"), result);
  l = new WLineEdit(result);
  l->setTextSize(50);
  l->keyPressed().connect(this, &EventsDemo::showKeyPressed);
  
  addText(tr("events-WKeyEvent-3"), result);
  l = new WLineEdit(result);
  l->setTextSize(50);
  l->enterPressed().connect(this, &EventsDemo::showEnterPressed);
  l->escapePressed().connect(this, &EventsDemo::showEscapePressed);
  new WBreak(result);
  addText("Last event: ", result);
  keyEventType_ = new WText(result);
  new WBreak(result);
  keyEventDescription_ = new WText(result);

  return result;
}
Пример #9
0
WFormWidget *UpdatePasswordWidget::createFormWidget(WFormModel::Field field)
{
  WFormWidget *result = 0;

  if (field == RegistrationModel::LoginNameField) {
    result = new WLineEdit();
  } else if (field == AuthModel::PasswordField) {
    WLineEdit *p = new WLineEdit();
    p->setEchoMode(WLineEdit::Password);
    result = p;
  } else if (field == RegistrationModel::ChoosePasswordField) {
    WLineEdit *p = new WLineEdit();
    p->setEchoMode(WLineEdit::Password);
    p->keyWentUp().connect
      (boost::bind(&UpdatePasswordWidget::checkPassword, this));
    p->changed().connect
      (boost::bind(&UpdatePasswordWidget::checkPassword, this));
    result = p;
  } else if (field == RegistrationModel::RepeatPasswordField) {
    WLineEdit *p = new WLineEdit();
    p->setEchoMode(WLineEdit::Password);
    p->changed().connect
      (boost::bind(&UpdatePasswordWidget::checkPassword2, this));
    result = p;
  }

  return result;
}
Пример #10
0
/*void BasePage::addAuthor(){
	WContainerWidget *container1 = new WContainerWidget();
	Wt::WTemplate *r = new Wt::WTemplate(Wt::WString::tr("addAuthorForm"));
	
	WLineEdit *editName = new WLineEdit(container1);
	editName->setPlaceholderText("name");
	r->bindWidget("name", editName);
	
	WLineEdit *editYears = new WLineEdit(container1);
	editYears->setPlaceholderText("years");
	r->bindWidget("years", editYears);
				  
	WPushButton *button = new WPushButton("Add author", container1);
	button->setMargin(10, Top | Bottom);
				  
	button->clicked().connect(std::bind([=] () {BookManager am; am.addAuthor("123","2016"); }));
				  
	r->bindWidget("button", button);
	_pagecontent->addWidget(r);
}*/
void BasePage::addMark(const Dbo::collection<Dbo::ptr<Book> >& listaddmark){	
	WTable *table = new WTable();
	table->setHeaderCount(1);
	table->setStyleClass("tablestyle");
	table->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>"));
	table->elementAt(0, 1)->addWidget(new WText("<p align='left'> Title of book </p>"));
	table->elementAt(0, 2)->addWidget(new WText("<p align='left'> Author </p>"));
	table->elementAt(0, 3)->addWidget(new WText("<p align='left'> Genre </p>"));
	table->elementAt(0, 4)->addWidget(new WText("<p align='left'> Add your mark </p>"));
	_pagecontent->addWidget(table);
	int row=1;
		for (Dbo::collection<Dbo::ptr<Book> >::const_iterator i = listaddmark.begin(); i != listaddmark.end(); ++i){
			Dbo::ptr<Book> book = *i;
			table->setStyleClass("tablestyle th,td,tr");
			//headers
			table->elementAt(row, 0)
			->addWidget(new WText(WString::fromUTF8("{1}")
					  .arg(row)));
			//titles
			table->elementAt(row, 1)
			->addWidget(new WText(WString::fromUTF8("{1}")
				      .arg(book.get()->title)));
			//authors
			table->elementAt(row, 2)
			->addWidget(new WText(WString::fromUTF8("{1}")
				      .arg((book.get()->author.get()->name))));
			//genres
			table->elementAt(row, 3)
			->addWidget(new WText(WString::fromUTF8("{1}")
				      .arg((book.get()->genre.get()->genre))));
			//add mark
			WLineEdit *editAddMark = new WLineEdit(table->elementAt(row,4));
			editAddMark->setPlaceholderText("Add mark");
			table->elementAt(row, 4)
			->addWidget(editAddMark);
			table->elementAt(row, 4)
			->addWidget(new WText("<br></br>"));
			WPushButton *button = new WPushButton("Add mark", table->elementAt(row,4));
			button->setMargin(10, Top | Bottom);
			table->elementAt(row, 4)
			->addWidget(button);
			/*button->clicked().connect(std::bind([] ( Dbo::ptr<Book> book) {
						BookManager bm;
						std::cout<<book.get()->title; 
						int curMark=book.get()->mark; 
						int curNumMarks=book.get()->numMarks; 	
						bm.refreshRate(book.get()->id, curMark+5, curNumMarks+1, session);												
			},*i ));*/
			row++;
			_pagecontent->addWidget(table);	
		}
}
Пример #11
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();
  }}
Пример #12
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());
    }
  }
Пример #13
0
void HelloApplication::greet()
{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}
Пример #14
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();
}
Пример #15
0
WWidget *WItemDelegate::createEditor(const WModelIndex& index,
				     WFlags<ViewItemRenderFlag> flags) const
{
  IndexContainerWidget *const result =
      new IndexContainerWidget(index);
  result->setSelectable(true);

  WLineEdit *lineEdit = new WLineEdit();
  lineEdit->setText(asString(index.data(EditRole), textFormat_));
  lineEdit->enterPressed().connect
    (boost::bind(&WItemDelegate::doCloseEditor, this, result, true));
  lineEdit->escapePressed().connect
    (boost::bind(&WItemDelegate::doCloseEditor, this, result, false));
  lineEdit->escapePressed().preventPropagation();

  if (flags & RenderFocused)
    lineEdit->setFocus(true);

  // We use a layout so that the line edit fills the entire cell.
  // Somehow, this does not work with konqueror, but it does respond
  // properly to width, height being set to 100% !
  WApplication *app = WApplication::instance();
  if (app->environment().agent() != WEnvironment::Konqueror) {
    result->setLayout(new WHBoxLayout());
    result->layout()->setContentsMargins(1, 1, 1, 1);
    result->layout()->addWidget(lineEdit);
  } else {
    lineEdit->resize(WLength(100, WLength::Percentage),
		     WLength(100, WLength::Percentage));
    result->addWidget(lineEdit);
  }

  return result;
}
Пример #16
0
WFormWidget *AuthWidget::createFormWidget(WFormModel::Field field)
{
  WFormWidget *result = 0;

  if (field == AuthModel::LoginNameField) {
    result = new WLineEdit();
    result->setFocus();
  } else if (field == AuthModel::PasswordField) {
    WLineEdit *p = new WLineEdit();
    p->enterPressed().connect(this, &AuthWidget::attemptPasswordLogin);
    p->setEchoMode(WLineEdit::Password);
    result = p;
  } else if (field == AuthModel::RememberMeField) {
    result = new WCheckBox();
  }

  return result;
}
Пример #17
0
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);

}
Пример #18
0
PasswordPromptDialog::PasswordPromptDialog(Login& login, AuthModel *model)
  : WDialog(tr("Wt.Auth.enter-password")),
    login_(login),
    model_(model)
{
  impl_ = new WTemplateFormView(tr("Wt.Auth.template.password-prompt"));

  model_->setValue(AuthModel::LoginNameField,
		   login_.user().identity(Identity::LoginName));
  model_->setReadOnly(AuthModel::LoginNameField, true);

  WLineEdit *nameEdit = new WLineEdit();
  impl_->bindWidget(AuthModel::LoginNameField, nameEdit);
  impl_->updateViewField(model_, AuthModel::LoginNameField);

  WLineEdit *passwordEdit = new WLineEdit();
  passwordEdit->setEchoMode(WLineEdit::Password);
  passwordEdit->setFocus(true);
  impl_->bindWidget(AuthModel::PasswordField, passwordEdit);
  impl_->updateViewField(model_, AuthModel::PasswordField);

  WPushButton *okButton = new WPushButton(tr("Wt.WMessageBox.Ok"));
  WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel"));

  model_->configureThrottling(okButton);

  impl_->bindWidget("ok-button", okButton);
  impl_->bindWidget("cancel-button", cancelButton);

  okButton->clicked().connect(this, &PasswordPromptDialog::check);
  cancelButton->clicked().connect(this, &PasswordPromptDialog::reject);

  contents()->addWidget(impl_);

  if (!WApplication::instance()->environment().ajax()) {
    /*
     * try to center it better, we need to set the half width and
     * height as negative margins.
     */
     setMargin(WLength("-21em"), Left); // .Wt-form width
     setMargin(WLength("-200px"), Top); // ???
  }
}
Пример #19
0
PasswordPromptDialog::PasswordPromptDialog(Login& login,
					   const AbstractPasswordService& auth)
  : WDialog(tr("Wt.Auth.enter-password")),
    login_(login),
    auth_(auth)
{
  impl_ = new WTemplate(tr("Wt.Auth.template.password-prompt"));
  impl_->addFunction("id", &WTemplate::Functions::id);
  impl_->addFunction("tr", &WTemplate::Functions::tr);

  WLineEdit *nameEdit
    = new WLineEdit(login.user().identity(Identity::LoginName));
  nameEdit->disable();
  nameEdit->addStyleClass("Wt-disabled");

  passwordEdit_ = new WLineEdit();
  WText *passwdInfo = new WText();
  WPushButton *okButton = new WPushButton(tr("Wt.WMessageBox.Ok"));
  WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel"));

  enterPasswordFields_ = new EnterPasswordFields(auth, passwordEdit_,
						 passwdInfo, okButton, this);

  impl_->bindWidget("user-name", nameEdit);
  impl_->bindWidget("password", passwordEdit_);
  impl_->bindWidget("password-info", passwdInfo);
  impl_->bindWidget("ok-button", okButton);
  impl_->bindWidget("cancel-button", cancelButton);

  okButton->clicked().connect(this, &PasswordPromptDialog::check);
  cancelButton->clicked().connect(this, &PasswordPromptDialog::reject);

  contents()->addWidget(impl_);

  if (!WApplication::instance()->environment().ajax()) {
    /*
     * try to center it better, we need to set the half width and
     * height as negative margins.
     */
     setMargin("-21em", Left); // .Wt-form width
     setMargin("-200px", Top); // ???
  }
}
Пример #20
0
WWidget *FormWidgets::wLineEdit()
{
  WContainerWidget *result = new WContainerWidget();

  topic("WLineEdit", result);
  addText(tr("formwidgets-WLineEdit"), result);

  WLineEdit *le = new WLineEdit(result);
  le->setEmptyText("Edit me");
  ed_->showSignal(le->keyWentUp(), "Line edit key up event");

  addText("<p>The line edit on the following line reacts on the "
	    "enter button:</p>", result);

  le = new WLineEdit(result);
  ed_->showSignal(le->enterPressed(), "Line edit enter pressed event");

  addText(tr("formwidgets-WLineEdit-more"), result);

  return result;
}
Пример #21
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();
}
Пример #22
0
 // Statless slots
 void focusName() { edtName->setFocus(); }
Пример #23
0
void BasePage::addBook(){
	WContainerWidget *container = new WContainerWidget();
	Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("addBookForm"));
	
	WLineEdit *editTitle = new WLineEdit(container);
	editTitle->setPlaceholderText("title");
	t->bindWidget("title", editTitle);
	
	WLineEdit *editAuthor = new WLineEdit(container);
	editAuthor->setPlaceholderText("author");
	t->bindWidget("author", editAuthor);
	
	WLineEdit *editAuthorYears = new WLineEdit(container);
	editAuthorYears->setPlaceholderText("years of life");
	t->bindWidget("years", editAuthorYears);
	
	WLineEdit *editGenre = new WLineEdit(container);
	editGenre->setPlaceholderText("genre");
	t->bindWidget("genre", editGenre);
	
	WLineEdit *editYear = new WLineEdit(container);
	editYear->setPlaceholderText("year");
	t->bindWidget("year", editYear);
	
	WLineEdit *editSeria = new WLineEdit(container);
	editSeria->setPlaceholderText("seria");
	t->bindWidget("seria", editSeria);
	
	WLineEdit *editNumOfBooks = new WLineEdit(container);
	editNumOfBooks->setPlaceholderText("num of books");
	t->bindWidget("numOfBooks", editNumOfBooks);
	
	WLineEdit *editNumInSeria = new WLineEdit(container);
	editNumInSeria->setPlaceholderText("number in seria");
	t->bindWidget("numInSeria", editNumInSeria);
	
	WLineEdit *editMark = new WLineEdit(container);
	editMark->setPlaceholderText("mark");
	editMark->setValidator(new Wt::WIntValidator(1, 10));
	t->bindWidget("mark", editMark);
	
	WPushButton *button = new WPushButton("Add book", container);
	button->setMargin(10, Top | Bottom);

	button->clicked().connect(std::bind([=] () {BookManager bm; bm.addBook(editTitle->valueText().toUTF8(),
																		   editAuthor->valueText().toUTF8(),
																		   editAuthorYears->valueText().toUTF8(),
																		   editGenre->valueText().toUTF8(),
																		   intoInt(editYear),
																		   editSeria->valueText().toUTF8(),
																		   intoInt(editNumOfBooks),
																		   intoInt(editNumInSeria),
																		   intoInt(editMark)); }));
	
	t->bindWidget("button", button);
	_pagecontent->addWidget(t);	
}
Пример #24
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());
      }));
  
}
Пример #25
0
UpdatePasswordWidget::UpdatePasswordWidget(const User& user,
					   const AbstractPasswordService& auth,
					   Login& login,
					   bool promptPassword,
					   WContainerWidget *parent)
  : WTemplate(tr("Wt.Auth.template.update-password"), parent),
    user_(user),
    promptPassword_(promptPassword),
    validated_(false),
    enterPasswordFields_(0)
{
  addFunction("id", &WTemplate::Functions::id);
  addFunction("tr", &WTemplate::Functions::tr);

  WLineEdit *nameEdit = new WLineEdit(user.identity(Identity::LoginName));
  nameEdit->disable();
  nameEdit->addStyleClass("Wt-disabled");
  bindWidget("user-name", nameEdit);

  WPushButton *okButton = new WPushButton(tr("Wt.WMessageBox.Ok"));
  WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel"));

  if (promptPassword_) {
    setCondition("if:old-password", true);
    WLineEdit *oldPasswd = new WLineEdit();
    WText *oldPasswdInfo = new WText();

    enterPasswordFields_ = new EnterPasswordFields(auth,
						   oldPasswd, oldPasswdInfo,
						   okButton, this);

    oldPasswd->setFocus();

    bindWidget("old-password", oldPasswd);
    bindWidget("old-password-info", oldPasswdInfo);
  }

  WLineEdit *password = new WLineEdit();
  password->setEchoMode(WLineEdit::Password);
  password->keyWentUp().connect
    (boost::bind(&UpdatePasswordWidget::checkPassword, this));
  password->changed().connect
    (boost::bind(&UpdatePasswordWidget::checkPassword, this));

  WText *passwordInfo = new WText();

  WLineEdit *password2 = new WLineEdit();
  password2->setEchoMode(WLineEdit::Password);
  password2->changed().connect
    (boost::bind(&UpdatePasswordWidget::checkPassword2, this));

  WText *password2Info = new WText();

  bindWidget("choose-password", password);
  bindWidget("choose-password-info", passwordInfo);

  bindWidget("repeat-password", password2);
  bindWidget("repeat-password-info", password2Info);

  model_ = new RegistrationModel(auth.baseAuth(), *user.database(),
				 login, this);

  model_->addPasswordAuth(&auth);

  model_->setValue(RegistrationModel::LoginName,
		   user.identity(Identity::LoginName));
  model_->setValue(RegistrationModel::Email,
		   WT_USTRING::fromUTF8(user.email() + " "
					+ user.unverifiedEmail()));

  model_->validatePasswordsMatchJS(password, password2, password2Info);

  passwordInfo->setText(model_->validationResult
			(RegistrationModel::Password).message());
  password2Info->setText(model_->validationResult
			 (RegistrationModel::Password2).message());

  okButton->clicked().connect(this, &UpdatePasswordWidget::doUpdate);
  cancelButton->clicked().connect(this, &UpdatePasswordWidget::close);

  bindWidget("ok-button", okButton);
  bindWidget("cancel-button", cancelButton);

  if (!promptPassword_)
    password->setFocus();
}
Пример #26
0
void WebGLDemo::main(){


    glContainer_ = new WContainerWidget(root());
    glContainer_->resize(500, 500);
    glContainer_->setInline(false);

    root()->addWidget(new WBreak());
    root()->addWidget(new WText("Rotate with mouse and zoom with scroll"));
    root()->addWidget(new WBreak());

    root()->addWidget(new WText(" "));
    root()->addWidget(new WBreak());
    root()->addWidget(new WText("LIGHT DIRECTION"));
    root()->addWidget(new WBreak());
    root()->addWidget(new WText("X : "));
    lightDirX = new WLineEdit("-1.0",root());
    root()->addWidget(new WText(" Y : "));
    lightDirY = new WLineEdit("-1.0",root());
    root()->addWidget(new WText(" Z : "));
    lightDirZ = new WLineEdit("-1.0",root());

    root()->addWidget(new WBreak());
    root()->addWidget(new WText(" "));
    root()->addWidget(new WBreak());
    root()->addWidget(new WText("LIGHT COLOR"));
    root()->addWidget(new WBreak());

    root()->addWidget(new WText("R : "));
    lightColR = new WLineEdit("0.8",root());
    root()->addWidget(new WText(" G : "));
    lightColG = new WLineEdit("0.8",root());
    root()->addWidget(new WText(" B : "));
    lightColB = new WLineEdit("0.8",root());

    root()->addWidget(new WBreak());
    root()->addWidget(new WText(" "));
    root()->addWidget(new WBreak());
    root()->addWidget(new WText("AMBIENT LIGHT COLOR"));
    root()->addWidget(new WBreak());
    root()->addWidget(new WText("R : "));
    ambLightColR = new WLineEdit("0.2",root());
    root()->addWidget(new WText(" G : "));
    ambLightColG = new WLineEdit("0.2",root());
    root()->addWidget(new WText(" B : "));
    ambLightColB = new WLineEdit("0.2",root());




    lightDirX->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    lightDirY->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    lightDirZ->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);

    lightColR->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    lightColG->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    lightColB->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);

    ambLightColR->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    ambLightColG->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);
    ambLightColB->keyWentUp().connect(this,&WebGLDemo::eventKeyWentUp);

    updateShaders();

    this->globalKeyWentDown().connect(this,&WebGLDemo::eventKeyWentDown);

}
Пример #27
0
 void focusPass1() { edtPass1->setFocus(); }
Пример #28
0
UpdatePasswordWidget::UpdatePasswordWidget(const User& user,
					   RegistrationModel *registrationModel,
					   AuthModel *authModel,
					   WContainerWidget *parent)
  : WTemplateFormView(tr("Wt.Auth.template.update-password"), parent),
    user_(user),
    registrationModel_(registrationModel),
    authModel_(authModel)
{
  registrationModel_->setValue(RegistrationModel::LoginNameField,
			       user.identity(Identity::LoginName));
  registrationModel_->setReadOnly(RegistrationModel::LoginNameField, true);

  if (authModel_->baseAuth()->emailVerificationEnabled()) {
    /*
     * This is set in the model so that the password checker can take
     * into account whether the password is derived from the email
     * address.
     */
    registrationModel_->setValue(RegistrationModel::EmailField,
			 WT_USTRING::fromUTF8(user.email() + " "
					      + user.unverifiedEmail()));
    registrationModel_->setVisible(RegistrationModel::EmailField, false);
  }

  WPushButton *okButton = new WPushButton(tr("Wt.WMessageBox.Ok"));
  WPushButton *cancelButton = new WPushButton(tr("Wt.WMessageBox.Cancel"));

  if (authModel_) {
    authModel_->setValue(AuthModel::LoginNameField,
			 user.identity(Identity::LoginName));

    updateViewField(authModel_, AuthModel::PasswordField);

    authModel_->configureThrottling(okButton);

    WLineEdit *password = resolve<WLineEdit *>(AuthModel::PasswordField);
    password->setFocus();
  }

  updateView(registrationModel_);

  WLineEdit *password = resolve<WLineEdit *>
    (RegistrationModel::ChoosePasswordField);
  WLineEdit *password2 = resolve<WLineEdit *>
    (RegistrationModel::RepeatPasswordField);
  WText *password2Info = resolve<WText *>
    (RegistrationModel::RepeatPasswordField + std::string("-info"));

  registrationModel_->validatePasswordsMatchJS(password,
					       password2, password2Info);

  if (!authModel_)
    password->setFocus();

  okButton->clicked().connect(this, &UpdatePasswordWidget::doUpdate);
  cancelButton->clicked().connect(this, &UpdatePasswordWidget::close);

  bindWidget("ok-button", okButton);
  bindWidget("cancel-button", cancelButton);

}
Пример #29
0
 void focusPass2() { edtPass2->setFocus(); }
Пример #30
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));
}