WWidget *RegistrationWidget::createFormWidget(WFormModel::Field field) { WFormWidget *result = 0; if (field == RegistrationModel::LoginNameField) { result = new WLineEdit(); result->changed().connect (boost::bind(&RegistrationWidget::checkLoginName, this)); } else if (field == RegistrationModel::EmailField) { result = new WLineEdit(); } else if (field == RegistrationModel::ChoosePasswordField) { WLineEdit *p = new WLineEdit(); p->setEchoMode(WLineEdit::Password); p->keyWentUp().connect (boost::bind(&RegistrationWidget::checkPassword, this)); p->changed().connect (boost::bind(&RegistrationWidget::checkPassword, this)); result = p; } else if (field == RegistrationModel::RepeatPasswordField) { WLineEdit *p = new WLineEdit(); p->setEchoMode(WLineEdit::Password); p->changed().connect (boost::bind(&RegistrationWidget::checkPassword2, this)); result = p; } return result; }
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; }
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; }
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); }
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(); }