diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-18 01:27:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-19 15:12:19 +0300 |
commit | 031a455d23a5b04bb2bcd32e43a946fd60be7c6a (patch) | |
tree | 1ed266901fd0b29f9b76ffab952e9150118666be /src/gui | |
parent | e8a57a478963950d2bf0ad5614e5f16240237b03 (diff) | |
download | manaplus-031a455d23a5b04bb2bcd32e43a946fd60be7c6a.tar.gz manaplus-031a455d23a5b04bb2bcd32e43a946fd60be7c6a.tar.bz2 manaplus-031a455d23a5b04bb2bcd32e43a946fd60be7c6a.tar.xz manaplus-031a455d23a5b04bb2bcd32e43a946fd60be7c6a.zip |
move virtual member calls from editdialog constuctor into postInit.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/editdialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/windows/editdialog.h | 4 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 6d1c38d48..862fc11d6 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -345,6 +345,7 @@ void SetupItemTextField::action(const gcn::ActionEvent &event) { mEditDialog = new EditDialog(mText, mTextField->getText(), mEventName + "_EDIT_OK"); + mEditDialog->postInit(); mEditDialog->addActionListener(this); } else if (eventId == mEventName + "_EDIT_OK") @@ -472,6 +473,7 @@ void SetupItemIntTextField::action(const gcn::ActionEvent &event) { mEditDialog = new EditDialog(mText, mTextField->getText(), mEventName + "_EDIT_OK"); + mEditDialog->postInit(); mEditDialog->addActionListener(this); } else if (eventId == mEventName + "_EDIT_OK") diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp index acd5d9f72..f3c583d00 100644 --- a/src/gui/windows/editdialog.cpp +++ b/src/gui/windows/editdialog.cpp @@ -36,21 +36,27 @@ EditDialog::EditDialog(const std::string &title, const std::string &msg, Window(title, modal, parent, "edit.xml"), gcn::ActionListener(), mEventOk(eventOk), - mTextField(new TextField(this)) + mTextField(new TextField(this)), + mDefaultWidth(width) { mTextField->setText(msg); +} + +void EditDialog::postInit() +{ // TRANSLATORS: edit dialog label Button *const okButton = new Button(this, _("OK"), mEventOk, this); const int numRows = 1; const int fontHeight = getFont()->getHeight(); const int height = numRows * fontHeight; + const int pad = getPadding(); - setContentSize(width, height + fontHeight + okButton->getHeight()); - mTextField->setPosition(getPadding(), getPadding()); - mTextField->setWidth(width - (2 * getPadding())); + setContentSize(mDefaultWidth, height + fontHeight + okButton->getHeight()); + mTextField->setPosition(pad, pad); + mTextField->setWidth(mDefaultWidth - 2 * pad); - okButton->setPosition((width - okButton->getWidth()) / 2, + okButton->setPosition((mDefaultWidth - okButton->getWidth()) / 2, height + getOption("buttonPadding", 8)); add(mTextField); diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h index 4199b6791..ce5160906 100644 --- a/src/gui/windows/editdialog.h +++ b/src/gui/windows/editdialog.h @@ -52,6 +52,8 @@ class EditDialog final : public Window, public gcn::ActionListener A_DELETE_COPY(EditDialog) + void postInit() override; + /** * Called when receiving actions from the widgets. */ @@ -62,8 +64,8 @@ class EditDialog final : public Window, public gcn::ActionListener private: std::string mEventOk; - TextField *mTextField; + int mDefaultWidth; }; #endif // GUI_WINDOWS_EDITDIALOG_H |