FormExample::FormExample() : WContainerWidget() { WContainerWidget *langLayout = this->addWidget(cpp14::make_unique<WContainerWidget>()); langLayout->setContentAlignment(AlignmentFlag::Right); langLayout->addWidget(cpp14::make_unique<WText>(tr("language"))); const char *lang[] = { "en", "nl" }; for (int i = 0; i < 2; ++i) { WText *t = langLayout->addWidget(cpp14::make_unique<WText>(lang[i])); t->setMargin(5); t->clicked().connect(std::bind(&FormExample::changeLanguage, this, t)); languageSelects_.push_back(t); } /* * Start with the reported locale, if available */ setLanguage(wApp->locale().name()); Form *form = this->addWidget(cpp14::make_unique<Form>()); form->setMargin(20); }
DragExample::DragExample(WContainerWidget *parent): WContainerWidget(parent) { new WText("<p>Help these people with their decision by dragging one of " "the pills.</p>", this); if (!wApp->environment().javaScript()) { new WText("<i>This examples requires that javascript support is " "enabled.</i>", this); } WContainerWidget *pills = new WContainerWidget(this); pills->setContentAlignment(AlignCenter); createDragImage("icons/blue-pill.jpg", "icons/blue-pill-small.png", "blue-pill", pills); createDragImage("icons/red-pill.jpg", "icons/red-pill-small.png", "red-pill", pills); WContainerWidget *dropSites = new WContainerWidget(this); new Character("Neo", dropSites); new Character("Morpheus", dropSites); new Character("Trinity", dropSites); }
WApplication *createApplication(const WEnvironment& env) { WApplication *app = new WApplication(env); app->setTitle(L"Drag & drop"); new WText("<h1>Wt Drag & drop example.</h1>", app->root()); new WText("<p>Help these people with their decision by dragging one of " "the pills.</p>", app->root()); if (!env.javaScript()) { new WText("<i>This examples requires that javascript support is " "enabled.</i>", app->root()); } WContainerWidget *pills = new WContainerWidget(app->root()); pills->setContentAlignment(WWidget::AlignCenter); createDragImage("blue-pill.jpg", "blue-pill-small.png", "blue-pill", pills); createDragImage("red-pill.jpg", "red-pill-small.png", "red-pill", pills); WContainerWidget *dropSites = new WContainerWidget(app->root()); new Character(L"Neo", dropSites); new Character(L"Morpheus", dropSites); new Character(L"Trinity", dropSites); app->useStyleSheet("dragdrop.css"); return app; }
LatestCommentsDialog::LatestCommentsDialog(Session* session, MediaCollection *mediaCollection, WObject* parent): WDialog{parent} { setResizable(true); setWindowTitle(wtr("menu.latest.comments")); setClosable(true); setTransient(true); setMaximumSize(700, WLength::Auto); Dbo::Transaction t(*session); Dbo::collection<CommentPtr> latestComments = session->find<Comment>().orderBy("last_updated desc").limit(5); if(!latestComments.size()) contents()->addWidget(new WText{wtr("comments.empty")}); for(CommentPtr comment: latestComments) { WContainerWidget* commentWidget = new WContainerWidget; Media media = mediaCollection->media(comment->mediaId()); WContainerWidget *header = WW<WContainerWidget>(); header->setContentAlignment(AlignCenter); WAnchor *videoLink = WW<WAnchor>("", media.title(t)).css("link-hand label label-info comment-box-element"); header->addWidget(videoLink); Dbo::ptr<AuthInfo> authInfo = session->find<AuthInfo>().where("user_id = ?").bind(comment->user().id()); header->addWidget(WW<WText>(WString("{1} ({2})").arg(authInfo->identity("loginname")).arg(comment->lastUpdated().toString())) .css("label label-success comment-box-element")); commentWidget->addWidget(header); videoLink->clicked().connect([=](WMouseEvent){ _mediaClicked.emit(media); accept(); }); commentWidget->addWidget(WW<WText>(WString::fromUTF8(comment->content())).css("well comment-text comment-box-element").setInline(false)); contents()->addWidget(WW<WContainerWidget>().css("comment-text").add(commentWidget)); } }