Esempio n. 1
0
	virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
	{
		uint32 i;
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		const vector<CInterfaceManager::SMasterGroup> &rVMG = pIM->getAllMasterGroup();
		for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
		{
			const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
			const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
			// Active all containers (that can be activated)
			for (i = 0; i < rV.size(); ++i)
			{
				CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(rV[i]);
				if (pGC == NULL) continue;
				if (pGC->isSavable())
				{
					// Yoyo: DO NOT force activation of containers who don't want to save their Active state.
					// Usually driven by server.
					if(pGC->isActiveSavable())
						pGC->setActive(true);
				}
			}

			pIM->checkCoords();
			pIM->getMasterGroup((uint8)nMasterGroup).centerAllContainers();

			// Pop in and close all containers
			for (i = 0; i < rV.size(); ++i)
			{
				CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(rV[i]);
				if (pGC == NULL) continue;
				if (pGC->isSavable())
				{
					if (pGC->isPopable()&&pGC->isPopuped())
						pGC->popin();

					// Can close ?
					if (pGC->isOpenable()&&pGC->isOpen())
						pGC->close();
				}
			}

			pIM->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers();
		}
	}
// ***************************************************************************
void CInterfaceConfig::CDesktopImage::fromCurrentDesktop()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	// Count number of container to save
	uint32 nCount = 0, nMasterGroup, i, nCount2;

	const vector<CInterfaceManager::SMasterGroup> &rVMG = pIM->getAllMasterGroup();
	for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
	{
		const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
		const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
		for (i = 0; i < rV.size(); ++i)
		{
			CGroupContainer		*pGC= dynamic_cast<CGroupContainer*>(rV[i]);
			if ( pGC != NULL && pGC->isSavable() )
				nCount++;
		}
	}

	GCImages.resize(nCount);
	SCont contTmp;
	nCount2 = 0;
	// retrieve all containers
	for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
	{
		const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
		const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
		for (i = 0; i < rV.size(); ++i)
		{
			CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(rV[i]);
			if ( pGC != NULL && pGC->isSavable() )
			{
				GCImages[nCount2].setFrom(pGC);
				nCount2++;
			}
		}
	}
	nlassert(nCount2 == nCount);
	// set extra data stream version (in memory)
	Version = INTERFACE_CONFIG_STREAM_VERSION;
	// serial extra data in the stream
	NLMISC::CMemStream &f = ExtraDatas;
	if (f.isReading())
	{
		f.invert();
	}
	f.resetPtrTable();
	f.seek(0, NLMISC::IStream::begin);
	// Save the Top Window for this config.
	CInterfaceGroup	*topWindow= pIM->getTopWindow(pIM->getLastTopWindowPriority());
	string	topWindowName;
	if (topWindow)
	{
		CGroupContainer *pGC= dynamic_cast<CGroupContainer*>(topWindow);
		if (pGC != NULL && pGC->isSavable())
			topWindowName = pGC->getId();
	}
	f.serial(topWindowName);


	// retrieve number of elements that want their config saved
	CCountUIElemWithConfigVisitor counter;
	pIM->visit(&counter);
	f.serial(counter.Count);
	// Serial specific infos for each widget that reclaims it
	CSaveUIConfigVisitor saver(f);
	pIM->visit(&saver);
}