Beispiel #1
0
void LoginView::createLayout()
{
  WLabel* userNameL = new WLabel(tr("login.userName"), contents());
  userNameL->setMargin(10, Left | Right);
  _user_name = new WLineEdit(contents());
  _user_name->setValidator(new WLengthValidator(5, 20, contents()));
  userNameL->setBuddy(_user_name);
  _user_name->setFocus();

  new WBreak(contents());

  WLabel* passwdL = new WLabel(tr("login.userPasswd"), contents());
  passwdL->setMargin(10, Left | Right);
  _user_passwd =  new WLineEdit(contents());
  passwdL->setBuddy(_user_passwd);
  _user_passwd->setValidator(new WLengthValidator(5, 20, contents()));
  _user_passwd->setEchoMode(WLineEdit::Password);
  _user_passwd->enterPressed().connect(this, &LoginView::loginCheck);

  new WBreak(contents());

  _login_button = new WPushButton(tr("login.loginButton"),
				  contents());
  //_login_button->clicked().connect(_user_passwd->jsRef() + ".value = " + "hex_md5(" + _user_passwd->jsRef() + ");");
  _login_button->clicked().connect(this, &LoginView::loginCheck2);
  //_user_passwd->enterPressed().connect(_user_passwd->jsRef() + ".value = " + "hex_md5(" + _user_passwd->jsRef() + ");");

}
Beispiel #2
0
TreeListExample::TreeListExample(WContainerWidget *parent)
  : WContainerWidget(parent),
    testCount_(0)
{
  tree_ = makeTreeMap(L"TreeListExample", 0);
  addWidget(tree_);
  tree_->expand();

  TreeNode *treelist = makeTreeMap(L"Tree List", tree_);
  TreeNode *wstateicon = makeTreeMap(L"class IconPair", treelist);
  makeTreeFile(L"IconPair.h", wstateicon);
  makeTreeFile(L"IconPair.C", wstateicon);
  TreeNode *wtreenode = makeTreeMap(L"class TreeNode", treelist);
  makeTreeFile(L"TreeNode.h", wtreenode);
  makeTreeFile(L"TreeNode.C", wtreenode);
  TreeNode *wtreeexample = makeTreeMap(L"class TreeListExample", treelist);
  makeTreeFile(L"TreeListExample.h", wtreeexample);
  makeTreeFile(L"TreeListExample.C", wtreeexample);

  testMap_ = makeTreeMap(L"Test map", tree_);

  /*
   * Buttons to demonstrate dynamically changing the tree contents
   * implies no magic at all.
   */
  addWidget
    (new WText(L"<p>Use the following buttons to change the "
	       "contents of the Test map:</p>"));

  WGroupBox *addBox = new WGroupBox(L"Add map", this);

  WLabel *mapNameLabel = new WLabel(L"Map name:", addBox);
  mapNameLabel->setMargin(WLength(1, WLength::FontEx), Right);
  mapNameEdit_ = new WLineEdit(L"Map", addBox);
  mapNameLabel->setBuddy(mapNameEdit_);

  /*
   * Example of validation: make the map name mandatory, and give
   * feedback when invalid.
   */
  mapNameEdit_->setValidator(new WValidator(true));
  WImage *invalid = new WImage("icons/invalid.png");
  WImage *invalidEmpty = new WImage("icons/invalid.png");

  WValidationStatus *statusIcon
    = new WValidationStatus(mapNameEdit_, 0, invalid, invalidEmpty, addBox);
  statusIcon->setMargin(WLength(5), Left | Right);

  addMapButton_ = new WPushButton(L"Add map", addBox);
  addMapButton_->clicked.connect(SLOT(this, TreeListExample::addMap));

  statusIcon->validated.connect(SLOT(addMapButton_, WFormWidget::setEnabled));

  new WBreak(this);

  WGroupBox *removeBox = new WGroupBox(L"Remove map", this);

  removeMapButton_
    = new WPushButton(L"Remove map", removeBox);
  removeMapButton_->clicked.connect(SLOT(this, TreeListExample::removeMap));
  removeMapButton_->disable();
}