/* 
Copyright (c) 1991-2000 UserLand Software, Inc. 

Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software and associated documentation files (the 
"Software"), to deal in the Software without restriction, including 
without limitation the rights to use, copy, modify, merge, publish, 
distribute, sublicense, and/or sell copies of the Software, and to 
permit persons to whom the Software is furnished to do so, subject to the 
following conditions: 

The above copyright notice and this permission notice shall be 
included in all copies or substantial portions of the Software. 

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
*/ 


#ifndef iowaruntimeinclude
#define iowaruntimeinclude

#ifndef iowacoreinclude

	#include "iowacore.h"

#endif


#define iowaInitEvent 1000 /*constants for (*ev).what in callbacks*/
#define iowaButtonHitEvent 1001
#define iowaCloseEvent 1002
#define iowaRunScriptEvent 1003
#define iowaCancelEvent 1004 
#define iowaSetHandleEvent 1005
#define iowaOkeyDokeyEvent 1006 /*dmb 1.0b21*/


typedef boolean (*tycardwindowvisitroutine) (WindowPtr);

typedef void (*tycardeventcallback) (EventRecord *); 


typedef struct tyruntimerecord {
	
	hdlcard hc; /*the unpacked version of the card*/
	
	WindowPtr macwindow; /*the window used to display the card*/
	
	boolean initfields; /*set true when the card starts up, consumed when the first event comes in*/
	
	boolean modeless; /*true if it's a modeless card, false if modal*/
	
	boolean closethiswindow; /*if true it's time to close this card's window*/
	
	boolean ownwindow; /*if true we created this window*/
	
	tycardeventcallback callback; /*a C routine that events filter thru*/
	} tyruntimerecord, **hdlruntimerecord;


extern hdlruntimerecord runtimedata;

extern boolean flquickrecalc; /*set false in cardrunner.c, under special circumstances*/

extern boolean flexitcardloop; /*for modal cards, the loop should exit if true*/

extern boolean flalertdialogrunning; /*prevent nested alerts*/


boolean initIowaRuntime (void);

WindowPtr newCardWindow (Point, boolean, Handle);

boolean handleCardEvent (WindowPtr w, EventRecord *, boolean *);

boolean cardEditCommand (short);

boolean isCardWindow (WindowPtr);

boolean cardToFront (bigstring);

boolean recalcCardWindow (WindowPtr, boolean);

boolean visitCardWindows (tycardwindowvisitroutine);

short countCardWindows (void);

boolean closeCardWindow (WindowPtr);

void closeAllCardWindows (void);

void getCardData (WindowPtr, hdlruntimerecord *); 

boolean isModelessCardEvent (EventRecord *, boolean *);

boolean cardIsModal (Handle);

void installRuntimeEventHandlers (void); /*1.0b20 dmb*/

boolean runModalCard (Handle, boolean, short, short, tycardeventcallback);

boolean runModelessCard (Handle, boolean, short, short, tycardeventcallback);

boolean runCard (Handle, boolean, short, short, tycardeventcallback);

boolean runHostedCard (WindowPtr hostwindow, Handle hpackedcard, boolean flscriptedcard, tycardeventcallback callback);

boolean setObjectValue (hdlcard, bigstring, Handle);

boolean getObjectValue (hdlcard, bigstring, Handle *);

boolean getObjectHandle (hdlcard, bigstring, hdlobject *);

boolean recalcObject (hdlobject);

boolean updateCard (hdlcard);

WindowPtr getcardrecordwindow (hdlcard card);

#endif