/****************************************************************************************

		IMFMenu.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Joshua
		Date:	2/19/99

		COM interface to internal Menu objects.

		Revision History

		when		who			what & why
		==========	==========	======================================================
		11/26/99	Greg		Added params to API version of Popup (with default values)
		11/9/99		Greg		Added fItemMenu to TMFMenuHitData
		9/29/99		Greg		Added Activate to IMFMenu
		7/18/99		Ian			Menu API change (inserts take a before item, not an after item).
		4/21/99		Ian			Added kMsg_NoMenuPartHit, sent when the user dismisses a
								menu without choosing from it.
		3/5/99		Ian			Popup(): Now takes a EPrePopupAction so you can specify
								enabling actions before poping up a menu, the defualt action
								is to enable all the menu items.
		2/19/99		Joshua		Moved kMsg_MenuPartHit, TMFMenuInfo, and TMFMenuHitData from MFMenuPart.h

*****************************************************************************************/

#ifndef __IMFMENU__
#define __IMFMENU__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCCompObj.h"
#include "MCMenuInfo.h"
#include "MCCountedPtr.h"

struct IMFResponder;
struct IMFMenu;
class  TMCPoint;

namespace EMFPartMessage
{
	enum
	{
		kMsg_MenuPartHit   = 41,	///<Data is a TMFMenuHitData*.
		kMsg_NoMenuPartHit = 42,	///<Data is NULL.
	};
}

enum EPrePopupAction
{
	kPrePopupAction_EnableAll,
	kPrePopupAction_Prepare,
	kPrePopupAction_None
};

/******************************************************************************\
*                                                                              *
*           TMFMenuHitData                                                     *
*                                                                              *
\******************************************************************************/

/// Undocumented, do NOT use in extensions.
///
class TMFMenuHitData
{
public:
	int16					fItemIndex;
	ActionNumber			fItemAction;
	TMCCountedPtr<IMFMenu>	fItemMenu;
};



/******************************************************************************\
*                                                                              *
*           TMFMenuInfo                                                        *
*                                                                              *
\******************************************************************************/

/// Use IShMenuUtilities if you need to manipulate menus
///
class TMFMenuInfo : public TMCMenuInfo
{
public:
	TMFMenuInfo(
		const TMCString&	inCommandName,
		ActionNumber		inActionNumber,
		int16				inMenuID,
		boolean				inIsSeparator,
		const TMCString&	inClassName,
		void*				inCustomData);

	TMFMenuInfo(const TMCMenuInfo& inFromMCMenuInfo);
	TMFMenuInfo(void);

	TMCDynamicString	fClassName;
	void*				fCustomData;
};

//----------------------------------------------------------------
inline TMFMenuInfo::TMFMenuInfo(
//----------------------------------------------------------------
		const TMCString&	inCommandName,
		ActionNumber		inActionNumber,
		int16				inMenuID,
		boolean				inIsSeparator,
		const TMCString&	inClassName,
		void*				inCustomData) : 
	TMCMenuInfo(inCommandName,
				inActionNumber,
				inMenuID,
				inIsSeparator)
{
	fClassName	= inClassName;
	fCustomData	= inCustomData;
}

//----------------------------------------------------------------
inline TMFMenuInfo::TMFMenuInfo(const TMCMenuInfo& inFromMCMenuInfo) :
//----------------------------------------------------------------
	TMCMenuInfo(inFromMCMenuInfo.fCommandName,
				inFromMCMenuInfo.fActionNumber,
				inFromMCMenuInfo.fMenuID,
				inFromMCMenuInfo.fIsSeparator)
{
	fCustomData	= NULL;
}

//----------------------------------------------------------------
inline TMFMenuInfo::TMFMenuInfo(void)
//----------------------------------------------------------------
{
	fCustomData	= NULL;
}

//*********************** Globally Unique Ids ********************************

MCDEFINE_GUID(IID_IMFMenu, 0xb7261fb0, 0xc857, 0x11d2, 0x88, 0x7f, 0x0, 0x60, 0x97, 0x14, 0x85, 0x21);

//****************************************************************************

/// \addtogroup MCF
/// \{


///<P>This object is a generic container that is used to handle menus and menu items.
///IMFMenu can be created using gMenuUtilities::CreateMenu()
///According to the context, an IMFMenu can be seen as the menu, or as the menu item.
///Its methods apply to either one or the other case.</P>
///\note Menus of the menu bar are better handled using gMenuUtilities methods.
///		 This class is only for special 'hand-crafted' menus.
struct IMFMenu : public IMCUnknown
{
	// These methods are for the menu.
	virtual void	MCCOMAPI	SelfRemoveAll		(void)=0;

	virtual void	MCCOMAPI	AppendMenuItem		(IMFMenu* inSubMenuItem)=0;
	virtual void	MCCOMAPI	InsertMenuItem		(IMFMenu* inSubMenuItem, const int16 inBeforeItem)=0;

	virtual void	MCCOMAPI	InsertMenuItem		(	const TMCString&	inCommandName, 
														ActionNumber		inActionNumber, 
														const int16			inBeforeItem= -1)= 0;

	virtual void	MCCOMAPI	RemoveMenuItem		(IMFMenu* inSubMenuItem)=0;

	virtual int16	MCCOMAPI	GetMenuItemsCount	(void) const = 0;
	virtual void	MCCOMAPI	GetMenuItem			(const int16 inItem, IMFMenu** outMenuItem) = 0;
	
	virtual void	MCCOMAPI	Activate			(boolean inActivate) = 0;

	virtual void	MCCOMAPI	Popup				(IMFResponder* 		inReceiver, 
													 const TMCPoint& 	inPosition, 
													 const TMCPoint* 	inSize, 
													 const TMCPoint* 	trackFrom,
													 EPrePopupAction	inPrePopupAction = kPrePopupAction_EnableAll,
													 boolean			inReportNoSelection = false,
													 boolean 			inNotifyFirstResponder = true)=0;
	virtual void	MCCOMAPI	Popdown				(void)=0;

	virtual void	MCCOMAPI	AppendSeparator		() = 0;
	virtual void	MCCOMAPI	InsertSeparator		(uint32 inIndex) = 0;


	// These methods are for the menu item.
	virtual	boolean	MCCOMAPI	IsEnabled			(void) const = 0;
	virtual	void	MCCOMAPI	Enable				(const boolean enable = true) = 0;
	virtual	boolean	MCCOMAPI	IsChecked			(void) const = 0;
	virtual	void	MCCOMAPI	Check				(const boolean checked = true) = 0;

	virtual	boolean	MCCOMAPI	IsAlwaysEnabled		(void) const = 0;
	virtual	void	MCCOMAPI	SetAlwaysEnable		(const boolean alwaysEnable) = 0;

	virtual	void	MCCOMAPI	GetText				(TMCString& outText) const = 0;
};
/// \}
#endif