www.pudn.com > Property_List_src.zip > PropertyList.h


#if !defined(AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_) 
#define AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
// PropertyList.h : header file 
// 
 
////////////////////////////////////////////////// 
// CPropertyList - Property List 
// 
// Author: Runming yan 
// Email:  HankersYan@msn.com 
// Copyright 2005, Runming yan 
// 
// You may freely use or modify this code provided this 
// Copyright is included in all derived versions. 
// 
// History - 2005/7/3 
// 
// Remarks: 
// This class implements a properties List like vb 
// 
//	Attention, please!  
//	checkboxes.bmp is neccessary, then it must be added into resources 
//	and it's resourceID must be "IDB_CHECKBOX" 
//	                            .............. 
// 
// 
//	the five following files also are neccessary. 
//	ChkComboBox.cpp (Refered to "http://www.codeproject.com/combobox/checkcombo.asp") 
//	ChkComboBox.h	(CheckComboBox Control By Magnus Egelberg, Lundalogik) 
//	FoldersDialog.cpp  
//	FoldersDialog.h 
//	MemDC.h 
// 
// 
 
 
 
 
#pragma warning(disable:4786) 
 
#include  
#include  
#include  
 
 
#include "ChkComboBox.h" 
 
// 
//PIT = property item type 
#define PIT_EDIT		0	//Edit 
#define PIT_COMBO		1	//Dropdownlist 
#define PIT_COMBO2		2	//Dropdown(editable) 
#define PIT_COMBO3		3	//CheckComboBox (multiSel)	e.g. "option1|option2" 
#define PIT_COLOR		4	//Color						e.g. "128 128 128" 
#define PIT_FONT		5	//Font 
#define PIT_FILE		6	//File Select Dialog 
#define PIT_FOLDER		7	//Folder Select Dialog 
#define PIT_CHECK		8	//BOOL						e.g. "Y" 
#define PIT_IP			9	//IP Address 
#define PIT_DATE		10	//Date						e.g. "2005/7/3" 
#define PIT_TIME		11	//Time						e.g. "12:32:45" 
#define PIT_DATETIME	12	//Date & Time				e.g. "2005/7/3 12:32:45" 
#define PIT_HOTKEY		13	//Hot Key	Temporarily unavailable 
#define PIT_CATALOG		99	//Catalog 
 
inline int GetSafePITType(int iType) 
{ 
	switch(iType) 
	{ 
	case PIT_COMBO: 
	case PIT_COMBO2: 
	case PIT_COMBO3: 
	case PIT_COLOR: 
	case PIT_FONT: 
	case PIT_FILE: 
	case PIT_CHECK: 
	case PIT_FOLDER: 
	case PIT_IP: 
	case PIT_DATE: 
	case PIT_TIME: 
	case PIT_DATETIME: 
//	case PIT_HOTKEY: 
	case PIT_CATALOG: 
		return iType; 
	default: 
		return PIT_EDIT; 
	} 
 
	return PIT_EDIT; 
}; 
 
 
////////////////////////////////////////////////////////////////////////// 
// Class Name:	CPropertyItem 
// Abstract: 
// Exception: 
// Remarks:		CPropertyList Item data struct 
//				m_catalog + m_propName is the Keyword 
// 
// Author:		Runming yan 
// Date: 
////////////////////////////////////////////////////////////////////////// 
class CPropertyItem 
{ 
public: 
	CString m_catalog; 
	CString m_propName; 
	CString m_curValue; 
	CString m_cmbItems; 
	CString m_propDesc; 
	int m_nItemType; 
 
	CPropertyItem() : m_iData(0) 
	{ 
	}; 
	CPropertyItem(const CPropertyItem& item) 
	{ 
		m_catalog	= item.m_catalog; 
		m_propName  = item.m_propName; 
		m_curValue  = item.m_curValue; 
		m_nItemType = item.m_nItemType; 
		m_cmbItems  = item.m_cmbItems; 
		m_propDesc	= item.m_propDesc; 
		m_iData		= item.m_iData; 
	}; 
	CPropertyItem(CString catalog, CString propName, CString curValue, 
				  int nItemType, CString cmbItems, CString propDesc) 
	{ 
		m_catalog	= catalog; 
		m_propName  = propName; 
		m_curValue  = curValue; 
		m_nItemType = nItemType; 
		m_cmbItems  = cmbItems; 
		m_propDesc	= propDesc; 
		m_iData		= 0; 
	}; 
 
	BOOL IsCollapsed() 
	{ 
		return GetBit(0); 
	}; 
	void SetCollapsed(BOOL bCollapsed) 
	{ 
		SetBit(0, !bCollapsed); 
	}; 
 
	BOOL IsHidden() 
	{ 
		return GetBit(1); 
	}; 
	void SetHidden(BOOL bHidden) 
	{ 
		SetBit(1, !bHidden); 
	}; 
 
	BOOL operator==(const CPropertyItem& item) 
	{ 
		return m_catalog.CompareNoCase(item.m_catalog) == 0 && m_propName.CompareNoCase(item.m_propName) == 0; 
	}; 
 
private: 
	BOOL GetBit(int index) 
	{ 
		if(index < 0 && index >= sizeof(m_iData)) 
		{ 
			_ASSERTE(FALSE); 
			return FALSE; 
		} 
		 
		return (m_iData>>index)&0x1; 
	}; 
	void SetBit(int index, BOOL bZero) 
	{ 
		if(index < 0 && index >= sizeof(m_iData)) 
		{ 
			_ASSERTE(FALSE); 
			return; 
		} 
		 
		if(bZero) 
			m_iData &= ~(1< m_mapData; 
	std::map::iterator m_mit; 
	PFN_OnSelChanged m_pfnOnSelChanged; 
}; 
 
///////////////////////////////////////////////////////////////////////////// 
 
//{{AFX_INSERT_LOCATION}} 
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. 
 
#endif // !defined(AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_)