home *** CD-ROM | disk | FTP | other *** search
- /*
- This file defines a "generic" plugin class for Arrange 2.0.
- To use it, you should modify the file 'SubClass.h', which subclasses
- the Plugin class definition by adding new fields and private functions,
- and implementing the appropriate methods in another C++ source file.
-
- I'd strongly suggest that you base your plugin on one of the examples,
- or at least be familiar with one or more of them. You should not have to
- examine or make changes to this file or Plugin.cp. Most of what is
- contained here hides the details of interfacing Arrange and the module
- 'hook' mechanism to C++
-
- This version of Plugin.h was written by Paul Chambers on 11/27/94 and
- last updated on 12/6/84.
- It is derived from the original GenericPlugin.h, written by
- Steve Newman on 12/24/93 and last updated on 7/15/94.
- */
-
- #ifndef __Plugin_h__
- #define __Plugin_h__
-
- #ifndef rez
-
- #include "ArrangeCallbacks.h"
-
- #if defined(__MWERKS__) && !defined(__powerc)
- #include <A4Stuff.h> // also included in <MacHeaders>
- #define SetupGlobals() long oldA4 = SetCurrentA4() // setup A4 to point to global data segment
- #define RestoreGlobals() SetA4(oldA4) // restore A4 to saved value before returning
- #else
- #define SetupGlobals()
- #define RestoreGlobals()
- #endif
-
- #pragma parameter Set1Reg(__D0)
- pascal void Set1Reg(int D0) = 0x4E71;
- #pragma parameter Set2Reg(__A0,__D0)
- pascal void Set2Reg(void *A0,int D0) = 0x4E71;
- #pragma parameter Set3Reg(__A0,__A1,__D0)
- pascal void Set3Reg(void *A0,void *A1,int D0) = 0x4E71;
-
- class Plugin
- {
- /* These hook functions simply pass control into the appropriate method */
- friend arHookResult OurClickHook( ModuleParamBlock* pb, arClickLocation loc,
- Point where, pShort modifiers, pShort clickCount,
- arNoteID note, arFieldID field, arPathID path ENDP );
- friend arHookResult OurKeyHook ( ModuleParamBlock* pb,
- pShort theChar, pShort key, pShort modifiers ENDP );
- friend arHookResult OurMenuHook ( ModuleParamBlock* pb, Integer commandCode,
- Integer commandParam, pShort modifiers ENDP );
- friend arHookResult OurFieldHook( ModuleParamBlock* pb, arNoteID note,
- arFieldID field, arFieldAction action,
- const char* choiceText ENDP );
- friend void OurTopicHook( ModuleParamBlock* pb, arTopicID newTopic,
- arWindowID newWindow, arTopicAction action ENDP);
- friend void OurTickHook ( ModuleParamBlock* pb ENDP);
- friend arHookResult OurFileHook ( ModuleParamBlock* pb, arFileAction action ENDP);
- friend arHookResult OurQuitHook ( ModuleParamBlock* pb ENDP);
- friend void OurATMHook ( ModuleParamBlock* pb ENDP);
- friend Integer OurImportHook( ModuleParamBlock* pb, const FSSpec *file,
- pShort fRefnum, Integer formatID,
- pBoolean sniff, arTopicID destTopic ENDP);
- friend Integer OurExportHook( ModuleParamBlock* pb, const FSSpec *file,
- pShort fRefnum, Integer formatID,
- arEFType type, arTopicID srcTopic ENDP );
-
- public:
- Plugin(const ArrangeCallbackTbl* theCalls);
- ~Plugin();
-
- void* operator new( size_t);
- void* operator new( size_t, void *p) { return p; };
- void operator delete( void * ) { /* do nothing */ };
-
-
- protected:
- /* This function is called whenever the user clicks in an "interesting place"
- in a document window. It should return true if we handle the click, false
- (the normal case) when the click should be passed along to other plug-ins
- or to Arrange's normal event processing. See the documentation for
- SetClickHook for more details. */
-
- void InstallClickHook ( uInteger refcon, pBoolean addHook );
- arHookResult ClickEvent( arClickLocation loc, Point where, Short modifiers,
- Short clickCount, arNoteID note, arFieldID field,
- arPathID path );
-
- /* This function is called whenever the user types a key which matches the
- filters we pass to SetKeyHook in Plugin's constructor. It should return
- true if we handle the event, false (the normal case) when the event
- should be passed along to other plug-ins or to Arrange's normal event
- processing. See the documentation for SetKeyHook for more details. */
-
- void InstallKeyHook ( uInteger refcon, pBoolean addHook,
- pShort charFilter, pShort keyFilter, pShort modFilter );
- arHookResult KeyEvent ( Short theChar, Short key, Short modifiers );
-
- /* This function is called whenever the user chooses a menu item for which
- we have registered (via the SetMenuHook function). It should return true
- if we handle the command, false (the normal case) when the command should
- be passed along to other plug-ins or to Arrange's normal event processing.
- See the documentation for SetMenuHook for more details. */
-
- void InstallMenuHook ( uInteger refcon, pBoolean addHook, Integer commandCode );
- arHookResult MenuEvent ( Integer commandCode, Integer commandParam,
- Short modifiers );
-
- /* If we register to recieve events for a field by calling SetFieldHook, this
- function will be called for any events in that field. It should return false
- in almost all cases.
- See the documentation for SetFieldHook and RegisterFieldProc for more details. */
-
- void InstallFieldHook ( uInteger refcon, pBoolean addHook, arFieldID field );
- void RegisterFieldProc ( const char* name, Integer id, arFPType type,
- Integer fieldTypes, uInteger refcon ENDP );
- arHookResult FieldEvent ( arNoteID note, arFieldID field, arFieldAction action,
- const char* choiceText );
-
- /* This function is called whenever the user switches windows or changes
- the current folder/topic/view in the front window. See the documentation
- for SetTopicHook for more details. */
-
- void InstallTopicHook ( uInteger refcon, pBoolean addHook );
- void TopicEvent ( arTopicID newTopic, arWindowID newWindow,
- arTopicAction action );
- /* This function is called periodically, whenever Arrange recieves a null
- event from the Event Manager. */
-
- void InstallTickHook ( uInteger refcon, pBoolean addHook );
- void TickEvent ( );
-
- /* This function is called whenever various file-level events occur.
- It should return true in almost all cases.
- See the documentation for SetFileHook for more details. */
-
- void InstallFileHook ( uInteger refcon, pBoolean addHook );
- arHookResult FileEvent ( arFileAction action );
-
- /* This function is called if the user voluntarily quits Arrange. It should
- return true to allow the user to quit, false to prevent it.
- See the documentation for SetQuitHook for more details. */
-
- void InstallQuitHook ( uInteger refcon, pBoolean addHook );
- arHookResult QuitEvent ( );
-
- /* This function is called whenever the user clicks in the menu bar or types
- a command key, just before processing the event. It should do any fixing
- up of menus which might be necessary based on the current state of affairs.
- See the documentation for SetATMHook for more details. */
-
- void InstallATMHook ( uInteger refcon, pBoolean addHook );
- void ATMEvent ( );
-
- /* This function is called whenever the user imports a file of a type
- for which this plugin registered a format. It is called first to
- assess how likely it is that the provided format is the import
- format supported, and then again to import the format. */
-
- void RegisterImportFormat ( const char* name, Integer formatID,
- OSType* fileTypes, Integer fileTypeCount,
- uInteger refcon ENDP );
- Integer ImportFile ( const FSSpec* file, pShort fRefnum,
- Integer formatID, pBoolean sniff, arTopicID destTopic );
-
- /* Export the provided topic to the given file. Assume that the file is already
- open, and leave the file open and unflushed. */
-
- void RegisterExportFormat ( const char* name, Integer formatID,
- arEFType type, uInteger refcon,
- OSType fileType, OSType fileCreator ENDP );
- Integer ExportTopic ( const FSSpec* file, pShort fRefnum,
- Integer formatID, arEFType type, arTopicID srcTopic);
-
- /****** inline functions, to make the code more readable ******/
-
- #include "inlineCallbacks.h"
-
- /****** Instance Data ******/
-
- const ArrangeCallbackTbl* calls; // callback table
-
- }; // Plugin
-
- #endif // rez
- #endif // __Plugin_h__