void CGUIAttributeEditor::refreshAttribs()
{
	// clear the attribute list
	u32 i;
	for (i=0; i<AttribList.size(); ++i)
	{
		AttribList[i]->remove();
		AttribList[i]->drop();
	}
	AttribList.clear();

	position2di top(10, 5);
	rect<s32> r(top.X,
				top.Y,
				getClientArea().getWidth() - 10,
				5 + Environment->getSkin()->getFont()->getDimension(L"A").Height);

	// add attribute elements
	u32 c = Attribs->getAttributeCount();
	for (i=0; i<c; ++i)
	{

		// try to create attribute
		stringc str = Attribs->getAttributeTypeString(i);
		str += "_attribute";
		CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this);

		if (n)
		{
			// add custom attribute editor
			AttribList.push_back(n);
			n->setParentID(getID());
			n->grab();
		}
		else
		{
			// create a generic string editor
			AttribList.push_back(new CGUIStringAttribute(Environment, this, getID()));
			// dont grab it because we created it with new
		}

		AttribList[i]->setSubElement(true);
		AttribList[i]->setRelativePosition(r);
		AttribList[i]->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		AttribList[i]->setAttrib(Attribs, i);
		r += position2di(0, AttribList[i]->getRelativePosition().getHeight() + 5);
		
	}
}
void CGUIAttributeEditor::refreshAttribs()
{
	// clear the attribute list
	u32 i;
	for (i=0; i<AttribList.size(); ++i)
	{
		AttribList[i]->remove();
		AttribList[i]->drop();
	}
	AttribList.clear();
	position2di top(10, 5);
	rect<s32> r(top.X,
				top.Y,
				AbsoluteRect.getWidth() - Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH) * 2,
				5 + Environment->getSkin()->getFont()->getDimension(L"A").Height);

	// add attribute elements
	u32 c = Attribs->getAttributeCount();
	for (i=0; i<c; ++i)
	{

		// try to 
		stringc str = Attribs->getAttributeTypeString(i);
		str += "_attribute";
		CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this);

		if (n)
		{
			// add custom editor
			AttribList.push_back(n);
			n->grab();
		}
		else
		{
			// create a generic string editor
			AttribList.push_back(new CGUIStringAttribute(Environment, this));
			// dont grab it because we created it with new
		}

		AttribList[i]->setSubElement(true);
		AttribList[i]->setRelativePosition(r);
		AttribList[i]->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		AttribList[i]->setAttrib(Attribs, i);
		r += position2di(0, AttribList[i]->getRelativePosition().getHeight() + 5);
		
	}

	if (r.UpperLeftCorner.Y > RelativeRect.getHeight())
	{
		ScrollBar->setVisible(true);
		ScrollBar->setMax(r.UpperLeftCorner.Y - RelativeRect.getHeight());
		LastOffset = ScrollBar->getPos();
	}
	else
	{
		ScrollBar->setVisible(false);
		ScrollBar->setPos(0);
		LastOffset = 0;
	}

}