| 30 | |
| 31 | template<typename T> |
| 32 | void assignWidget(T*& _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) |
| 33 | { |
| 34 | _widget = nullptr; |
| 35 | for (const auto& iter : mListWindowRoot) |
| 36 | { |
| 37 | MyGUI::Widget* find = iter->findWidget(mPrefix + _name); |
| 38 | if (nullptr != find) |
| 39 | { |
| 40 | T* cast = find->castType<T>(false); |
| 41 | if (nullptr != cast) |
| 42 | { |
| 43 | _widget = cast; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | MYGUI_LOG( |
| 48 | Warning, |
| 49 | "Widget with name '" |
| 50 | << _name << "' have wrong type ('" << find->getTypeName() << "instead of '" |
| 51 | << T::getClassTypeName() << "'). [" << mLayoutName << "]"); |
| 52 | MYGUI_ASSERT( |
| 53 | !_throw, |
| 54 | "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); |
| 55 | if (_createFakeWidgets) |
| 56 | _widget = _createFakeWidget<T>(mMainWidget); |
| 57 | } |
| 58 | |
| 59 | return; |
| 60 | } |
| 61 | } |
| 62 | MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); |
| 63 | MYGUI_ASSERT(!_throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); |
| 64 | if (_createFakeWidgets) |
| 65 | _widget = _createFakeWidget<T>(mMainWidget); |
| 66 | } |
| 67 | |
| 68 | template<typename T> |
| 69 | void assignBase(T*& _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) |
nothing calls this directly
no test coverage detected