/*    Foundation Window/Control Resource Editor Module  */
/*    Main Routines                                     */
#pragma noroot
#include <foundation.h>
#include <event.h>

extern EventRecordPtr fEventPtr;

Rect	ColorRect[14] =	{	{ 11, 168,  23, 198},     /* 0	these are used	*/
							{ 16, 180,  28, 210},     /* 1	by our "pseudo	*/
							{ 32, 168,  44, 198},     /* 2	control" color	*/
							{ 37, 180,  49, 210},     /* 3	pickers.		*/
							{ 53, 168,  65, 198},     /* 4	*/
							{ 58, 180,  70, 210},     /* 5	*/
							{ 74, 168,  86, 198},     /* 6	*/
							{ 79, 180,  91, 210},     /* 7	*/
							{ 95, 168, 107, 198},     /* 8	*/
							{100, 180, 112, 210},     /* 9	*/
                            {116, 168, 128, 198},     /* A	*/
                            {121, 180, 133, 210},     /* B	*/
                            {137, 168, 149, 198},     /* C	*/
                            {142, 180, 154, 210}};    /* D	*/

Point	StringLoc[7] =		{023, 20 },
							{044, 20 },
							{056, 20 },
							{086, 20 },
							{107, 20 },
							{128, 20 },
							{149, 20 }};

servant Slave[13] ={{9, {A,9,8,7,6,4,3,2,0}, {8,6,7,4,5,3,1,2,0},
						6, {0,1,2,3,4,5} , {0,1,2,3,4,5}},	/* Window */
					{3, {3,2,0,0,0,0,0,0,0}, {9,A,0,0,0,0,0,0,0},
						2, {0,1}, {0,6}, },					/* Alert  */
					{6, {5,4,3,2,1,0,0,0,0}, {5,2,4,3,1,0,0,0,0},
						3, {0,1,2}, {7,8,0}},				/* ChkBox */
					{6, {5,4,3,2,1,0,0,0,0}, {5,2,4,3,1,0,0,0,0}},
						3, {0,1,2}, {7,8,0}},				/* RadBtn */
					{5, {5,4,3,1,0,0,0,0,0}, {3,2,4,1,0,0,0,0,0},
						4, {0,1,2,3}, {7,8,9,10}},			/* SimBtn */
					{5, {5,4,3,1,0,0,0,0,0}, {3,2,4,1,0,0,0,0,0},
						4, {0,1,2,3}, {7,8,9,10}},			/* IcnBtn */
					{5, {5,4,3,2,0,0,0,0,0}, {4,3,1,2,0,0,0,0,0},
						3, {0,1,2}, {0,9,10}},				/* List   */
					{5, {5,4,3,2,0,0,0,0,0}, {4,3,1,2,0,0,0,0,0}
						3, {0,1,2}, {11,9,12}},				/* PopUp /*
					{8, {7,6,5,4,3,2,1,0,0}, {7,6,4,3,5,2,1,0,0}
						4, {0,1,2,3}, {13,14,15,16}},		/* Scroll */
					{3, {3,2,0,0,0,0,0,0,0}, {1,3,4,0,0,0,0,0,0}
						2, {0,1}, {11,17}},					/* SizeBx */
					{2, {1,0,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0,0}
						1, {0}, {17}},						/* TEdit  */
					{4, {3,2,1,0,0,0,0,0,0}, {4,3,1,0,0,0,0,0,0}
						2, {0,1}, {18,19}},					/* Thermo */
					{2, {D,C,0,0,0,0,0,0,0}, {1,0,0,0,0,0,0,0,0}
						1, {6}, {20}}};						/* IcnHlt */

point  ourPen[2] =  { {1, 1}, {1, 2}};  /* 0 for 640 mode     1 for 320  */

char				tempText[256];
char				*rDesString[21];
char				*tempName;
word				TEType[] = { rPString, rCString, rC1InputString,
                            rC1OutputString, rTextForLETextBox2, rText };
word				~TOOLERROR,
					~USERID,
					edUserID,
					edResFileID,
					shResFileID,
					fdResFileID,
					bad,
					temp;
long				*edCtlList;
long				*wkCtlList;
fPrivateDataRec		PrivPB;
fResDataRec			DataPB;
fResData2Rec		Data2PB;
fResNameRec			NamePB;
fResRefRec			RefPB;
fResCopyRec			CopyPB;
fResLinkRec			LinkPB;
fResConverterRec	ConvertPB;
fGetFileRec			FilePB;
WinTemplatePtr		edWin;
WinTemplatePtr		wkWin;
control				edCtl;
privateDataHndl		private;
privateDataPtr		pPtr;
QDIconRecordPtr		ArrowIcon[2];

word REM_OPEN(fSessionRecPtr p)
{
	doOpen(p);
	return  0;
}

word REM_CLOSE(fSessionRecPtr p)
{
GrafPortPtr			winP;
PrivateDataHndl		private;

	winP = p->windowPtr;

	PrivPB.pCount = 3;
	PrivPB.winPtr = winP;
	fGetPrivateData(&PrivPB);
	(Handle) private = PrivPB.Data;
	DisposeHandle((**Data).title);
	DisposeHandle((**Data).data);
	DisposeHandle((PrivPB.Data);

	return  0;
}

word REM_WRITE(fSessionRecPtr p)
{
	return  0;
}

word REM_EVENT(fEventRecPtr p)
{
	return  0;
}

word REM_ACTIVATE(fActivateRecPtr p)
{
privateDataHndl private;

    privPB.pCount = 4;
	privPB.winPtr = fEventPtr->wmTaskData;
	fGetPrivateData(&privPB);

	if (p->fFlag & ACTIVATE)
		p->fFlag |= (MENU_UNDO | MENU_CLIP | MENU_CLEAR | MENU_SELECT |MENU_APPLY);

    return  0;
}

/*	========================================================================
    REM_GETLINK is an extension to the shell's dependency knowlege.  Pascal
    Strings don't have dependents.  The supports REM_GETLINK rFlag bit 6 in
    the remStartRes is clear.

	Marc Wolfgram,  3/ 7/92  1:10:48
*/
word REM_GETLINK(fLinkRecPtr p)
{
	return  0;
}

/*	========================================================================
    REM_VIDMODE lets the editor know when it's world is changing.  We don't
    see a valid reason for a 320 mode Pascal String editor.  The 320 mode
    aware rFlag bit 4 in the remStartRes is clear.

	Marc Wolfgram,  3/ 7/92  1:03:41
*/
word REM_VIDMODE(fVidModeRecPtr p)
{
	return  0;
}

/*	========================================================================
    REM_PRINT must be supported entirely by the editor.  Why would we want
    to print a Pascal String?  We don't.

	Marc Wolfgram,  3/ 7/92  1:07:20
*/
word REM_PRINT(fPrintRecPtr p)
{
	return  0;
}

/*	========================================================================
    REM_STARTUP is called only when the REM is first loaded.

    The REM should do whatever it needs to do to setup globals, etc.

    This is the only time when the various Foundation and REM resource file
    ID's are passed to the REM.  Also, the REM's specific memory manager ID
    is passed here - READ THE WARNING IN REM_SHUTDOWN!

	Marc Wolfgram,  3/ 6/92 20:27:26
    ---------------------------------------------------------------
*/
word REM_STARTUP(fStartStopRecPtr p)
{
	~USERID = edUserID = p->edUserID;
	edResFileID = p->edResFileID;
	shResFileID = p->shResFileID;
	fdResFileID = p->shResFileID;
	return  0;
}

/*	========================================================================
    REM_SHUTDOWN is called when an editor is unloaded.

    WARNING: The REM must release any memory alloceated at startup during
             the shutdown call.  There is no guarantee that once the editor
             is released that it will be reloaded.

	Marc Wolfgram,  3/ 6/92 20:41:12
    ---------------------------------------------------------------
*/
word REM_SHUTDOWN(fStartStopRecPtr p)
{
	DisposeAll(edUserID);	/* before assuming that this simplicity is 	*/
	return  0;				/* all you need, read TBR-1, page 12-23!	*/
}
