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(); }
WInteractWidget *WNavigationBar::createExpandButton() { WPushButton *result = new WPushButton(tr("Wt.WNavigationBar.expand-button")); result->setTextFormat(XHTMLText); wApp->theme()->apply(this, result, NavbarBtn); return result; }
/* * The env argument contains information about the new session, and * the initial request. It must be passed to the WApplication * constructor so it is typically also an argument for your custom * application constructor. */ HelloApplication::HelloApplication(const WEnvironment& env) : WApplication(env) { setTitle("Hello world"); // application title // show some text root()->addWidget(new WText("Your name, please ? ")); nameEdit_ = new WLineEdit(root()); // allow text input nameEdit_->setFocus(); // give focus // create a button WPushButton *b = new WPushButton("Greet me.", root()); 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)); }
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(); }
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; }
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); }
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 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); }
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); }
WPushButton *WMessageBox::addButton(const WString& text, StandardButton result) { WPushButton *b = new WPushButton(text, buttonContainer_); buttonMapper_->mapConnect(b->clicked(), result); return b; }
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; }
WPopupMenu::~WPopupMenu() { if (button_) { WPushButton *b = dynamic_cast<WPushButton *>(button_); if (b) b->setMenu(0); } }
CommentsContainerWidget::CommentsContainerWidget(string videoId, Session* session, WContainerWidget* parent) : WContainerWidget(parent), d(videoId, session) { string querysql = "select content,last_updated,\ auth_info.email as email,\ auth_identity.identity as identity\ from comment\ inner join auth_info on comment.user_id = auth_info.user_id\ inner join auth_identity on auth_info.id = auth_identity.auth_info_id\ "; wApp->log("notice") << "comments query: " << querysql; auto query = d->session->query<CommentTuple>(querysql); query.where("media_id = ?").bind(videoId); query.where("auth_identity.provider = 'loginname'"); query.orderBy("last_updated DESC"); addWidget(WW<WText>(wtr("comments.label")).css("label").setInline(false)); WTextArea* newCommentContent = new WTextArea(); newCommentContent->setRows(3); newCommentContent->setInline(false); WPushButton* insertComment = WW<WPushButton>(wtr("comments.addcomment.button")).css("btn btn-primary btn-sm").onClick([=](WMouseEvent){ if(newCommentContent->text().empty()) return; Comment *comment = new Comment(videoId, d->session->user(), newCommentContent->text().toUTF8()); Dbo::Transaction t(*d->session); Dbo::ptr< Comment > newComment = d->session->add(comment); t.commit(); newCommentContent->setText(""); commentViewers.commentAdded(videoId, newComment.id()); }); newCommentContent->keyWentUp().connect([=](WKeyEvent){ insertComment->setEnabled(!newCommentContent->text().empty()); }); insertComment->setEnabled(false); // newCommentContent->setWidth(500); newCommentContent->addStyleClass("col-md-8"); addWidget(WW<WContainerWidget>().css("add-comment-box row").add(newCommentContent).add(insertComment).setContentAlignment(AlignCenter)); addWidget(d->commentsContainer = WW<WContainerWidget>().css("container") ); Dbo::Transaction t(*d->session); for(CommentTuple comment : query.resultList()) d->commentsContainer->addWidget(new CommentView(comment) ); auto commentAdded = [=] (string commentVideoId, long commentId) { if(commentVideoId != videoId) return; Dbo::Transaction t(*d->session); auto query = d->session->query<CommentTuple>(querysql).where("comment.id = ?").bind(commentId); query.where("auth_identity.provider = 'loginname'"); d->commentsContainer->insertWidget(0, new CommentView(query.resultValue())); d->commentsContainer->refresh(); wApp->triggerUpdate(); }; commentViewers.addClient(wApp->sessionId(), commentAdded); }
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)); }
void SVConditionParam::createAddButton(int nRow) { WText(" " , (WContainerWidget*) m_pOperate->elementAt(nRow, 1)); WPushButton * pAdd = new WPushButton(SVResString::getResString("IDS_Add"), (WContainerWidget*) m_pOperate->elementAt(nRow, 1)); if(pAdd) { pAdd->setToolTip(SVResString::getResString("IDS_Add_Title")); WObject::connect(pAdd, SIGNAL(clicked()), this, SLOT(addCondition())); } }
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); }
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"); }
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 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); } }
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 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 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)); }
StrucView::StrucView( int x, int y, Symbol * info ) :WBRWindow( WRect(x,y,StrucWidth,StrucHeight), "" ) ,_listbox( new VerboseListBox( WRect( 5, 30, -5, -25 ), this )) ,_listobjs( new WVList ) ,_type( new WText( this, WRect( 5, -20, -5, -2 ), NULL, TextStyleLeftNoWrap | TextStyleAmpersands )) ,_treeRoot(NULL) ,_nodesSeen( new WVList ) ,_lattice( new ClassLattice( info ) ) ,_filter( activeProject->getFiltFlags( Filt_Members )) //------------------------------------------------------------------- { WString title = info->name(); Symbol * sym; title.concat( " Structure" ); setText( title ); _listbox->setCallbacks( this, (cbw)&StrucView::itemSelected, (bcbwi)&StrucView::keyPressed, (cbw)&StrucView::itemDblClicked ); // _listbox->setFont(stdFont); _listbox->select( 0 ); _listbox->show(); // _type->setFont(stdFont); _type->show(); WPushButton * bttn; bttn = new WPushButton( this, WRect( 5, 2, 25, 25 ), "+" ); bttn->onClick( this, (cbw) plusSelected ); bttn->show(); bttn = new WPushButton( this, WRect( 40, 2, 25, 25 ), "-" ); bttn->onClick( this, (cbw) minusSelected ); bttn->show(); bttn = new WPushButton( this, WRect( 75, 2, 25, 25 ), "*" ); bttn->onClick( this, (cbw) starSelected ); bttn->show(); bttn = new WPushButton( this, WRect( -70, 2, 65, 25 ), "&Filters..." ); bttn->onClick( this, (cbw) filterSelected ); bttn->show(); sym = Symbol::defineSymbol( info ); _treeRoot = new StrucViewItem( this, sym ); reset(); _listbox->setFocus(); show(); }
CoderWidget::CoderWidget() { WApplication::instance()->enableUpdates(true); session_ = new CodeSession(boost::bind(&CoderWidget::sessionChanged, this)); WApplication::instance()->setInternalPath("/" + session_->id()); WPushButton *addBuffer = new WPushButton("Add file", this); observerCount_ = new WText("Observers: 0", this); addBuffer->clicked().connect(this, &CoderWidget::addBuffer); buffers_ = new WContainerWidget(this); insertBuffer(0); }
void CSVBatchAdd::CreateOperater() { WTable * pSub = new WTable(this); if(pSub) { WPushButton * pSave = new WPushButton(m_szSave, pSub->elementAt(0, 0)); if(pSave) { pSave->setToolTip(m_szSaveTip); } WPushButton * pCancel = new WPushButton(m_szCancel, pSub->elementAt(0,1)); if(pCancel) { pCancel->setToolTip(m_szCancelTip); WObject::connect(pCancel, SIGNAL(clicked()), "window.close();", WObject::ConnectionType::JAVASCRIPT); } } }