EditorPanel::EditorPanel(const std::string& name_, rapidxml::xml_node<>* elem_)
		: GUI::Widget(name_, elem_)
		, _tooltipExist(false)
		, _tooltip(Core::resourceManager.Get<Render::Text>("EditorTooltipText"))
	{
		std::string textureID = Xml::GetStringAttributeOrDef(elem_, "tex", "EditPanel");
		_texture = Core::resourceManager.Get<Render::Texture>(textureID);
		int col_count = Xml::GetIntAttributeOrDef(elem_, "col_count", 19);
		_cellSize = Xml::GetIntAttributeOrDef(elem_, "side", 19);
		_scrollable = Xml::GetBoolAttributeOrDef(elem_, "scrollable", false);

		_buttons.clear();
		rapidxml::xml_node<>* xml_button = elem_->first_node("button");
		int i = 0;
		while(xml_button)
		{
			IRect rect(i % col_count * _cellSize, i / col_count * _cellSize, _cellSize, _cellSize);
			_buttons.push_back( ButtonInfo(rect, xml_button) );
			xml_button = xml_button->next_sibling("button");
			i++;
		}

		IPoint pos(elem_);
		pos.y += MyApplication::GAME_HEIGHT;
		int width = col_count * _cellSize;
		int height = (i - 1) / col_count * _cellSize + _cellSize;

		setClientRect(IRect(pos.x, pos.y, width, height) );
	}
 Button* EnclosedRenderableContainerWidget::CreateButton(ConstString& Name, const RenderableRect& Rect, const Real& LineHeight, ConstString& Text)
 {
     RenderablesAdded++;
     Vector2 Offset;
     if(Rect.Relative) Offset = (Rect.Position - RelPosition) * ParentScreen->GetViewportDimensions();
     else Offset = Rect.Position - GetActualPosition();
     OffsetWidgetInfo ButtonInfo(ParentScreen->CreateButton(Name,Rect,LineHeight,Text),UI::RA_AnchorMiddle,UI::RT_TetherBoth,Offset);
     Widgets.push_back(ButtonInfo);
     AddSubRenderable(RenderablesAdded,ButtonInfo.Object);
     ButtonInfo.Object->SetVisible(Visible);
     return static_cast<Button*>(ButtonInfo.Object);
 }