/******************************************************************************
 GMessageViewDir.h

	Interface for the GMessageViewDir class

	Copyright © 1997 by Glenn Bach. 

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

#ifndef _H_GMessageViewDir
#define _H_GMessageViewDir

#include <GMManagedDirector.h>
#include <JString.h>

class GMessageHeader;
class GMessageView;
class JXTextButton;
class JXTextMenu;
class JXScrollbarSet;
class GMessageTableDir;
class JXGetPasswordDialog;
class JXVertPartition;
class JXToolBar;
class JXImage;

class GMessageViewDir : public GMManagedDirector
{
public:
	
	GMessageViewDir(GMessageTableDir* supervisor, const JString& mailfile,
							GMessageHeader* header);
	virtual ~GMessageViewDir();

	GMessageHeader*	GetMessageHeader();
	void			SaveState(ostream& os);
	void			ReadState(istream& is);	

	virtual JXImage*	GetMenuIcon() const;

protected:

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

	GMessageTableDir*	itsDir;
	GMessageView*		itsView;
	GMessageView*		itsHeader;
	JXTextMenu*			itsFileMenu;
	JXTextMenu*			itsMessageMenu;
	JXTextMenu*			itsPrefsMenu;
	JXTextMenu*			itsHelpMenu;
	
	JString				itsFrom;
	JString				itsTo;
	JString				itsReplyTo;
	JString				itsDate;
	JString				itsCC;
	JString				itsSubject;
	JString				itsFullHeader;
	JString				itsBody;
	
	JXScrollbarSet*		itsSBSet;
	JBoolean			itsShowFullHeaders;
	GMessageHeader*		itsMessageHeader;

	JXGetPasswordDialog*	itsPasswdDialog;
	JXVertPartition*		itsPart;

	JXToolBar*			itsToolBar;

	JXImage*			itsMenuIcon;
	
private:
	
	void		HandleFileMenu(const JIndex index);
	void		UpdateFileMenu();
	
	void		HandleMessageMenu(const JIndex index);
	void		UpdateMessageMenu();
	
	void		HandlePrefsMenu(const JIndex index);
	void		HandleHelpMenu(const JIndex index);

	void		ShowNext();
	void		ShowPrev();
	void		ShowHeader(GMessageHeader* header);

	void		FixHeaderForReply(JString* sub);

	void		AppendMessagesToFile(const JBoolean headers);
	
	void		BuildWindow(const JString& mailfile);
	
	
	// not allowed

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

};

/******************************************************************************
 GetMessageHeader

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

inline GMessageHeader*	
GMessageViewDir::GetMessageHeader()
{
	return itsMessageHeader;
}

/******************************************************************************
 GetMenuIcon (public)

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

inline JXImage*
GMessageViewDir::GetMenuIcon()
	const
{
	return itsMenuIcon;
}

#endif
