//
//	ObjectMain.cpp
//
//	Main entry point for VectorWorks Plug-in Object code.
//
//	Copyright © Nemetschek North America, Inc  2004.
//	All Rights Reserved.
//
//

#if _WINDOWS
#include <Windows.h>
#include "GSWinSDK.h"	// Graphsoft Required.
#else
#include "StdHeaders.h"
#endif

#include <MiniCadCallBacks.h>
#include <MiniCadExternals.h>
#include "CustomObjects.h"

#include <GSString.h>
#include <RecordHandler.h>

/*
// Parametrics
														Message:					Result:
Action						Task							Gets						Returns
------------------------------------------------------------------------------------------------------------------------------
kParametricInitGlobals		Allocates global data				0								0 or kParametricSetupFailed
kParametricRecalculate		Regenerate objects					0								0
kParametricPreference		pose preference dialog				0 or parmFormat					0 or kParametricNotImplemented
kParametricDisposeGlobals	Disposes of global data				0								0
*/



long ParametricMain(long action, MCObjectHandle parmHand, long message, long &userData)
//
//	Main entry point for parametric object regeneration external code resource.
//	See MiniCadHookIntf.h for constants.
//
{
	message; // Eliminate warning

	long	reply = kParametricNoErr;

	switch (action) {
		case kParametricInitGlobals : {
				/*
					This action is called when an overlay is activated and serves the
					primary purpose of allowing the external function to define any
					defaults and global information and to initialize data space that
					may be stored in userData.
				*/

				break;
			}



		case kParametricDisposeGlobals : {
				/*
					This action is called when an overlay is deactivated and serves the
					primary purpose of allowing the external function to dispose data
					space that may be stored in userData.
				*/
				if (userData)
				{
					GS_DisposeHandle(gCBP, (GSHandle) userData);
				}
				break;
			}
		case kParametricRecalculate : {
			//
			//	This action is called to regenerate the look of a parametric object in response to a change
			//	in one of the parameter values on the object info palette, or a rotate, move, attribute change.
			//
			//	I would like to use a super class TParmRegen in this file and then have it overridden in specific
			//	files, but the userData scheme will not allow virtual functions. JAK
			//
			//	The message argument contains a handle to a wall, if we are inserted in a wall directly. Only for this action.
			//
			break;
		}

		case kParametricPreference : {
			//	This action gives the parametric an opportunity to pose a custom dialog for parameter value editting.
			//	If this parametric handles the request and poses its own dialog, then it returns kParametricNoErr regardless of
			//	whether chose ok or cancel.  If this parametric does not have a custom dialog, it returns kParametricNotImplemented.
			// 	Most parametrics will simply set reply to kParametricNotImplemented and let MiniCAD pose the standard dialog.

			reply = kParametricNoErr;

			break;
		}
	}

	return reply;
}
