示例#1
0
	void CInterfaceElement::setSizeParent( const std::string &id )
	{
		// Parent or empty id simply means the group parent
		if( ( id == "parent" ) || ( id.empty() ) )
		{
			setParentSize( getParent() );
			return;
		}

		CInterfaceElement *pp = NULL;

		// Check if it's a short Id
		std::string::size_type idx = id.find( "ui:" );
		if( idx == std::string::npos )
		{
			// If it is, find the widget in the parent group and set as posparent
			CInterfaceGroup *p = getParent();
			if( p != NULL )
			{
				pp = p->findFromShortId( id );
			}
		}
		else
		{
			// If it is not, find using the widgetmanager
			// TODO: refactor, shouldn't use a singleton
			pp = CWidgetManager::getInstance()->getElementFromId( id );
		}

		if( pp != NULL )
			setParentSize( pp );
	}