//------------------------------------------------------------------------ //! 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; }
void SetEncConverter(const CStringW& strConverterName, CSilEncConverter* pEC) { int nIndex; if ((nIndex = m_mapECs.FindKey(strConverterName)) != -1) { CSilEncConverter* p = m_mapECs.GetValueAt(nIndex); m_mapECs.RemoveAt(nIndex); delete p; } m_mapECs.Add(strConverterName, pEC); }
CSilEncConverter* GetEncConverter(const CStringW& strConverterName) { CSilEncConverter* pEC = 0; int nIndex; if ((nIndex = m_mapECs.FindKey(strConverterName)) != -1) { pEC = m_mapECs.GetValueAt(nIndex); } else { pEC = new CSilEncConverter(); SetEncConverter(strConverterName, pEC); } ATLASSERT(pEC != 0); return pEC; }