#include "Hex Editor.h"

#ifndef _ResKnife_HexEditor_Events_
#define _ResKnife_HexEditor_Events_

// classic event handler
#if !TARGET_API_MAC_CARBON
	typedef CALLBACK_API(OSStatus, ClassicEventHandlerProcPtr)	(EventRecord *event, UInt32 eventKind, void *userData);
	typedef STACK_UPP_TYPE(ClassicEventHandlerProcPtr)			ClassicEventHandlerUPP;
	enum { uppClassicEventHandlerProcInfo = 0x00000FF0 };		/* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
	#ifdef __cplusplus
		inline ClassicEventHandlerUPP NewClassicEventHandlerUPP(ClassicEventHandlerProcPtr userRoutine) { return (ClassicEventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppClassicEventHandlerProcInfo, GetCurrentArchitecture()); }
	#else
		#define NewClassicEventHandlerUPP(userRoutine) (ClassicEventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppClassicEventHandlerProcInfo, GetCurrentArchitecture())
	#endif
#endif

/*!
 *	@function		CarbonWindowEventHandler
 *	@discussion		
 */
pascal OSStatus		CarbonWindowEventHandler( EventHandlerCallRef handler, EventRef event, void *userData );
/*!
 *	@function		CarbonHIEventHandler
 *	@discussion		
 */
pascal OSStatus		CarbonHIEventHandler( EventHandlerCallRef handler, EventRef event, void *userData );
#if !TARGET_API_MAC_CARBON
/*!
 *	@function		ClassicWindowEventHandler
 *	@discussion		
 */
pascal OSStatus		ClassicWindowEventHandler( EventRecord *event, UInt32 eventKind, void *userData );
#endif
/*!
 *	@function		ConstrainWindowResize
 */
pascal OSStatus		ConstrainWindowResize( EventHandlerCallRef handler, EventRef event, void *userData );
/*!
 *	@function		SizeChanging
 */
OSStatus			SizeChanging( WindowRef window, EventRef event );
/*!
 *	@function		SizeChanged
 */
OSStatus SizeChanged( WindowRef window );
/*!
 *	@function		HandleEditClick
 */
OSStatus HandleEditClick( WindowRef window, EventRef event, Point mouse, EventModifiers modifiers );
/*!
 *	@function		HandleEditDrag
 */
OSStatus HandleEditDrag( WindowRef window, EventRef event, Point mouse, EventModifiers modifiers );
/*!
 *	@function		HandleKeyDown
 */
OSStatus HandleKeyDown( WindowRef window, unsigned char charCode, EventModifiers modifiers );
/*!
 *	@function		HandleArrowKeyDown
 */
OSStatus HandleArrowKeyDown( WindowRef window, unsigned char charCode, EventModifiers modifiers );
/*!
 *	@function		FindSelectedRegions
 */
OSStatus FindSelectedRegions( WindowRef window, RgnHandle hexRgn, RgnHandle asciiRgn );
/*!
 *	@function		UpdateSelection
 */
OSStatus UpdateSelection( WindowRef window, Boolean editingHex );
/*!
 *	@function		HexKeyFilter
 */
pascal ControlKeyFilterResult HexKeyFilter( ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers );
/*!
 *	@function		AsciiKeyFilter
 */
pascal ControlKeyFilterResult AsciiKeyFilter( ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers );
/*!
 *	@function		TrackScrollbar
 */
pascal void TrackScrollbar( ControlRef control, short part );
/*!
 *	@function		BlinkInsertionPoint
 */
pascal void BlinkInsertionPoint( EventLoopTimerRef inTimer, void *inUserData );

#endif