示例#1
0
void AttrWidgetVectorFloat::Refresh(const XMLAttribute &attribute)
{
    AttributeWidget::Refresh(attribute);

    XMLAttribute::Type attrType = attribute.GetType();

    Array<float> vf;
    if (attrType == XMLAttribute::Type::Float)
    {
        float v = attribute.GetFloat();
        vf = {v};
    }
    else if (attrType == XMLAttribute::Type::Vector2)
    {
        Vector2 v = attribute.GetVector2();
        vf = {v.x, v.y};
    }
    else if (attrType == XMLAttribute::Type::Vector3)
    {
        Vector3 v = attribute.GetVector3();
        vf = {v.x, v.y, v.z};
    }
    else if (attrType == XMLAttribute::Type::Vector4 ||
             attrType == XMLAttribute::Type::Quaternion ||
             attrType == XMLAttribute::Type::Rect)
    {
        Vector4 v = attribute.GetVector4();
        vf = {v.x, v.y, v.z, v.w};
    }

    SetValue(vf);
}
示例#2
0
XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
{
    XMLAttribute* last = 0;
    XMLAttribute* attrib = 0;
    for( attrib = rootAttribute;
         attrib;
         last = attrib, attrib = attrib->next )
    {
        if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
            break;
        }
    }
    if ( !attrib ) {
        attrib = new (document->attributePool.Alloc() ) XMLAttribute();
        attrib->memPool = &document->attributePool;
        if ( last ) {
            last->next = attrib;
        }
        else {
            rootAttribute = attrib;
        }
        attrib->SetName( name );
    }
    return attrib;
}
示例#3
0
XMLAttribute *XMLTreeNode::GetAttribute(const char *name) const
{
	XMLAttribute *a;

	a=attributes;

	while (a)
	{
		if (a->GetName())
		{
			switch (mmode)
			{
			case MATCH_CASE:
				if (!strcmp(a->GetName(), name)) return a;

			case MATCH_NOCASE:
				if (!stricmp(a->GetName(), name)) return a;
			}
		}

		a=a->GetNext();
	}

	return 0;
}
示例#4
0
	XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
	{
		XMLAttribute* last = 0;
		XMLAttribute* attrib = 0;
		for( attrib = _rootAttribute;
			attrib;
			last = attrib, attrib = attrib->_next ) {
				if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
					break;
				}
		}
		if ( !attrib ) {
			attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
			attrib->_memPool = &_document->_attributePool;
			if ( last ) {
				last->_next = attrib;
			}
			else {
				_rootAttribute = attrib;
			}
			attrib->SetName( name );
			attrib->_memPool->SetTracked(); // always created and linked.
		}
		return attrib;
	}
示例#5
0
void ConfigSingleton::configure(std::string xml_file_path)
{
    //Open XML config file and try to load it
    XMLDocument doc;
    if(doc.LoadFile(xml_file_path.c_str()) != XML_SUCCESS)
    {
        std::cerr << "Cannot reach configuration file: " << xml_file_path << "!" << std::endl;
        return;
    }

    //Look for <config> element
    XMLElement* pConfig = doc.FirstChildElement("root")->FirstChildElement("config");
    if(pConfig==nullptr)
    {
        std::cerr << "Invalid configuration file: " << xml_file_path << "!" << std::endl;
        return;
    }

    //Iterate attribute list and set parameter values
    //Version 2 of TinyXML won't let me iterate over Attribute list this way by returning
    //const XMLAttribute*. I'm forced to const_cast before I find an elegant way of doing this.
    XMLAttribute* pAttrib = const_cast<XMLAttribute*>(pConfig->FirstAttribute());
    while(pAttrib != nullptr)
    {
        set_parameter(pAttrib->Name(),pAttrib->Value());
        pAttrib = const_cast<XMLAttribute*>(pAttrib->Next());
    }
}
示例#6
0
void XMLElement::walkTree(Log::ModuleId logModule, Log::Level level,
        unsigned int depth, XMLElement node) {
#ifdef PUGIXML
    xml_tree_walker walker(logModule, level);
    node.nodePtr.traverse(walker);
#else
    while (node.isValid()) {
        XMLElement::Type nodeType = node.getType();
        XMLAttribute attr;
        xmlChar *value;

        if (XMLElement::ELEMENT_NODE == nodeType) {
            if (node.nodePtr->name) {
                Log::log(logModule, level, "Element = %s",
                        node.nodePtr->name);
            } else {
                Log::log(logModule, level, "Element, unnamed");
            }

            for (attr = node.getFirstAttribute(); attr.isValid(); attr.next()) {
                attr.log(logModule, level, depth);
            }

            walkTree(logModule, level, depth + 1, node.getFirstSubElement());
        } else if (XMLElement::CDATA_NODE == nodeType) {
            value = xmlNodeGetContent(node.nodePtr);
            if (value) {
                Log::log(logModule, level, "CDATA = '%s'",
                        value);
                xmlFree(value);
            } else {
                Log::log(logModule, level, "CDATA unable to retrieve value");
            }
        } else if (XMLElement::TEXT_NODE == nodeType) {
            value = xmlNodeGetContent(node.nodePtr);
            if (value) {
                Log::log(logModule, level, "TEXT = '%s'", value);
                xmlFree(value);
            } else {
                Log::log(logModule, level, "TEXT unable to retrieve value");
            }
        } else {
            value = xmlNodeGetContent(node.nodePtr);
            if (value) {
                Log::log(logModule, level, "Type = %d, value = %s",
                        nodeType, value);
                xmlFree(value);
            } else {
                Log::log(logModule, level,
                        "Type = %d, unable to retrieve value",
                        nodeType);
            }
        }

        node.nextSibling();
    }
#endif
}
const XMLAttribute* XMLElement::FindAttribute( const char* name ) const
{
	XMLAttribute* a = 0;
	for( a=rootAttribute; a; a = a->next ) {
		if ( XMLUtil::StringEqual( a->Name(), name ) )
			return a;
	}
	return 0;
}
示例#8
0
char *XMLTreeNode::GetAttributeValue(const char *name) const
{
	XMLAttribute *a;

	a=GetAttribute(name);
	if (a) return a->GetValue();

	return 0;
}
/** helper function to return the real value of the string (HEX or normal) */
static std::string getRealValue(XMLElement* e)
{
	std::string str = e->getFirstText();
	XMLAttribute* a = e->getAttribute("type");

	if (a && a->getValue() == "HEX")
		return StringFilter::hexparser(str);

	return str;
}
示例#10
0
void XMLTag:: addAttribute
(
  const XMLAttribute<double>& attribute )
{
  preciceTrace1 ( "addAttribute<double>()", attribute.getName() );
  assertion(not utils::contained(attribute.getName(), _attributes));
  _attributes.insert(attribute.getName());
  _doubleAttributes.insert(std::pair<std::string,XMLAttribute<double> >
                           (attribute.getName(), attribute));
}
示例#11
0
	char* XMLElement::ParseAttributes( char* p )
	{
		const char* start = p;
		XMLAttribute* prevAttribute = 0;

		// Read the attributes.
		while( p ) {
			p = XMLUtil::SkipWhiteSpace( p );
			if ( !p || !(*p) ) {
				_document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
				return 0;
			}

			// attribute.
			if (XMLUtil::IsNameStartChar( *p ) ) {
				XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
				attrib->_memPool = &_document->_attributePool;
				attrib->_memPool->SetTracked();

				p = attrib->ParseDeep( p, _document->ProcessEntities() );
				if ( !p || Attribute( attrib->Name() ) ) {
					DELETE_ATTRIBUTE( attrib );
					_document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
					return 0;
				}
				// There is a minor bug here: if the attribute in the source xml
				// document is duplicated, it will not be detected and the
				// attribute will be doubly added. However, tracking the 'prevAttribute'
				// avoids re-scanning the attribute list. Preferring performance for
				// now, may reconsider in the future.
				if ( prevAttribute ) {
					prevAttribute->_next = attrib;
				}
				else {
					_rootAttribute = attrib;
				}
				prevAttribute = attrib;
			}
			// end of the tag
			else if ( *p == '/' && *(p+1) == '>' ) {
				_closingType = CLOSED;
				return p+2;	// done; sealed element.
			}
			// end of the tag
			else if ( *p == '>' ) {
				++p;
				break;
			}
			else {
				_document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
				return 0;
			}
		}
		return p;
	}
示例#12
0
bool Parser::proceedNode(Node* node, rapidxml::xml_node<>* xml_node)
{
	if (node && xml_node)
	{
		// Check required attributes
		for (std::map<std::string, bool>::const_iterator it = node->getAttributes().begin(); it != node->getAttributes().end(); ++it)
		{
			XMLAttribute* attr = xml_node->first_attribute(it->first.c_str());

			if (attr == NULL && it->second)
			{
				std::cout << "Error: Attribute `" << it->first << "` in node `" << node->getName() << "` is required." << std::endl;
				return false;
			}
		}

		// Check unsupported attributes
		for (XMLAttribute* attr = xml_node->first_attribute(); attr; attr = attr->next_attribute())
		{
			if (!node->hasAttribute(attr->name()))
				std::cout << "Warning: Attribute `" << attr->name() << "` in node `" << node->getName() << "` not supported." << std::endl;
		}

		// Node callback
		if (node->getName().compare(xml_node->name()) == 0)
			(*node)(xml_node);

		// Proceed sibling nodes
		XMLNode* sibling = xml_node->next_sibling();
		if (sibling && sibling->name())
		{
			if (node->hasSibling(sibling->name()))
			{
				if (!this->proceedNode(node->getSibling(sibling->name()), sibling))
					return false;
			}
			else
				std::cout << "Warning: Sibling `" << sibling->name() << "` of `" << node->getName() << "` not supported." << std::endl;
		}

		// Proceed child nodes
		XMLNode* child = xml_node->first_node();
		if (child && child->name())
		{
			if (node->hasChild(child->name()))
			{
				if (!this->proceedNode(node->getChild(child->name()), child))
					return false;
			}
			else
				std::cout << "Warning: Child `" << child->name() << "` of `" << node->getName() << "` not supported." << std::endl;
		}
	}
	return true;
}
示例#13
0
	const XMLAttribute* XMLElement::FindAttribute(const char* name) const
	{
		for (XMLAttribute* a = _rootAttribute; a; a = a->_next)
		{
			if (XMLUtil::StringEqual(a->Name(), name))
			{
				return a;
			}
		}
		return 0;
	}
示例#14
0
XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
{
	XMLAttribute* attrib = FindAttribute( name );
	if ( !attrib ) {
		attrib = new (document->attributePool.Alloc() ) XMLAttribute();
		attrib->memPool = &document->attributePool;
		LinkAttribute( attrib );
		attrib->SetName( name );
	}
	return attrib;
}
示例#15
0
文件: xml.cpp 项目: dsmo7206/genesis
std::string getXMLTypeAttribute(const XMLNode& node)
{
	if (rapidxml::count_attributes(const_cast<XMLNode*>(&node)) != 1)
		raiseXMLException(node, "Expected 1 attribute");

	XMLAttribute* attr = node.first_attribute();
	if (strcmp(attr->name(), "type"))
		raiseXMLException(node, "Missing \"type\" attribute");

	return std::string(attr->value());
}
示例#16
0
//来自:TinyXML
void XMLElement::ToFile(FILE *file,int blankdepth)
{
	int i;
	for ( i = 0; i < blankdepth; i++ )
	{
		fprintf( file, "    " );
	}

	fprintf_s( file, "<%s", value.c_str() );

	XMLAttribute* attri = NULL;
	for ( attri = attributes.First(); attri; attri = attri->Next() )
	{
		fprintf_s( file, " " );
		attri->ToFile( file, blankdepth );
	}

	// There are 3 different formatting approaches:
	// 1) An element without children is printed as a <foo /> node
	// 2) An element with only a text child is printed as <foo> text </foo>
	// 3) An element with children is printed on multiple lines.
	
	if ( !firstChild )
	{
		fprintf_s( file, " />" );
	}
	else if ( firstChild == lastChild && firstChild->ToText() )
	{
		fprintf_s( file, ">" );
		firstChild->ToFile( file, blankdepth + 1 );
		fprintf_s( file, "</%s>", value.c_str() );
	}
	else
	{
		XMLNode* node = NULL;
		fprintf_s( file, ">" );
		for ( node = firstChild; node; node=node->NextSibling() )
		{
			if ( !node->ToText() )
			{
				fprintf_s( file, "\n" );
			}
			node->ToFile( file, blankdepth + 1 );
		}
		fprintf_s( file, "\n" );
		for( i=0; i < blankdepth; ++i )
			fprintf_s( file, "    " );
		fprintf_s( file, "</%s>", value.c_str() );
	}
}
示例#17
0
AttrWidgetVectorFloat::AttrWidgetVectorFloat(const XMLAttribute &xmlAttribute,
                                             InspectorWidget *inspectorWidget) :
    AttributeWidget(xmlAttribute, inspectorWidget, false, true, true)
{
    QHBoxLayout *hLayout = new QHBoxLayout();
    m_layout->addLayout(hLayout, 1);
    m_layout->setSpacing(0);
    m_layout->setMargin(0);

    String labels[] = {"X", "Y", "Z", "W"};
    int numberOfFields = xmlAttribute.GetNumberOfFieldsOfType();
    for (unsigned int i = 0; i < numberOfFields; ++i)
    {
        AttrWidgetFloat *s = new AttrWidgetFloat(xmlAttribute, inspectorWidget, true);
        m_floatSlots.PushBack(s);

        QLabel *label = new QLabel(QString::fromStdString(labels[i]));
        if (i != 0)
        {
            hLayout->setSpacing(3);
        }
        hLayout->addWidget(label, 0, Qt::AlignRight | Qt::AlignVCenter);
        hLayout->addWidget(s,     0, Qt::AlignLeft | Qt::AlignVCenter);
    }

    setMinimumWidth(40);
    setFixedHeight(20);
    AfterConstructor();
}
示例#18
0
文件: SXml.cpp 项目: hillwah/darkeden
void XMLTree::AddAttribute(const string& name, const string& value )
{
	ATTRIBUTES_MAP::iterator itr = m_AttributesMap.find(name);
	
	if (itr == m_AttributesMap.end() )
	{
		XMLAttribute *pAttr = new XMLAttribute(name, value);
		
		m_AttributesVector.push_back(pAttr);
		m_AttributesMap.insert(ATTRIBUTES_MAP::value_type(name, pAttr ));
	}
	else
	{
		XMLAttribute *pAttr = itr->second;
		pAttr->SetValue(value);
	}
}
示例#19
0
void XMLElement::walkTree(Log::ModuleId logModule, Log::Level level,
        unsigned int depth, XMLElement node) {
    while (node.isValid()) {
        XMLElement::Type nodeType = node.getType();
        XMLAttribute attr;
        if (XMLElement::ELEMENT_NODE == nodeType) {
            std::string name;
            if (node.getName(name)) {
                Log::log(logModule, level, "Element = %s",
                        name.c_str());
            } else {
                Log::log(logModule, level, "Element, unnamed");
            }

            for (attr = node.getFirstAttribute(); attr.isValid(); attr.next()) {
                attr.log(logModule, level, depth);
            }

            walkTree(logModule, level, depth + 1, node.getFirstSubElement());

        } else if (XMLElement::CDATA_NODE == nodeType) {
            std::string value;
            if (node.getValue(value)) {
                Log::log(logModule, level, "CDATA = '%s'",
                        value.c_str());
            } else {
                Log::log(logModule, level, "CDATA unable to retrieve value");
            }
        } else if (XMLElement::TEXT_NODE == nodeType) {
            std::string value;
            if (node.getValue(value)) {
                Log::log(logModule, level, "TEXT = '%s'",
                        value.c_str());
            } else {
                Log::log(logModule, level, "TEXT unable to retrieve value");
            }
        } else {
            Log::log(logModule, level, "Type = %d, unknown node type",
                    nodeType);
        }
        node.nextSibling();
    }
}
示例#20
0
Shape* Shape::buildFromXMLNode(XMLNode& node)
{
	if (rapidxml::count_attributes(&node) != 1)
		raiseXMLException(node, "Expected 1 attribute");

	XMLAttribute* attr = node.first_attribute();
	if (strcmp(attr->name(), "type"))
		raiseXMLException(node, "Missing \"type\" attribute");

	const std::string type(attr->value());

	if (type == "Planet")
		return Planet::buildFromXMLNode(node);
	else if (type == "Star")
		return Star::buildFromXMLNode(node);

	raiseXMLException(node, std::string("Invalid type: ") + type);
	return nullptr; // Keep compiler happy
}
示例#21
0
char* XMLElement::ParseAttributes( char* p )
{
	const char* start = p;

	// Read the attributes.
	while( p ) {
		p = XMLUtil::SkipWhiteSpace( p );
		if ( !p || !(*p) ) {
			document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
			return 0;
		}

		// attribute.
		if ( XMLUtil::IsAlpha( *p ) ) {
			XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute();
			attrib->memPool = &document->attributePool;

			p = attrib->ParseDeep( p, document->ProcessEntities() );
			if ( !p || Attribute( attrib->Name() ) ) {
				DELETE_ATTRIBUTE( attrib );
				document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
				return 0;
			}
			LinkAttribute( attrib );
		}
		// end of the tag
		else if ( *p == '/' && *(p+1) == '>' ) {
			closingType = CLOSED;
			return p+2;	// done; sealed element.
		}
		// end of the tag
		else if ( *p == '>' ) {
			++p;
			break;
		}
		else {
			document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
			return 0;
		}
	}
	return p;
}
示例#22
0
void AttributeWidget::Refresh(const XMLAttribute &attribute)
{
    m_readonly =  attribute.HasProperty(XMLProperty::Readonly);
    m_enabled  = !attribute.HasProperty(XMLProperty::Disabled);
    m_inlined  =  attribute.HasProperty(XMLProperty::Inline);
    m_hidden   =  attribute.HasProperty(XMLProperty::Hidden);

    setEnabled(m_enabled);

    if (m_hidden) // Only hide, to avoid window flickering
    {
        setVisible(false);
        setHidden(true);
        if (m_label)
        {
            m_label->setVisible(false);
            m_label->setHidden(true);
        }
    }
}
示例#23
0
	void XMLElement::DeleteAttribute(const char* name)
	{
		XMLAttribute* prev = 0;
		for (XMLAttribute* a = _rootAttribute; a; a = a->_next)
		{
			if (XMLUtil::StringEqual(name, a->Name()))
			{
				if (prev)
				{
					prev->_next = a->_next;
				}
				else
				{
					_rootAttribute = a->_next;
				}
				DeleteAttribute(a);
				break;
			}
			prev = a;
		}
	}
示例#24
0
unsigned int CfgBase::getTimeInUnit(const std::string& name, timeUnit unit, uint32_t def, XMLElement* elem)
{
	unsigned int time;
	if (!elem)
		elem = _elem;

	XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
	XMLNode::XMLSet<XMLElement*>::const_iterator it = set.begin();
	for (; it != set.end(); it++) {
		XMLElement* e = *it;

		try {
			if (e->getName() != name)
				continue;
		} catch (IllegalEntry ie) {

		}

		time = atoi(e->getFirstText().c_str());

		XMLAttribute* a = e->getAttribute("unit");
		if (!a)
			continue;

		if (a->getValue() == "sec")
			return time*unit/SEC;
		else if (a->getValue() == "msec")
			return time*unit/mSEC;
		else if (a->getValue() == "usec")
			return time*unit/uSEC;
		else
			THROWEXCEPTION("Unkown time unit '%s'", a->getValue().c_str());
	}

	// we didn't find the element, return default
	return def;
}
void ConfigParser::locateElement()
{
   if (pParent != 0)
   {
      for (int i=0; i<pParent->pElement->GetChildrenCount(); i++)
      {
         XMLElement *pElem = pParent->pElement->GetChild(i);
         if (pElem->GetName().Equals(sElemName))
         {
            if (lID == -1)
            {
               pElement = pElem;
               return;
            }
            else
            {
               XMLAttribute *pAttr = pElem->FindAttribute("id");
               if (pAttr)
               {
                  if (pAttr->GetValue().ToLong() == lID)
                  {
                     pElement = pElem;
                     return;
                  }
               }
            }
         }
      }
      
      pElement = pParent->addChild(sElemName);
      if (-1 != lID)
      {
         pElement->AddAttribute("id", lID);
      }
   }
}
示例#26
0
void XMLTreeNode::SetAttribute(char *name, char *value)
{
	XMLAttribute *a;

	a=GetAttribute(name);

	if (a)
		a->SetValue(value);
	else
	{
		a=attributes;

		if (a)
		{
			while (a->GetNext()) a=a->GetNext();

			a->SetNext(new XMLAttribute(a, name, value, 0));
		}
		else
		{
			a=attributes=new XMLAttribute(0, name, value, 0);
		}
	}
}
示例#27
0
String
XMLNodeImpl::getAttribute(const String& name, bool throwException) const
{
	int arraySize = m_XMLAttributeArray.size();

	for (int i = 0; i < arraySize; i++)
	{
		XMLAttribute attr = m_XMLAttributeArray[i];

		// Should this be case insensentive? NO
		if (attr.getName().equals(name))
		{
			return attr.getValue();
		}
	}
	if (throwException)
	{
		OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
				Format("Failed to find "
					"attribute: %1 in node: %2", name, m_strName).c_str() );
	}

	return String();
}
示例#28
0
void XMLReader::parserRootElement(uint32_t depth)
{
	LPCWSTR  pwszLocalName, aValue, aName,nameSpace;
	uint32_t  uCounter;

	this->pReader->GetLocalName(&pwszLocalName, NULL);
	this->pReader->GetPrefix(&nameSpace, NULL);
	this->pReader->GetValue(&aValue, NULL);
	
   //Set Element
	root = new  XMLElement(pwszLocalName);
	root->setPrefix(nameSpace);
	root->setZIndex(depth);

	if (aValue != L"")
	{
		root->setText(aValue);
	}

	//move to the first attribute of the element and parser it 
	HRESULT hr= this->pReader->MoveToFirstAttribute();
	while (hr == S_OK)
	{
	    this->pReader->GetPrefix(&nameSpace, NULL);
		this->pReader->GetLocalName(&pwszLocalName, NULL);
		this->pReader->GetValue(&aValue, NULL);
		//set the attribute values
		XMLAttribute *attribute = new  XMLAttribute(pwszLocalName);
		attribute->setValue(aValue);
		attribute->setPrefix(nameSpace);
		this->root->addAttribute(attribute);

		hr = this->pReader->MoveToFirstAttribute();
	}

}
示例#29
0
AttributeWidget::AttributeWidget(const XMLAttribute &xmlAttribute,
                                 InspectorWidget *inspectorWidget,
                                 bool isSubWidget,
                                 bool createLabel,
                                 bool labelAbove ) :
    m_inspectorWidget(inspectorWidget)
{
    m_xmlAttribute = xmlAttribute;
    Refresh(xmlAttribute);

    m_layout = new QHBoxLayout();
    m_layout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
    m_layout->setContentsMargins(4, 4, 4, 4);
    setLayout(m_layout);
    setMinimumWidth(40);

    if (!labelAbove)
    {
        m_layout->setSpacing(10); // Margin to the right of the label
    }

    if (!isSubWidget)
    {
        QString label = "";
        if (createLabel)
        {
            String name = xmlAttribute.GetName();
            name = StringUtils::FormatInspectorLabel(name);
            label = QString::fromStdString(name);
        }

        QGridLayout *gridLayout = m_inspectorWidget->GetGridLayout();
        m_rowIndexInGridLayout = m_inspectorWidget->GetNextRowIndex();

        int widgetRow = m_rowIndexInGridLayout + (labelAbove ? 1 : 0);
        int widgetCol = (labelAbove ? 0 : 1);
        int colSpan   = (labelAbove ? 2 : 1);
        m_label = new QLabel(label);
        gridLayout->addWidget(m_label, m_rowIndexInGridLayout,         0, 1, colSpan, Qt::AlignLeft | Qt::AlignVCenter);
        gridLayout->addWidget(this,    widgetRow,              widgetCol, 1, colSpan, Qt::AlignVCenter);
    }

    Refresh(xmlAttribute);
}
void cSDL2DSceneManager::addLayerObjects(c2DLayer *Layer, XMLElement *Element)
{
    cSceneObject* Object = new cSceneObject();
    unsigned int r=0;
    unsigned int g=0;
    unsigned int b=0;

	if(!Object)
		return;

    for(XMLAttribute* ElementAttrib = const_cast<XMLAttribute*>(Element->FirstAttribute()); ElementAttrib; ElementAttrib = const_cast<XMLAttribute*>(ElementAttrib->Next()))
    {
        std::string AttribName = ElementAttrib->Name();
        std::string AttribValue = ElementAttrib->Value();

        if(AttribName=="resourceID")
        {
            cResourceManager* ResourceManager = cResourceManager::GetResourceManager();

            Object->setResourceObject((cRenderResource*) ResourceManager->findResourcebyID(atoi(AttribValue.c_str())));
        }

        if(AttribName=="posx")
        {
            Object->m_PosX = atof(AttribValue.c_str());
        }

        if(AttribName=="posy")
        {
            Object->m_PosY = atof(AttribValue.c_str());
        }

        if(AttribName=="colorkey")
        {
            if(AttribValue=="true")
               Object->m_bColorKeyEnabled=true;
            else
               Object->m_bColorKeyEnabled=false;
        }

        if(AttribName=="r")
        {
            r = atoi(AttribValue.c_str());
        }

        if(AttribName=="g")
        {
            g = atoi(AttribValue.c_str());
        }

        if(AttribName=="b")
        {
            b = atoi(AttribValue.c_str());
        }
    }

    if(Object->m_bColorKeyEnabled)
        Object->setColorKey(r,g,b);

    Layer->m_SceneObjects.push_back(Object);
}