BOOL CTDLFindResultsListCtrl::AddHeaderRow(LPCTSTR szText)
{
	if (m_nCurGroupID == -1)
		EnableGroupView();

	return InsertGroupHeader(-1, ++m_nCurGroupID, szText);
}
Пример #2
0
//------------------------------------------------------------------------
//! Create a group for each unique values within a column
//!
//! @param nCol The index of the column
//! @return Succeeded in creating the group
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::GroupByColumn(int nCol)
{
	CWaitCursor waitCursor;

	SetSortArrow(-1, false);

	SetRedraw(FALSE);

	RemoveAllGroups();

	EnableGroupView( GetItemCount() > 0 );

	if (IsGroupViewEnabled())
	{
		CSimpleMap<CString,CSimpleArray<int> > groups;

		// Loop through all rows and find possible groups
		for(int nRow=0; nRow<GetItemCount(); ++nRow)
		{
			CString cellText = GetItemText(nRow, nCol);

			int nGroupId = groups.FindKey(cellText);
			if (nGroupId==-1)
			{
				CSimpleArray<int> rows;
				groups.Add(cellText, rows);
				nGroupId = groups.FindKey(cellText);
			}
			groups.GetValueAt(nGroupId).Add(nRow);
		}

		// Look through all groups and assign rows to group
		for(int nGroupId = 0; nGroupId < groups.GetSize(); ++nGroupId)
		{
			const CSimpleArray<int>& groupRows = groups.GetValueAt(nGroupId);
			DWORD dwState = LVGS_NORMAL;
#ifdef LVGS_COLLAPSIBLE
			if (IsGroupStateEnabled())
				dwState = LVGS_COLLAPSIBLE;
#endif
			VERIFY( InsertGroupHeader(nGroupId, nGroupId, groups.GetKeyAt(nGroupId), dwState) != -1);

			for(int groupRow = 0; groupRow < groupRows.GetSize(); ++groupRow)
			{
				VERIFY( SetRowGroupId(groupRows[groupRow], nGroupId) );
			}
		}

		SetRedraw(TRUE);
		Invalidate(FALSE);
		return TRUE;
	}

	SetRedraw(TRUE);
	Invalidate(FALSE);
	return FALSE;
}
Пример #3
0
//------------------------------------------------------------------------
//! Override this method to change the context menu when activating context
//! menu in client area with no rows
//!
//! @param pWnd Handle to the window in which the user right clicked the mouse
//! @param point Position of the cursor, in screen coordinates, at the time of the mouse click.
//------------------------------------------------------------------------
void CGridListCtrlGroups::OnContextMenuGrid(CWnd* pWnd, CPoint point)
{
	if (IsGroupStateEnabled())
	{
		CMenu menu;
		UINT uFlags = MF_BYPOSITION | MF_STRING;
		VERIFY( menu.CreatePopupMenu() );

		menu.InsertMenu(0, uFlags, 1, _T("Expand all groups"));
		menu.InsertMenu(1, uFlags, 2, _T("Collapse all groups"));
		menu.InsertMenu(2, uFlags, 3, _T("Disable grouping"));

		int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0);
		switch(nResult)
		{
			case 1: ExpandAllGroups(); break;
			case 2: CollapseAllGroups(); break;
			case 3: RemoveAllGroups(); EnableGroupView(FALSE); break;
		}
	}
}
Пример #4
0
void CFeedIcoItemListCtrl::Init()
{
	//SetName(_T("RSSIcoListCtrl"));

	ModifyStyle(0, WS_CLIPCHILDREN);

	m_PosterImageList.Create(100,100,ILC_COLORDDB,1,1);

	m_imageRss_PosterBg = GetPng(_T("PNG_RSS_POSTER_BG"));
	m_imageRss_PosterDefault = GetPng(_T("PNG_RSS_POSTER_DEFAULT"));
	m_imageRss_PosterSelBg = GetPng(_T("PNG_RSS_POSTER_SELECTED_BG"));
	m_imageRss_GroupBg = GetPng(_T("PNG_RSS_GROUP_BG"));

	m_imageRss_Group_Drop_Up_Nor = GetPng(_T("RSS_GROUP_DROP_UP_NORMAL"));
	m_imageRss_Group_Drop_Up_Hov = GetPng(_T("RSS_GROUP_DROP_UP_HOVER"));
	m_imageRss_Group_Drop_Down_Nor = GetPng(_T("RSS_GROUP_DROP_DOWN_NORMAL"));
	m_imageRss_Group_Drop_Down_Hov = GetPng(_T("RSS_GROUP_DROP_DOWN_HOVER"));

	this->SetImageList(&m_PosterImageList,LVSIL_NORMAL);

	//AddImg2List(m_imageRss_PosterDefault);

	SetIconSpacing(150,150);

	m_FontBold.CreateFont(16,0,0,0,FW_BOLD,FALSE,FALSE,0,0,0,0,0,0,_TEXT("tahoma"));//标题 

	m_pMenuXP = NULL;

	EnableGroupView(TRUE);

	if ( thePrefs.GetWindowsVersion() >= _WINVER_VISTA_ )
	{
		SetGroupHeight(38);
	}
	else
	{
		SetGroupHeight(28);
	}
}
Пример #5
0
//------------------------------------------------------------------------
//! Override this method to change the context menu when activating context
//! menu for the column headers
//!
//! @param pWnd Handle to the window in which the user right clicked the mouse
//! @param point Position of the cursor, in screen coordinates, at the time of the mouse click.
//! @param nCol The index of the column
//------------------------------------------------------------------------
void CGridListCtrlGroups::OnContextMenuHeader(CWnd* pWnd, CPoint point, int nCol)
{
	// Only Windows XP and above supports groups
	if (!IsCommonControlsEnabled())
	{
		CGridListCtrlEx::OnContextMenuHeader(pWnd, point, nCol);
		return;
	}

	// Show context-menu with the option to show hide columns
	CMenu menu;
	VERIFY( menu.CreatePopupMenu() );

	if (nCol!=-1)
	{
		// Retrieve column-title
		const CString& columnTitle = GetColumnHeading(nCol);
		menu.AppendMenu(MF_STRING, 3, CString(_T("Group by: ")) + columnTitle);
	}

	if (IsGroupViewEnabled())
	{
		menu.AppendMenu(MF_STRING, 4, _T("Disable grouping"));
	}

	CString title_editor;
	if (HasColumnEditor(nCol, title_editor))
	{
		menu.AppendMenu(MF_STRING, 1, static_cast<LPCTSTR>(title_editor));
	}

	CString title_picker;
	if (HasColumnPicker(title_picker))
	{
		menu.AppendMenu(MF_STRING, 2, static_cast<LPCTSTR>(title_picker));		
	}
	else
	{
		if (menu.GetMenuItemCount()>0)
			menu.AppendMenu(MF_SEPARATOR, 0, _T(""));

		InternalColumnPicker(menu, 6);
	}

	CSimpleArray<CString> profiles;
	InternalColumnProfileSwitcher(menu, GetColumnCount() + 7, profiles);

	CString title_resetdefault;
	if (HasColumnDefaultState(title_resetdefault))
	{
		if (profiles.GetSize()==0)
			menu.AppendMenu(MF_SEPARATOR, 0, _T(""));
		menu.AppendMenu(MF_STRING, 5, title_resetdefault);
	}

	// Will return zero if no selection was made (TPM_RETURNCMD)
	int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0);
	switch(nResult)
	{
		case 0: break;
		case 1:	OpenColumnEditor(nCol); break;
		case 2: OpenColumnPicker(); break;
		case 3: GroupByColumn(nCol); break;
		case 4:
		{
			// Very strange problem when disabling group mode, then scrollbars are not updated
			// If placed in the bottom and disables group mode, then suddenly there is a strange offset
			//	- Quick fix scroll to top, and then fix scroll bars afterwards
			int pos = GetScrollPos(SB_VERT);
			EnsureVisible(0,FALSE);
			RemoveAllGroups();
			EnableGroupView(FALSE);
			Scroll(CSize(0,pos));
		} break;
		case 5: ResetColumnDefaultState(); break;
		default:
		{
			int nCol = nResult-6;
			if (nCol < GetColumnCount())
			{
				ShowColumn(nCol, !IsColumnVisible(nCol));
			}
			else
			{
				int nProfile = nResult-GetColumnCount()-7;
				SwichColumnProfile(profiles[nProfile]);
			}
		} break;
	}
}
Пример #6
0
BOOL CFeedIcoItemListCtrl::GroupAllFeedsByType(int nType)
{
	if (!IsCommonControlsEnabled())
		return FALSE;

	SetRedraw(FALSE);

	RemoveAllGroups();
	RemoveAllGroupData();
	EnableGroupView( GetItemCount() > 0 );

	if (IsGroupViewEnabled())
	{
		// Loop through all rows and find possible groups
		for(int nItem = 0; nItem < GetItemCount(); nItem++ )
		{
			CString strCatalogName = GetResString( IDS_UNKNOWN );

			CRssFeed* pFeed = (CRssFeed*)GetItemData(nItem);

			if (pFeed == NULL)
				continue;

			if ( pFeed->m_uCatalogId != FeedCatalog::INVALID_CATALOG_ID )
			{
				FeedCatalog & catalog = CFeedCatalogs::GetInstance()[pFeed->m_uCatalogId];
				ASSERT(catalog.m_uId == pFeed->m_uCatalogId);
				ASSERT(catalog.IsLeaf());

				FeedCatalog * catalogParent;
				if (catalog.m_pParent != NULL)
				{
					catalogParent = catalog.m_pParent;
					strCatalogName = catalogParent->m_strName;
				}
			}

			int nGroupId = m_mapGroups.FindKey(strCatalogName);
			if (nGroupId == -1)
			{
				CSimpleArray<int> nItems;
				m_mapGroups.Add(strCatalogName, nItems);
				nGroupId = m_mapGroups.FindKey(strCatalogName);
			}

			//必须添加不重复数据
			if (m_mapGroups.GetValueAt(nGroupId).Find(nItem) == -1)
			{
				m_mapGroups.GetValueAt(nGroupId).Add(nItem);
			}
			
		}

		// Look through all groups and assign rows to group
		for(int nGroupId = 0; nGroupId < m_mapGroups.GetSize(); nGroupId++)
		{
			const CSimpleArray<int>& groupRows = m_mapGroups.GetValueAt(nGroupId);
			DWORD dwState = LVGS_NORMAL;

#ifdef LVGS_COLLAPSIBLE
			if (IsGroupStateEnabled())
				dwState = LVGS_COLLAPSIBLE;
#endif

			VERIFY( InsertTypeGroup(nGroupId, nGroupId, m_mapGroups.GetKeyAt(nGroupId), dwState) != -1);

			for(int groupRow = 0; groupRow < groupRows.GetSize(); ++groupRow)
			{
				VERIFY( SetItemGroupId(groupRows[groupRow], nGroupId) );
			}
		}

	}

	SetRedraw(TRUE);

	Invalidate(TRUE);
	return FALSE;
}
Пример #7
0
BOOL CFeedIcoItemListCtrl::GroupFeedByType(int nIndex, int nType)
{
	if (!IsCommonControlsEnabled())
		return FALSE;

	SetRedraw(FALSE);

	EnableGroupView(TRUE);
	if (IsGroupViewEnabled())
	{
		CString cellText = GetResString( IDS_UNKNOWN );
		bool	bNew = false;//Is new Group?

		CRssFeed* pFeed = (CRssFeed*)GetItemData(nIndex);
		
		if (pFeed == NULL)
			return FALSE;

		if ( pFeed->m_uCatalogId != FeedCatalog::INVALID_CATALOG_ID )
		{
			FeedCatalog & catalog = CFeedCatalogs::GetInstance()[pFeed->m_uCatalogId];
			ASSERT(catalog.m_uId == pFeed->m_uCatalogId);
			ASSERT(catalog.IsLeaf());

			FeedCatalog * catalogParent;
			if (catalog.m_pParent != NULL)
			{
				catalogParent = catalog.m_pParent;
				cellText = catalogParent->m_strName;
			}
		}

		int nGroupId = m_mapGroups.FindKey(cellText);
		if (nGroupId == -1)
		{
			CSimpleArray<int> nItems;
			m_mapGroups.Add(cellText, nItems);
			nGroupId = m_mapGroups.FindKey(cellText);

			bNew = true;
		}

		//必须添加不重复数据
		if (m_mapGroups.GetValueAt(nGroupId).Find(nIndex) == -1)
		{
			m_mapGroups.GetValueAt(nGroupId).Add(nIndex);
		}

		if (bNew)//new Group
		{
			DWORD dwState = LVGS_NORMAL;

			#ifdef LVGS_COLLAPSIBLE
					if (IsGroupStateEnabled())
						dwState = LVGS_COLLAPSIBLE;
			#endif

			//InsertTypeGroup(nGroupId, nGroupId, cellText, dwState);
			VERIFY(InsertTypeGroup(nGroupId, nGroupId, cellText, dwState) != -1);
		}

		VERIFY( SetItemGroupId(nIndex, nGroupId) );
	}

	SetRedraw(TRUE);
	Invalidate(TRUE);
	

	return FALSE;
}