/******************************************************************************
 JXSpellChecker.h

	Interface for the JXSpellChecker class

	Copyright © 1997 by Glenn W. Bach.  All rights reserved.
	
	Base code generated by Codemill v0.1.0

 *****************************************************************************/

#ifndef _H_JXSpellChecker
#define _H_JXSpellChecker

#include <JBroadcaster.h>
#include <JPtrArray.h>
#include <JString.h>

#include <jTypes.h>

class JXTEBase;
class JXSpellCheckerDialog;
class JInPipeStream;
class JOutPipeStream;
class JProcess;

class JXSpellChecker : virtual public JBroadcaster
{
public:

	JXSpellChecker(JXTEBase* editor);
	virtual ~JXSpellChecker();

	void	CheckWords();
	
	static void		ReadSetup(istream& is);
	static void		WriteSetup(ostream& os);
	
protected:

	virtual void	Receive(JBroadcaster* sender,
								const JBroadcaster::Message& message);

private:

	JXTEBase*		itsEditor;			// We don't own this
	JIndex			itsCurrentIndex;
	
	JXSpellCheckerDialog*	itsDialog;
	JInPipeStream*			itsIn;
	JOutPipeStream*			itsOut;
	JPtrArray<JString>*		itsWords;
	JProcess*				itsProcess;

	JBoolean				itsFoundErrors;
	
	static JString	itsPrefsString;

private:

	JBoolean	CheckWord(const JString& word);

	void		CleanUpOnFinished();

	// not allowed

	JXSpellChecker(const JXSpellChecker& source);
	const JXSpellChecker& operator=(const JXSpellChecker& source);

public:

// Broadcaster messages

	static const JCharacter* kSpellCheckFinished;

	class SpellCheckFinished : public JBroadcaster::Message
		{
		public:

			SpellCheckFinished(const JBoolean errors)
				:
				JBroadcaster::Message(kSpellCheckFinished),
				itsFoundErrors(errors)
				{ };

			JBoolean
			FoundErrors() const
				{
				return itsFoundErrors;
				}

		private:

			JBoolean itsFoundErrors;
		};

};
#endif
