1 /*! 2 @file 3 @author Albert Semenov 4 @date 08/2010 5 */ 6 7 #include "Precompiled.h" 8 #include "MessageBoxManager.h" 9 10 template <> tools::MessageBoxManager* MyGUI::Singleton<tools::MessageBoxManager>::msInstance = nullptr; 11 template <> const char* MyGUI::Singleton<tools::MessageBoxManager>::mClassTypeName = "MessageBoxManager"; 12 13 namespace tools 14 { 15 initialise()16 void MessageBoxManager::initialise() 17 { 18 } 19 shutdown()20 void MessageBoxManager::shutdown() 21 { 22 } 23 create(const MyGUI::UString & _caption,const MyGUI::UString & _message,MyGUI::MessageBoxStyle _style)24 MyGUI::Message* MessageBoxManager::create(const MyGUI::UString& _caption, const MyGUI::UString& _message, MyGUI::MessageBoxStyle _style) 25 { 26 MyGUI::Message* message = new MyGUI::Message("MessageBox2.layout"); 27 28 message->setCaption(_caption); 29 message->setMessageText(_message); 30 message->setSmoothShow(true); 31 message->setMessageStyle(_style); 32 33 message->setMessageModal(true); 34 35 registerMessageBox(message); 36 37 return message; 38 } 39 hasAny()40 bool MessageBoxManager::hasAny() 41 { 42 return !mMessages.empty(); 43 } 44 endTop(MyGUI::MessageBoxStyle _button)45 void MessageBoxManager::endTop(MyGUI::MessageBoxStyle _button) 46 { 47 if (!mMessages.empty()) 48 mMessages.back()->endMessage(_button); 49 } 50 registerMessageBox(MyGUI::Message * _message)51 void MessageBoxManager::registerMessageBox(MyGUI::Message* _message) 52 { 53 mMessages.push_back(_message); 54 _message->eventMessageBoxResult += MyGUI::newDelegate(this, &MessageBoxManager::notifMessageBoxResultRegister); 55 } 56 notifMessageBoxResultRegister(MyGUI::Message * _sender,MyGUI::MessageBoxStyle _result)57 void MessageBoxManager::notifMessageBoxResultRegister(MyGUI::Message* _sender, MyGUI::MessageBoxStyle _result) 58 { 59 VectorMessage::iterator item = std::find(mMessages.begin(), mMessages.end(), _sender); 60 if (item != mMessages.end()) 61 mMessages.erase(item); 62 } 63 64 } 65