/******************************************************************************
 GNBApp.h

	Interface for the GNBApp class

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

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

#ifndef _H_GNBApp
#define _H_GNBApp

#include <JXApplication.h>
#include <JFileArray.h>
#include <JString.h>

class GNBNoteDir;
class GNBTreeDir;

class GNBApp : public JXApplication
{
public:

	GNBApp(int* argc, char* argv[], JBoolean* displayAbout, JString* prevVersStr);
	virtual ~GNBApp();
	
	void	DisplayAbout(const JCharacter* prevVersStr = NULL);
	void	ShowNoteTree();
	void	OpenNote(const JFAID_t id);
	void	CloseNote(const JFAID_t id);
	JFAID_t	NewNote();
	void	DeleteFileElement(const JFAID_t id);

	void	Flush(const JBoolean reopen);
	void	NeedsSave();

	void	NoteNameChanged(const JFAID_t id, const JString& title);
	
	virtual void	Quit();

	JFileArray*		GetFileArray();

protected:

	virtual void	DirectorClosed(JXDirector* theDirector);
	virtual void	CleanUpBeforeSuddenDeath(const JXDocumentManager::SafetySaveReason reason);

private:

	JPtrArray<GNBNoteDir>*	itsNoteDirs;
	JFileArray*				itsFileArray;
	GNBTreeDir*				itsTreeDir;
	JBoolean				itsWaitingForFlush;
	JString					itsFileName;
	JBoolean				itsIsStarting;

private:

	void SaveOpenWindows();
	void OpenWindows();
	
	// not allowed

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

public:

	static const JCharacter* kDataChanged;

	class DataChanged: public JBroadcaster::Message
		{
		public:
		
			DataChanged
				(
				const JFAID_t  id,
				const JString& title
				)
				:
				JBroadcaster::Message(kDataChanged),
				itsID(id),
				itsTitle(title)
				{ };

			const JString&
			GetTitle()
				const
				{
				return itsTitle;
				}

			JFAID_t
			GetID()
				const
				{
				return itsID;
				}

		private:

			JFAID_t 		itsID;
			const JString&	itsTitle;
		};
};

/******************************************************************************
 GetFileArray (public)

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

inline JFileArray*
GNBApp::GetFileArray()
{
	return itsFileArray;
}

#endif
