Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wt/WContainerWidget>
- #include <Wt/WGridLayout>
- #include <Wt/WText>
- #include "Login_GUI.h"
- using namespace Wt;
- Login_GUI::Login_GUI()
- {
- WContainerWidget *container = new WContainerWidget(dialog_.contents());
- // dialog_.resize(WLength(), 600);
- dialog_.setWindowTitle("Please Login ");
- dialog_.setClosable(true);
- dialog_.setResizable(true);
- WGridLayout *grid = new WGridLayout();
- container->setLayout(grid );
- const int col = 0;
- int row = 0;
- const int colSpan = 2;
- WText *label = new WText("Id (e.g. admin)");
- grid->addWidget(label, row, col, 1, colSpan);
- idLE_ = new WLineEdit("----");
- grid->addWidget(idLE_, row, col+colSpan);
- row +=1;
- label = new WText("Password");
- grid->addWidget(label, row, col, 1, colSpan);
- passwdLE_ = new WLineEdit("----");
- passwdLE_->setEchoMode(WLineEdit::Password);
- grid->addWidget(passwdLE_, row, col+colSpan);
- row +=1;
- label = new WText("User Name (e.g. Joe Smith)");
- grid->addWidget(label, row, col, 1, colSpan);
- nameLE_ = new WLineEdit("----");
- grid->addWidget(passwdLE_, row, col+colSpan);
- row +=1;
- label = new WText("Location (e.g. Firestone)");
- grid->addWidget(label, row, col, 1, colSpan);
- locationLE_ = new WLineEdit("----");
- grid->addWidget(passwdLE_, row, col+colSpan);
- row +=1;
- label = new WText("Comment");
- grid->addWidget(label, row, col,1, colSpan);
- commentLE_ = new WLineEdit("----");
- grid->addWidget(passwdLE_, row, col+colSpan);
- row += 3;
- WPushButton *ok = new WPushButton("OK");
- WPushButton *cancel = new WPushButton("Cancel");
- grid->addWidget(cancel, row, col+1);
- grid->addWidget(ok, row, col+2);
- ok->clicked().connect(SLOT(&dialog_, WDialog::accept));
- cancel->clicked().connect(SLOT(&dialog_, WDialog::reject));
- }
- bool Login_GUI::confirm(Wt::WString &id, Wt::WString &passwd,
- Wt::WString &name, Wt::WString &location,
- Wt::WString &comment)
- {
- if (dialog_.exec() == WDialog::Accepted) {
- id = idLE_->text();
- passwd = passwdLE_->text();
- name = nameLE_->text();
- location = locationLE_->text();
- comment = commentLE_->text();
- return true;
- }
- return false;
- }
- ========================================Login_GUI.h===============================================
- /*
- * Login_GUI.h
- *
- * Created on Oct 31, 2012 by Joe VanAndel
- */
- #ifndef LOGIN_GUI_H
- #define LOGIN_GUI_H
- #include <Wt/WDialog>
- #include <Wt/WPushButton>
- #include <Wt/WText>
- #include <Wt/WLineEdit>
- class Login_GUI : public Wt::WObject {
- public:
- Login_GUI();
- virtual ~Login_GUI () {}
- // returrns true if user clicked 'OK'
- bool confirm(Wt::WString &id, Wt::WString &passwd,
- Wt::WString &name, Wt::WString &location, Wt::WString &comment);
- private:
- Wt::WDialog dialog_;
- Wt::WLineEdit *idLE_;
- Wt::WLineEdit *passwdLE_;
- Wt::WLineEdit *nameLE_;
- Wt::WLineEdit *locationLE_;
- Wt::WLineEdit *commentLE_;
- };
- #endif // LOGIN_GUI_H
Advertisement
Add Comment
Please, Sign In to add comment