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

		IComponentChooser.h

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

		Author:	Greg 
		Date:	8/11/98

		COM interface to internal ComponentChooser parts.

		Revision History

		when		who			what & why
		==========	==========	======================================================
		5/6/99		Greg		Added ISingleCompChooserWithPreview, IComponentChooserPreview
		01/18/99	Mathieu		GetInternalComponentUI in ISingleComponentChooser
		10/6/98		Greg		Added IMultipleComponentChooser, changed message names
		9/1/98		Greg		Added kMsg_SelectedComponentModified
		8/18/98		Greg		Added kMsg_NewComponentSelected

*****************************************************************************************/
#ifndef __ICOMPONENTCHOOSER__
#define __ICOMPONENTCHOOSER__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "ComMessages.h"

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

struct IShParameterComponent;
struct IShComponent;
struct IMFCollapsiblePart;


//****** Globally Unique Ids **************************************************
MCDEFINE_GUID_H(IID_ISingleComponentChooser);
MCDEFINE_GUID_H(IID_IMultipleComponentChooser);
MCDEFINE_GUID_H(IID_IComponentChooserPreview);
MCDEFINE_GUID_H(IID_ISingleCompChooserWithPreview);

//****** Family Id ************************************************************
#define kComponentValueType 'comp'
#define kComponentListValueType 'cmp#'
	
/// \addtogroup BasicCOM
/// \{

/// A single component chooser. For example, the Scene Effects components in the Effects list in Carrara.  
/// Allows the user to choose a component from a popup list of components in a given family.  Displays the 
/// name of the current component in its UI part.
struct ISingleComponentChooser : public IMCUnknown
{
	// ****************************************************************************
	//								Initialize
	// 
	/// Initializes the component chooser.
	/// 
	/// \param inFamilyID        Family ID of components to make available for choosing
	/// \param inCanBeNone       If true, having no component chosen is allowed
	/// \param inShowFamilyName  If true, shows the family name in the UI
	/// \param inComponent       Initial component to use.  NULL to default to None.
	/// \param inShowToolBar	 Show the tool bar (open, save and preset buttons).
	/// 
	virtual void 	MCCOMAPI	Initialize		(const IDType&			inFamilyID,
												 boolean				inCanBeNone, 
												 boolean				inShowFamilyName,
												 IShParameterComponent* inComponent,
												 boolean				inShowToolBar=true) = 0;

	// ****************************************************************************
	//								SetCanCollapse
	// 
	/// Hides or shows the collapse/expand arrow, to prevent user changing if desired.
	/// 
	/// \param canCollapse  If true, allows the user to collapse/expand the chooser contents
	/// 
	virtual void	MCCOMAPI	SetCanCollapse	(boolean	canCollapse) = 0;	// hides the collapse/expand arrow, so the user can not change this
	virtual boolean	MCCOMAPI	GetCanCollapse	() = 0;

	// ****************************************************************************
	//								SetRefuseDrop
	// 
	/// Set if the chooser accept component drop.
	/// 
	virtual void	MCCOMAPI	SetRefuseDrop	(boolean refuseDrop) = 0;

	// ****************************************************************************
	//								SetComponentUI
	// 
	/// Sets the component for the chooser.  Clones the component.
	/// 
	/// \param inComponent  Pointer to the component
	/// 
	virtual void 	MCCOMAPI	SetComponentUI	(IShParameterComponent* inComponent) = 0;
	
	// ****************************************************************************
	//								GetComponentUI
	// 
	/// Gets the component from the chooser.  Clones the component.
	/// 
	/// \param outComponent  Returns a pointer to the component
	/// 
	virtual boolean MCCOMAPI	GetComponentUI	(IShParameterComponent** outComponent) = 0;


	// ****************************************************************************
	//								GetComponentUI
	// 
	/// Gets the components from the chooser.  Clones the components.
	/// There are several components only in multivalue mode
	/// 
	/// \param outComponents  Returns a pointer to the cloned components
	/// 
	virtual void	MCCOMAPI	GetComponentsUI	(TMCCountedPtrArray<IShParameterComponent>& outComponents) = 0;


	// ****************************************************************************
	//								GetInternalComponentUI
	// 
	/// Gets the internal representation of the component for this chooser.  Does not clone the component.
	/// 
	/// \param outComponent  Returns a pointer to the component.
	/// 
	virtual boolean MCCOMAPI	GetInternalComponentUI (IShParameterComponent** outComponent) = 0;

	// ****************************************************************************
	//								GetOriginalComponentUI
	// 
	/// Gets the original representation of the component for this chooser. Does not clone the component.
	/// WARNING: do not use this function unless you really need what you do.
	/// 
	/// \param outComponent  Returns a pointer to the component.
	/// 
	virtual boolean MCCOMAPI	GetOriginalComponentUI (IShParameterComponent** outComponent) = 0;

	virtual IDType	MCCOMAPI	GetFamilyID		() = 0;
	virtual void MCCOMAPI		Filter(boolean (*filterCallBack)(IDType classSignature)) = 0;

	virtual	void 	MCCOMAPI	SetSubPopupMode( boolean popupSubMode ) = 0;
	virtual	void	MCCOMAPI	SetSortMode(	 boolean popupSortMode) = 0;
		
	virtual	void	MCCOMAPI	SetPopupIncludeMask( uint32 popupMaskInclude ) = 0;
	virtual	void 	MCCOMAPI	SetPopupExcludeMask( uint32 popupMaskExclude ) = 0;

	virtual	void 	MCCOMAPI	SetPopupVisible	( boolean doShow ) = 0;
	virtual	boolean	MCCOMAPI	IsPopupVisible	() = 0;

	//Returns the collapsible part interface (supported by SCC)
	virtual	IMFCollapsiblePart* MCCOMAPI GetCollapsiblePart() = 0;
};

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

/// Multiple component chooser.  Used in the Modifiers tab in Carrara.  Supports adding components to and removing components 
/// from a list of active components.
struct IMultipleComponentChooser : public IMCUnknown
{
	virtual void 	MCCOMAPI	Initialize			(const IDType& inFamilyID) = 0;
	virtual IDType	MCCOMAPI	GetFamilyID			() = 0;

	virtual void	MCCOMAPI	ReInitPopup			() = 0;

	virtual void	MCCOMAPI	InsertComponentUI	(IShParameterComponent*	inComponent,
													 int32					inInsertionIndex,
													 boolean				inBroadcastMessage) = 0;

	virtual void	MCCOMAPI	SetComponentList	(TMCCountedPtrArray<IShParameterComponent>* inComponentList) = 0;
	virtual void    MCCOMAPI	GetComponentList	(TMCCountedPtrArray<IShParameterComponent>* ioComponentList) = 0;

	// ****************************************************************************
	//								GetInternalComponentUI
	// 
	/// Gets the internal representation of the list of components for this chooser.
	/// Does not clone the component.
	/// 
	/// \param outComponentList  Returns a list of components.
	/// 
	virtual void	MCCOMAPI	GetInternalComponentList(TMCCountedPtrArray<IShParameterComponent>* outComponentList) = 0;

	virtual	void 	MCCOMAPI	SetSubPopupMode( boolean popupSubMode ) = 0;
	virtual	void	MCCOMAPI	SetSortMode(	 boolean popupSortMode) = 0;
		
	virtual	void	MCCOMAPI	SetPopupIncludeMask( uint32 popupMaskInclude ) = 0;
	virtual	void 	MCCOMAPI	SetPopupExcludeMask( uint32 popupMaskExclude ) = 0;

};

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

/// This class is used for certain type of previews.
///
struct IComponentChooserPreview : public IMCUnknown
{
	virtual void 	MCCOMAPI	SetComponent(IShComponent*	inComponent) = 0;
};

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

/// This class is used for certain type of previews.
///
struct ISingleCompChooserWithPreview : public IMCUnknown
{
	virtual void	MCCOMAPI	SetPreview(IComponentChooserPreview*	inPreview) = 0;
};

/// \}
#endif