/* Copyright 1990-1992 Laboratoire de Recherche en Informatique (LRI)Permission to use, copy, and modify this software and its documentationfor your own purposes is hereby granted without fee, provided thatthe above copyright notice appear in all copies and that both thatcopyright notice and this permission notice appear in supportingdocumentation, and use acknowledge that the software was developedby Laboratoire de Recherche en Informatique, Universite de Paris-Sud,Orsay, France. LRI makes no representations about the suitability ofthis software for any purpose.  It is provided "as is" without expressor implied warranty.This software or modified versions of this software cannot bedistributed in source or binary form, nor included into productswithout prior written permission of the author.LRI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALLIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL LRIBE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTIONOF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.Author:   ___    0  Thomas Baudel                 e-mail: thomas@lri.fr  /   \  /   LRI - Bat 490 /  __/ /    Universite de Paris-Sud       voice : +33 (1) 69 41 69 10/__   \/     91 405 ORSAY Cedex - FRANCE   fax   : +33 (1) 69 41 65 86*//* Fonctions de dialogue modal Usuelles  *//* INCLUDE */# include <Types.h> 				/* Nearly always required */# include <QuickDraw.h> 			/* To access the qd globals */# include <ToolUtils.h> 			/* CursHandle and iBeamCursor */# include <Fonts.h> 				/* Only for InitFonts() trap */# include <Events.h>				/* GetNextEvent(), ... */# include <OSEvents.h># include <Files.h># include <memory.h>			# include <Packages.h># include <Resources.h>	# include <windows.h>				/* GetNewWindow(), ... */# include <dialogs.h>				/* InitDialogs() and GetNewDialog() */# include <OSUtils.h>				/* SysBeep *//* CONSTANTES */ #define aboutMeDLOG	128#define	AlerteId	130#define	ConfirmeId	131#define	Confirme3Id	132#define DemandeId	133#define GeFDialogue 135/* CODE */void AProposDialogue() {	GrafPtr 	savePort; DialogPtr	theDialog; short itemHit;	GetPort(&savePort);	theDialog = GetNewDialog(aboutMeDLOG, nil, (WindowPtr) -1); SetPort(theDialog);	do { ModalDialog(nil, &itemHit); } while (itemHit != 1);	CloseDialog(theDialog); SetPort(savePort);}void Alerte(char *c){	GrafPtr 	savePort; short i;	GetPort(&savePort); 	paramtext(c, NULL, NULL, NULL); 	i = StopAlert(AlerteId, NULL); 	SetPort(savePort); } int Demande(Str255 c, Str255 reply)  {	GrafPtr 	savePort; DialogPtr	theDialog; short itemHit; Handle h; Rect r;		GetPort(&savePort);	theDialog = GetNewDialog(DemandeId, nil, (WindowPtr) -1); 	ParamText(c, NULL, NULL, NULL); 	GetDItem(theDialog, 3, &itemHit, &h, &r); SetIText(h, reply);	ShowWindow(theDialog); SetPort(theDialog);	do { ModalDialog(nil, &itemHit); } while (itemHit > 2) ;	if (itemHit==1) {		GetDItem(theDialog, 3, &itemHit, &h, &r);		GetIText(h, reply);		}	CloseDialog(theDialog); SetPort(savePort);	return itemHit; } int Confirme(char *c){	GrafPtr 	savePort; short itemHit;	GetPort(&savePort); 	paramtext(c, NULL, NULL, NULL); 	itemHit = CautionAlert(ConfirmeId, NULL); 	SetPort(savePort); 	return(itemHit); } int Confirme3 (char *c) {	GrafPtr 	savePort; short itemHit;		GetPort(&savePort); 	paramtext(c, NULL, NULL, NULL); 	itemHit = CautionAlert(Confirme3Id, NULL); 	SetPort(savePort); 	return(itemHit); } pascal short SFDlgFilter(short Item, DialogPtr theDlg) { // *** appdependent  short itemHit; Handle h; Rect r;	switch(Item) {	case 11 : GetDItem(theDlg, Item, &itemHit, &h, &r);  /* read only */								itemHit=GetCtlValue((ControlHandle) h);								if(itemHit) SetCtlValue((ControlHandle) h, 0);								else SetCtlValue((ControlHandle) h,1);								return Item;	case 12 :  GetDItem(theDlg, Item, &itemHit, &h, &r); /* resource fork */								itemHit=GetCtlValue((ControlHandle) h);								if(itemHit) SetCtlValue((ControlHandle) h, 0);								else SetCtlValue((ControlHandle) h, 1);								return Item;	default : return Item;	}}/* int ChoixItem() */short GetDocument (ch, t, resf) Str255 ch; SFTypeList* t; short resf; { 	Point LePoint; 	SFTypeList TypeList; 	SFReply Reply; 	short  LeFichierS=0 , Test;		 SetPt(&LePoint,80,60);	 if(t) {	 		LeFichierS=2; // *** appdependent	 		 SFPGetFile(LePoint, "\pFile Name", NULL, LeFichierS, *t, (DlgHookProcPtr) SFDlgFilter, 			 									&Reply, GeFDialogue, NULL); 	 } else SFPGetFile(LePoint, "\pFile Name", NULL, -1, TypeList, (DlgHookProcPtr) SFDlgFilter, 	 											&Reply, GeFDialogue, NULL); 	 if (Reply.good) {		Test = setvol(NULL, Reply.vRefNum);		if (resf)			LeFichierS = OpenResFile (Reply.fName);		else Test = FSOpen (Reply.fName, Reply.vRefNum, &LeFichierS); 		Test=Reply.fName[0]+1; while(Test>=0) { ch[Test]=Reply.fName[Test]; Test--; }		return LeFichierS;		} else return 0;}/* PutDocument() */
