summaryrefslogtreecommitdiff
path: root/src/gui/login.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-06 17:50:52 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-06 17:50:52 +0100
commit9219f1ffd4b05886b66c9074c918850fc97c430c (patch)
treecc6750b62b825636abb898297489d1372fc55848 /src/gui/login.cpp
parent631a8a85e8be0ec472850ba672676fe31679e7c3 (diff)
downloadmana-9219f1ffd4b05886b66c9074c918850fc97c430c.tar.gz
mana-9219f1ffd4b05886b66c9074c918850fc97c430c.tar.bz2
mana-9219f1ffd4b05886b66c9074c918850fc97c430c.tar.xz
mana-9219f1ffd4b05886b66c9074c918850fc97c430c.zip
Merged layout handler from mainline
Also fixed login dialog layout. This is the layout handler by Guillaume Melquiond, which he started in commit 59472ef68fdef3f7e8858a81a46e28c127119c58.
Diffstat (limited to 'src/gui/login.cpp')
-rw-r--r--src/gui/login.cpp59
1 files changed, 16 insertions, 43 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 5a748b52..db81c683 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -34,6 +34,8 @@
#include "passwordfield.h"
#include "textfield.h"
+#include "widgets/layout.h"
+
#include "../utils/gettext.h"
LoginDialog::LoginDialog(LoginData *loginData):
@@ -50,33 +52,6 @@ LoginDialog::LoginDialog(LoginData *loginData):
mCancelButton = new Button(_("Cancel"), "cancel", this);
mRegisterButton = new Button(_("Register"), "register", this);
- const int width = 250;
- const int height = 100;
-
- setContentSize(width, height);
-
- userLabel->setPosition(5, 5);
- passLabel->setPosition(5, 14 + userLabel->getHeight());
- serverLabel->setPosition(
- 5, 23 + userLabel->getHeight() + passLabel->getHeight());
- mUserField->setPosition(65, 5);
- mPassField->setPosition(65, 14 + userLabel->getHeight());
- mServerField->setPosition(
- 65, 23 + userLabel->getHeight() + passLabel->getHeight());
- mUserField->setWidth(width - 70);
- mPassField->setWidth(width - 70);
- mServerField->setWidth(width - 70);
- mKeepCheck->setPosition(4, 77);
- mCancelButton->setPosition(
- width - mCancelButton->getWidth() - 5,
- height - mCancelButton->getHeight() - 5);
- mOkButton->setPosition(
- mCancelButton->getX() - mOkButton->getWidth() - 5,
- height - mOkButton->getHeight() - 5);
- mRegisterButton->setPosition(
- mKeepCheck->getX() + mKeepCheck->getWidth() + 10,
- height - mRegisterButton->getHeight() - 5);
-
mUserField->setActionEventId("ok");
mPassField->setActionEventId("ok");
mServerField->setActionEventId("ok");
@@ -89,16 +64,17 @@ LoginDialog::LoginDialog(LoginData *loginData):
mServerField->addActionListener(this);
mKeepCheck->addActionListener(this);
- add(userLabel);
- add(passLabel);
- add(serverLabel);
- add(mUserField);
- add(mPassField);
- add(mServerField);
- add(mKeepCheck);
- add(mOkButton);
- add(mCancelButton);
- add(mRegisterButton);
+ place(0, 0, userLabel);
+ place(0, 1, passLabel);
+ place(0, 2, serverLabel);
+ place(1, 0, mUserField, 3).setPadding(2);
+ place(1, 1, mPassField, 3).setPadding(2);
+ place(1, 2, mServerField, 3).setPadding(2);
+ place(0, 3, mKeepCheck, 4);
+ place(0, 4, mRegisterButton).setHAlign(LayoutCell::LEFT);
+ place(2, 4, mOkButton);
+ place(3, 4, mCancelButton);
+ reflowLayout(250, 0);
setLocationRelativeTo(getParent());
setVisible(true);
@@ -116,8 +92,7 @@ LoginDialog::~LoginDialog()
{
}
-void
-LoginDialog::action(const gcn::ActionEvent &event)
+void LoginDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && canSubmit())
{
@@ -147,14 +122,12 @@ LoginDialog::action(const gcn::ActionEvent &event)
}
}
-void
-LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
mOkButton->setEnabled(canSubmit());
}
-bool
-LoginDialog::canSubmit()
+bool LoginDialog::canSubmit()
{
return !mUserField->getText().empty() &&
!mPassField->getText().empty() &&