//	Album List for Winamp
//	Copyright (C) 1999-2001 Safai Ma
//
//	This program is free software; you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation; either version 2 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program; if not, write to the Free Software
//	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef __PROPERTY_H__
#define __PROPERTY_H__

#include <commctrl.h>

#define MAX_PAGE_COUNT		16

/////////////////////////////////////////////////////////////////////////
// CTreePropertyPage
//

class CTreePropertyPage
{
public:
	CTreePropertyPage(UINT nIDTemplate, LPCTSTR szName = NULL, int nTree = 0);
	virtual ~CTreePropertyPage();

	void SetParams(LPCTSTR szName, int nTree = 0);
	BOOL Create(HWND hParent);
	BOOL SubclassDlgItem(UINT nID, WNDPROC wndProc, LPCTSTR str = NULL, DWORD dwData = 0);

	BOOL		IsTreeChild()				 { return m_nTree; }
	void		SetTreeItem(HTREEITEM hItem) { m_hTreeItem = hItem; }
	HTREEITEM	GetTreeItem()				 { return m_hTreeItem; }
	LPTSTR		GetName();

	HWND		m_hWnd;

private:
	int			m_nTree;	// 0 - root, 1 - child
	HTREEITEM	m_hTreeItem;
	char		m_szName[MAX_PATH];
	LPCTSTR		m_lpszTemplateName;

private:
	static CTreePropertyPage *m_pPage;

public:
	static BOOL CALLBACK TPPWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

	virtual BOOL CALLBACK DefWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	virtual BOOL OnInitDialog();
	virtual void OnDestroy();
	virtual void OnOK();
	virtual void OnCancel();
};

/////////////////////////////////////////////////////////////////////////
// CTreePropertySheet
//

class CTreePropertySheet
{
public:
	CTreePropertySheet();
	virtual ~CTreePropertySheet();

	BOOL	Create		(UINT nIDTemplate, HWND pParentWnd = NULL);
	void	AddPage		(CTreePropertyPage *pPage);
	void	AddPage		(CTreePropertyPage *pPage, LPCTSTR szName, int nTree);
	int		GetPageCount() { return m_nPageCount; }
	BOOL	IsWindow	() { return ::IsWindow(m_hWnd); }
	BOOL	SetForegroundWindow() { return ::SetForegroundWindow(m_hWnd); }

private:
	HWND				m_hWnd;
	int					m_nPageCount;
	CTreePropertyPage*	m_PageArray[MAX_PAGE_COUNT];

private:
	static	CTreePropertySheet *m_pSheet;

public:
	static BOOL CALLBACK TPSWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

	virtual BOOL CALLBACK DefWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	virtual BOOL OnInitDialog();
	virtual void OnDestroy();
	virtual void OnOK();
	virtual void OnCancel();
	virtual void OnNotifyTVNSelChanged(LPNMTREEVIEW pnmtv);

private:
	void SelectPage(int nPage);
};

#endif /* __PROPERTY_H__ */
