// GUIObjectList.h: interface for the GUIObjectList class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GUIOBJECTLIST_H__111066B6_E268_4895_88F2_9C8CC7CDF65A__INCLUDED_)
#define AFX_GUIOBJECTLIST_H__111066B6_E268_4895_88F2_9C8CC7CDF65A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include"EdGUIObject.h"
class DrawInfo;
class CameraController;

class GUIObjectList:public EdGUIObject  
{
private:
protected:
	void Copy(GUIObjectList &obj);
	int ObjectCount,ArrayMax;
	int LastFoundAt;
	EdGUIObject **ObjData;
	bool ExistEmpty;

	HTREEITEM MyItem;
	int CorrectSelectionState();
	void GrowArray();
	virtual void RemoveObject(int idx);
	bool HoldsSelected();
	EdGUIObject *SelectClosestInternal(Point3D &pnt,Scalar *crat);	
	bool DeleteSelected(UndoCommand **delcom); 
	bool DeleteSelected(); 
	void DrawTagInternal(DrawInfo &dinf, unsigned long tag_flags);

public:
	void DefaultExtraData();
	void Freeze(); 
	void UnFreeze(); 

	EdGUIObject *Clone();
	void SaveTextInfo(NotationFile *not_file);
	virtual bool CanTakeChildren() {return true;}
	
	EdGUIObject *GetObjectByName(CString name);
	int FindObjectIdx(EdGUIObject *gobj);	
	int FindObjectIdxByName(CString &objname);	
	bool AllSelected();
	void SortChildren(); 
	bool IsMultiZone();
	bool IsMultiTile();		
	void SelectMultiZone();	
	void SelectMultiTile();	
	void AddPanel(CObjPanelDlg *pnl,UndoCommand **cmd);
	void MoveToGroup(EdGUIObject *gobj);
	GUIObjectList *PlaceInGroup(EdGUIObject *gobj);
	void RemoveObject(EdGUIObject *gobj);
	bool IsMine(EdGUIObject *gobj) {return gobj->GetParent()==this;}
	EdGUIObject *FindFirstSelected();

	void Select();		
	void DeSelect();		
	void ToggleSelect(); 
	bool IsModified();
	void ClearModifyFlags();
//	void Hide();
//	void UnHide();
	void GetMultiPropsIfSelected(CObjProps *props); 
	void SetMultiPropsIfSelected(CObjProps *props,UndoCommand **cmd); 
	void GetMultiProps(CObjProps *props);
	void SetMultiProps(CObjProps *props,UndoCommand **cmd);

	void UpdateVisibility(DWORD visflag);

	CString GetTypeName() {return ("Group");} 
	HTREEITEM AddToBranch(CTreeCtrl *tree,HTREEITEM itm);

	int SelectionCount();	
	int SelectionDepth(Point3D &pnt);	
	int ObjectDepth(Point3D &pnt);	
	int DeSelect(Point3D &pnt);	
	int Select(Point3D &pnt);	
	int ToggleSelect(Point3D &pnt);	
	int Select(Point3D &topleft,Point3D &bottomright);	


	virtual void InsertObjectAt(int idx,EdGUIObject *gobj);
	virtual void AddObject(EdGUIObject *gobj);
	virtual void DeleteObject(int idx);	
	void DeleteAllObjects();
	void CopySelectionToList(GUIObjectList *list);

	bool UnGroupSelected(UndoCommand **cmd);
	int GroupSelected(UndoCommand **cmd);
	bool IsEmpty() {return GetObjectCount()==0;}
	void PruneEmpty(UndoCommand **cmd);

	void Dissociate();

	bool ContainsSelection();

	EdGUIObject *GetObjAtPoint(Point3D &pnt);	
	bool InTree(EdGUIObject *gobj);	
	void GetExtents(Point3D *tl,Point3D *br);
	bool GetSelectionExtents(Point3D *tl,Point3D *br); 
	void OffsetBy( Point3D &pnt);
	void RotateBy(UnitQuaternion &rot);
	void RemoveFromMap();
	void AddToMap();
	void SnapObjectToGround(bool overrideflag=true);

	EdGUIObject *AddNodeIfSelected(Point3D &pnt,bool insert);

	void Draw(DrawInfo &dinf);
	void DrawTag(DrawInfo &dinf, unsigned long tag_flags);
	void DrawTileViolation(DrawInfo &dinf);
	virtual void CorrectGroupPosition(Point3D &pnt);

	void DrawAllObjects(DrawInfo &dinf,bool drawTags, unsigned long tag_flags);
	void DrawSelectedObjects(DrawInfo &dinf,bool drawTags, unsigned long tag_flags);
	void DrawUnSelectedObjects(DrawInfo &dinf,bool drawTags, unsigned long tag_flags);
	void OffsetSelection(Point3D &vct); 
	void RotateSelection(UnitQuaternion &vct);
	void RotateAround(Point3D &pnt,UnitQuaternion &vct);
	void RotateSelectionAround(Point3D &pnt,UnitQuaternion &vct);
	void SetSnapToGround(bool snap,bool preservepos=false); 
	void SetHoverElevation(float elev); 
	int GetObjectCount() {return ObjectCount; }
	bool SelectNext(Point3D &pnt,bool found=false); 	
	void SyncData();

	EdGUIObject *GetObject(int idx); 

	GUIObjectList(CString name="Group");
	virtual ~GUIObjectList();
	int GetUnSelIcon() {return ICON_GROUP; }
	int GetSelIcon()   {return ICON_GROUP; }
	void SavePosIfSelected(UndoCommand **cmd);
	void SaveRotIfSelected(UndoCommand **cmd);


};

#endif // !defined(AFX_GUIOBJECTLIST_H__111066B6_E268_4895_88F2_9C8CC7CDF65A__INCLUDED_)
