Beispiel #1
0
void CNBTreeView::Visit(CDiskObjectPtr o)
{
	const CObjectUIHandler *pHandler = CObjectUIHandler::GetUIHandler(o);

	switch ( m_nAction )
	{
	case NDASBINDVIEW_INSERT_OBJECT:
		{
			m_htiLast = CTreeViewCtrlEx::InsertItem( 
				pHandler->GetTitle(o), 
				pHandler->GetIconIndex(o),
				pHandler->GetSelectedIconIndex(o),
				m_htiParent,
				TVI_LAST 
				);
			m_htiLast.SetData( o->GetUniqueID() );
			m_mapIDToTreeItem[o->GetUniqueID()] = m_htiLast;
			Expand(m_htiParent, TVE_EXPAND);
		}
		break;
	case NDASBINDVIEW_UPDATE_OBJECT:
		{
			CTreeItem htiUpdate = m_mapIDToTreeItem[o->GetUniqueID()];
			htiUpdate.SetText( pHandler->GetTitle(o) );
			htiUpdate.SetImage(
				pHandler->GetIconIndex(o),
				pHandler->GetSelectedIconIndex(o)
				);
		}
	}
};
Beispiel #2
0
void CMainFrame::InitViews()
{
	//
	{
		CTreeItem t;
		CTreeItem tail;
		//如何插入根节点
		{
			t = m_wndTreeView.InsertItem ( NULL, TVI_ROOT, TVI_LAST);
			t.SetText("root");

		}
		//如何插入子节点
		{
			tail = t.AddTail("child", 0);
		}
		//如同线性列表,head是头,tail是尾;如同std::list, push_front, push_back
		{
			tail.AddHead("head0", 0);
			tail.AddHead("head1", 0);
			tail.AddTail("tail0", 0);
			tail.AddTail("tail1", 0);
		}
	}
	
	// Create list view columns
	m_wndListView.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 200, 0);
	m_wndListView.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 100, 1);
	m_wndListView.InsertColumn(2, _T("Type"), LVCFMT_LEFT, 100, 2);
}
Beispiel #3
0
void CMainFrame::_createTreeView()
{
	//
	m_tvCtrl.Create(m_hSplit, rcDefault, NULL, 
		WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 
		TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, 
		WS_EX_CLIENTEDGE);
	m_hSplit.SetSplitterPane(SPLIT_PANE_TOP, m_tvCtrl);
	CTreeItem t;
	CTreeItem tail;
	//如何插入根节点
	{
		t = m_tvCtrl.InsertItem ( NULL, TVI_ROOT, TVI_LAST);
		t.SetText("data");
	}
	//如何插入子节点
	{
		HANDLE hFind = INVALID_HANDLE_VALUE;
		std::string dataPath = Buddha::FileSystem::getInstancePtr()->getDataDirectory();
		std::stack<std::string> pathes;
		std::stack<CTreeItem> items;
		pathes.push(dataPath);
		items.push(t);

		WIN32_FIND_DATA ffd;
		while(!pathes.empty())
		{
			t = items.top();
			items.pop();
			dataPath = pathes.top();
			pathes.pop();
			hFind = FindFirstFile((dataPath +  + "/*").c_str(), &ffd);
			do
			{
				std::string name = ffd.cFileName;
				if(name != "." && name != ".." )
				{
					if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					{
						pathes.push(dataPath + "/" + ffd.cFileName);
						tail = t.AddTail(ffd.cFileName, 0);
						items.push(tail);
					}
					else
					{
						std::string name = Buddha::FileSystem::getInstancePtr()->getFileExtension(ffd.cFileName);
							std::transform(name.begin(), name.end(), name.begin(), std::tolower);
						if (name == "mz" || name == "mesh" || name == "entity" || name == "group" || name == "subentity")
						{
							t.AddTail(ffd.cFileName, 0);
						}
					}
				}
			}while (FindNextFile(hFind, &ffd) != 0);
		}
		
	}
	m_uPane.SetClient(m_tvCtrl);
}