/* 

02/12/97
Power Plant Sample External
Paul C. Pharr

*/



#include <MiniCadHookIntf.h>
#include <MiniCadCallBacks.h>


#include "RunDialog.h"



long DangerousMenuMain(long , long , long &)
{
	return 0L;
}

long MenuMain(long action, long message1, long &userData)

{
	#pragma unused(message1, userData)

	long reply = 0L;

	switch (action) {
		case kMenuItemDisplayContextualHelp: { 
			if (GS_DisplayContextualHelp(gCBP, "com.yourcompany.help.menuitem.???")) { 
				 return kMenuItemHasContextualHelp; 
			} 
			break; 
		} 
			
		case kMenuInitGlobals : {
				//
				//	This action is called when an workspace is activated and serves the 
				//	primary purpose of allowing the plug-in to define any 
				//	defaults and global information and to initialize data space that 
				//	may be stored in userData.
				//

				// Construct explicitly with 'placement new'. Get memory from the app because
				// memory allocated with normal 'new' disappears when the dll unloads.

			/* Example:

				void* pRawMemory = GS_NewPtr(gCBP, sizeof(FooClass));
				if (pRawMemory) {
					FooClass* pConstructedMemory = (FooClass*) new(pRawMemory) FooClass();	
					userData = (long) pConstructedMemory;
				}
				else {
					userData = nil;
				}
	
			*/

				break;
			}

		case kMenuDisposeGlobals : {
				//
				//	This action is called when a workspace is deactivated and serves the 
				//	primary purpose of allowing the external function to dispose data 
				//	space that may be stored in userData.
				//

				// Destruct explicitly when using 'placement new'

			/* Example:

				if (userData) {
					FooClass* pData = (FooClass*) userData;
					pData->~FooClass();
					GS_DisposePtr(gCBP, pData);
					userData = nil;
				}
	
			*/
				
				break;
			}

		case kMenuDoInterface: {
				MyPPDialog ppd;
				//Rect r = {50, 10, 470, 630}; // this should come from the PPob
				Rect r = {50, 10, 400, 600}; // this should come from the PPob
				ppd.DoDialog(r);
				reply = kMenuDidNotChangeDoc;
				break;
			}
	}
	
	return reply;
}




