home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks96
/
troz.cgi.sit
/
troz.cgi
/
MyHandlers.c
< prev
next >
Wrap
Text File
|
1996-06-22
|
5KB
|
257 lines
/*****
*
* MyHandlers.c
*
* Optional custom functions to handle special events. Includes:
* document opening, startup and quitting
*
* Modify these functions if you need to add to the standard support
* built into the framework.
*
* The function prototypes are contained in the relevent headers.
* For example, AEHandlers.h contains the prototype for CustomOpenDocument
*
* This is a support file for "Grant's CGI Framework".
* Please see the license agreement that accompanies the distribution package
* for licensing details.
*
* Copyright ©1995,1996 by Grant Neufeld
* grant@acm.com
* http://arpp.carleton.ca/grant/
*
*****/
#include "MyConfiguration.h"
#if kCompileWithDragNDrop
#include <Drag.h>
#endif
#include "AEHandlers.h"
#include "CGI.h"
#include "CustomHandlers.h"
#include "DebugUtil.h"
#include "EventUtil.h"
#include "ListSTAR.h"
#include "ProcessUtil.h"
#include "Quit.h"
#include "Startup.h"
#include "WindowInt.h"
/*** FUNCTIONS ***/
#pragma segment AppleEvents
/* The application is expected to open the given document, if possible */
OSErr
CustomOpenDocument ( FSSpec *theFile )
{
OSErr theErr;
my_assert ( theFile != NULL, "\pCustomOpenDocument: theFile ptr is NULL" );
theErr = noErr;
return theErr;
} /* CustomOpenDocument */
#pragma segment Utilities
/* Close any custom application windows */
#if kCompileWithApplicationWindows
OSErr
CustomCloseWindow ( WindowPtr theWindow )
{
OSErr theErr;
theErr = noErr;
return theErr;
} /* CustomCloseWindow */
#endif
/* If activate is true, restore theWindow's selections.
If activate is false, hide, or reduce to outline, theWindow's selections.
If theWindow has a grow box in the bottom right corner,
you should invalidate the growrect */
#if kCompileWithApplicationWindows
void
CustomActivateWindow ( WindowPtr theWindow, Boolean activate )
{
} /* CustomActivateWindow */
#endif
/* Draw contents of window on an update event */
#if kCompileWithApplicationWindows
void
CustomUpdateWindow ( WindowPtr theWindow )
{
} /* CustomUpdateWindow */
#endif
/* Support a click in a window.
If the click is on a dragable item, set onDragItem to true. */
#if kCompileWithApplicationWindows
void
CustomClickInWindow ( WindowPtr theWindow, Point thePoint, Boolean *onDragItem )
{
} /* CustomClickInWindow */
#endif
/* Grow the window */
#if kCompileWithApplicationWindows
void
CustomGrowWindow ( WindowPtr theWindow, Point thePoint )
{
/* this call is in here by default. You can replace it with your own custom
handler if you want */
WindowGrowHandler ( theWindow, thePoint );
} /* CustomGrowWindow */
#endif
/* Handle Idle time tasks for a window. */
#if kCompileWithApplicationWindows
void
CustomWindowIdle ( WindowPtr theWindow )
{
} /* CustomWindowIdle */
#endif
/* If you add windows that allow for text entry or you accept non-command-key
keyboard input, you need to support this function. */
#if kCompileWithKeyboardEvents
void
CustomKeyPress ( EventRecord *theEvent )
{
} /* CustomKeyPress */
#endif
/* */
#if kCompileWithDragNDrop
OSErr
CustomDoStartDrag ( EventRecord *theEvent, WindowPtr theWindow )
{
OSErr theErr;
GrafPtr savePort;
DragReference theDrag;
RgnHandle dragRegion;
GetPort ( &savePort );
SetPort ( (GrafPtr)theWindow );
theErr = NewDrag ( &theDrag );
if ( theErr == noErr )
{
dragRegion = NewRgn ();
/* ••• You need to call a function that sets up the drag values such as:
theErr = customSetupDrag ( theWindow, theDrag, dragRegion, theEvent->where ); */
}
else
{
theDrag = nil;
}
SetPort ( savePort );
theErr = TrackDrag ( theDrag, theEvent, dragRegion );
if ( dragRegion != CustomOpenDocument )
{
DisposeRgn ( dragRegion );
}
if ( theDrag != nil )
{
DisposeDrag ( theDrag );
}
return theErr;
} /* CustomDoStartDrag */
#endif
/** OTHER TASKS **/
#pragma mark -
/* The prototype for this function is in "ProcessUtil.h" */
#if kCompileWithPeriodicTask
void
CustomPeriodicTask ( void )
{
//•••WARNING: THIS DOESN'T EXECUTE EXCEPT WHEN COMPILING AS WEBSTAR PLUG-IN.
// THIS WILL BE FIXED IN A FUTURE VERSION
} /* CustomPeriodicTask */
#endif
/* The prototype for this function is in "ProcessUtil.h" */
#if kCompileWithDeferredTask
void
CustomDeferredTask ( void )
{
//•••WARNING: THIS DOESN'T EXECUTE IF COMPILING AS WEBSTAR PLUG-IN.
// THIS WILL BE FIXED IN A FUTURE VERSION
} /* CustomDeferredTask */
#endif
/** **/
#pragma mark -
#pragma segment Startup
/* add things like installing additional AppleEvent handlers in this function */
OSErr
CustomStartup ( void )
{
OSErr theErr;
Boolean success;
CustomCGIStartup (); /* CGI Specific */
success = CustomListSTARStartup (); /* ListSTAR Specific */
theErr = noErr;
return theErr;
} /* CustomStartup */
#pragma segment Main
/* Unless allowUserInteract is true, don't make any calls that might require
user interaction.
Return true if your clean up was successful and quitting should proceed. */
Boolean
CustomQuit ( Boolean allowUserInteract )
{
return CustomCGIQuit ( allowUserInteract );
} /* CustomQuit */
#pragma segment Main
/* this function is called if some sort of emergency has arisen.
What you're basically being asked to do is release any memory,
resources, files, etc. that you can. */
void
CustomEmergencyHandler ( void )
{
} /* CustomEmergencyHandler */
/***** EOF *****/