Esempio n. 1
0
/** \brief Merge a property set containing menu information into a destination property set
 *
 * This recursive method takes a property bag and peruses it, adding its
 * contents to the source property bag. This allows you to add a menu to another menu.
 * Menu weights are respected.
 *
 * \param[in] dest The destination property bag where \p source is merged
 * \param[in] source The source property bag to add to the destination
 *
 * \sa MergeMenu
 */
void moMenuManager::MergeMenu( moPropBagRef dest, moPropBagRef source )
{
	unsigned long idx = 0;
	const unsigned long end = source.Count();

	for( ; idx < end; idx++ )
	{
		moPropRef		sourceProp	= source[idx];
		moProp::prop_type_t	type		= sourceProp.GetType();
		moName			name		= sourceProp.GetName();
		moIndexOrName		mo_index( (moWCString) name );

		switch( type )
		{
		case moProp::MO_PROP_TYPE_ARRAY:
			{
				moPropArrayRef	array = sourceProp;
				try
				{
					moPropArrayRef	p = dest[mo_index];
					MergeMenu( p, array );
				}
				catch( const moError& )
				{
					moPropArrayRef	destArrayProp( name );
					destArrayProp.NewProp();
					MergeMenu( destArrayProp, array );
					dest.Set( mo_index, destArrayProp );
				}
	
			}
			break;

		case moProp::MO_PROP_TYPE_STRING:
		case moProp::MO_PROP_TYPE_INT:
			{
				dest.Set( mo_index, sourceProp );
			}
			break;

		default:
			// TODO: Message needed here
			// to indicate we have an unsupported type for this structure
			std::cerr << "Unsupported property type for this structure!" << std::endl;
		}
	}
}
Esempio n. 2
0
void CBrowserPlugin::Init()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// merge menu
	CMenu append;
	append.LoadMenu(IDR_BROWSER_MENU);
	MergeMenu(&append, TRUE);
}
Esempio n. 3
0
/** \brief Merge a prop array containing menu information into a destination array
 *
 * This recursive method takes a property array and peruses it, adding its
 * contents to the source array. This allows you to add a menu to another menu.
 * Menu weights are respected.
 *
 * \param[in] dest Merge the \p source array of menu items to this property array
 * \param[in] source The source of menu items to merge
 *
 * \sa MergeMenu
 */
void moMenuManager::MergeMenu( moPropArrayRef dest, moPropArrayRef source )
{
	unsigned long idx = 0;
	const unsigned long end = source.CountIndexes();

	for( ; idx < end; idx++ )
	{
		const int		item_no		= source.ItemNoAtIndex( idx );
		moPropSPtr		sourceProp	= source.Get( item_no );
		moProp::prop_type_t	type		= sourceProp->GetType();
		moName			name		= sourceProp->GetName();

		switch( type )
		{
		case moProp::MO_PROP_TYPE_PROP_BAG:
		    {
			    moPropBagRef	sourceRef(name);
			    sourceRef.NewProp();
			    sourceRef.GetProperty()->Copy(*sourceProp);

			    moPropBagRef	destRef(name);
			    destRef.NewProp();
			    moProp*	prop = dest.Get( item_no );
			    if( prop )
			    {
			    	destRef = *((moPropBag*)prop);
			    }

			    MergeMenu( destRef, sourceRef );
			    dest.Set( item_no, destRef );
		    }
		    break;
		
		case moProp::MO_PROP_TYPE_STRING:
		    {
			moPropStringRef	strProp(name);
			strProp.NewProp();
			strProp.GetProperty()->Copy( *sourceProp );
			dest.Set( item_no, strProp );
		    }
		    break;

		default:
			// TODO: Message needed here
			// to indicate we have an unsupported type for this structure
			std::cerr << "Unsupported property type for this structure!" << std::endl;
		}
	}
}
Esempio n. 4
0
/** \brief Add new menus and menu entries
 *
 * Adds a new bag of menus and menu entries to the current menu set. This can
 * throw molib::moError on failure.
 *
 * \exception moError
 *
 * \param[in] newPropBag The property bag to add to the current menu set.
 */
void moMenuManager::AddMenu( moPropBagRef newPropBag )
{
	MergeMenu( f_mainPropBag, newPropBag );
}