// ExtendedProperties.h

#pragma once

#include "GSString.X.h"


//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
//\\//\\//\\//\\//\\//\\//\\//\\/            Extended Properties      \\//\\//\\//\\//\\//\\//\\//\\//\\//\\
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//

typedef long		CodeRefID;
typedef	Uint32		TComponentTypeID;
typedef	short		TParametricFileIndex;


//---------------------------------------------------
//---------------------------------------------------


struct EPE_Kludge
//
//	Structure for the private API between the ExtendedProperties Module and the application.
{
public:
	enum {
		kKludgeSelector = 3463,
		
		kKludgeCallParametric = 6,				// Extended Properties Application Access
		kKludgeCurrentRegenPluginFileIndex = 7,	// Extended Properties Application Access
		kKludgeObjectHasExtendedProperties = 8,	// Extended Properties Application Access
		kKludgeSetRegenReturnValue = 9,			// Extended Properties Application Access
		kKludgeGetRegenStateEventID = 10,		// Extended Properties Application Access
		kKludgeGetRegenStateMessageData = 11,
		kKludgeRegisterToolForSelChange = 12,	
		kKludgeUnregisterToolForSelChange = 13,
		kKludgeCallAppObject = 14,
		kKludgeSubSelector15 = 15,
		kKludgeSubSelector16 = 16,
		kKludgeSubSelector17 = 17,
		kKludgeDrawDashed3DSeg = 18,
		kKludgeAddAssociation = 19,
		kKludgeRemoveAssociation = 20,
		kKludgeGetPluginNameByFileIndex = 21,		// Extended Properties Application Access
		kKludgeGetPluginParameter = 22,
		kKludgeClearExtendedProperties = 23,
	};

	EPE_Kludge(short selector, void* inData) :
		fSelector(selector),
		fData(inData)
	{}
		
	short fSelector;
	void* fData;
	
	
	//	fData structs:
	//
	//	kKludgeCallParametric fData:
	struct KludgeCallParametricData
	{
		short 			fPluginFileIndex;
		CodeRefID 		fObjectID;
		MCObjectHandle	fInstance;
		long 			fEventID;
		long 			fMessage;
		long			fCallReturn;
	};

	struct KludgeCallObjectData
	//
	//	Call application object handler
	{
		TDType 			fObjectID;
		MCObjectHandle	fInstance;
		long 			fEventID;
		long 			fMessage;
		long			fCallReturn;
	};

	class KludgeCall3DReshapeToolData
	//
	//	Call application 3D Reshape Tol Def
	{
	public:
		KludgeCall3DReshapeToolData(long theAction, long message1, long message2, long &userData) :
			fAction(theAction),
			fMessage1(message1),
			fMessage2(message2),
			fUserData(userData)
		{}
		
		long 			fAction;
		long 			fMessage1;
		long 			fMessage2;
		long& 			fUserData;
		long 			fCallReturn;
	};
	
	struct KludgeCallNearestPtOnRayToRayParams {
		Ray fOnRay;
		Ray	fToRay;
		WorldPt3 fGetPtValue;
	};
	struct KludgeDraw3DDashedSegParams {
		WorldPt3	fPoint1;
		WorldPt3	fPoint2;
		short		fDashDistance;
		short	fDashLength;
	};

};


struct WidgetInfoType
//
//	Information for a single object info palette widget.
{
	int		fParameterType;			// Parameter type
	int		fMappingID;				// Maps widget to a parameter
									// or widget ID for added parameters
	char	text[128];				// Widget text
	char	fFlag;	

	enum { 
		kDefault = 0, 
		kHide = 1, 
		kShow = 2, 
		kDisable = 4 
	};

	WidgetInfoType() {
		fParameterType = fMappingID = 0;
		text[0] = 0;
		fFlag = kDefault;
	}
};

//----------------------------------------------------------
class DYNAMIC_ATTRIBUTE IWidgetData
{
public:
	virtual					~IWidgetData() {}
	virtual const TXString&	GetData() const = 0;
	virtual void			SetData(const TXString& data) = 0;
};

class DYNAMIC_ATTRIBUTE IWidgetDataPopup : public IWidgetData
{
public:
	virtual void		Clear() = 0;
	virtual void		Add(const TXString& idName, const TXString& text) = 0;

	virtual size_t		GetCount() const = 0;
	virtual bool		GetAt(size_t index, TXString& outIdName, TXString& outText) const = 0;
	virtual bool		SetAt(size_t index, const TXString& idName, const TXString& text) = 0;

	virtual void		Insert(size_t beforeIndex, const TXString& idName, const TXString& text) = 0;
	virtual void		RemoveAt(size_t index) = 0;

	virtual bool		IsModified() const = 0;
	virtual void		SetModified(bool bModified) = 0;

	virtual bool		GetTextByIDName(const TXString& idName, TXString& outText) = 0;
	virtual bool		GetIDNameByText(const TXString& text, TXString& outIdName) = 0;
	virtual bool		GetIndexByIDName(const TXString& idName, size_t& outIndex) = 0;
};

//----------------------------------------------------------
struct SWidgetDefinition
// modern widget definiiton of the widget (WidgetInfoType)
//	This works with IWidgetsProvider for providing extended state of the widgets
{
	Sint32			fWidgetID;
	EWidgetType		fWidgetType;
	TXString		fWidgetText;
	bool			fWidgedVisible;
	bool			fWidgetEnabled;
	bool			fWidgetRed;

	// if ( fWidgetID == kWidgetPopUp ) fpWidgetData => (IWidgetDataPopup*)
	// if ( fWidgetID == kWidgetRadio ) fpWidgetData => (IWidgetDataPopup*)
	// else								fpWidgetData => (IWidgetData*)
	IWidgetData*	fpWidgetData;

	// data support
	TXString		fRecordName;
	Sint16			fRecordParamIndex;

					SWidgetDefinition() {
						fWidgetID = 0; fWidgedVisible = fWidgetEnabled = true;
						fpWidgetData = NULL;
						fRecordParamIndex = 0;
						fWidgetRed	= false;
					}
};

//----------------------------------------------------------
class IWidgetsProvider
// Widgets provider interface for parametric objects
{
public:
	virtual						~IWidgetsProvider()		{}
	virtual bool				IsUsed(bool bCheck) = 0;
	virtual TComponentTypeID	GetComponentTypeID() const = 0;
	virtual size_t				GetWidgetsCount() const = 0;
	virtual	SWidgetDefinition&	GetWidgetAt(size_t index) = 0;
	virtual	SWidgetDefinition*	GetWidgetByID(Sint32 widgetID) = 0;
};

//----------------------------------------------------------
class IContextMenuProvider
// Context menu provider interface for parametric objects
{
public:
	virtual			~IContextMenuProvider() {};
	virtual Sint16	AddItemSeparator() = 0;
	virtual Sint16	AddItem(const TXString& text) = 0;
	virtual bool	AddItem(const TXString& text, IContextMenuProvider*& outSubMenuProvider) = 0;
	
	virtual void	EnableItem(Sint16 itemID, bool bEnable) = 0;
	virtual void	CheckItem(Sint16 itemID, bool bChecked) = 0;
};


#define GS_DEFINE_OLD_XPROP_NAMES 1 // remove for VW 12
 #if GS_DEFINE_OLD_XPROP_NAMES
////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////		Old Names			////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////
//	Object Properties
const ObjectPropID kObjectEditGroupPropertyID = kObjXPropEditGroup;		// Object has non default "Enter Group" behavior	
const ObjectPropID kObjectSpecialEditPropertyID = kObjXPropSpecialEdit;	// object handles kOnObjectSpecialEditID event
const ObjectPropID kObjectPreferencePropertyID = kObjXPropPreference;		// Handles preferences dialog

const ObjectPropID kDirectModeling = kObjXPropDirectModeling;		// Under Development: Handles 3D Resahpe tool events
const ObjectPropID kAttributeTool = kObjXPropAttributeTool;		// Under Development: Handles Attribute tool events

const ObjectPropID kObjectHasUIOverrideID = kObjXPropHasUIOverride;			// Object adds widgets to Object Info Palette

const ObjectPropID kLastObjectPropertyID = kObjectHasUIOverrideID;		// last property ID
/////////////////////////////


/////////////////////////////
// OLD NAME:  kObjectEditGroupPropertyID property values:
const char kEditGroupDefaultProperty 	= kObjXPropEditGroupDefault;
const char kEditGroupProfile 			= kObjXPropEditGroupProfile;
const char kEditGroupPath 				= kObjXPropEditGroupPath;
const char kEditGroupCustom 			= kObjXPropEditGroupCustom;
/////////////////////////////


/////////////////////////////
// OLD NAMES: kObjectSpecialEditPropertyID property values:
const char kSpecialEditDefaultProperty 	= kObjXPropSpecialEditDefault;
const char kSpecialEditCustom 			= kObjXPropSpecialEditCustom;
const char kSpecialEditProperties 		= kObjXPropSpecialEditProperties;
const char kSpecialEditReshape 			= kObjXPropSpecialEditReshape;
/////////////////////////////




/////////////////////////////
//	Object Event IDs:
//  
//		(to be move down to Plug-in Object action constants below)
//
const ObjectEventID kOnObjectInitXPropertiesEventID = kObjOnInitXProperties;
const ObjectEventID kObjOnRotate				= kObjUnsupported6;		// The Plug-in Object called with kParametricOnRotate when kHasRotateDependancy extended property set  
const ObjectEventID kOnObjectSpecialEditID 		= kObjOnSpecialEditID;
const ObjectEventID kObjOnMove					= kObjUnsupported8;		// The Plug-in Object called with kParametricOnMove when kHasMoveDependancy extended property set 

const ObjectEventID kOnDM_Select 			= kObjOnDM_Select;	
const ObjectEventID kOnDM_Cancel 			= kObjOnDM_Cancel;	
const ObjectEventID kOnDM_MouseDown 		= kObjOnDM_MouseDown;	
const ObjectEventID kOnDM_Draw 				= kObjOnDM_Draw;	
const ObjectEventID kOnDM_Complete 			= kObjOnDM_Complete;	
const ObjectEventID kOnDM_GetCursor 		= kObjOnDM_GetCursor;	
const ObjectEventID kOnDM_ModeEvent 		= kObjOnDM_ModeEvent;	
const ObjectEventID kOnDM_GetStatus 		= kObjOnDM_GetStatus;	
const ObjectEventID kOnDM_CustomBarEvent	= kObjOnDM_CustomBarEvent;
const ObjectEventID kOnDM_BeginPauseEvent	= kObjOnDM_BeginPauseEvent;
const ObjectEventID kOnDM_EndPauseEvent		= kObjOnDM_EndPauseEvent;


//	Attribute reshape events for Attribute mapping tool
const ObjectEventID kOnAttributeSelect 		= kObjOnAttributeSelect;	
const ObjectEventID kOnAttributeCancel 		= kObjOnAttributeCancel;	
const ObjectEventID kOnAttributeMouseDown 	= kObjOnAttributeMouseDown;	
const ObjectEventID kOnAttributeDraw 		= kObjOnAttributeDraw;	
const ObjectEventID kOnAttributeComplete 	= kObjOnAttributeComplete;	
const ObjectEventID kOnAttributeGetCursor 	= kObjOnAttributeGetCursor;	
const ObjectEventID kOnAttributeMove2D 	    = kObjOnAttributeMove2D;	
const ObjectEventID kOnAttributeGetStatus 	= kObjOnAttributeGetStatus;	
const ObjectEventID kOnAttributeModeEvent 	= kObjOnAttributeModeEvent;

const ObjectEventID kOnObjectUIButtonHit = kObjOnObjectUIButtonHit;	// The user has pressed a butoom in the Properties UI of an object
	
const ObjectEventID kLastEventID = kObjLastEventID;		// last property ID
/////////////////////////////



// 	Current VectorScript Regeneration CodeRefID.  
//	Used by SetObjectProperty VectorScript implementation 
const CodeRefID kCurrentRegenObjectID = -1;



/////////////////////////////
//	Old XProp Names Tool Properties
const ToolPropID kToolSelectionChangeEventPropertyID = kToolXPropSelectionChange;	// tool wants selection change events.
const ToolPropID kToolEnterKeyEventPropertyID = kToolXPropUnsupported;			// not supported
const ToolPropID kToolWantsMoveSelection2DEventsID = kToolXPropWantsMoveSelection2D;		// tool wants kToolMoveSelection2DEvent event.
/////////////////////////////



/////////////////////////////
//	OLD NAMES: Tool Event IDs under construction:
//

const ToolEventID kOnToolInitXProperties 	= kToolOnInitXProperties;
const ToolEventID kToolSelectionChange   	= kToolOnSelectionChange;															
const ToolEventID kToolMoveSelection2DEvent	= kToolOnMoveSelection2D;														
const ToolEventID kToolCustomBarEvent      	= kToolOnCustomBarEvent;					
/////////////////////////////

#endif


//
//
//		END NNA DECLARATION SPACE:
//
//
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
