/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      
// Copyright:   (c) Aleksandras Gluchovas
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __RESBROWSER_G__
#define __RESBROWSER_G__

#include "wx/pmf/pm.h"
#include "wx/pmf/treesplit.h"
#include "dmcmn.h"

class ResSectionInfo : public wxObject
{
public:
	ResSectionInfo();
	ResSectionInfo( const wxString& resClass, const wxString& displayName );

public:
	wxString			mResClassName;
	wxString			mDisplayName;
	wxTSItemData*		mpItem;
	wxTSBranchHandler*	mpHandler;
};

class ResourceBrowser : public wxPMPane, public wxTSBranchHandler
{
public:
	ResourceBrowser();
	~ResourceBrowser();

	// overriden methods of wxPMService
	virtual bool Start();
	virtual bool Stop();

	// overriden method of wxPMPane
	virtual wxWindow* GetPaneWindow();
	virtual void CreatePaneWindow( wxWindow* pParent );
	virtual wxStringList* GetDocumentTypes(); 

	// overriden methods of wxTSBranchHandler 

	virtual wxEvtHandler* GetEvtHandler();
	virtual void OnBranchItemExpanding( wxTreeItemId id, wxTSItemData* pData );

	// other methods

	virtual void AddDocumentType( const wxString& type );
	virtual void RemoveDocumentType( const wxString& type );

	enum BITMAP_IDS
	{
		ID_BMP_WKP = 100,
		ID_BMP_FOLDER
	};

	enum ITEM_TYPES
	{
		ID_RESOURCE_ROOT  = 0,
		ID_SECTION_FOLDER = 1,
		ID_RESOURCE_ITEM  = 2
	};

	DECLARE_DYNAMIC_CLASS( ResourceBrowser )
	DECLARE_EVENT_TABLE()

protected:
	virtual void CreateImageList( bool withResourceIcons );

protected:
	wxStringList mDocTypes;
	wxPMProject* mpPrj;

	ResSectionInfo* mpSections;
	int mSectionCount;
};

class ResItemDocumentBase;
class wxDMNodeCommandHandler;

class DMNodeTreeHandler : public wxEvtHandler, public wxTSBranchHandler, public wxDMListener
{
public:
	DMNodeTreeHandler();
	DMNodeTreeHandler( ResItemDocumentBase* pDoc );
	~DMNodeTreeHandler();

	// overriden methods of wxTSBranchHandler 

	virtual wxEvtHandler* GetEvtHandler();
	virtual void OnBranchItemExpanding( wxTreeItemId id, wxTSItemData* pData );

	virtual void OnAddItemsToPopup( wxMenu* pMenu );
	virtual void OnSelectionChanged( wxTreeItemId id, wxTSItemData* pData );

	enum COMMAND_IDS
	{
		ID_NEW = 200
	};

	// command-event handlers

	void OnNew( wxCommandEvent& event );

	// overriden methods of wxDMListener

	virtual void OnNodeRemoved( wxDMNode& node );
	virtual void OnNodeAdded( wxDMNode& node );
	virtual void OnNodeChanged( wxDMNode& node );
	virtual void OnNodeOrderChanged( wxDMNode& node );
	virtual void OnNodeReplaced( wxDMNode& node, wxDMNode& withNode );
	
	virtual void OnFocusChanged( wxDMNode& node );
	virtual void OnFocusRemoved();

	DECLARE_DYNAMIC_CLASS( DMNodeTreeHandler )
	DECLARE_EVENT_TABLE()

protected:
	virtual void CreateBranchForNode( wxDMNode* pNode );


protected:
	ResItemDocumentBase*	mpDoc;
	wxDMNodeCommandHandler* mpDMHandler;
};

#endif // __RESBROWSER_G__