/*	TEditDoc.h
 *
 *		Edit document; this is the overrides to the XGDocument
 *	class which maintains my document interface
 */

/*  XT - An example text editor application built with the YAAF library
 *
 *	PUBLIC DOMAIN: The source kit of 'xt' has been placed into the
 *	public domain by the author, William Edward Woody, on the hope
 *	that the source kit will provide a useful example of using the
 *	YAAF Library.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#ifndef PandaWave_TEDITDOC
#define PandaWave_TEDITDOC

#include <XDocument.h>
#include <XHandle.h>
#include "TFile.h"

/************************************************************************/
/*																		*/
/*	Messages															*/
/*																		*/
/************************************************************************/

#define KRevertDoc		'Reve'

/************************************************************************/
/*																		*/
/*	Document Specification												*/
/*																		*/
/************************************************************************/

/*	TEditDoc
 *
 *		The edit document
 */

class TEditDoc : public XGDocument {
	public:
								TEditDoc();
		virtual					~TEditDoc();
		
		/*
		 *	Document construction
		 */
		
		static TEditDoc			*NewDocument();
		static TEditDoc			*OpenDocument();
#if OPT_MACOS
		static TEditDoc			*OpenDocument(FSSpec *);
#endif

#if OPT_WINOS || OPT_XWIN
		static TEditDoc			*OpenDocument(char *);
#endif
		
		/*
		 *	Document save/restore
		 */
		
		virtual bool			IsDocumentNamed();
		virtual bool			IsDocumentDirty();
		virtual void			GetDocumentName(char *);
		virtual bool			DoDocumentSave();
		virtual bool			DoDocumentSaveAs();
		virtual void			DoDocumentRevert();
		
		/*
		 *	Document contents
		 */
		
		void					MarkDirty()
									{
										fDirty = true;
									}
		XGHandle				*GetText()
									{
										return &fText;
									}
	
	private:
		bool					DoOpenDialog();
		bool					DoSaveDialog();
		
		bool					fDirty;
		char					fName[64];
		TFile					*fFile;
		
		XGHandle				fText;
};

#endif // PandaWave_TEDITDOC
