summaryrefslogtreecommitdiff
path: root/src/gui/ok_dialog.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-27 13:25:04 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-27 13:25:24 +0100
commitdd05447445dc1766e532130318af2cb6bb72a994 (patch)
treec8b2cbac64ccf9545a39c143088b57fe2cb8e678 /src/gui/ok_dialog.cpp
parent05e753294c1a603252d2eed4b1731c3f50543a7e (diff)
parent2aab736bc5d77ffda789d7de56cef100fac207e1 (diff)
downloadmana-client-dd05447445dc1766e532130318af2cb6bb72a994.tar.gz
mana-client-dd05447445dc1766e532130318af2cb6bb72a994.tar.bz2
mana-client-dd05447445dc1766e532130318af2cb6bb72a994.tar.xz
mana-client-dd05447445dc1766e532130318af2cb6bb72a994.zip
Merge branch 'aethyra/master'
Conflicts: src/beingmanager.cpp src/gui/confirm_dialog.cpp src/gui/inventorywindow.cpp src/gui/inventorywindow.h src/gui/label.cpp src/gui/label.h src/gui/popup.cpp src/gui/popup.h src/gui/scrollarea.cpp src/gui/skin.cpp src/gui/skin.h src/gui/speechbubble.cpp src/gui/window.cpp src/gui/window.h src/localplayer.h src/main.cpp src/net/ea/playerhandler.cpp src/resources/ambientoverlay.h src/resources/dye.cpp src/resources/imagewriter.cpp src/resources/itemdb.cpp src/shopitem.cpp
Diffstat (limited to 'src/gui/ok_dialog.cpp')
-rw-r--r--src/gui/ok_dialog.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index f1a97b49..24ffa80c 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -30,7 +30,7 @@
#include "../utils/gettext.h"
OkDialog::OkDialog(const std::string &title, const std::string &msg,
- Window *parent):
+ Window *parent):
Window(title, true, parent)
{
mTextBox = new TextBox;
@@ -46,30 +46,24 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
mTextBox->setTextWrapped(msg, 260);
- int numRows = mTextBox->getNumberOfRows();
+ const int numRows = mTextBox->getNumberOfRows();
const int fontHeight = getFont()->getHeight();
+ const int height = numRows * fontHeight;
+ int width = getFont()->getWidth(title);
- if (numRows > 1)
- {
- // 14 == row top + bottom graphic pixel heights
- setContentSize(mTextBox->getMinWidth() + fontHeight, ((numRows + 1) *
- fontHeight) + okButton->getHeight());
- mTextArea->setDimension(gcn::Rectangle(4, 5,
- mTextBox->getMinWidth() + 5, 3 + (numRows * fontHeight)));
- }
- else
- {
- int width = getFont()->getWidth(title);
- if (width < getFont()->getWidth(msg))
- width = getFont()->getWidth(msg);
- if (width < okButton->getWidth())
- width = okButton->getWidth();
- setContentSize(width + fontHeight, 30 + okButton->getHeight());
- mTextArea->setDimension(gcn::Rectangle(4, 5, width + 5, 17));
- }
+ if (width < mTextBox->getMinWidth())
+ width = mTextBox->getMinWidth();
+ if (width < okButton->getWidth())
+ width = okButton->getWidth();
+
+ setContentSize(mTextBox->getMinWidth() + fontHeight, height +
+ fontHeight + okButton->getHeight());
+ mTextArea->setDimension(gcn::Rectangle(4, 5, width + 2 * getPadding(),
+ height + getPadding()));
- okButton->setPosition((mTextBox->getMinWidth() - okButton->getWidth()) / 2,
- ((numRows - 1) * fontHeight) + okButton->getHeight() + 2);
+ // 8 is the padding that GUIChan adds to button widgets
+ // (top and bottom combined)
+ okButton->setPosition((width - okButton->getWidth()) / 2, height + 8);
add(mTextArea);
add(okButton);