From 2b4110a217110dfe9919fa3cc70e41c6920ac597 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 18 Oct 2012 18:37:10 +0300 Subject: Fix ok dialog resize issue. Also allow set from ouside preferred width. --- src/gui/okdialog.cpp | 9 +++++---- src/gui/okdialog.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 22ae9d41a..5a2e39022 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -37,14 +37,15 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, const int soundEvent, const bool modal, - const bool showCenter, Window *const parent): + const bool showCenter, Window *const parent, + const int minWidth) : Window(title, modal, parent, "ok.xml"), ActionListener(), mTextBox(new TextBox) { mTextBox->setEditable(false); mTextBox->setOpaque(false); - mTextBox->setTextWrapped(msg, 260); + mTextBox->setTextWrapped(msg, minWidth); Button *const okButton = new Button(_("OK"), "ok", this); @@ -58,8 +59,8 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, if (width < okButton->getWidth()) width = okButton->getWidth(); - setContentSize(mTextBox->getMinWidth() + fontHeight, height + - fontHeight + okButton->getHeight()); + width = mTextBox->getWidth() + fontHeight; + setContentSize(width, height + fontHeight + okButton->getHeight()); mTextBox->setPosition(getPadding(), getPadding()); // 8 is the padding that GUIChan adds to button widgets diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index be6d73c49..7c03b8a93 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -53,7 +53,8 @@ class OkDialog final : public Window, public gcn::ActionListener */ OkDialog(const std::string &title, const std::string &msg, const int soundEvent = DIALOG_OK, const bool modal = true, - const bool showCenter = true, Window *const parent = nullptr); + const bool showCenter = true, Window *const parent = nullptr, + const int minWidth = 260); A_DELETE_COPY(OkDialog) -- cgit v1.2.3-70-g09d2