/*****************************************************************************
* Copyright (c) 1990-99 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/


#if !defined(AFX_TREEDIALOG_H__FF27FDE3_07B3_11D2_BB01_00805F9E3135__INCLUDED_)
#define AFX_TREEDIALOG_H__FF27FDE3_07B3_11D2_BB01_00805F9E3135__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000


// TreeDialog.h : header file
//

#ifdef NT5
#include <BaseTsd.h>
#include <setupapi.h>
#endif

#if !NT5_BUILD && !_M_IA64
// NT5 and newer DDKs define these types.  They float (at compile time) from 32 to 64
// bit width depending on the size of pointers in the system being compiled for.
// Define it for NT4.
typedef DWORD        DWORD_PTR, *PDWORD_PTR;
#endif


class CINFEntryApp;

/////////////////////////////////////////////////////////////////////////////
// CTreeDialog dialog
#ifdef NT5
class CTreeDialog : public CPropertyPage
{
	DECLARE_DYNCREATE(CTreeDialog)
#else
class CTreeDialog : public CDialog
{
#endif

// Construction / Destruction
public:
#ifdef NT5
	CTreeDialog();
#else
	CTreeDialog(CWnd* pParent = NULL);   // standard constructor
#endif

	~CTreeDialog();

// Properties
#ifdef NT5
	void SetDevInfo(const HDEVINFO hDevInfoSet, const PSP_DEVINFO_DATA pDevInfoData);
#endif

	void SetAppObject(CINFEntryApp const * const pApp) { ASSERT(pApp != NULL); m_pApp = (CINFEntryApp *)pApp; }

// Dialog Data
	//{{AFX_DATA(CTreeDialog)
#ifndef NT5
	enum { IDD = IDD_TreeDialog };
	CButton	m_btnApplyNow;
#else
	enum { IDD = IDD_TreeDialog_Proppage };
#endif
	CButton	m_btnWizard;
	CButton	m_btnRemove;
	CButton	m_btnProperties;
	CButton	m_btnAdd;
	CTreeCtrl	m_ctrlTree;
	CString	m_strInformation;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTreeDialog)
	public:
	virtual INT_PTR DoModal();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CTreeDialog)
	virtual BOOL OnInitDialog();
	afx_msg void OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnRclickTree(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnDoubleClickTree(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnPopupAdd();
	afx_msg void OnPopupRemove();
	afx_msg void OnPopupProperties();
	afx_msg void OnAddButton();
	afx_msg void OnRemoveButton();
	afx_msg void OnPropertiesButton();
	afx_msg void OnWizardButton();
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
	afx_msg void OnApplyNow();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnDestroy();
	//}}AFX_MSG
#if defined NT5
  	afx_msg void OnNotifyHelp(NMHDR* pNMHDR, LRESULT* pResult);
#endif // #if defined NT5
DECLARE_MESSAGE_MAP()

private:
   CINFEntryApp * m_pApp;
   CImageList m_ilTreeIcons;

#if defined NT5
   CAdapter * m_pAdapter;
   CString m_strAdapterType;
   CString m_strAdapterRegPath;
   HDEVINFO m_hDevInfoSet;
   PSP_DEVINFO_DATA m_pDevInfoData;
#endif

   BOOL m_fConfigIsDirty;        // current config in memory has been modified buy not yet saved
   BOOL m_fConfigHasChanged;     // config has been saved to registry at least once

   BOOL m_fDeletingTree;
   CPtrArray m_aVisibleItems;
   CConfigObject * m_pSelectedObject;
   HTREEITEM m_hSelectedItem;

   int GetItemLevel(HTREEITEM const hTreeItem);
   void PopulateTree(HTREEITEM const hParent, CTreeNode const & Node);
   void RefreshTree(void);

   CConfigObject * GetConfigObject(HTREEITEM const hTreeItem);
   HTREEITEM RecursivelyFindHTreeItem(HTREEITEM const hStartHere, CConfigObject const * const pObjToFind);
   HTREEITEM GetHTreeItem(CConfigObject const * const pObjToFind);

   BOOL CanDoAdd(HTREEITEM const hSelected, CConfigObject const * const pSelectedObj);
   BOOL CanDoRemove(HTREEITEM const hSelected, CConfigObject const * const pSelectedObj);
   BOOL CanDoProperties(HTREEITEM const hSelected, CConfigObject const * const pSelectedObj);

   void UpdateButtonStates(HTREEITEM const hSelected, CConfigObject const * const pSelectedObj);
   void BuildVisibleItemArray(HTREEITEM hItem);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TREEDIALOG_H__FF27FDE3_07B3_11D2_BB01_00805F9E3135__INCLUDED_)
