10 #include <Wt/WApplication.h> 12 #include <Wt/WStringUtil.h> 17 WContainerWidget *langLayout = this->addWidget(cpp14::make_unique<WContainerWidget>());
18 langLayout->setContentAlignment(AlignmentFlag::Right);
19 langLayout->addWidget(cpp14::make_unique<WText>(tr(
"language")));
21 const char *lang[] = {
"en",
"nl" };
23 for (
int i = 0; i < 2; ++i) {
24 WText *t = langLayout->addWidget(cpp14::make_unique<WText>(lang[i]));
36 Form *form = this->addWidget(cpp14::make_unique<Form>());
42 bool haveLang =
false;
48 bool isLang = lang.find(t->text().toUTF8()) == 0;
49 t->setStyleClass(isLang ?
"langcurrent" :
"lang");
51 haveLang = haveLang || isLang;
56 WApplication::instance()
59 WApplication::instance()->setLocale(lang);
69 std::unique_ptr<WApplication> app
70 = cpp14::make_unique<WApplication>(env);
71 app->messageResourceBundle().use(WApplication::appRoot() +
"form-example");
72 app->setTitle(
"Form example");
74 app->root()->addWidget(cpp14::make_unique<FormExample>());
76 WCssDecorationStyle langStyle;
77 langStyle.font().setSize(FontSize::Smaller);
78 langStyle.setCursor(Cursor::PointingHand);
79 langStyle.setForegroundColor(WColor(
"blue"));
80 langStyle.setTextDecoration(TextDecoration::Underline);
81 app->styleSheet().addRule(
".lang", langStyle);
83 langStyle.setCursor(Cursor::Arrow);
84 langStyle.font().setWeight(FontWeight::Bold);
85 app->styleSheet().addRule(
".langcurrent", langStyle);
90 int main(
int argc,
char **argv)