// Initialize the control(s) attached.
void UIButtonMetadata::InitializeControl(const String& controlName, const Vector2& position)
{
    BaseMetadata::InitializeControl(controlName, position);

    int paramsCount = this->GetParamsCount();
    for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++)
    {
        UIButton* button = dynamic_cast<UIButton*>(this->treeNodeParams[i].GetUIControl());

        WideString controlText = StringToWString(button->GetName());
        HierarchyTreeNode* activeNode = GetTreeNode(i);
    
        // Initialize the button for all states.
        int statesCount = UIControlStateHelper::GetUIControlStatesCount();
        for (int stateID = 0; stateID < statesCount; stateID ++)
        {
            UIControl::eControlState state = UIControlStateHelper::GetUIControlState(stateID);
            button->SetStateFont(state, EditorFontManager::Instance()->GetDefaultFont());
            button->SetStateText(state, controlText);

            // Button is state-aware.
            activeNode->GetExtraData().SetLocalizationKey(controlText, state);
        }
        
        // Define some properties for the reference state.
        button->SetStateDrawType(GetReferenceState(), UIControlBackground::DRAW_SCALE_TO_RECT);
    }
}
//----------------------------------------------------------------------------
void UIAuiManager::SetActiveTableFrame(const std::string &tabName)
{
	std::map<std::string, UIButtonPtr>::iterator it = mAuiTabButs.find(tabName);
	if (it != mAuiTabButs.end())
	{
		UIButton *tabBut = it->second;
		UIFrame *uiContentFrame = mAuiContentFrames[tabBut];
		UITabFrame *tabFrame = DynamicCast<UITabFrame>(
			uiContentFrame->GetParent()->GetParent());

		tabFrame->_SetActiveTab(tabBut->GetName());

		if (mActiveTableBut)
		{
			mActiveTableBut->SetActivate(false);
			mActiveTableBut = 0;
		}

		if (mActiveTableContentFrame)
		{
			mActiveTableContentFrame->SetActivate(false);
			mActiveTableContentFrame = 0;
		}

		mActiveTableBut = tabBut;
		mActiveTableContentFrame = uiContentFrame;

		if (mActiveTableBut)
			mActiveTableBut->SetActivate(true);

		if (mActiveTableContentFrame)
			mActiveTableContentFrame->SetActivate(true);
	}
}