/* File: ShowBookmarks.cpp Contains: When the document is opened check to see if the bookmark pane is showing. If it is not then open it and display the bookmarks. Written by: Mark Gavin Digital Applications, Inc. 215 East Providence Road Aldan, PA 19018-4129 ( 610 ) 284-4006 Copyright: ©1997 by Digital Applications, Inc. Change History (most recent first): */ #include "CorCalls.h" #include "AVCalls.h" #include "PDCalls.h" #include "CosCalls.h" #include "ASCalls.h" #if MAC_PLATFORM #include "SafeResources.h" #ifndef _H_PIQuickdraw #include "PIQuickdraw.h" #endif #ifndef _H_MacCalls #include "MacCalls.h" #endif #ifndef _STDIO #include "stdio.h" #endif #ifndef _STRING #include "string.h" #endif #ifndef __TYPES__ #include "Types.h" #endif #endif // MAC_PLATFORM #if WIN_ENV #include "resource.h" extern HINSTANCE gHINSTANCE ; #endif #ifndef _TASUtils_ #include "TASUtils.h" #endif #ifndef _TAVUtils_ #include "TAVUtils.h" #endif // -------------------------- // Display the About box for the Print Page plug-in static ACCB1 void ACCB2 DoAboutShowBookmarks( void * data ) { TAVUtils::SimpleAlert( 27336 ) ; return ; } // end DoAboutShowBookmarks // -------------------------- static ACCB1 void ACCB2 DoAVDocDidOpen( AVDoc inAVDoc, ASInt32 outError, void *data ) { PDDoc thePDDoc ; PDBookmark thePDBookmarkRoot ; ASInt32 theSplitterPosition ; if ( inAVDoc == NULL ) // if there is no frontmost document (e.g.,the last document was just closed) return ; DURING thePDDoc = AVDocGetPDDoc( inAVDoc ) ; thePDBookmarkRoot = PDDocGetBookmarkRoot( thePDDoc ) ; if ( PDBookmarkHasChildren ( thePDBookmarkRoot ) ) { theSplitterPosition = AVDocGetSplitterPosition( inAVDoc ) ; // the default splitter position is 150, I would like it slightly larger if ( theSplitterPosition < 151 ) AVDocSetSplitterPosition( inAVDoc, 180 ) ; // do not set the document as dirty PDDocClearFlags ( thePDDoc, PDDocNeedsSave ) ; } HANDLER TASUtils::DisplayErrorAlert( ERRORCODE ) ; END_HANDLER return ; } // end DoAVDocDidOpen // ------------------------- #pragma mark -- init // ------------------------- // Initialize all of the ASAtoms once static ACCB1 boolean ACCB2 InitASAtoms( void ) { DURING HANDLER TASUtils::DisplayErrorAlert( ERRORCODE ) ; return false ; END_HANDLER return true ; } // end InitASAtoms // ------------------------- static ACCB1 boolean ACCB2 InitPlugInMenus( void ) { AVMenubar theAVMenubar ; DURING theAVMenubar = AVAppGetMenubar() ; // get the main menu if ( ! theAVMenubar ) E_RETURN( false ) ; TAVUtils::AppendToAboutMenu( "ShowBookmarks...", "DGAP:DoAboutShowBookmarks", &DoAboutShowBookmarks ) ; HANDLER TASUtils::DisplayErrorAlert( ERRORCODE ) ; END_HANDLER return true ; } // end InitPlugInMenus // ------------------------- static ACCB1 boolean ACCB2 InitPlugIn( void ) { boolean theResult ; // theResult = InitASAtoms() ; // if ( theResult == false ) // return theResult ; theResult = InitPlugInMenus() ; if ( theResult == false ) return theResult ; return theResult ; } // end InitPlugIn // ------------------------- static ACCB1 boolean ACCB2 UnloadPlugIn( void ) { return true ; } // end UnloadPlugIn // ------------------------- // This is the pre-initialization routine for the plug-in. // The pre-initialization routine is installed in PIHandshake(). Use the // pre-initialization routine to register for any event notifications. // This is important in this particular plug-in since the main // initialization function itself causes events to occur. Since this // plug-in counts various events, we don't want to miss out on any of the action. static ACCB1 boolean ACCB2 PreInitPlugIn( void ) { AVAppRegisterNotification( AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification( AVDocDidOpen, ( void * )DoAVDocDidOpen ), NULL ) ; return true ; } // end PreInitPlugIn // ------------------------- ACCB1 boolean ACCB2 PIHandshake( Uns32 handshakeVersion, void *handshakeData ) { if ( handshakeVersion == HANDSHAKE_V0200 ) { PIHandshakeData_V0200 *hsData = ( PIHandshakeData_V0200 * )handshakeData ; hsData->extensionName = ASAtomFromString( "DGAP:ShowBookmarks" ) ; hsData->exportHFTsCallback = NULL ; hsData->importReplaceAndRegisterCallback = ASCallbackCreateProto( PIImportReplaceAndRegisterProcType, ( void * )PreInitPlugIn ) ; hsData->initCallback = ASCallbackCreateProto( PIInitProcType, ( void * )InitPlugIn ) ; hsData->unloadCallback = ASCallbackCreateProto( PIUnloadProcType, ( void * )UnloadPlugIn ) ; return true ; } return false ; } // end PIHandshake // -------------------------