//-----------------------------------------------------------------------------
#ifndef PropDataH
#define PropDataH PropDataH
//-----------------------------------------------------------------------------
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <string>
#include <wxPropGrid/Include/propgrid.h>

class PropData;
class PropTree;
class wxPGProperty;
class wxPropertyGrid;

//------------------------------------------------------------------------------
class PropData
//------------------------------------------------------------------------------
{
public:
	enum ECtrl
	{ 
		_ctrlStatic,
		_ctrlSpinner,
		_ctrlEdit,
		_ctrlCombo
	};
	explicit						PropData( mvIMPACT::acquire::HOBJ hObj );
	virtual						   ~PropData( void ) {;}
	virtual	void					OnExpand( void ) {;}
	virtual	void					UpdatePropData( void ) {;}
	virtual	void					EnsureValidGridItem( PropTree *pPropTree, wxPGId parentGridComponent, bool* boModified = 0  ) = 0;
			void					UpdateGridItem( PropTree *pPropTree, bool boDisplayDebugInfo, bool boDisplayInvisibleComponents, bool *boModified );
	virtual	void					Update( PropTree *pPropTree, bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount ) = 0;
	void							InvalidatePropGridItem( void ) { m_GridItemId = wxPGId(); }
	mvIMPACT::acquire::Component	Component( void ) const { return m_Component; }
	bool							HasChanged( void ) const { return m_Component.changedCounter() != m_lastChangedCounter; }
	ECtrl							Type( void ) const { return m_Type; }
	wxPGId							GetGridItem( void ) const { return m_GridItemId; }

protected:
	void							AppendComponentInfo( wxString& info, unsigned int actChangedCount, unsigned int actAttrChangedCount );
	mvIMPACT::acquire::Component	m_Component;
	unsigned int					m_lastChangedCounter;
	unsigned int					m_lastChangedCounterAttr;
	ECtrl							m_Type;
	wxPGId							m_GridItemId;
	wxPropertyGrid*					m_pParentGrid;
};

//------------------------------------------------------------------------------
class MethodObject : public PropData
//------------------------------------------------------------------------------
{
public:
	explicit						MethodObject( mvIMPACT::acquire::HOBJ hObj );
	std::string						Call( void );
	const std::string&				Params( void ) const { return m_Params; }
	void							UpdatePropData();
	void							Update( PropTree *pPropTree, bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount );
	void							EnsureValidGridItem( PropTree *pPropTree, wxPGId parentItem, bool* boModified = 0  );
private:
	std::string						m_Params;
	std::string						m_FriendlyName;
};

//------------------------------------------------------------------------------
class ListObject : public PropData
//------------------------------------------------------------------------------
{
public:
	explicit						ListObject( mvIMPACT::acquire::HOBJ hObj, const char *title = 0 );
	bool							IsExpanded( void ) const { return m_boExpanded; }
	void							OnExpand( void );
	void							EnsureValidGridItem( PropTree *pPropTree, wxPGId parentItem, bool* boModified = 0  );
	void							Update( PropTree *pPropTree, bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount );
	static const wxColour			BACKGROUND_COLOR;
private:
	bool							GetColour( std::string& text, wxColour& colour );
	bool							m_boExpanded;
	wxString						m_Title;
	static std::string				m_colourKey;
};

//------------------------------------------------------------------------------
class PropertyObject : public PropData
//------------------------------------------------------------------------------
{
public:
	explicit						PropertyObject( mvIMPACT::acquire::HOBJ hObj, int index = 0 );
	void							UpdatePropData();
	void							EnsureValidGridItem( PropTree *pPropTree, wxPGId parentItem, bool* boModified = 0  );
	int								GetIndex( void ) const { return m_Index; }
	void							Update( PropTree *pPropTree, bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount );
private:
	void							UpdateLabel( bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount );
	void							WritePropVal( const std::string& value );
	int								m_Index;
	bool							m_boVectorAsList;
};

//------------------------------------------------------------------------------
class VectorPropertyObject : public PropData
//------------------------------------------------------------------------------
{
public:
	explicit						VectorPropertyObject( mvIMPACT::acquire::HOBJ hObj );
								   ~VectorPropertyObject();
	bool							IsExpanded( void ) const { return m_boExpanded; }
	void							OnExpand( void );
	PropData*						GetVectorItem( int index );
	void							EnsureValidGridItem( PropTree *pPropTree, wxPGId parentItem, bool* boModified = 0 );
	void							RemoveValue( unsigned int index );
	void							Resize( void );
	void							Update( PropTree *pPropTree, bool boDisplayDebugInfo, unsigned int actChangedCount, unsigned int actAttrChangedCount );
private:
	bool							m_boExpanded;
	std::vector<PropertyObject*>	m_VectorItems;
	mvIMPACT::acquire::Property		m_Property;
};

#endif // PropDataH
