本文整理汇总了C++中mygui::WidgetPtr::createWidgetT方法的典型用法代码示例。如果您正苦于以下问题:C++ WidgetPtr::createWidgetT方法的具体用法?C++ WidgetPtr::createWidgetT怎么用?C++ WidgetPtr::createWidgetT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygui::WidgetPtr
的用法示例。
在下文中一共展示了WidgetPtr::createWidgetT方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseWidget
void EditorWidgets::parseWidget(MyGUI::xml::xmlNodeIterator & _widget, MyGUI::WidgetPtr _parent)
{
WidgetContainer * container = new WidgetContainer();
// парсим атрибуты виджета
MyGUI::IntCoord coord;
MyGUI::Align align = MyGUI::ALIGN_DEFAULT;
_widget->findAttribute("name", container->name);
_widget->findAttribute("type", container->type);
_widget->findAttribute("skin", container->skin);
_widget->findAttribute("layer", container->layer);
if (_widget->findAttribute("align", container->align)) align = MyGUI::SkinManager::getInstance().parseAlign(container->align);
if (_widget->findAttribute("position", container->position)) coord = MyGUI::IntCoord::parse(container->position);
if (_widget->findAttribute("position_real", container->position_real)) coord = MyGUI::Gui::getInstance().convertRelativeToInt(MyGUI::FloatCoord::parse(container->position_real), _parent);
// в гуе на 2 одноименных виджета ругается и падает, а у нас будет просто переименовывать
if (false == container->name.empty())
{
WidgetContainer * iter = find(container->name);
if (null != iter)
{
LOGGING(LogSection, Warning, "widget with same name name '" << container->name << "'. Renamed");
static long renameN=0;
container->name = MyGUI::utility::toString(container->name, renameN++);
}
}
std::string tmpname = container->name;
if (tmpname.empty())
{
tmpname = MyGUI::utility::toString(container->type, global_counter);
global_counter++;
}
//может и не стоит
tmpname = "LayoutEditor_" + tmpname;
if (null == _parent) {
container->widget = MyGUI::Gui::getInstance().createWidgetT(container->type, container->skin, coord, align, container->layer, tmpname);
add(container);
}
else
{
container->widget = _parent->createWidgetT(container->type, container->skin, coord, align, tmpname);
add(container);
}
// берем детей и крутимся
MyGUI::xml::xmlNodeIterator widget = _widget->getNodeIterator();
while (widget.nextNode()) {
std::string key, value;
if (widget->getName() == "Widget") parseWidget(widget, container->widget);
else if (widget->getName() == "Property") {
// парсим атрибуты
if (false == widget->findAttribute("key", key)) continue;
if (false == widget->findAttribute("value", value)) continue;
// и парсим свойство
if (("Message_Modal" != key) && ("Window_AutoAlpha" != key)) MyGUI::WidgetManager::getInstance().parse(container->widget, key, value);
container->mProperty.push_back(std::make_pair(key, value));
}
else if (widget->getName() == "UserString") {
// парсим атрибуты
if (false == widget->findAttribute("key", key)) continue;
if (false == widget->findAttribute("value", value)) continue;
container->mUserString.insert(std::make_pair(key, value));
}
};
}
示例2: parseWidget
void EditorWidgets::parseWidget(MyGUI::xml::xmlNodeIterator & _widget, MyGUI::WidgetPtr _parent)
{
WidgetContainer * container = new WidgetContainer();
// парсим атрибуты виджета
MyGUI::IntCoord coord;
MyGUI::Align align = MyGUI::ALIGN_DEFAULT;
_widget->findAttribute("name", container->name);
_widget->findAttribute("type", container->type);
_widget->findAttribute("skin", container->skin);
_widget->findAttribute("layer", container->layer);
if (_widget->findAttribute("align", container->align)) align = MyGUI::SkinManager::getInstance().parseAlign(container->align);
if (_widget->findAttribute("position", container->position)) coord = MyGUI::IntCoord::parse(container->position);
if (_widget->findAttribute("position_real", container->position_real)) coord = MyGUI::Gui::getInstance().convertRelativeToInt(MyGUI::FloatCoord::parse(container->position_real), _parent);
// в гуе на 2 одноименных виджета ругается и падает, а у нас будет просто переименовывать
if (false == container->name.empty())
{
WidgetContainer * iter = find(container->name);
if (null != iter)
{
static long renameN=0;
std::string mess = MyGUI::utility::toString("widget with same name name '", container->name, "'. Renamed to '", container->name, renameN, "'.");
LOGGING(LogSection, Warning, mess);
MyGUI::Message::_createMessage("Warning", mess, "", "LayoutEditor_Popup", true, null, MyGUI::Message::IconWarning | MyGUI::Message::Ok);
container->name = MyGUI::utility::toString(container->name, renameN++);
}
}
std::string tmpname = container->name;
if (tmpname.empty())
{
tmpname = MyGUI::utility::toString(container->type, global_counter);
global_counter++;
}
//может и не стоит
tmpname = "LayoutEditor_" + tmpname;
if (null == _parent) {
container->widget = MyGUI::Gui::getInstance().createWidgetT(container->type, container->skin, coord, align, container->layer, tmpname);
add(container);
}
else
{
container->widget = _parent->createWidgetT(container->type, container->skin, coord, align, tmpname);
add(container);
}
// берем детей и крутимся
MyGUI::xml::xmlNodeIterator widget = _widget->getNodeIterator();
while (widget.nextNode()) {
std::string key, value;
if (widget->getName() == "Widget") parseWidget(widget, container->widget);
else if (widget->getName() == "Property") {
// парсим атрибуты
if (false == widget->findAttribute("key", key)) continue;
if (false == widget->findAttribute("value", value)) continue;
// и парсим свойство
try{
if (("Message_Modal" != key) && ("Window_AutoAlpha" != key) && ("Window_Snap" != key))
MyGUI::WidgetManager::getInstance().parse(container->widget, key, value);
Ogre::Root::getSingleton().renderOneFrame();
}
catch(...)
{
MyGUI::Message::_createMessage("Warning", "No such " + key + ": '" + value + "'", "", "LayoutEditor_Popup", true, null, MyGUI::Message::IconWarning | MyGUI::Message::Ok);
if (key == "Image_Texture") MyGUI::WidgetManager::getInstance().parse(container->widget, key, "");
}// for incorrect meshes or textures
container->mProperty.push_back(std::make_pair(key, value));
}
else if (widget->getName() == "UserString") {
// парсим атрибуты
if (false == widget->findAttribute("key", key)) continue;
if (false == widget->findAttribute("value", value)) continue;
container->mUserString.insert(std::make_pair(key, value));
}
};
}