joe_vanandel

Wt Dialog with WGrid

Nov 1st, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #include <Wt/WContainerWidget>
  2. #include <Wt/WGridLayout>
  3. #include <Wt/WText>
  4.  
  5. #include "Login_GUI.h"
  6.  
  7. using namespace Wt;
  8.  
  9.  
  10. Login_GUI::Login_GUI()
  11. {
  12. WContainerWidget *container = new WContainerWidget(dialog_.contents());
  13. // dialog_.resize(WLength(), 600);
  14.  
  15. dialog_.setWindowTitle("Please Login ");
  16. dialog_.setClosable(true);
  17. dialog_.setResizable(true);
  18.  
  19. WGridLayout *grid = new WGridLayout();
  20. container->setLayout(grid );
  21.  
  22. const int col = 0;
  23.  
  24. int row = 0;
  25. const int colSpan = 2;
  26.  
  27. WText *label = new WText("Id (e.g. admin)");
  28. grid->addWidget(label, row, col, 1, colSpan);
  29. idLE_ = new WLineEdit("----");
  30. grid->addWidget(idLE_, row, col+colSpan);
  31. row +=1;
  32.  
  33. label = new WText("Password");
  34. grid->addWidget(label, row, col, 1, colSpan);
  35. passwdLE_ = new WLineEdit("----");
  36. passwdLE_->setEchoMode(WLineEdit::Password);
  37. grid->addWidget(passwdLE_, row, col+colSpan);
  38. row +=1;
  39.  
  40. label = new WText("User Name (e.g. Joe Smith)");
  41. grid->addWidget(label, row, col, 1, colSpan);
  42. nameLE_ = new WLineEdit("----");
  43. grid->addWidget(passwdLE_, row, col+colSpan);
  44. row +=1;
  45.  
  46. label = new WText("Location (e.g. Firestone)");
  47. grid->addWidget(label, row, col, 1, colSpan);
  48. locationLE_ = new WLineEdit("----");
  49. grid->addWidget(passwdLE_, row, col+colSpan);
  50. row +=1;
  51.  
  52. label = new WText("Comment");
  53. grid->addWidget(label, row, col,1, colSpan);
  54. commentLE_ = new WLineEdit("----");
  55. grid->addWidget(passwdLE_, row, col+colSpan);
  56. row += 3;
  57.  
  58. WPushButton *ok = new WPushButton("OK");
  59. WPushButton *cancel = new WPushButton("Cancel");
  60.  
  61. grid->addWidget(cancel, row, col+1);
  62. grid->addWidget(ok, row, col+2);
  63.  
  64. ok->clicked().connect(SLOT(&dialog_, WDialog::accept));
  65. cancel->clicked().connect(SLOT(&dialog_, WDialog::reject));
  66. }
  67.  
  68. bool Login_GUI::confirm(Wt::WString &id, Wt::WString &passwd,
  69. Wt::WString &name, Wt::WString &location,
  70. Wt::WString &comment)
  71. {
  72. if (dialog_.exec() == WDialog::Accepted) {
  73.  
  74. id = idLE_->text();
  75. passwd = passwdLE_->text();
  76. name = nameLE_->text();
  77. location = locationLE_->text();
  78. comment = commentLE_->text();
  79. return true;
  80. }
  81. return false;
  82. }
  83. ========================================Login_GUI.h===============================================
  84. /*
  85. * Login_GUI.h
  86. *
  87. * Created on Oct 31, 2012 by Joe VanAndel
  88. */
  89.  
  90. #ifndef LOGIN_GUI_H
  91. #define LOGIN_GUI_H
  92. #include <Wt/WDialog>
  93. #include <Wt/WPushButton>
  94. #include <Wt/WText>
  95. #include <Wt/WLineEdit>
  96.  
  97.  
  98. class Login_GUI : public Wt::WObject {
  99. public:
  100. Login_GUI();
  101. virtual ~Login_GUI () {}
  102.  
  103. // returrns true if user clicked 'OK'
  104. bool confirm(Wt::WString &id, Wt::WString &passwd,
  105. Wt::WString &name, Wt::WString &location, Wt::WString &comment);
  106.  
  107. private:
  108. Wt::WDialog dialog_;
  109. Wt::WLineEdit *idLE_;
  110. Wt::WLineEdit *passwdLE_;
  111. Wt::WLineEdit *nameLE_;
  112. Wt::WLineEdit *locationLE_;
  113. Wt::WLineEdit *commentLE_;
  114.  
  115.  
  116. };
  117.  
  118. #endif // LOGIN_GUI_H
Advertisement
Add Comment
Please, Sign In to add comment