//====================================================================================================
//
// CustomObjects.h
//
// Copyright © Nemetschek North America 1997-2002.
// All Rights Reserved.
//
// Utility functions and custom resource structures for Plug-in Objects.
//
// Created 8/25/97 by Jeff Koppi
// Modified 8/30/02 by Jeff Koppi
//====================================================================================================

#ifndef _CustomObjects_
#define _CustomObjects_
// #include "StdHeaders.h"

#include "RecordHandler.h"		// need type FormatHandle

//====================================================================================================
//	STRUCTS
//
//	Structure definitions that coorespond to custom resource templates in GSTMPL.rsrc
//
//====================================================================================================

//--------------------------------------------------
//	'Prm#'	Parameter resource.
//--------------------------------------------------
#define OST_Prm							'Prm#'
const short kUnivParmResID				= 128;

// UnivParmSpec is the repeating part of the 'Prm#' resource in memory.
//--------------------------------------------------------------------
#pragma pack(push, 2) // BEGIN 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
struct UnivParmSpec {
	Str63	fUniversalName;		// Universal Name of a Parameter.  Limited to 20 characters as of VW 10.
	Str63	fLocalizedName;		// Localized Name of a Parameter.  Supports up to 63 characters.
	Str255	fDefaultValue;		// Default value for this parameter.  If text, it is Localized.
	Byte	fPad;				// pad byte 
	Byte	fType;				// Type of this parameter.  Constants define in MiniCadCallBacks.h
	short 	fChoices;			// For parameters of type Popup or Radio, this is the resource ID of possible choices.
};
#pragma pack(pop) // END 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
//--------------------------------------------------------------------

typedef struct UnivParmSpec UnivParmSpec, *UnivParmSpecPtr;
typedef UnivParmSpec UnivParmSpecArray[1];

// UnivParmTable is an entire 'Prm#' resource in memory.  Call GetResource and assign resulting handle to a UnivParmTabHandle.
//--------------------------------------------------------------------
#pragma pack(push, 2) // BEGIN 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
struct UnivParmTable {
	short 				numParms;		// number of entries in the following array.
	UnivParmSpecArray	parms;			// array of UnivParmSpec structs
};
#pragma pack(pop) // END 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
//--------------------------------------------------------------------

typedef struct UnivParmTable *UnivParmTabPtr, **UnivParmTabHandle;


//--------------------------------------------------
//	'Chc#'	Choice resource stores choices for popup and radio button parameter.
//--------------------------------------------------
#define OST_Chc								'Chc#'
// The resource id of the Chc# resource is specified in the fChoices field of a Prm# resource for a specific parameter.

// The "ParmChoice" structure describes one entry in a 'Chc#' resource.  It contains a pair of names.
//--------------------------------------------------------------------
#pragma pack(push, 2) // BEGIN 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
struct ParmChoice {
	Str255	fUniversalChoiceName;		// Universal Name of a Popup or Radio choice.
	Str255	fLocalizedChoiceName;		// Localized Name of a Popup or Radio choice.
};
#pragma pack(pop) // END 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
//--------------------------------------------------------------------

typedef struct ParmChoice ParmChoice, *ParmChoicePtr;
typedef ParmChoice ParmChoiceArray[1]; 

// The "ParmChoiceTable" structure describes the entire 'Chc#' resource in memory.   Call GetResource and assign resulting handle to a ParmChoiceTabHandle.
//--------------------------------------------------------------------
#pragma pack(push, 2) // BEGIN 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
struct ParmChoiceTable {
	short 				numChoices;		// number of entries in the following array.
	ParmChoiceArray		choices;		// array of ParmChoice structs.
};
#pragma pack(pop) // END 2 BYTE STRUCTURE ALIGNMENT (RESOURCES)
//--------------------------------------------------------------------

typedef struct ParmChoiceTable *ParmChoiceTabPtr, **ParmChoiceTabHandle;


//====================================================================================================
//	FUNCTIONS
//
// Convenience functions for use by the plug-in tool and regeneration code.
//
//====================================================================================================
Boolean GetCustomObjectName(Str63 universalName, Str63 displayName, short &version);	// new for VW 10.0.0
Boolean GetCustomObjectName(Str20 parmName, short &version);
Boolean GetCustomObjectDefinition(CallBackPtr cbp, MCObjectHandle parmHand, RecordHandle& recordHand, FormatHandle& formatHand);
Boolean GetParameterChoice(short parameterIndex, short choiceIndex, Str255 univChoiceStr, Str255 localChoiceStr);
Boolean GetNumParameterChoices(short parameterIndex, short &numChoices);
Boolean GetLocalParameterName(short parameterIndex, Str255 localParameterName);

#endif