DialogButtonBar(WDialog& dialog) : MoreAwesomeTemplate(dialog.contents()) { setTemplateText(tr("dialog-button-bar")); bindAndCreateWidget(_okBtn, "ok-btn", tr("ok-btn")); bindAndCreateWidget(_cancelBtn, "cancel-btn", tr("cancel-btn")); _okBtn->clicked().connect(&dialog, &WDialog::accept); _cancelBtn->clicked().connect(&dialog, &WDialog::reject); }
WApplication *createApplication(const WEnvironment& env) { WApplication *appl = new WApplication(env); new WText("<h1>Your mission</h1>", appl->root()); WText *secret = new WText("Your mission, Jim, should you accept, is to create solid " "web applications.", appl->root()); new WBreak(appl->root()); new WBreak(appl->root()); new WText("This program will quit in ", appl->root()); CountDownWidget *countdown = new CountDownWidget(10, 0, 1000, appl->root()); new WText(" seconds.", appl->root()); new WBreak(appl->root()); new WBreak(appl->root()); WPushButton *cancelButton = new WPushButton("Cancel!", appl->root()); WPushButton *quitButton = new WPushButton("Quit", appl->root()); quitButton->clicked().connect(appl, &WApplication::quit); countdown->done().connect(appl, &WApplication::quit); cancelButton->clicked().connect(countdown, &CountDownWidget::cancel); cancelButton->clicked().connect(cancelButton, &WFormWidget::disable); cancelButton->clicked().connect(secret, &WWidget::hide); return appl; }
WebGLDemo::WebGLDemo(const WEnvironment& env) : WApplication(env) { setTitle("WebGL Demo"); root()->addWidget(new WText("If your browser supports WebGL, you'll " "see a teapot below.<br/>Use your mouse to move around the teapot.<br/>" "Edit the shaders below the teapot to change how the teapot is rendered.")); root()->addWidget(new WBreak()); paintWidget_ = 0; glContainer_ = new WContainerWidget(root()); glContainer_->resize(500, 500); glContainer_->setInline(false); WPushButton *updateButton = new WPushButton("Update shaders", root()); updateButton->clicked().connect(this, &WebGLDemo::updateShaders); WPushButton *resetButton = new WPushButton("Reset shaders", root()); resetButton->clicked().connect(this, &WebGLDemo::resetShaders); WTabWidget *tabs = new WTabWidget(root()); fragmentShaderText_ = new WTextArea; fragmentShaderText_->resize(750, 250); tabs->addTab(fragmentShaderText_, "Fragment Shader"); WText *shaderInfo = new WText(root()); vertexShaderText_ = new WTextArea; vertexShaderText_->resize(750, 250); tabs->addTab(vertexShaderText_, "Vertex Shader"); resetShaders(); }
ChatApplication::ChatApplication(const WEnvironment& env, SimpleChatServer& server) : WApplication(env), server_(server), env_(env) { setTitle("Wt Chat"); useStyleSheet("chatapp.css"); messageResourceBundle().use(appRoot() + "simplechat"); javaScriptTest(); root()->addWidget(new WText(WString::tr("introduction"))); SimpleChatWidget *chatWidget = new SimpleChatWidget(server_, root()); chatWidget->setStyleClass("chat"); root()->addWidget(new WText(WString::tr("details"))); WPushButton *b = new WPushButton("I'm schizophrenic ...", root()); b->clicked().connect(b, &WPushButton::hide); b->clicked().connect(this, &ChatApplication::addChatWidget); }
TreeViewExample::TreeViewExample(WStandardItemModel *model, const WString& titleText) : model_(model) { belgium_ = model_->item(0, 0)->child(0, 0); new WText(titleText, this); /* * Now create the view */ WPanel *panel = new WPanel(this); panel->resize(600, 300); panel->setCentralWidget(treeView_ = new WTreeView()); if (!WApplication::instance()->environment().ajax()) treeView_->resize(WLength::Auto, 290); treeView_->setAlternatingRowColors(true); treeView_->setRowHeight(25); treeView_->setModel(model_); treeView_->setColumnWidth(1, WLength(100)); treeView_->setColumnAlignment(1, AlignCenter); treeView_->setColumnWidth(3, WLength(100)); treeView_->setColumnAlignment(3, AlignCenter); /* treeView_->setRowHeaderCount(1); treeView_->setColumnWidth(0, 300); */ /* * Expand the first (and single) top level node */ treeView_->setExpanded(model->index(0, 0), true); treeView_->setExpanded(model->index(0, 0, model->index(0, 0)), true); /* * Setup some buttons to manipulate the view and the model. */ WContainerWidget *wc = new WContainerWidget(this); WPushButton *b; b = new WPushButton("Toggle row height", wc); b->clicked().connect(this, &TreeViewExample::toggleRowHeight); b->setToolTip("Toggles row height between 31px and 25px"); b = new WPushButton("Toggle stripes", wc); b->clicked().connect(this, &TreeViewExample::toggleStripes); b->setToolTip("Toggle alternating row colors"); b = new WPushButton("Toggle root", wc); b->clicked().connect(this, &TreeViewExample::toggleRoot); b->setToolTip("Toggles root item between all and the first continent."); b = new WPushButton("Add rows", wc); b->clicked().connect(this, &TreeViewExample::addRows); b->setToolTip("Adds some cities to Belgium"); }
JavascriptExample::JavascriptExample(const WEnvironment& env) : WApplication(env) { setTitle("Javascript example"); // Create a popup for prompting the amount of money, and connect the // okPressed button to the slot for setting the amount of money. // // Note that the input provided by the user in the prompt box is passed as // an argument to the slot. promptAmount_ = Popup::createPrompt("How much do you want to pay?", "", this); promptAmount_->okPressed().connect(this, &JavascriptExample::setAmount); // Create a popup for confirming the payment. // // Since a confirm popup does not allow input, we ignore the // argument carrying the input (which will be empty anyway). confirmPay_ = Popup::createConfirm("", this); confirmPay_->okPressed().connect(this, &JavascriptExample::confirmed); new WText("<h2>Wt Javascript example</h2>" "<p>Wt makes abstraction of Javascript, and therefore allows you" " to develop web applications without any knowledge of Javascript," " and which are not dependent on Javascript." " However, Wt does allow you to add custom Javascript code:</p>" " <ul>" " <li>To call custom JavaScript code from an event handler, " "connect the Wt::EventSignal to a Wt::JSlot.</li>" " <li>To call C++ code from custom JavaScript, use " "Wt.emit() to emit a Wt::JSignal.</li>" " <li>To call custom JavaScript code from C++, use " "WApplication::doJavascript() or Wt::JSlot::exec().</li>" " </ul>" "<p>This simple application shows how to interact between C++ and" " JavaScript using the JSlot and JSignal classes.</p>", root()); currentAmount_ = new WText("Current amount: $" + promptAmount_->defaultValue(), root()); WPushButton *amountButton = new WPushButton("Change ...", root()); amountButton->setMargin(10, Left | Right); new WBreak(root()); WPushButton *confirmButton = new WPushButton("Pay now.", root()); confirmButton->setMargin(10, Top | Bottom); // Connect the event handlers to a JSlot: this will execute the JavaScript // immediately, without a server round trip. amountButton->clicked().connect(promptAmount_->show); confirmButton->clicked().connect(confirmPay_->show); // Set the initial amount setAmount("1000"); }
DialogExample::DialogExample(const WEnvironment& env) : WApplication(env), messageBox_(0) { setTitle("Dialog example"); WContainerWidget *textdiv = new WContainerWidget(root()); textdiv->setStyleClass("text"); new WText("<h2>Wt dialogs example</h2>", textdiv); new WText("You can use WMessageBox for simple modal dialog boxes. <br />", textdiv); WContainerWidget *buttons = new WContainerWidget(root()); buttons->setStyleClass("buttons"); WPushButton *button; button = new WPushButton("One liner", buttons); button->clicked().connect(this, &DialogExample::messageBox1); button = new WPushButton("Comfortable ?", buttons); button->clicked().connect(this, &DialogExample::messageBox2); button = new WPushButton("Havoc!", buttons); button->clicked().connect(this, &DialogExample::messageBox3); button = new WPushButton("Discard", buttons); button->clicked().connect(this, &DialogExample::messageBox4); button = new WPushButton("Familiar", buttons); button->clicked().connect(this, &DialogExample::custom); textdiv = new WContainerWidget(root()); textdiv->setStyleClass("text"); status_ = new WText("Go ahead...", textdiv); styleSheet().addRule(".buttons", "padding: 5px;"); styleSheet().addRule(".buttons BUTTON", "padding-left: 4px; padding-right: 4px;" "margin-top: 4px; display: block"); // avoid scrollbar problems styleSheet().addRule(".text", "padding: 4px 8px"); styleSheet().addRule("body", "margin: 0px;"); }
WWidget *MvcWidgets::viewsCombo() { WContainerWidget *result = new WContainerWidget(); // WComboBox #if !defined(WT_TARGET_JAVA) topic("WComboBox", "WSelectionBox", "Ext::ComboBox", result); #else topic("WComboBox", "WSelectionBox", result); #endif addText(tr("mvc-stringlistviews"), result); addText("<h3>WComboBox</h3>", result); (new WComboBox(result))->setModel(stringList_); // WSelectionBox addText("<h3>WSelectionBox</h3>", result); (new WSelectionBox(result))->setModel(stringList_); #ifndef WT_TARGET_JAVA // Ext::ComboBox addText("<h3>Ext::ComboBox</h3>", result); extComboBox_ = new Ext::ComboBox(result); extComboBox_->setModel(stringList_); extComboBox_->setEditable(true); WPushButton *pb = new WPushButton("Press here to add the edited value " "to the model", result); pb->clicked().connect(this, &MvcWidgets::comboBoxAdd); #endif return result; }
HelloApplication::HelloApplication(const WEnvironment& env) : WApplication(env) { setTitle("Hello world"); // application title root()->addWidget(new WText("Your name, please ? ")); // show some text nameEdit_ = new WLineEdit(root()); // allow text input nameEdit_->setFocus(); // give focus WPushButton *b = new WPushButton("Greet me.", root()); // create a button b->setMargin(5, Left); // add 5 pixels margin root()->addWidget(new WBreak()); // insert a line break greeting_ = new WText(root()); // empty text /* * Connect signals with slots * * - simple Wt-way */ b->clicked().connect(this, &HelloApplication::greet); /* * - using an arbitrary function object (binding values with boost::bind()) */ nameEdit_->enterPressed().connect (boost::bind(&HelloApplication::greet, this)); /* * - using a c++0x lambda: */ // b->clicked().connect(std::bind([=]() { // greeting_->setText("Hello there, " + nameEdit_->text()); // })); }
void SimpleChatWidget::letLogin() { disconnect(); clear(); WVBoxLayout *vLayout = new WVBoxLayout(); setLayout(vLayout, AlignLeft | AlignTop); WHBoxLayout *hLayout = new WHBoxLayout(); vLayout->addLayout(hLayout); hLayout->addWidget(new WLabel("User name:"), 0, AlignMiddle); hLayout->addWidget(userNameEdit_ = new WLineEdit(user_), 0, AlignMiddle); userNameEdit_->setFocus(); WPushButton *b = new WPushButton("Login"); hLayout->addWidget(b, 0, AlignMiddle); b->clicked().connect(this, &SimpleChatWidget::login); userNameEdit_->enterPressed().connect(this, &SimpleChatWidget::login); vLayout->addWidget(statusMsg_ = new WText()); statusMsg_->setTextFormat(PlainText); }
void menuWidget::revengeProposed() { WApplication *app = WApplication::instance(); information->setText("Revenge was proposed. Press start to begin"); startGame->enable(); revenge->disable(); giveUp->disable(); endGame->enable(); gameButtons.clear(); everything->clear(); delete everything; everything = new WTable(this); for(int i = 0; i<SIZE; i++) { for(int j = 0; j<SIZE; j++) { WPushButton * newButton = new WPushButton(); newButton->disable(); newButton->resize(35,35); //images are 30x30, just in case newButton->setVerticalAlignment(Wt::AlignMiddle); newButton->clicked().connect(boost::bind(&menuWidget::processClickButton,this,newButton,i,j)); everything->elementAt(i,j)->addWidget(newButton); gameButtons.insert(make_pair(Coordinates(j,i),newButton)); }//adding the noughts&crosses buttons (225) } app->triggerUpdate(); }
WPushButton *WMessageBox::addButton(const WString& text, StandardButton result) { WPushButton *b = new WPushButton(text, buttonContainer_); buttonMapper_->mapConnect(b->clicked(), result); return b; }
void bindPanelTemplates() { if (!session_.user()) return; dbo::Transaction t(session_); if (authorPanel_) { WPushButton *newPost = new WPushButton(tr("new-post")); newPost->clicked().connect(SLOT(this, BlogImpl::newPost)); WContainerWidget *unpublishedPosts = new WContainerWidget(); showPosts(session_.user()->allPosts(Post::Unpublished), unpublishedPosts); authorPanel_->bindString("user", session_.user()->name); authorPanel_->bindInt("unpublished-count", (int)session_.user()->allPosts(Post::Unpublished) .size()); authorPanel_->bindInt("published-count", (int)session_.user()->allPosts(Post::Published) .size()); authorPanel_->bindWidget("new-post", newPost); authorPanel_->bindWidget("unpublished-posts", unpublishedPosts); } t.commit(); }
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); }
void Reports::createUi() { WContainerWidget *dateSelectForm = new WContainerWidget(this); dateSelectForm ->setStyleClass("form-inline"); dateSelectForm ->setId("dateselectform"); WLabel *label; label = new WLabel(tr("reports.begindate"), dateSelectForm ); m_pBeginDateEdit = new WDateEdit(dateSelectForm ); //label->setBuddy(m_pBeginDateEdit->lineEdit()); label->setBuddy(m_pBeginDateEdit); //m_pBeginDateEdit->setBottom(WDate(WDate::currentDate().year(), WDate::currentDate().month(), 1)); m_pBeginDateEdit->setFormat("dd.MM.yyyy"); m_pBeginDateEdit->setDate(WDate(WDate::currentDate().year(), WDate::currentDate().month(), 1)); m_pBeginDateEdit->setTop(WDate::currentDate()); //m_pBeginDateEdit->lineEdit()->validator()->setMandatory(true); m_pBeginDateEdit->validator()->setMandatory(true); m_pBeginDateEdit->setStyleClass("input-medium"); //m_pBeginDateEdit->setWidth(120); label = new WLabel(tr("reports.enddate"), dateSelectForm ); m_pEndDateEdit = new WDateEdit(dateSelectForm ); //label->setBuddy(m_pEndDateEdit->lineEdit()); label->setBuddy(m_pEndDateEdit); //m_pEndDateEdit->setBottom(WDate::currentDate()); m_pEndDateEdit->setFormat("dd.MM.yyyy"); m_pEndDateEdit->setDate(WDate::currentDate()); m_pEndDateEdit->setTop(WDate::currentDate()); //m_pEndDateEdit->lineEdit()->validator()->setMandatory(true); m_pEndDateEdit->validator()->setMandatory(true); m_pEndDateEdit->setStyleClass("input-medium"); /* WContainerWidget *corner_kick = new WContainerWidget(dateSelectForm ); corner_kick->setStyleClass("corner_kick get_filter"); WTemplate *button = new WTemplate("<ins class=\"i1\"></ins><ins class=\"i2\"></ins><ins class=\"i3\"></ins><ins class=\"i4\"></ins>${anchor}",corner_kick); LineEdit *submitBtn = new LineEdit(0,LineEdit::Submit); submitBtn->setValueText(tr("reports.filtered")); submitBtn->clicked().connect(boost::bind(&Reports::changed, this, submitBtn)); button->bindWidget("anchor",submitBtn); */ //WTemplate *button = new WTemplate("<ins class=\"i1\"></ins><ins class=\"i2\"></ins><ins class=\"i3\"></ins><ins class=\"i4\"></ins>${anchor}",dateSelectForm); WPushButton *anchor = new WPushButton(tr("reports.filtered"),dateSelectForm); anchor->clicked().connect(boost::bind(&Reports::changed, this, dateSelectForm)); //button->bindWidget("anchor",anchor); //button->setStyleClass("corner_kick get_filter"); //(new WLabel(tr("reports.filtered"), corner_kick))->setBuddy(new LineEdit(corner_kick,LineEdit::Submit)); }
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); // ??? } }
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); // ??? } }
void menuWidget::processCreateNewGameButton(WPushButton *b) { //stuff that requires database connection //if everything's fine, database return info (let's say "true") //and we can proceed information->setText("New game created, waiting for another player"); gamePointer = gamesConnector->newGame(*this); joined = false; ifCreator = true; endConnection->show(); showGames->disable(); gamesAvailable->hide(); success->show(); newGameButton->disable(); startGame->disable(); startGame->show(); highScoresButton->hide(); endGame->enable(); endConnection->hide(); success->hide(); if(newGameButton) newGameButton->hide(); showGames->hide(); //preparing the game screen (nothing interesting above) gameButtons.clear(); everything->clear(); delete everything; everything = new WTable(this); //everything->setStyleClass("myStyle"); for(int i = 0; i<SIZE; i++) { for(int j = 0; j<SIZE; j++) { WPushButton * newButton = new WPushButton(); newButton->resize(35,35); //images are 30x30, just in case newButton->disable(); newButton->setVerticalAlignment(Wt::AlignMiddle); newButton->clicked().connect(boost::bind(&menuWidget::processClickButton,this,newButton,i,j)); everything->elementAt(i,j)->addWidget(newButton); gameButtons.insert(make_pair(Coordinates(j,i),newButton)); }//adding the noughts&crosses buttons (225) } map<Coordinates,WPushButton*>::iterator it; for(it = gameButtons.begin(); it!=gameButtons.end(); it++) { it->second->disable(); } endGame->show(); giveUp->show(); revenge->show(); revenge->disable(); gamesConnector->unregister(*this); //adding two buttons on the right (End Game and Take Revenge) }
void AuthWidget::createLoggedInView() { setTemplateText(tr("Wt.Auth.template.logged-in")); bindString("user-name", login_.user().identity(Identity::LoginName)); WPushButton *logout = new WPushButton(tr("Wt.Auth.logout")); logout->clicked().connect(this, &AuthWidget::logout); bindWidget("logout", logout); }
WWidget *Home::quoteForm() { WContainerWidget *result = new WContainerWidget(); result->setStyleClass("quote"); WTemplate *requestTemplate = new WTemplate(tr("quote.request"), result); WPushButton *quoteButton = new WPushButton(tr("quote.requestbutton")); requestTemplate->bindWidget("button", quoteButton); WWidget *quoteForm = createQuoteForm(); result->addWidget(quoteForm); quoteButton->clicked().connect(quoteForm, &WWidget::show); quoteButton->clicked().connect(requestTemplate, &WWidget::hide); quoteForm->hide(); return result; }
void Recaptcha::add_buttons() { WPushButton* u = new WPushButton(tr("wc.common.Update"), get_impl()); u->clicked().connect(this, &AbstractCaptcha::update); WPushButton* get_image = new WPushButton(get_impl()); get_image->addStyleClass("recaptcha_only_if_audio"); get_image->setText(tr("wc.captcha.Get_image")); get_image->clicked().connect(this, &Recaptcha::get_image); WPushButton* get_audio = new WPushButton(get_impl()); get_audio->addStyleClass("recaptcha_only_if_image"); get_audio->setText(tr("wc.captcha.Get_audio")); get_audio->clicked().connect(this, &Recaptcha::get_audio); }
EditUsers::EditUsers(dbo::Session& aSession, const std::string& basePath) : session_(aSession), basePath_(basePath) { setStyleClass("user-editor"); setTemplateText(tr("edit-users-list")); limitEdit_ = new WLineEdit; WPushButton* goLimit = new WPushButton(tr("go-limit")); goLimit->clicked().connect(SLOT(this,EditUsers::limitList)); bindWidget("limit-edit",limitEdit_); bindWidget("limit-button",goLimit); limitList(); }
WebGLDemo::WebGLDemo(const WEnvironment& env) : WApplication(env) { std::string googAnalytics(" var _gaq = _gaq || [];" "_gaq.push(['_setAccount', 'UA-22447986-1']);" "_gaq.push(['_trackPageview']);" "" "(function() {" " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;" " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';" " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);" "})();"); doJavaScript(googAnalytics); setTitle("Demo"); root()->addWidget(new WText("Wt/WebGL Lesson 11: Spheres, Rotation Matrices, and Mouse Events")); root()->addWidget(new WBreak()); drawGLWidget_ = 0; video=new WHTML5Video(root()); video->addSource("ladybug8.webm"); video->setPoster("./moon.gif"); video->load(); WPushButton *button = new WPushButton("push to start",root()); button->clicked().connect(this,&WebGLDemo::main); //Set up the Timer in order to animate the scene. //timer = new WTimer(drawGLWidget_); //timer->setInterval(25); //timer->start(); //timer->timeout().connect(this,&WebGLDemo::animate);// */ ///////////////////////////////////////////// root()->addWidget(new WBreak()); root()->addWidget(new WBreak()); root()->addWidget(new WBreak()); root()->addWidget(new WText("This demo has been developed by Vicomtech-IK4 Research Center")); root()->addWidget(new WBreak()); root()->addWidget(new WText("Based on the learningwebgl.com lessons.")); root()->addWidget(new WBreak()); root()->addWidget(new WText("www.vicomtech.es")); //root()->addWidget(new WBreak()); //root()->addWidget(new WImage("vicomLogoSm.png")); ///////////////////////////////////////////// }
void menuWidget::processShowGamesButton() { information->setText(""); highScoresButton->hide(); showGames->disable(); newGameButton->disable(); success->hide(); joinButtons.clear(); gamesAvailable->clear(); delete gamesAvailable; gamesAvailable = new WTable(this); gamesAvailable->setStyleClass("gamesAvailable"); addWidget(gamesAvailable); gamesAvailable->elementAt(0,0)->addWidget(new WText("List of all available games:")); //preparing whole "scene" (nothing interesting above) int i = 1; gamesConnector->iterationBegin(); GamesConnector::const_iterator cit = gamesConnector->begin(); for(cit ; cit != gamesConnector->end(); ++cit) { string gameName = *cit; //this will be returned by the database //gameName is important, 'cause it is the parameter of the join event gamesAvailable->elementAt(i,0)->addWidget(new WText(gameName)); WPushButton * btn = new WPushButton("Join",this); btn->clicked().connect(boost::bind(&menuWidget::processChooseGameButton,this,btn)); gamesAvailable->elementAt(i,1)->addWidget(btn); joinButtons.push_back(std::make_pair(btn,cit)); //vector of join buttons i++; } gamesConnector->iterationEnd(); gamesConnector->refRegister(*this); WPushButton * hideGames = new WPushButton("Hide games list"); hideGames->clicked().connect(boost::bind(&menuWidget::processHideListButton,this)); gamesAvailable->elementAt(i,0)->addWidget(hideGames); }
void AdsEditor::renderUI() { AdsApplication *app = AdsApplication::adsApplication(); cppdb::session &db = app->db_; clear(); WPushButton *btn = new WPushButton("Criar Anuncio", this); btn->clicked().connect(this, &AdsEditor::novoAnuncio); WPushButton *update = new WPushButton("Atualiza", this); update->clicked().connect(this, &AdsEditor::renderUI); new WBreak(this); new WBreak(this); new WText("<h3>Lista de Anuncios</h3>",this); Wt::WContainerWidget *w = new Wt::WContainerWidget(this); w->resize(600, WLength::Auto); WVBoxLayout *layout = new Wt::WVBoxLayout(); cppdb::result res = db << "select id, titulo, url, imagem, texto, ativo " " from anuncio"; while(res.next()) { WContainerWidget *cont = new WContainerWidget(); AdsAnuncio *anuncio = new AdsAnuncio(cont); res >> anuncio->id >> anuncio->titulo_ >> anuncio->link_ >> anuncio->imagem_ >> anuncio->texto_ >> anuncio->ativo_; WPushButton *tituloBtn = new WPushButton("Titulo",cont); tituloBtn->clicked().connect(anuncio, &AdsAnuncio::editarTitulo); WPushButton *urlBtn = new WPushButton("URL",cont); urlBtn->clicked().connect(anuncio, &AdsAnuncio::editarURL); WPushButton *imagemBtn = new WPushButton("Imagem",cont); imagemBtn->clicked().connect(anuncio, &AdsAnuncio::editarImagem); WPushButton *textoBtn = new WPushButton("Texto",cont); textoBtn->clicked().connect(anuncio, &AdsAnuncio::editarTexto); WCheckBox *ativoCheck = new Wt::WCheckBox("Ativo",cont); if(anuncio->ativo_ == 1) ativoCheck->setChecked(true); else ativoCheck->setChecked(false); ativoCheck->changed().connect(anuncio, &AdsAnuncio::changeAtiva); WPushButton *deletaBtn = new WPushButton("Deleta",cont); deletaBtn->clicked().connect(anuncio, &AdsAnuncio::deletaAnuncio); anuncio->renderUI(); layout->addWidget(cont); } w->setLayout(layout); }
void WMessageBox::setButtons(WFlags<StandardButton> buttons) { buttons_ = buttons; buttonContainer_->clear(); for (int i = 0; i < 9; ++i) if (buttons_ & order_[i]) { WPushButton *b = new WPushButton(tr(buttonText_[i]), buttonContainer_); buttonMapper_->mapConnect(b->clicked(), order_[i]); if (order_[i] == Ok || order_[i] == Yes) b->setFocus(); } }
void CommentView::edit() { clear(); dbo::Transaction t(session_); setTemplateText(tr("blog-edit-comment")); editArea_ = new WTextArea(); editArea_->setText(comment_->textSrc()); editArea_->setFocus(); WPushButton *save = new WPushButton(tr("save")); save->clicked().connect(this, &CommentView::save); WPushButton *cancel = new WPushButton(tr("cancel")); cancel->clicked().connect(this, &CommentView::cancel); bindWidget("area", editArea_); bindWidget("save", save); bindWidget("cancel", cancel); t.commit(); }
WWidget *FormWidgets::wPushButton() { WContainerWidget *result = new WContainerWidget(); topic("WPushButton", result); addText(tr("formwidgets-WPushButton"), result); WPushButton *pb = new WPushButton("Click me!", result); ed_->showSignal(pb->clicked(), "WPushButton click"); addText(tr("formwidgets-WPushButton-more"), result); pb = new WPushButton("Try to click me...", result); pb->setEnabled(false); return result; }
void RootLogin::ForgotForm() { if (!m_forgotFormFlag) { Div *dvForgotForm = new Div(m_dvForgot, "dvForgotForm", "form"); WGridLayout *dvForgotFormLayout = new WGridLayout(); m_forgotEmailEdit = new WLineEdit(); m_forgotCaptchaEdit = new WLineEdit(); dvForgotFormLayout->addWidget(new WText(m_lang->GetString("ROOT_LOGIN_FORM_EMAIL_TEXT")), 0, 0, AlignLeft | AlignMiddle); dvForgotFormLayout->addWidget(m_forgotEmailEdit, 0, 1); dvForgotFormLayout->addWidget(new WText(m_lang->GetString("ROOT_LOGIN_FORM_CAPTCHA_TEXT")), 1, 0, AlignLeft | AlignMiddle); dvForgotFormLayout->addWidget(m_forgotCaptchaEdit, 1, 1); dvForgotFormLayout->setVerticalSpacing(11); dvForgotFormLayout->setColumnStretch(0, 100); dvForgotFormLayout->setColumnStretch(1, 200); dvForgotForm->resize(300, WLength::Auto); dvForgotForm->setLayout(dvForgotFormLayout); m_errForgotText = new WText(m_dvForgot); WPushButton *btnForgot = new WPushButton(m_lang->GetString("ROOT_LOGIN_FORM_RECOVER_TEXT"), m_dvForgot); btnForgot->setStyleClass("formButton"); WRegExpValidator *forgotEmailValidator = new WRegExpValidator(Base::REGEX_EMAIL); forgotEmailValidator->setFlags(MatchCaseInsensitive); forgotEmailValidator->setMandatory(true); m_forgotCaptchaValidator = new WIntValidator(m_captcha->Result, m_captcha->Result); m_forgotCaptchaValidator->setMandatory(true); m_forgotEmailEdit->setValidator(forgotEmailValidator); m_forgotCaptchaEdit->setValidator(m_forgotCaptchaValidator); m_forgotEmailEdit->enterPressed().connect(this, &RootLogin::ForgotOK); m_forgotCaptchaEdit->enterPressed().connect(this, &RootLogin::ForgotOK); btnForgot->clicked().connect(this, &RootLogin::ForgotOK); m_forgotFormFlag = true; } else { m_dvForgot->clear(); m_forgotFormFlag = false; } }
HelloApplication::HelloApplication(const Wt::WEnvironment &env) : WApplication(env) { setTitle("Hello World"); root()->addWidget(new WText("Your name, please? ")); mNameEdit = new WLineEdit(root()); mNameEdit->setFocus(); WPushButton *button = new WPushButton("Greet me.", root()); button->setMargin(5, Left); root()->addWidget(new WBreak()); mGreeting = new WText(root()); button->clicked().connect(this, &HelloApplication::greet); mNameEdit->enterPressed().connect(boost::bind(&HelloApplication::greet, this)); }