2012-05-23 03:28:25 +00:00
|
|
|
#include "confirmationdialog.hpp"
|
|
|
|
|
2015-01-10 01:50:43 +00:00
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
#include <MyGUI_EditBox.h>
|
|
|
|
|
2017-09-22 14:58:05 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
|
2012-05-23 03:28:25 +00:00
|
|
|
namespace MWGui
|
|
|
|
{
|
2013-04-10 18:46:21 +00:00
|
|
|
ConfirmationDialog::ConfirmationDialog() :
|
|
|
|
WindowModal("openmw_confirmation_dialog.layout")
|
2012-05-23 03:28:25 +00:00
|
|
|
{
|
|
|
|
getWidget(mMessage, "Message");
|
|
|
|
getWidget(mOkButton, "OkButton");
|
|
|
|
getWidget(mCancelButton, "CancelButton");
|
|
|
|
|
|
|
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onCancelButtonClicked);
|
|
|
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onOkButtonClicked);
|
|
|
|
}
|
|
|
|
|
2017-03-30 13:05:56 +00:00
|
|
|
void ConfirmationDialog::askForConfirmation(const std::string& message)
|
2012-05-23 03:28:25 +00:00
|
|
|
{
|
|
|
|
setVisible(true);
|
|
|
|
|
|
|
|
mMessage->setCaptionWithReplacing(message);
|
|
|
|
|
2017-03-30 13:05:56 +00:00
|
|
|
int height = mMessage->getTextSize().height + 60;
|
2014-09-07 01:18:01 +00:00
|
|
|
|
2017-03-30 13:05:56 +00:00
|
|
|
int width = mMessage->getTextSize().width + 24;
|
2012-05-23 03:28:25 +00:00
|
|
|
|
2017-03-30 13:05:56 +00:00
|
|
|
mMainWidget->setSize(width, height);
|
2012-05-23 03:28:25 +00:00
|
|
|
|
2017-03-30 13:05:56 +00:00
|
|
|
mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height + 24);
|
2012-05-23 03:28:25 +00:00
|
|
|
|
2019-06-08 23:08:09 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mOkButton);
|
2017-09-22 14:58:05 +00:00
|
|
|
|
2012-05-23 03:28:25 +00:00
|
|
|
center();
|
|
|
|
}
|
|
|
|
|
2017-09-23 10:18:39 +00:00
|
|
|
bool ConfirmationDialog::exit()
|
2012-05-23 03:28:25 +00:00
|
|
|
{
|
2019-09-02 14:49:29 +00:00
|
|
|
setVisible(false);
|
2014-06-09 23:57:54 +00:00
|
|
|
eventCancelClicked();
|
2017-09-23 10:18:39 +00:00
|
|
|
return true;
|
2012-05-23 03:28:25 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 07:00:31 +00:00
|
|
|
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2012-05-23 03:28:25 +00:00
|
|
|
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
setVisible(false);
|
2014-06-09 23:57:54 +00:00
|
|
|
|
|
|
|
eventOkClicked();
|
2012-05-23 03:28:25 +00:00
|
|
|
}
|
|
|
|
}
|