本文整理汇总了C++中ListView::GetItems方法的典型用法代码示例。如果您正苦于以下问题:C++ ListView::GetItems方法的具体用法?C++ ListView::GetItems怎么用?C++ ListView::GetItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListView
的用法示例。
在下文中一共展示了ListView::GetItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleHierarchyListSelectionChange
void InGameEditor::HandleHierarchyListSelectionChange(StringHash eventType, VariantMap& eventData)
{
ListView* hierarchyList = hierarchyWindow_->GetHierarchyList();
const PODVector<UIElement*>& items = hierarchyList->GetItems();
const PODVector<unsigned>& indices = hierarchyList->GetSelections();
editorData_->ClearSelection();
for (unsigned int i = 0; i < indices.Size(); ++i)
{
unsigned int index = indices[i];
UIElement* item = items[index];
int type = item->GetVar(TYPE_VAR).GetInt();
if (type == ITEM_COMPONENT)
{
Component* comp = GetListComponent(item);
editorData_->AddSelectedComponent(comp);
}
else if (type == ITEM_NODE)
{
Node* node = GetListNode(item);
editorData_->AddSelectedNode(node);
}
else if (type == ITEM_UI_ELEMENT)
{
UIElement* element = GetListUIElement(item);
editorData_->AddSelectedUIElement(element);
}
}
// If only one node/UIElement selected, use it for editing
if (editorData_->GetNumSelectedNodes() == 1)
editorData_->SetEditNode(editorData_->GetSelectedNodes()[0]);
if (editorData_->GetNumSelectedUIElements() == 1)
editorData_->SetEditUIElement(editorData_->GetSelectedUIElements()[0]);
// If selection contains only components, and they have a common node, use it for editing
if (editorData_->GetSelectedNodes().Empty() && !editorData_->GetSelectedComponents().Empty())
{
Node* commonNode = NULL;
for (unsigned int i = 0; i < editorData_->GetNumSelectedComponents(); ++i)
{
if (i == 0)
commonNode = editorData_->GetSelectedComponents()[i]->GetNode();
else
{
if (editorData_->GetSelectedComponents()[i]->GetNode() != commonNode)
commonNode = NULL;
}
}
editorData_->SetEditNode(commonNode);
}
// Now check if the component(s) can be edited. If many selected, must have same type or have same edit node
if (!editorData_->GetSelectedComponents().Empty())
{
if (editorData_->GetEditNode() == NULL)
{
StringHash compType = editorData_->GetSelectedComponents()[0]->GetType();
bool sameType = true;
for (unsigned int i = 1; i < editorData_->GetNumSelectedComponents(); ++i)
{
if (editorData_->GetSelectedComponents()[i]->GetType() != compType)
{
sameType = false;
break;
}
}
if (sameType)
editorData_->SetEditComponents(editorData_->GetSelectedComponents());
}
else
{
editorData_->SetEditComponents(editorData_->GetSelectedComponents());
editorData_->SetNumEditableComponentsPerNode(editorData_->GetNumSelectedComponents());
}
}
// If just nodes selected, and no components, show as many matching components for editing as possible
if (!editorData_->GetSelectedNodes().Empty() && editorData_->GetSelectedComponents().Empty() && editorData_->GetSelectedNodes()[0]->GetNumComponents() > 0)
{
unsigned int count = 0;
for (unsigned int j = 0; j < editorData_->GetSelectedNodes()[0]->GetNumComponents(); ++j)
{
StringHash compType = editorData_->GetSelectedNodes()[0]->GetComponents()[j]->GetType();
bool sameType = true;
for (unsigned int i = 1; i < editorData_->GetNumSelectedNodes(); ++i)
{
if (editorData_->GetSelectedNodes()[i]->GetNumComponents() <= j || editorData_->GetSelectedNodes()[i]->GetComponents()[j]->GetType() != compType)
{
sameType = false;
break;
}
}
if (sameType)
{
++count;
//.........这里部分代码省略.........