Project

General

Profile

RE: Wt new page ยป login_new_window.cpp

Roel Standaert, 07/25/2019 04:03 PM

 
#include <Wt/WApplication.h>
#include <Wt/WBreak.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WDialog.h>
#include <Wt/WEnvironment.h>
#include <Wt/WLabel.h>
#include <Wt/WLineEdit.h>
#include <Wt/WPushButton.h>
#include <Wt/WRegExpValidator.h>
#include <Wt/WText.h>
#include <Wt/WVBoxLayout.h>
#include <Wt/WHBoxLayout.h>
#include <Wt/WImage.h>
#include <Wt/WFormWidget.h>
#include <Wt/WIntValidator.h>
#include <Wt/WInPlaceEdit.h>
#include <Wt/WDialog.h>


class HelloApplication : public Wt::WApplication
{
public:
HelloApplication(const Wt::WEnvironment& env);

void loginClicked();

private:
void greet();
};

using namespace Wt;
HelloApplication::HelloApplication(const Wt::WEnvironment& env)
: WApplication(env)
{
setTitle("Management");
useStyleSheet("S.css");
internalPath() == "A";
setInternalPath("A");

root()->addWidget(Wt::cpp14::make_unique<Wt::WText>("Username"));

auto container = Wt::cpp14::make_unique<Wt::WContainerWidget>();
root()->resize(380, 400);
root()->setStyleClass("Abox");

auto vbox = root()->setLayout(Wt::cpp14::make_unique<Wt::WVBoxLayout>());

auto item = Wt::cpp14::make_unique<Wt::WText>("Management Login");
item->setStyleClass("Bbox");
item->setFloatSide(Side::CenterY);
vbox->addWidget(std::move(item),5);

auto hbox = vbox->addLayout(Wt::cpp14::make_unique<Wt::WHBoxLayout>());
auto dbox = vbox->addLayout(Wt::cpp14::make_unique<Wt::WHBoxLayout>());
auto ebox = vbox->addLayout(Wt::cpp14::make_unique<Wt::WHBoxLayout>());

auto txtuser = Wt::cpp14::make_unique<Wt::WText>("Username");
txtuser->setStyleClass("Bbox");
txtuser->setFloatSide(Side::Left);
hbox->addWidget(std::move(txtuser),1);

auto useredit = Wt::cpp14::make_unique<Wt::WLineEdit>();
useredit->setFloatSide(Side::Right);
useredit->setStyleClass("h1");
useredit->setPlaceholderText("username");
hbox->addWidget(std::move(useredit),3);

auto txtpassword = Wt::cpp14::make_unique<Wt::WText>("Password");
txtpassword->setFloatSide(Side::Left);
txtpassword->setStyleClass("Bbox");
dbox->addWidget(std::move(txtpassword),1);
auto passedit = Wt::cpp14::make_unique<Wt::WLineEdit>();
passedit->setFloatSide(Side::Right);
passedit->setStyleClass("input");
passedit->setStyleClass("h1");
passedit->setPlaceholderText("password");
passedit->setEchoMode(EchoMode::Password);
passedit->setMaxLength(12);
dbox->addWidget(std::move(passedit),3 );
WLink link = WLink(LinkType::InternalPath, "/B");
link.setTarget(Wt::LinkTarget::NewWindow);

auto btnlogin = Wt::cpp14::make_unique<Wt::WPushButton>("Login");
btnlogin->setStyleClass("Cbox");
btnlogin->setFloatSide(Side::CenterX);
btnlogin->setLink(link);
btnlogin->clicked().connect(this, &HelloApplication::loginClicked);
ebox->addWidget(std::move(btnlogin));

root()->addWidget(Wt::cpp14::make_unique<Wt::WBreak>());
}

void HelloApplication::loginClicked()
{
// FIXME: VALIDATE LOGIN
root()->clear();
root()->addNew<Wt::WText>(Wt::utf8("logged in"));
}

int main(int argc, char** argv)
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
return Wt::cpp14::make_unique<HelloApplication>(env);
});
}
    (1-1/1)