/*	TTagFileForm.h
 *
 *		TagFile form; this is the object which provides the form
 *	functionality for my project
 */

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

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

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

#ifndef PandaWave_TPROJECTFORM
#define PandaWave_TPROJECTFORM

#include <XTypes.h>
#include <XForm.h>
#include "tags.h"

class XGDialog;
struct tag_entry;

/*	TTagFileForm
 *
 *		The form object which provides functionality for how to manage
 *	my project object
 */

class TTagFileForm : public XGForm {
	public:
								TTagFileForm( struct tag_file *tf );
		virtual					~TTagFileForm();
		
		/*
		 *	Events
		 */
		
		void					DoFormInitialize();
		void					DoDocumentRenamed();
		void					DoDocumentRevert();
		
		virtual bool			DoQueryDestroyWindow();
		
		void					NoticeItem( tag_entry *e, bool select, bool clear_select );
		void					ReloadTableContents(bool endraw = true);
		void					GetInfoItem( struct tag_entry * );
		
		DECLAREDISPATCH
		long					DoDoubleClick(long,void *);
		long					DoGetMenuStatus(long,void *);
		long					DoMenuCommand(long,void *);
		long					DoKeyEvent( long arg, void * );
		long					DoTreeCanDrop(long arg, void* );
		long					DoTreeDrop(long arg, void* );
		
		/*
		 *	Resource editor management
		 */
		
		//void					CloseResEditor(TResForm *f);
		
		struct tag_file *		GetFile()
				{ return fTagFile; }
	
	private:
		void					DeleteItem( struct tag_entry * );
		void					CutItem( struct tag_entry *e );
		void					CopyItem( struct tag_entry * );
		void					PasteItems();
		void					CreateItem();
		void					FindDuplicates( struct tag_entry * );
		void					DoToAllSelectedEntries( void (TTagFileForm::*proc)( tag_entry *e ) );
		void					ExecuteScriptFile( void );
		
		void					ImportColormap();
		void					ImportCamAnm();
		void					ImportCINFile();
		
		//uint32					fTreeID[KNumResTypes];
		
		static long				NewTagDialogProc(XGDialog *, void *, long, long, void *);
		static long				InfoDialogProc(XGDialog *, void *, long, long, void *);
		static long				CollapseTerrainDetailsProc(XGDialog*, void*, long, long, void*);
		
		bool					DoSave();
		bool					DoSaveAs();

		//void					AddResTable(long resType, short resID, TResForm *editor);
		//TResForm				*FindResTable(long resType, short resID);

		XGHandle				fResTable;
		struct tag_file *		fTagFile;
		
		static int tagClipCount;
		static int tagClipMax;
		static struct tagClipDataRecord {
			char name[128];
			const void *data;
			unsigned length;
			short version;
			tag type;
			tag id;
			tag_entry *pasteTemp;
		} *tagClipData;
		
		void ClearTagClip( int max = 20 );
		void AddTagClip( tag_entry *e, bool copy_data );
		
};

#endif // PandaWave_TPROJECTFORM
