
//ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
//	FILE	: Tree.h
//	AUTHOR	: Catalin Cocos
//__________________________________________________________________________________________________

#ifndef __TREEH__
#define __TREEH__

#include "Scr2Bin.h"



#define TI_STATE_NONE		INDEXTOSTATEIMAGEMASK(0x1)
#define TI_STATE_FILES		INDEXTOSTATEIMAGEMASK(0x2)
#define TI_STATE_RECURSE	INDEXTOSTATEIMAGEMASK(0x3)
#define TI_STATE_LOCKED		INDEXTOSTATEIMAGEMASK(0x4)

#define CDIR_ALL 0x01
#define CDIR_RECURSE 0x02
//__________________________________________________________________________________________________
//	Name
//ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
class CFileName
{
	void Set( char* szName ) { m_szName = strcpy (new char[lstrlen(szName)+1], szName); }
	void Del() {  if(m_szName) delete[] m_szName; }
protected:
	char* m_szName;
public:
	CFileName() { m_szName  = 0; }
	CFileName( char* szName ) { Set(szName); }
	void SetFileName( char* szName ) { Del(); Set(szName); }
	const char * FileName() { return m_szName; }
	~CFileName(){ Del(); }
	static int Compare( CFileName* a, CFileName* b, int key = 0 ) { return stricmp(a->m_szName,b->m_szName); }
};


class CDirInfo: public CFileName, public CSTPArray<CFileName>
{
public:
	WORD m_Flags;
	CDirInfo() { SetGranularity(20); m_szName  = 0; m_Flags = 0; }
	CDirInfo( char* szName ) {  SetGranularity(20); SetFileName(szName); m_Flags = 0; }
	~CDirInfo() { DeleteAll(); }
};

extern WNDPROC TreeIWP;
extern WNDPROC ViewIWP;
LRESULT CALLBACK TreeWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
LRESULT CALLBACK ViewWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
void ClearTree();
void InitTree();
void ToggleTreeItemState(HTREEITEM hItem, BOOL RecurseState );
void DisplayView( HTREEITEM hItem, CDirInfo* dirInfo );
void SetTreeItemChildren(TV_ITEM* pItem);
void NotifyParents( HTREEITEM hiItem);
void NotifyChildren( HTREEITEM hiItem, HTREEITEM hParent = NULL);




#endif