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

		I3DShModule.h

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

		I3DShModule definition

		Author:	Joshua
		Date:	5/12/98

		Revision History

		when		who			what & why
		==========	==========	======================================================
		12/01/99    David		Added fRefCountAfterInitialization and a method to get it
		8/26/99		Yann		Changes related to undoable actions for creating/destroying sub modules (MMMM)
		7/26/99		Greg		Added GetPrefs
		05/06/99	Arnaud		Added GetPreferredRoom and IsActive
		4/5/99		Greg		Added Destroy
		3/23/99		Greg		Added GetToolbarPart
		2/19/99		Joshua		Added calls for GetIsHydrated and Initialize
		11/23/98	pbk			Separating 3DDB from MCFrame
		11/19/98	Greg		Added Activate() and Deactivate()
		9/25/98		Greg		Added AttachWindow/DetachWindow()
		9/18/98		Greg		Changed Module API (major change)
		8/20/98		Greg		Removed CreateWindow(), added GetClassID()
		6/10/98		cph/emil	added include of aiptypes.h for tdatakey
		
*****************************************************************************************/

#ifndef __I3DSHMODULE__
#define __I3DSHMODULE__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "IExtension.h"
#include "APITypes.h"

struct IMFWindow;
struct IMFPart;
struct IMFDocument;
struct I3DShModule;
struct IPropertiesClient;
struct IMCMenuBar;
struct TModelerToolInfo;

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

MCDEFINE_GUID(IID_I3DShModule, 0x74f637c0, 0xe9ed, 0x11d1, 0xab, 0x25, 0x0, 0x60, 0x8, 0x15, 0xad, 0x45);

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


/*****************************************************************************\
*  I3DShModule                                                                *
*                                                                             *
*                                                                             *
*                                                                             *
\*****************************************************************************/

/// \addtogroup ShellInterface
/// \{


/// I3DShModule is the shell interface of a module.
///
/// <P>There are two interfaces to access a modifier: The shell interface (I3DShModule) and
/// the external interface (I3DExModule) . You can get one from the other using QueryInterface.</P>
///
/// <P>Whenever it is possible you should use the Shell interface (I3DShModule) to access the component
/// because the Shell will make sure that the parameter map of the external component is valid.
/// This is especially important if the component is animated. For more information on components
/// see the Overview of the SDK.</P>
///
/// \see I3DExModule
///
struct I3DShModule: public IMCUnknown
{
	// ****************************************************************************
	//								CreateWindowByResource
	// 
	/// Creates a windows from a resource.
	/// 
	/// \param outPart  A pointer to the window that is created.
	/// \param inResID  The resource ID of the resource to read (of type 'Wind')
	/// \param inIsMainWindow True if it is the main window of the module.    
	/// 
	virtual void			MCCOMAPI CreateWindowByResource			(IMFPart** outPart, ResourceID inResID, boolean inIsMainWindow = false) = 0;
	
	// ****************************************************************************
	//								GetNewModuleDataKey
	// 
	/// Returns a Data Key for the module.
	/// 
	virtual TDataKey		MCCOMAPI GetNewModuleDataKey			() = 0;
	
	// ****************************************************************************
	//								GetDocumentNoAddRef
	// 
	/// Returns a pointer to the document that is edited by this module.
	/// 
	virtual IMFDocument*	MCCOMAPI GetDocumentNoAddRef			() = 0;
	
	// ****************************************************************************
	//								GetClassID
	// 
	/// Returns the classID of the module.
	/// 
	virtual IDType			MCCOMAPI GetClassID						() = 0;

	// ****************************************************************************
	//								Hydrate
	// 
	/// Called before the module is Activated.
	/// 
	virtual void			MCCOMAPI Hydrate						() = 0;
	
	// ****************************************************************************
	//								Dehydrate
	// 
	/// Should deallocate resources that are not used anymore once the module is not
	/// active.
	/// 
	virtual void			MCCOMAPI Dehydrate						() = 0;

	// ****************************************************************************
	//								Activate
	// 
	/// Called when the module is activated.
	/// 
	virtual void			MCCOMAPI Activate						() = 0;
	
	// ****************************************************************************
	//								Deactivate
	// 
	/// Called when the module is deactivated.
	/// 
	virtual void			MCCOMAPI Deactivate						() = 0;
	
	virtual void			MCCOMAPI AttachWindow					(IMFWindow* inWindow) = 0;
	virtual void 			MCCOMAPI DetachWindow					(IMFWindow* inWindow) = 0;

	virtual void			MCCOMAPI Initialize						(IMCUnknown* inElement) = 0;
	virtual void			MCCOMAPI Destroy						() = 0;

	virtual	void			MCCOMAPI Import							(IMCUnknown* inElement, void* inImportData) = 0;

	virtual boolean			MCCOMAPI GetIsHydrated					() = 0;
	

	// ****************************************************************************
	//								GetRefCountAfterInitialization
	// 
	/// Returns the refcount of the module at the end of the initialization (useless before)
	/// includes all the references (even those you make)
	/// to use it, you should be in the same state(concerning external refcount) than when calling initialize()
	/// 
	virtual uint32			MCCOMAPI GetRefCountAfterInitialization	() = 0;
	
	// ****************************************************************************
	//								GetPreferredRoom
	// 
	/// Returns true if the module has a prefered room and gives its ID
	/// 
	/// \param roomId  The prefered room ID if there is one
	/// 
	virtual boolean			MCCOMAPI GetPreferredRoom				(IDType& roomId) = 0;

	// ****************************************************************************
	//								WantsToBeInCurrentRoom
	// 
	/// Returns true if the module can be inserted in the current room
	/// 
	virtual boolean 		MCCOMAPI WantsToBeInCurrentRoom			() = 0;

	// ****************************************************************************
	//								IsActive
	// 
	/// Returns true if module is active
	/// 
	virtual boolean			MCCOMAPI IsActive						() = 0;

	// ****************************************************************************
	//								HaveSubModuleActive
	// 
	/// Returns true if this master module have a sub module active
	/// 
	virtual boolean			MCCOMAPI HaveSubModuleActive			() = 0;

	// ****************************************************************************
	//								SetMasterModule
	// 
	/// Call SetMasterModule() if this module if managed by another. This way your SubModuleClosedMainWindow() will be 
	/// called when the "Main Window" of this sub-module will be closed, so you have a chance to react.
	/// 
	/// \param masterModule  A pointer to the master module.
	/// 
	virtual void			MCCOMAPI SetMasterModule				(I3DShModule* masterModule) = 0;	// 'masterModule' will not be ref counted

	// ****************************************************************************
	//								SubModuleClosedMainWindow
	// 
	/// Your own SubModuleClosedMainWindow() proc will be called by any sub module that have its "Main Window" being closed, so you can react
	/// and return true if it if OK to close and destroy the module (return true)
	/// 
	/// \param subModule  A pointer to the subModule.
	/// 
	virtual boolean			MCCOMAPI SubModuleClosedMainWindow		(I3DShModule* subModule) = 0;

	// ****************************************************************************
	//								SubModuleAboutToBeDestroyed
	// 
	/// Your own SubModuleAboutToBeDestroyed() proc will be called by any sub module that is about to destroy itself, so you can react.
	/// 
	/// \param subModule  
	/// 
	virtual MCCOMErr		MCCOMAPI SubModuleAboutToBeDestroyed	(I3DShModule* subModule) = 0;

	// ****************************************************************************
	//								SubModuleAboutToBeHydrated
	// 
	/// Your own SubModuleAboutToBeHydrated() proc will be called by any sub module that is about to hydrate itself, so you can react.
	/// 
	/// \param subModule  
	/// 
	virtual MCCOMErr		MCCOMAPI SubModuleAboutToBeHydrated		(I3DShModule* subModule) = 0;

	// ****************************************************************************
	//								BuildMenuBar
	// 
	/// Gives the opportunity to the module to change the menu bar. Return true if it did so.
	/// 
	virtual boolean			MCCOMAPI BuildMenuBar					(IMCMenuBar* theBar) = 0;

	// ****************************************************************************
	//								GetPrefs
	// 
	/// Returns a pointer the preference buffer for the module.
	/// 
	virtual void*			MCCOMAPI GetPrefs						() = 0;

	// ****************************************************************************
	//								GetElement
	// 
	/// Get edited element (='inElement' parameter passed in Initialize)
	/// 
	/// \param outElement  
	/// 
	virtual MCCOMErr		MCCOMAPI GetElement						(IMCUnknown** outElement) = 0;

	// ****************************************************************************
	//								SavesInNativeFormat
	// 
	/// Whether the module wants to save data in the nativefile format
	/// 
	virtual	boolean			MCCOMAPI SavesInNativeFormat			() = 0;

	// ****************************************************************************
	//								SetElement
	// 
	/// Sets the edited element. This is used with a global module (such as the preview
	/// module) when the element being edited changed (for instance the scene being
	/// previewed).
	/// 
	/// \param element  A pointer to the new element edited (can be null)
	/// 
	virtual void MCCOMAPI SetElement(IMCUnknown* element) = 0;

	// ****************************************************************************
	//								GetMasterModulePropertiesClient
	// 
	/// If you are a sub module, you can retreve the default properties client
	/// from your master module.
	///
	/// \param outPropClient 
	/// 
	virtual	MCCOMErr		MCCOMAPI GetMasterModulePropertiesClient(IPropertiesClient** outPropClient) = 0;

	// ****************************************************************************
	//								GetDefaultPropertiesClient
	// 
	/// Get the default properties client for this module.
	///
	/// \param outPropClient 
	/// 
	virtual	MCCOMErr		MCCOMAPI GetDefaultPropertiesClient(IPropertiesClient** outPropClient) = 0;

	///sets the module that will override menus and tools
	virtual	void			MCCOMAPI SetOverrideModule	(I3DShModule* inOverrideModule) = 0;


	///gets the module that overrides menus and tools
	virtual	I3DShModule*	MCCOMAPI GetOverrideModule	() = 0;

	// ****************************************************************************
	//								GetMainToolInfo
	// 
	/// Returns the information about the main tool that activate the modeler in
	/// the 3DView. Note that this function is only implemented by modelers
	/// that can be instantiated in the 3DView (Vertex Modeler, 3D Paint...).
	///
	/// \param mainToolInfo		A struct describing the tool.
	/// 
	virtual MCCOMErr		MCCOMAPI GetMainToolInfo(TModelerToolInfo& mainToolInfo) = 0;


	// ****************************************************************************
	//								ShowToolGroups
	// 
	/// Called to hide/reveal the toolbars associated with this module (Note that you
	/// might need to call RebuildMenuBar() for this to take effect).
	///
	/// \param inShow		True if the tool bars should be shown.
	/// 
	virtual void			MCCOMAPI ShowToolGroups(const boolean inShow)=0;

};

/// \}

#endif