diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-18 17:39:16 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-18 21:18:29 +0100 |
commit | a2c136d3ae4f192f30ea229c4a313bc528e26c90 (patch) | |
tree | b286aefe9edff5dbe036bf2122cc2b81769be56e /src/gui | |
parent | 4ca64dd439555cb7dcddc34108e0d935cd5824da (diff) | |
download | mana-a2c136d3ae4f192f30ea229c4a313bc528e26c90.tar.gz mana-a2c136d3ae4f192f30ea229c4a313bc528e26c90.tar.bz2 mana-a2c136d3ae4f192f30ea229c4a313bc528e26c90.tar.xz mana-a2c136d3ae4f192f30ea229c4a313bc528e26c90.zip |
Used dynamic layout for registration window
The dialog looks nicer now and the layout problems when the dialog is
translated have been fixed.
Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/playerbox.cpp | 6 | ||||
-rw-r--r-- | src/gui/register.cpp | 99 | ||||
-rw-r--r-- | src/gui/register.h | 17 |
3 files changed, 44 insertions, 78 deletions
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index b6b7663a..b196753b 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -74,8 +74,7 @@ PlayerBox::~PlayerBox() } } -void -PlayerBox::draw(gcn::Graphics *graphics) +void PlayerBox::draw(gcn::Graphics *graphics) { if (mPlayer) { @@ -88,8 +87,7 @@ PlayerBox::draw(gcn::Graphics *graphics) } } -void -PlayerBox::drawFrame(gcn::Graphics *graphics) +void PlayerBox::drawFrame(gcn::Graphics *graphics) { int w, h, bs; bs = getFrameSize(); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index ce36efa2..cb2f468d 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -39,17 +39,30 @@ #include "textfield.h" #include "ok_dialog.h" +#include "widgets/layout.h" + #include "../utils/gettext.h" #include "../utils/strprintf.h" -void -WrongDataNoticeListener::setTarget(gcn::TextField *textField) +/** + * Listener used while dealing with wrong data. It is used to direct the focus + * to the field which contained wrong data when the Ok button was pressed on + * the error notice. + */ +class WrongDataNoticeListener : public gcn::ActionListener { + public: + void setTarget(gcn::TextField *textField); + void action(const gcn::ActionEvent &event); + private: + gcn::TextField *mTarget; +}; + +void WrongDataNoticeListener::setTarget(gcn::TextField *textField) { mTarget = textField; } -void -WrongDataNoticeListener::action(const gcn::ActionEvent &event) +void WrongDataNoticeListener::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { @@ -57,9 +70,10 @@ WrongDataNoticeListener::action(const gcn::ActionEvent &event) } } + RegisterDialog::RegisterDialog(LoginData *loginData): - Window("Register"), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + Window(_("Register")), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *userLabel = new gcn::Label(_("Name:")); @@ -68,46 +82,29 @@ RegisterDialog::RegisterDialog(LoginData *loginData): gcn::Label *serverLabel = new gcn::Label(_("Server:")); mUserField = new TextField(loginData->username); mPasswordField = new PasswordField(loginData->password); - mConfirmField = new PasswordField(); + mConfirmField = new PasswordField; mServerField = new TextField(loginData->hostname); mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); - const int width = 220; - const int height = 150; - setContentSize(width, height); - - mUserField->setPosition(65, 5); - mUserField->setWidth(width - 70); - mPasswordField->setPosition( - 65, mUserField->getY() + mUserField->getHeight() + 7); - mPasswordField->setWidth(mUserField->getWidth()); - mConfirmField->setPosition( - 65, mPasswordField->getY() + mPasswordField->getHeight() + 7); - mConfirmField->setWidth(mUserField->getWidth()); - mServerField->setPosition( - 65, 23 + mConfirmField->getY() + mConfirmField->getHeight() + 7); - mServerField->setWidth(mUserField->getWidth()); - - userLabel->setPosition(5, mUserField->getY() + 1); - passwordLabel->setPosition(5, mPasswordField->getY() + 1); - confirmLabel->setPosition(5, mConfirmField->getY() + 1); - serverLabel->setPosition(5, mServerField->getY() + 1); - - mMaleButton->setPosition( - 70, mConfirmField->getY() + mConfirmField->getHeight() + 7); - mFemaleButton->setPosition( - 70 + 10 + mMaleButton->getWidth(), - mMaleButton->getY()); - - mCancelButton->setPosition( - width - mCancelButton->getWidth() - 5, - height - mCancelButton->getHeight() - 5); - mRegisterButton->setPosition( - mCancelButton->getX() - mRegisterButton->getWidth() - 5, - height - mRegisterButton->getHeight() - 5); + ContainerPlacer place; + place = getPlacer(0, 0); + place(0, 0, userLabel); + place(0, 1, passwordLabel); + place(0, 2, confirmLabel); + place(1, 3, mMaleButton); + place(2, 3, mFemaleButton); + place(0, 4, serverLabel); + place(1, 0, mUserField, 3).setPadding(2); + place(1, 1, mPasswordField, 3).setPadding(2); + place(1, 2, mConfirmField, 3).setPadding(2); + place(1, 4, mServerField, 3).setPadding(2); + place = getPlacer(0, 2); + place(1, 0, mRegisterButton); + place(2, 0, mCancelButton); + reflowLayout(250, 0); mUserField->addKeyListener(this); mPasswordField->addKeyListener(this); @@ -128,19 +125,6 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mConfirmField->addActionListener(this); mServerField->addActionListener(this); - add(userLabel); - add(passwordLabel); - add(serverLabel); - add(confirmLabel); - add(mUserField); - add(mPasswordField); - add(mConfirmField); - add(mServerField); - add(mMaleButton); - add(mFemaleButton); - add(mRegisterButton); - add(mCancelButton); - setLocationRelativeTo(getParent()); setVisible(true); mUserField->requestFocus(); @@ -154,8 +138,7 @@ RegisterDialog::~RegisterDialog() delete mWrongDataNoticeListener; } -void -RegisterDialog::action(const gcn::ActionEvent &event) +void RegisterDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { @@ -244,14 +227,12 @@ RegisterDialog::action(const gcn::ActionEvent &event) } } -void -RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) +void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) { mRegisterButton->setEnabled(canSubmit()); } -bool -RegisterDialog::canSubmit() +bool RegisterDialog::canSubmit() const { return !mUserField->getText().empty() && !mPasswordField->getText().empty() && diff --git a/src/gui/register.h b/src/gui/register.h index 771962cc..d696c686 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -31,19 +31,7 @@ class LoginData; class OkDialog; - -/** - * Listener used while dealing with wrong data. It is used to direct the focus - * to the field which contained wrong data when the Ok button was pressed on - * the error notice. - */ -class WrongDataNoticeListener : public gcn::ActionListener { - public: - void setTarget(gcn::TextField *textField); - void action(const gcn::ActionEvent &event); - private: - gcn::TextField *mTarget; -}; +class WrongDataNoticeListener; /** * The registration dialog. @@ -82,8 +70,7 @@ class RegisterDialog : public Window, public gcn::ActionListener, * Returns whether submit can be enabled. This is true in the register * state, when all necessary fields have some text. */ - bool - canSubmit(); + bool canSubmit() const; gcn::TextField *mUserField; gcn::TextField *mPasswordField; |