/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $Id: dmbrowser.h,v 1.5 2001/04/04 12:42:36 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __DMBROWSER_G__
#define __DMBROWSER_G__

#include "dmcmn.h"
#include "wx/dynarray.h"
#include "wx/grid.h"

#include "wx/wspp/pagectrl.h"

class Container;

class wxDMPropertySheet : public wxGrid
{
public:
	wxDMPropertySheet( wxWindow* parent );
	~wxDMPropertySheet();

	void ReloadPropeties( wxDMNode* pNode, wxDMAttrGroupInfo* pAttrGroup );

	bool NeedsReloading( wxDMAttrGroupInfo* pAttrGroup );
	void RefreshValueFields();

	bool ValidateAllFields();
	void ApplayValuesToFields();

	// event handlers

	void OnCellLeftClick( wxGridEvent& event );
	void OnCellRightClick( wxGridEvent& event );
	void OnColSize( wxGridEvent& event );
	void OnCellValueChanged( wxGridEvent& event );

	void OnIdle( wxIdleEvent& event );
	void OnSize( wxSizeEvent& event );

	void OnCheckBox( wxCommandEvent& event );
	void OnChoice( wxCommandEvent& event );

	void OnKeyDown( wxKeyEvent& event );

	DECLARE_EVENT_TABLE()
	DECLARE_CLASS( wxDMPropertySheet )

protected:
	void AdjustColumnSizes();

protected:

	wxDMAttrGroupInfo* mpAttrGroup;
	wxDMNode*		   mpNode;
	void*			   mpGroupData;
	bool			   mLeftClicked;
	bool			   mApplyPending;
	bool			   mDisablePending;
	bool			   mCreated;

	Container* mpContainer;
};

class wxTabbedWindow;

WX_DEFINE_ARRAY( wxDMPropertySheet*, DMPropertySheetListT );

class wxDMNodePropertyGroupEditor : public wxTabbedWindow, public wxDMListener
{
public:
	wxDMNodePropertyGroupEditor( wxWindow* parent );
	~wxDMNodePropertyGroupEditor();

	// overriden notifictaions of wxDMListener

	virtual void OnFocusChanged( wxDMNode& node );
	virtual void OnFocusRemoved( wxDMNode& node );
	virtual void OnNodeChanged( wxDMNode& node );

	void RemoveAll();
	void RecreateTabs();
	void RefreshProperties();

	void Update( wxDMNode* pRootNode );
	
protected:
	void ReloadProperties();

protected:
	DMPropertySheetListT mSheets;

	wxDMNode* mpFocusedNode; // currently edited node
};

class wxDMNodeCommandHandler : public wxEvtHandler
{
public:
	wxDMNodeCommandHandler( wxDMNode* pRoot );

	enum COMMAND_IDS
	{
		ID_MOVE_TOP = 500,
		ID_MOVE_BOTTOM,
		ID_MOVE_DOWN,
		ID_MOVE_UP,
		ID_COPY,
		ID_PASTE,
		ID_CUT,
		ID_DELETE,
		ID_DUPLICATE,
		ID_SELECT_ALL,
		ID_UNDO,
		ID_REDO
	};

	void OnMoveTop( wxCommandEvent& event );
	void OnMoveBottom( wxCommandEvent& event );
	void OnMoveUp( wxCommandEvent& event );
	void OnMoveDown( wxCommandEvent& event );
	void OnCopy( wxCommandEvent& event );
	void OnPaste( wxCommandEvent& event );
	void OnCut( wxCommandEvent& event );
	void OnDelete( wxCommandEvent& event );
	void OnDuplicate( wxCommandEvent& event );
	void OnSelectAll( wxCommandEvent& event );
	void OnUndo( wxCommandEvent& event );
	void OnRedo( wxCommandEvent& event );

	void OnCopyUI( wxUpdateUIEvent& event );
	void OnPasteUI( wxUpdateUIEvent& event );
	void OnCutUI( wxUpdateUIEvent& event );
	void OnDeleteUI( wxUpdateUIEvent& event );
	void OnDuplicateUI( wxUpdateUIEvent& event );
	void OnSelectAllUI( wxUpdateUIEvent& event );
	void OnUndoUI( wxUpdateUIEvent& event );
	void OnRedoUI( wxUpdateUIEvent& event );

	virtual void SetRoot( wxDMNode* pRoot );
	virtual void AddMenuCommands( wxMenu* pMenu );

//glt	DECLARE_EVENT_TABLE( wxDMNodeCommandHandler )
    	DECLARE_EVENT_TABLE()  //glt

protected:

protected:
	wxDMNode* mpRoot;
};

#endif // __DMBROWSER_G__