コード例 #1
0
ファイル: nsAEGenericClass.cpp プロジェクト: fortunto2/celtx
/*----------------------------------------------------------------------------
	AEGenericClass 
	
----------------------------------------------------------------------------*/
AEGenericClass::AEGenericClass(DescType classType, DescType containerClass)
:	mClass(classType)
,	mContainerClass(containerClass)
,	mItemFromContainerAccessor(nil)
{

	// Window from null accessor used by the entire window hierarchy
	mItemFromContainerAccessor = NewOSLAccessorUPP(AEGenericClass::ItemFromContainerAccessor);
	ThrowIfNil(mItemFromContainerAccessor);
	
	OSErr	err;
	err = AEInstallObjectAccessor(mClass,	 	containerClass, 
										mItemFromContainerAccessor, 
										(long)this, 
										false);

	// although items of a given class can't contain other items of the same class, 
	// we need this accessor to support formRelativePostion,
	// which sends us one item as a "container" and asks us to find
	// either the item before or after that item
	err = AEInstallObjectAccessor(mClass, 		mClass, 
										mItemFromContainerAccessor, 
										(long)this, 
										false);
	ThrowIfOSErr(err);

}
コード例 #2
0
ファイル: nsAECoreClass.cpp プロジェクト: rn10950/RetroZilla
AECoreClass::AECoreClass(Boolean suspendEvents)
:	mSuspendEventHandlerUPP(nil)
,	mStandardSuiteHandlerUPP(nil)
,	mRequiredSuiteHandlerUPP(nil)
,	mCreateElementHandlerUPP(nil)
,	mMozillaSuiteHandlerUPP(nil)
,	mGetURLSuiteHandlerUPP(nil)
,	mSpyGlassSuiteHandlerUPP(nil)
,	mPropertyFromListAccessor(nil)
,	mAnythingFromAppAccessor(nil)
,	mCountItemsCallback(nil)
,	mCompareItemsCallback(nil)
{
	mSuspendedEvent.descriptorType = typeNull;
	mSuspendedEvent.dataHandle = nil;

	mReplyToSuspendedEvent.descriptorType = typeNull;
	mReplyToSuspendedEvent.dataHandle = nil;
	
	OSErr	err = ::AEObjectInit();
	ThrowIfOSErr(err);
	
	mSuspendEventHandlerUPP = NewAEEventHandlerUPP(AECoreClass::SuspendEventHandler);
	ThrowIfNil(mSuspendEventHandlerUPP);

	mRequiredSuiteHandlerUPP = NewAEEventHandlerUPP(AECoreClass::RequiredSuiteHandler);
	ThrowIfNil(mRequiredSuiteHandlerUPP);

	mStandardSuiteHandlerUPP = NewAEEventHandlerUPP(AECoreClass::CoreSuiteHandler);
	ThrowIfNil(mStandardSuiteHandlerUPP);

	mMozillaSuiteHandlerUPP = NewAEEventHandlerUPP(AECoreClass::MozillaSuiteHandler);
	ThrowIfNil(mMozillaSuiteHandlerUPP);

	mGetURLSuiteHandlerUPP = NewAEEventHandlerUPP(AECoreClass::GetURLSuiteHandler);
	ThrowIfNil(mGetURLSuiteHandlerUPP);

	mSpyGlassSuiteHandlerUPP = NewAEEventHandlerUPP(AECoreClass::SpyglassSuiteHandler);
	ThrowIfNil(mSpyGlassSuiteHandlerUPP);

	InstallSuiteHandlers(suspendEvents);

	mCreateElementHandlerUPP = NewAEEventHandlerUPP(AECoreClass::CreateElementHandler);
	ThrowIfNil(mCreateElementHandlerUPP);
	
	// Special handler for StandardSuite Make (CreateElement) event
	// Make (CreateElement) is different than the other events processed above
	// because it passes its ospec in the insertionLoc parameter instead of
	// in the direct object parameter.

	err = ::AEInstallEventHandler(kAECoreSuite, 	kAECreateElement, 
										mCreateElementHandlerUPP, 
										(long)this, 
										false);
	ThrowIfOSErr(err);

	/*	We'd like to be able to install a generic handler that is used to get anything from null.
		Unfortunately, some formRelative requests require a handler for getting an item from
		another of the same type (e.g. "get the window after window 'foo'" requires a cWindow
		from cWindow handler).
	*/
	// Install a generic handler to get an item from the app
	mAnythingFromAppAccessor = NewOSLAccessorUPP(AECoreClass::AnythingFromAppAccessor);
	ThrowIfNil(mAnythingFromAppAccessor);
	
	// Install a handler to get properties from anything.
	err = ::AEInstallObjectAccessor(typeWildCard, typeWildCard, mAnythingFromAppAccessor, (long)this, false);
	ThrowIfOSErr(err);
	
	// Install a generic handler to get a property from a typeAEList of tokens
	mPropertyFromListAccessor = NewOSLAccessorUPP(AECoreClass::PropertyTokenFromAnything);
	ThrowIfNil(mPropertyFromListAccessor);
	
	// Install a handler to get properties from anything.
	err = ::AEInstallObjectAccessor(cProperty, typeWildCard, mPropertyFromListAccessor, (long)this, false);
	ThrowIfOSErr(err);

	// Install the OSL object callbacks, use for compare and count
	mCountItemsCallback = NewOSLCountUPP(AECoreClass::CountObjectsCallback);
	ThrowIfNil(mCountItemsCallback);

	mCompareItemsCallback = NewOSLCompareUPP(AECoreClass::CompareObjectsCallback);
	ThrowIfNil(mCompareItemsCallback);
	
	err = ::AESetObjectCallbacks(
						mCompareItemsCallback,
						mCountItemsCallback,
						(OSLDisposeTokenUPP)	nil, 
						(OSLGetMarkTokenUPP)	nil, 
						(OSLMarkUPP)			nil, 
						(OSLAdjustMarksUPP)	nil, 
						(OSLGetErrDescUPP)  	nil);
	ThrowIfOSErr(err);

	// create the dispatchers for various object types. This should be the only place
	// that new classes have to be added
	AEApplicationClass*		appDispatcher = new AEApplicationClass;
	RegisterClassHandler(cApplication, appDispatcher);
	RegisterClassHandler(typeNull, appDispatcher, true);

	AEDocumentClass*		docDispatcher = new AEDocumentClass;
	RegisterClassHandler(cDocument, docDispatcher);

	AEWindowClass*		windowDispatcher = new AEWindowClass(cWindow, kAnyWindowKind);
	RegisterClassHandler(cWindow, windowDispatcher);

/*	
	AETextClass*		textDispatcher = new AETextClass;
	RegisterClassHandler(AETextClass::cTEText, textDispatcher);
	
	AEWordClass*		wordDispatcher = new AEWordClass;
	RegisterClassHandler(cWord, wordDispatcher);
	
	AECharacterClass*	charDispatcher = new AECharacterClass;
	RegisterClassHandler(cChar, charDispatcher);
*/
}