本文整理汇总了C++中core::Element::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::GetId方法的具体用法?C++ Element::GetId怎么用?C++ Element::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core::Element
的用法示例。
在下文中一共展示了Element::GetId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateSourceElement
void ElementInfo::UpdateSourceElement()
{
// Set the title:
Core::Element* title_content = GetElementById("title-content");
if (title_content != NULL)
{
if (source_element != NULL)
title_content->SetInnerRML(source_element->GetTagName());
else
title_content->SetInnerRML("Element Information");
}
// Set the attributes:
Core::Element* attributes_content = GetElementById("attributes-content");
if (attributes_content)
{
int index = 0;
Core::String name;
Core::String value;
Core::String attributes;
if (source_element != NULL)
{
while (source_element->IterateAttributes(index, name, value))
attributes.Append(Core::String(name.Length() + value.Length() + 32, "%s: <em>%s</em><br />", name.CString(), value.CString()));
}
if (attributes.Empty())
{
while (attributes_content->HasChildNodes())
attributes_content->RemoveChild(attributes_content->GetChild(0));
}
else
attributes_content->SetInnerRML(attributes);
}
// Set the properties:
Core::Element* properties_content = GetElementById("properties-content");
if (properties_content)
{
Core::String properties;
if (source_element != NULL)
BuildElementPropertiesRML(properties, source_element, source_element);
if (properties.Empty())
{
while (properties_content->HasChildNodes())
properties_content->RemoveChild(properties_content->GetChild(0));
}
else
properties_content->SetInnerRML(properties);
}
// Set the position:
Core::Element* position_content = GetElementById("position-content");
if (position_content)
{
// left, top, width, height.
if (source_element != NULL)
{
Core::Vector2f element_offset = source_element->GetRelativeOffset(Core::Box::BORDER);
Core::Vector2f element_size = source_element->GetBox().GetSize(Core::Box::BORDER);
Core::String positions;
positions.Append(Core::String(64, "left: <em>%.0fpx</em><br />", element_offset.x));
positions.Append(Core::String(64, "top: <em>%.0fpx</em><br />", element_offset.y));
positions.Append(Core::String(64, "width: <em>%.0fpx</em><br />", element_size.x));
positions.Append(Core::String(64, "height: <em>%.0fpx</em><br />", element_size.y));
position_content->SetInnerRML(positions);
}
else
{
while (position_content->HasChildNodes())
position_content->RemoveChild(position_content->GetFirstChild());
}
}
// Set the ancestors:
Core::Element* ancestors_content = GetElementById("ancestors-content");
if (ancestors_content)
{
Core::String ancestors;
Core::Element* element_ancestor = NULL;
if (source_element != NULL)
element_ancestor = source_element->GetParentNode();
int ancestor_depth = 1;
while (element_ancestor)
{
Core::String ancestor_name = element_ancestor->GetTagName();
const Core::String ancestor_id = element_ancestor->GetId();
if (!ancestor_id.Empty())
{
ancestor_name += "#";
ancestor_name += ancestor_id;
}
ancestors.Append(Core::String(ancestor_name.Length() + 32, "<p id=\"a %d\">%s</p>", ancestor_depth, ancestor_name.CString()));
element_ancestor = element_ancestor->GetParentNode();
//.........这里部分代码省略.........