2010-09-14 21:17:08 +00:00
|
|
|
#include "text_input.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2010-09-14 21:17:08 +00:00
|
|
|
|
|
|
|
using namespace MWGui;
|
|
|
|
|
2012-08-12 16:11:09 +00:00
|
|
|
TextInputDialog::TextInputDialog(MWBase::WindowManager& parWindowManager)
|
2012-07-03 09:34:20 +00:00
|
|
|
: WindowBase("openmw_text_input.layout", parWindowManager)
|
2010-09-14 21:17:08 +00:00
|
|
|
{
|
|
|
|
// Centre dialog
|
2010-11-06 10:27:53 +00:00
|
|
|
center();
|
2010-09-14 21:17:08 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
getWidget(mTextEdit, "TextEdit");
|
|
|
|
mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
|
2010-09-14 21:17:08 +00:00
|
|
|
|
|
|
|
MyGUI::ButtonPtr okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
2012-03-21 12:27:08 +00:00
|
|
|
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
|
2010-09-15 17:37:06 +00:00
|
|
|
|
|
|
|
// Make sure the edit box has focus
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
|
2010-09-15 17:37:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::setNextButtonShow(bool shown)
|
|
|
|
{
|
|
|
|
MyGUI::ButtonPtr okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
2012-04-16 17:14:05 +00:00
|
|
|
|
2010-09-15 17:37:06 +00:00
|
|
|
if (shown)
|
2012-04-16 17:14:05 +00:00
|
|
|
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
|
2010-09-15 17:37:06 +00:00
|
|
|
else
|
2012-04-16 17:14:05 +00:00
|
|
|
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
2010-09-15 17:37:06 +00:00
|
|
|
}
|
2010-09-15 14:12:36 +00:00
|
|
|
|
2010-09-15 17:37:06 +00:00
|
|
|
void TextInputDialog::setTextLabel(const std::string &label)
|
|
|
|
{
|
|
|
|
setText("LabelT", label);
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 17:48:37 +00:00
|
|
|
void TextInputDialog::open()
|
|
|
|
{
|
|
|
|
// Make sure the edit box has focus
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit);
|
2010-09-15 17:48:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-14 21:17:08 +00:00
|
|
|
// widget controls
|
|
|
|
|
|
|
|
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2012-09-18 17:00:20 +00:00
|
|
|
if (mTextEdit->getCaption() == "")
|
|
|
|
{
|
|
|
|
mWindowManager.messageBox ("#{sNotifyMessage37}", std::vector<std::string>());
|
|
|
|
MyGUI::InputManager::getInstance ().setKeyFocusWidget (mTextEdit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eventDone(this);
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
|
|
|
|
{
|
2012-09-18 17:00:20 +00:00
|
|
|
if (mTextEdit->getCaption() == "")
|
|
|
|
{
|
|
|
|
mWindowManager.messageBox ("#{sNotifyMessage37}", std::vector<std::string>());
|
|
|
|
MyGUI::InputManager::getInstance ().setKeyFocusWidget (mTextEdit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eventDone(this);
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|