/******************************************************************************
FILE
    sq.m
DESCRIPTION
	This module contains stub routines. These are the low-level routines
	called by the Squeak interpreter. They're implemented by sending a
	message to the application object or the view object.
AUTHOR
	<PJB> Pascal J. Bourguignon
MODIFICATIONS
	1998/06/12 <PJB> Creation.
LEGAL
	Copyright Pascal J. Bourguignon 1998 - 1998

	This program is free software; you can redistribute it and/or
	modify it under the terms of the version 2 of the GNU General Public 
	License as published by the Free Software Foundation.
	
	This program is distributed in the hope that it will be useful, but 
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
	or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
	hereafter for more details.
******************************************************************************/
#import <appkit/appkit.h>
#import "SqApplication.h"
#import "SqView.h"

#define sq_application  ((SqApplication*)NXApp)
#define sq_view         ((SqView*)(sq_application->view))


// These two variable are normally defined in the translator.
int contextCacheEntries=16;
int stackCacheEntries=16;


extern int interruptKeycode;
extern int interruptPending;
extern int interruptCheckCounter;



/* display,mouse,keyboard,time i/o  ==> view */


	int ioForceDisplayUpdate(void)
	{
		return([sq_view ioForceDisplayUpdate]);
	}//ioForceDisplayUpdate;
	
	
	int ioFormPrint(
		int bitsAddr,int width,int height,int depth,
		double hScale,double vScale,int landscapeFlag)
	{
		return([sq_view ioFormPrintBitsAddr:bitsAddr 
			width:width height:height depth:depth 
			hScale:hScale vScale:vScale landscapeFlag:landscapeFlag]);
	}//ioFormPrint;
	

	int ioSetFullScreen(int fullScreen)
	{
		return([sq_view ioSetFullScreen:fullScreen]);
	}//ioSetFullScreen;
	

	int ioGetButtonState(void)
	{
		return([sq_view ioGetButtonState]);
	}//ioGetButtonState;
	

	int ioGetKeystroke(void)
	{
		return([sq_view ioGetKeystroke]);
	}//ioGetKeystroke;
	
	int ioMousePoint(void)
	{
		return([sq_view ioMousePoint]);
	}//ioMousePoint;
	

	int ioPeekKeystroke(void)
	{
		return([sq_view ioPeekKeystroke]);
	}//ioPeekKeystroke;
	

	int ioScreenSize(void)
	{
		return([sq_view ioScreenSize]);
	}//ioScreenSize;
	

	int ioSetCursorWithMask(int cursorBitsIndex,int cursorMaskIndex,
			int offsetX,int offsetY)
	{
		return([sq_view ioSetCursorBitsIndex:cursorBitsIndex 
				withMask:cursorMaskIndex
				offsetX:offsetX offsetY:offsetY]);
	}//ioSetCursorWithMask;


	int ioSetCursor(int cursorBitsIndex,int offsetX,int offsetY)
	{
		return([sq_view ioSetCursorBitsIndex:cursorBitsIndex 
				offsetX:offsetX offsetY:offsetY]);
	}//ioSetCursor;
	

	int ioShowDisplay(
		int dispBitsIndex,int width,int height,int depth,
		int affectedL,int affectedR,int affectedT,int affectedB)
	{
		return([sq_view ioShowDisplayBitsIndex:dispBitsIndex 
			width:width height:height depth:depth 
			affectedLeft:affectedL affectedRight:affectedR 
			affectedTop:affectedT affectedBottom:affectedB]);
	}//ioShowDisplay;
	




/* display,mouse,keyboard,time i/o  ==> application */
	
	int ioBeep(void)
	{
		return([sq_application ioBeep]);
	}//ioBeep;
	
	
	int ioExit(void)
	{
		return([sq_application ioExit]);
	}//ioExit;
	
	
	

	int ioMicroMSecs(void)
	{
		return([sq_application ioMicroMSecs]);
	}//ioMicroMSecs;
	

	int ioMSecs(void)
	{
		return([sq_application ioMSecs]);
	}//ioMSecs;
	

	int ioSeconds(void)
	{
		return([sq_application ioSeconds]);
	}//ioSeconds;
	

	int ioProcessEvents(void)
	{
		return([sq_application ioProcessEvents]);
	}//ioProcessEvents;
	

	int ioRelinquishProcessorForMicroseconds(int microSeconds)
	{
		return([sq_application 
				ioRelinquishProcessorForMicroseconds:microSeconds]);
	}//ioRelinquishProcessorForMicroseconds;
	

/* image file and VM path names */

	char imageName[MAXPATHLEN+1];
		/*
			This is a little dirty: imageName is directly accessed by 
			writeImageFile (while readImageFromFileHeapSize does take 
			a FILE* parameter!).
			To avoid the need for SqApplication to know about this, the 
			following function will automatically update this variable.
		*/
		

	int imageNameGetLength(int sqImageNameIndex,int length)
	{
		int len;
		len=[sq_application imageNameGet:(int)(&imageName) Length:MAXPATHLEN];
		imageName[len]='\0';
		return([sq_application imageNameGet:sqImageNameIndex Length:length]);
	}//imageNameGetLength;
	

	int imageNamePutLength(int sqImageNameIndex,int length)
	{
		int res=[sq_application imageNamePut:sqImageNameIndex Length:length];
		int len;
		len=[sq_application imageNameGet:(int)(&imageName) Length:MAXPATHLEN];
		imageName[len]='\0';
		return(res);
	}// PutLength;
	

	int imageNameSize(void)
	{
		return([sq_application imageNameSize]);
	}//imageNameSize;
	

	int vmPathSize(void)
	{
		return([sq_application vmPathSize]);
	}//vmPathSize;
	

	int vmPathGetLength(int sqVMPathIndex,int length)
	{
		return([sq_application vmPathGet:sqVMPathIndex Length:length]);
	}//vmPathGetLength;
	

	
	
/* clipboard (cut/copy/paste) */
	
	int clipboardSize(void)
	{
		return([sq_application clipboardSize]);
	}//clipboardSize;
	

	int clipboardReadIntoAt(int count,int byteArrayIndex,int startIndex)
	{
		return([sq_application clipboardRead:count 
				Into:byteArrayIndex At:startIndex]);
	}//clipboardReadIntoAt;
	

	int clipboardWriteFromAt(int count,int byteArrayIndex,int startIndex)
	{
		return([sq_application clipboardWrite:count
				From:byteArrayIndex At:startIndex]);
	}//clipboardWriteFromAt;
	

	
/* profiling */
	
	int clearProfile(void)
	{
		return([sq_application clearProfile]);
	}//clearProfile;
	

	int dumpProfile(void)
	{
		return([sq_application dumpProfile]);
	}//dumpProfile;
	

	int startProfiling(void)
	{
		return([sq_application startProfiling]);
	}//startProfiling;
	

	int stopProfiling(void)
	{
		return([sq_application stopProfiling]);
	}//stopProfiling;
	

	
	/* system attributes */
	int attributeSize(int ident)
	{
		return([sq_application attributeSize:ident]);
	}//attributeSize;
	

	int getAttributeIntoLength(int ident,int byteArrayIndex,int length)
	{
		return([sq_application getAttribute:ident 
				Into:byteArrayIndex Length:length]);
	}//getAttributeIntoLength;
	

	
	
/*** sq.m / Thu Aug 27 23:21:13 MET 1998 / PJB ***/
