summaryrefslogtreecommitdiff
path: root/src/gui/confirm_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/confirm_dialog.cpp')
-rw-r--r--src/gui/confirm_dialog.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 5ad2e26c..a40593e3 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -23,6 +23,7 @@
#include "button.h"
#include "confirm_dialog.h"
+#include "gui.h"
#include "scrollarea.h"
#include "textbox.h"
@@ -49,14 +50,16 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
int numRows = mTextBox->getNumberOfRows();
int width = getFont()->getWidth(title);
int inWidth = yesButton->getWidth() + noButton->getWidth() + 5;
+ const int fontHeight = getFont()->getHeight();
if (numRows > 1)
{
- // 15 == height of each line of text (based on font heights)
+ // fontHeight == height of each line of text (based on font heights)
// 14 == row top + bottom graphic pixel heights
- setContentSize(mTextBox->getMinWidth() + 15, 15 + (numRows * 15) + noButton->getHeight());
+ setContentSize(mTextBox->getMinWidth() + fontHeight, ((numRows + 1) *
+ fontHeight) + noButton->getHeight());
mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5,
- 3 + (numRows * 14)));
+ 3 + (numRows * fontHeight)));
}
else
{
@@ -64,16 +67,17 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
width = getFont()->getWidth(msg);
if (width < inWidth)
width = inWidth;
- setContentSize(width + 15, 30 + noButton->getHeight());
+ setContentSize(width + fontHeight, (2 * fontHeight) +
+ noButton->getHeight());
mTextArea->setDimension(gcn::Rectangle(4, 5, width + 5, 17));
}
yesButton->setPosition(
(mTextBox->getMinWidth() - inWidth) / 2,
- (numRows * 14) + noButton->getHeight() - 8);
+ ((numRows - 1) * fontHeight) + noButton->getHeight() + 2);
noButton->setPosition(
yesButton->getX() + yesButton->getWidth() + 5,
- (numRows * 14) + noButton->getHeight() - 8);
+ ((numRows - 1) * fontHeight) + noButton->getHeight() + 2);
add(mTextArea);
add(yesButton);
@@ -81,7 +85,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
if (getParent())
{
- setLocationRelativeTo(getParent());
+ center();
getParent()->moveToTop(this);
}
setVisible(true);
@@ -104,7 +108,5 @@ void ConfirmDialog::action(const gcn::ActionEvent &event)
// Can we receive anything else anyway?
if (event.getId() == "yes" || event.getId() == "no")
- {
scheduleDelete();
- }
}