当前位置: 首页>>代码示例>>C++>>正文


C++ Widget::getName方法代码示例

本文整理汇总了C++中mygui::Widget::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::getName方法的具体用法?C++ Widget::getName怎么用?C++ Widget::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mygui::Widget的用法示例。


在下文中一共展示了Widget::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

BaseGui::BaseGui(std::string & layout)
{
	std::string mainWidgetName = "main";

	_layoutRoot = MyGUI::LayoutManager::getInstance().loadLayout(layout);
	_mainWidget = nullptr;
	for (MyGUI::VectorWidgetPtr::iterator it = _layoutRoot.begin(); it != _layoutRoot.end(); it++)
	{
		MyGUI::Widget* ptr = *it;
		if (ptr->getName() == mainWidgetName)
		{
			_mainWidget = ptr;
			return;
		}
	}
	std::cout << "Could not find widget named " + mainWidgetName + " in layout " + layout << std::endl;
}
开发者ID:AditGame,项目名称:Adit,代码行数:17,代码来源:BaseGui.cpp

示例2: getWidgetSlotByScreenPosition_modified

	MyGUI::Widget* StashPanel::getWidgetSlotByScreenPosition_modified(const MyGUI::types::TPoint<int>&  _value)
	{
		int slot_count = this->mslot_container_panelWidget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
			if (widget->getAbsoluteRect().inside(_value))
			{
				MyGUI::types::TRect<int> big_rect = widget->getAbsoluteRect();
				MyGUI::types::TSize<int> big_size = widget->getSize();

				/********/
				/* 1  2 */
				/* 3  4 */
				/********/

				MyGUI::types::TRect<int> rect_1;
				rect_1.set(big_rect.left, big_rect.top, big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2);

				MyGUI::types::TRect<int> rect_2;
				rect_2.set(big_rect.left + big_size.width / 2, big_rect.top, big_rect.left + big_size.width, big_rect.top + big_size.height / 2);

				MyGUI::types::TRect<int> rect_3;
				rect_3.set(big_rect.left, big_rect.top + big_size.height / 2, big_rect.left + big_size.width / 2, big_rect.top + big_size.height);

				MyGUI::types::TRect<int> rect_4;
				rect_4.set(big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2, big_rect.left + big_size.width , big_rect.top + big_size.height);

				if (rect_1.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_1");
					return widget;
				}

				if (rect_2.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_2");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r, c+1);
							return ret;
						}
					}
				}

				if (rect_3.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_3");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c);
							return ret;
						}
					}
				}

				if (rect_4.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_4");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c+1);
							return ret;
						}
					}
				}

				return widget; //should not return this !
			}
		}
		return 0;
	}
开发者ID:Alex-G,项目名称:MuOnline,代码行数:96,代码来源:StashPanel.cpp


注:本文中的mygui::Widget::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。