2010-09-14 21:17:08 +00:00
|
|
|
#include "text_input.hpp"
|
2010-10-22 22:17:41 +00:00
|
|
|
#include "window_manager.hpp"
|
2010-09-14 21:17:08 +00:00
|
|
|
|
|
|
|
using namespace MWGui;
|
|
|
|
|
2011-02-21 19:36:35 +00:00
|
|
|
TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
|
|
|
|
: WindowBase("openmw_text_input_layout.xml", 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
|
|
|
|
|
|
|
getWidget(textEdit, "TextEdit");
|
2012-03-21 12:27:08 +00:00
|
|
|
textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
|
2010-09-14 21:17:08 +00:00
|
|
|
|
|
|
|
// TODO: These buttons should be managed by a Dialog class
|
|
|
|
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
|
|
|
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::setNextButtonShow(bool shown)
|
|
|
|
{
|
|
|
|
MyGUI::ButtonPtr okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
|
|
|
if (shown)
|
2010-09-14 21:17:08 +00:00
|
|
|
{
|
|
|
|
okButton->setCaption("Next");
|
2010-09-15 17:37:06 +00:00
|
|
|
okButton->setCoord(MyGUI::IntCoord(264 - 18, 60, 42 + 18, 23));
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|
2010-09-15 17:37:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
okButton->setCaption("OK");
|
|
|
|
okButton->setCoord(MyGUI::IntCoord(264, 60, 42, 23));
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);
|
|
|
|
setVisible(true);
|
|
|
|
}
|
|
|
|
|
2010-09-14 21:17:08 +00:00
|
|
|
// widget controls
|
|
|
|
|
|
|
|
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2011-02-21 21:33:29 +00:00
|
|
|
eventDone(this);
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
|
|
|
|
{
|
2011-02-21 21:33:29 +00:00
|
|
|
eventDone(this);
|
2010-09-14 21:17:08 +00:00
|
|
|
}
|