// ***************************************************************************
void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd &macro)
{
	CInterfaceManager	*pIM = CInterfaceManager::getInstance();

	vector< pair<string, string> > vParams;
	vParams.push_back(pair<string,string>("id", "m"+toString(macNb)));
	CInterfaceGroup *pNewMacro = CWidgetManager::getInstance()->getParser()->createGroupInstance(TEMPLATE_MACRO_ELT, pParent->getId(), vParams);
	if (pNewMacro == NULL) return;

	CViewText *pVT = dynamic_cast<CViewText*>(pNewMacro->getView(TEMPLATE_MACRO_ELT_TEXT));
	if (pVT != NULL) pVT->setText(macro.Name);

	CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(pNewMacro->getCtrl(TEMPLATE_MACRO_ELT_ICON));
	if (pCS != NULL) pCS->readFromMacro(macro);

	pVT = dynamic_cast<CViewText*>(pNewMacro->getView(TEMPLATE_MACRO_ELT_KEYTEXT));
	if (pVT != NULL)
	{
		if (macro.Combo.Key != KeyCount)
			pVT->setText(macro.Combo.toUCString());
		else
			pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
	}

	pNewMacro->setParent (pParent);
	pParent->addChild (pNewMacro);
}
// ***************************************************************************
void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName)
{
	CInterfaceManager	*pIM = CInterfaceManager::getInstance();

	vector< pair<string, string> > vParams;
	vParams.push_back(pair<string,string>("id", "c"+toString(cmdNb)));
	CInterfaceGroup *pNewCmd = CWidgetManager::getInstance()->getParser()->createGroupInstance(TEMPLATE_NEWMACRO_COMMAND, pParent->getId(), vParams);
	if (pNewCmd == NULL) return;

	CViewText *pVT = dynamic_cast<CViewText*>(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT));
	if (pVT != NULL) pVT->setText(cmdName);

	pNewCmd->setParent (pParent);
	pParent->addChild (pNewCmd);
}
// *********************************************************************************************************
void CDisplayerVisual::onPostRender()
{
	//H_AUTO(R2_CDisplayerVisual_onPostRender)
	if (!getActive()) return;

	// if this entity is currently moving then don't display the 'stop' icon
	// (it is already drawn by the mouse cursor)
	if (getDisplayedInstance() == getEditor().getSelectedInstance()
		&& dynamic_cast<CToolSelectMove *>(getEditor().getCurrentTool()))
	{
		if (_IconInScene)
		{
			_IconInScene->setActive(false);
		}
	}
	else
	{
		if (getDisplayFlag(FlagBadPos))
		{
			if (!_IconInScene && !_IconInSceneCreationFailed)
			{
				CInterfaceManager *pIM = CInterfaceManager::getInstance();
				const char *iconTemplateName = "r2ed_bad_pos_icon";
				// if the in scene 'stop' window wasn't created, then create it now
				CInterfaceGroup *group = CWidgetManager::getInstance()->getParser()->createGroupInstance (iconTemplateName , "ui:interface", NULL, 0);
				if (group)
				{
					_IconInScene = dynamic_cast<CGroupInScene *>(group);
					if (!_IconInScene)
					{
						nlwarning("Template %s has bad type : should be a derived group from CGroupInScene", iconTemplateName);
						delete group;
						_IconInSceneCreationFailed = true;
					}
					else
					{
						// Link to the interface
						CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
						CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
						group->setParent(pRoot);
						if (pRoot)
							pRoot->addGroup (group);
					}
				}
				else
				{
					_IconInSceneCreationFailed = true;
				}
			}
			if (_IconInScene)
			{
				_IconInScene->setActive(true);
				// tmp set a position above head
				evalIconInScenePos(_IconInScene->Position);
			}
		}
		else
		{
			if (_IconInScene)
			{
				_IconInScene->setActive(false);
			}
		}
	}
}