Ejemplo n.º 1
0
BOOL CQuoteColumnSetting::ChangeCurColGroup(CString strGroupName)
{
	int nCurSel = m_wndCurGroup.GetCurSel();
	if (nCurSel == m_nPreCurGroup)
	{
		return FALSE;
	}
	if (m_bCurChanged)
	{
		CString strGroup;
		m_wndCurGroup.GetLBText(m_nPreCurGroup,strGroup);
		SaveCurGroup(strGroup);
	}
	m_wndCurGroupCol.DeleteAllItems();
	if (strGroupName.IsEmpty())
	{
		m_wndCurGroup.GetWindowText(strGroupName);
	}

	CUIntArray* pAyDispCol = NULL;
	m_iCol->GetDispColGroup(strGroupName, pAyDispCol);
	if (pAyDispCol)
	{
		for (int i = 0; i < pAyDispCol->GetCount(); i++)
		{
			int nID = pAyDispCol->GetAt(i++);
			int nWidth = pAyDispCol->GetAt(i);
			CString strColName = m_iCol->GetColumnName(nID);
			int nIndex = m_wndCurGroupCol.InsertItem(m_wndCurGroupCol.GetItemCount(),strColName,nWidth);
			m_wndCurGroupCol.SetItemData(nIndex,nID);

		}
	}
// 	CArray<CStringArray*,CStringArray*>* payDispCol = m_iCol->GetColHeadTemplate(strGroupName);
// 	if (payDispCol)
// 	{
// 		for (int i=0; i<payDispCol->GetCount(); i++)
// 		{
// 			CStringArray* pDispCol = payDispCol->GetAt(i);
// 			if (pDispCol)
// 			{
// 				int nID = atoi(pDispCol->GetAt(0));
// 				int nWidth = atoi(pDispCol->GetAt(1));
// 				CString strColName = m_iCol->GetColumnName(nID);
// 				int nIndex = m_wndCurGroupCol.InsertItem(m_wndCurGroupCol.GetItemCount(),strColName,nWidth);
// 				m_wndCurGroupCol.SetItemData(nIndex,nID);
// 			}
// 		}
// 	}
	m_nPreCurGroup = nCurSel;
	return TRUE;
}
Ejemplo n.º 2
0
UINT GetFormatTypeIndex(UINT nFormat)
{
	int i; for (i=0;i<arFormatType.GetSize();i++) {
		if (arFormatType.GetAt(i) == nFormat) {
			return i;
		}
	}
	return -1;
}
Ejemplo n.º 3
0
BOOL COptionsDlg::OnSetActive() {
	CSnmp *pSnmp = &theApp.m_wnd.snmp;
	if (pSnmp != NULL) {
		CStringArray s;
		CUIntArray nAdapterArray;
		pSnmp->GetInterfaceDescriptions(&s, &nAdapterArray);
		m_Interfaces.ResetContent();
		
		int active = 0;
		for (int i = 0; i <= s.GetUpperBound(); i++) {
			int index = m_Interfaces.AddString(s.GetAt(i));
			if (index != CB_ERR) {
				m_Interfaces.SetItemData(index, nAdapterArray.GetAt(i));
				if (nAdapterArray.GetAt(i) == g_dwAdapter)
					active = i;
			}
		}
		m_Interfaces.SetCurSel(active);
	}
	return CPropertyPage::OnSetActive();
}
Ejemplo n.º 4
0
void EditSerializer::WriteSimpleArray(DataField field, const CUIntArray& a)
{
	CString result;
	char buf[16];

	for (int i=0; i<a.GetSize(); i++)
	{
		unsigned int val = a.GetAt(i);
		if (i > 0)
			result += ";";

		sprintf(buf, "%d", val);
		result += buf;
	}

	WriteString(field, (LPCTSTR)result);
}
Ejemplo n.º 5
0
BOOL CQuoteColumnSetting::SaveCurGroup(CString strGroupName /* = _T */)
{
	if (!m_bCurChanged)
	{
		return FALSE;
	}
	if (strGroupName.IsEmpty())
	{
		m_wndCurGroup.GetWindowText(strGroupName);
	}

	//CArray<CStringArray*,CStringArray*> ayNewColGroup;
	CUIntArray ayNewColGroup;
	CMapWordToPtr mapFixedCol;
	//CString strTemp;
	// 生成所有显示列项
	for (int i=0; i<m_wndCurGroupCol.GetItemCount(); i++)
	{
		//CStringArray* pCol = new CStringArray;
		CUIntArray* pAyCol = new CUIntArray;
		
		LVITEM item;
		ZeroMemory(&item,sizeof(LVITEM));
		item.mask = LVIF_PARAM | LVIF_IMAGE;
		item.iItem = i;

		m_wndCurGroupCol.GetItem(&item);
		int nID = (int)item.lParam;
		pAyCol->Add(nID);
		//strTemp.Format("%d",nID);
		//pCol->Add(strTemp);
		
		long nWidth = (long)item.iImage;
		nWidth = nWidth>0 ? nWidth : m_iCol->GetColumnWidth(nID);
		pAyCol->Add(nWidth);
		//strTemp.Format("%d",nWidth);
		//pCol->Add(strTemp);

		if (CQuoteReportTable::IsFixedColumn(nID))		// 判断是否固定列
		{
			mapFixedCol.SetAt(nID,(void*)pAyCol);		// 固定列暂时放入哈希表,后面处理
		} 
		else
		{
			ayNewColGroup.Add(nID);
			ayNewColGroup.Add(nWidth);
			//ayNewColGroup.Add(pCol);			// 正常列直接放入数组
		}
	}

	if (mapFixedCol.GetCount() > 0)		// 处理固定列
	{
		int nID = 0;
		//CStringArray* payTempCol = NULL;
		CUIntArray* pAyCol = NULL;
		if (mapFixedCol.Lookup(COLUMN_HQ_BASE_ARROW,(void*&)pAyCol) && pAyCol)
		{
			ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
			ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
			delete pAyCol;
			mapFixedCol.RemoveKey(COLUMN_HQ_BASE_ARROW);
			//ayNewColGroup.InsertAt(0,payTempCol);
		}
		if (mapFixedCol.Lookup(COLUMN_HQ_BASE_INFO_MARK,(void*&)pAyCol) && pAyCol)
		{
			ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
			ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
			delete pAyCol;
			mapFixedCol.RemoveKey(COLUMN_HQ_BASE_INFO_MARK);
		}
		if (mapFixedCol.Lookup(COLUMN_HQ_BASE_NAME,(void*&)pAyCol) && pAyCol)
		{
			ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
			ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
			delete pAyCol;
			mapFixedCol.RemoveKey(COLUMN_HQ_BASE_NAME);
		}
		if (mapFixedCol.Lookup(COLUMN_HQ_BASE_CODE,(void*&)pAyCol) && pAyCol)
		{
			ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
			ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
			delete pAyCol;
			mapFixedCol.RemoveKey(COLUMN_HQ_BASE_CODE);
		}
		if (mapFixedCol.Lookup(COLUMN_HQ_BASE_NUMBER,(void*&)pAyCol) && pAyCol)
		{
			ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
			ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
			delete pAyCol;
			mapFixedCol.RemoveKey(COLUMN_HQ_BASE_NUMBER);
		}
	}
	m_iCol->SetDispColGroup(strGroupName, &ayNewColGroup);

// 	for (int i=0; i<ayNewColGroup.GetCount(); i++)
// 	{
// 		CStringArray* pTemp = ayNewColGroup.GetAt(i);
// 		if (pTemp)
// 		{
// 			delete pTemp;
// 		}
// 	}
	ayNewColGroup.RemoveAll();

	m_bCurChanged = FALSE;
	return TRUE;
}
void CXTPReportSelectedRows::SelectBlock(int nBlockBegin, int nEnd, BOOL bControlKey)
{
	CXTPReportRows* pRows;
	switch(m_nRowType)
	{
		case xtpRowTypeHeader : pRows = m_pControl->GetHeaderRows(); break;
		case xtpRowTypeFooter : pRows = m_pControl->GetFooterRows(); break;
		default : pRows = m_pControl->GetRows(); break;
	}
	int nRowsCount(0);
	if (pRows)
		nRowsCount = pRows->GetCount();
	BOOL bGo = (nBlockBegin >= 0 && nBlockBegin < nRowsCount && nEnd < nRowsCount);
	if (!bGo)
	{
		Clear(GetNotifyOnSelectedRowsClear());
		return;
	}

	if (bControlKey == FALSE)
	{
		nBlockBegin = m_nRowBlockBegin != -1 ? m_nRowBlockBegin : nBlockBegin;

		int nBegin = nBlockBegin;

		if (nBegin == -1 || nEnd == -1)
			return;

		if (nBegin > nEnd)
		{
			nBegin = nEnd;
			nEnd = nBlockBegin;
		}

		if (m_arrSelectedBlocks.GetSize() == 1 && m_arrSelectedBlocks[0].nIndexBegin == nBegin &&
			m_arrSelectedBlocks[0].nIndexEnd == nEnd + 1)
		{
			return;
		}

		XTPReportRowType nRowType = m_nRowType;
		Clear(GetNotifyOnSelectedRowsClear());
		m_nRowType = nRowType;
		if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin;


		BOOL bSkipGroupFocus = m_pControl->IsSkipGroupsFocusEnabled();
		BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;

		if (!bHasGroups || !bSkipGroupFocus)
		{
			_InsertBlock(0, nBegin, nEnd + 1);
		}
		else
		{
			for (int i = nBegin; i <= nEnd; i++)
			{
				CXTPReportRow* pRow = pRows->GetAt(i);
				if (!pRow)
					continue;

				if (!bSkipGroupFocus || !pRow->IsGroupRow() || !pRow->IsExpanded() || (i == nBegin) || (i == nEnd))
				{
					Add(pRow);
				}
			}
		}

		// notify owner the selection state has changed.
		_NotifyStateChanged(nBegin, nEnd);
	}
	else
	{
		int kSB = (int) m_arrSelectedBlocks.GetSize();
		if (kSB > 0)
		{
			int iMin = m_arrSelectedBlocks[0].nIndexBegin;
			int iMax = m_arrSelectedBlocks[kSB - 1].nIndexEnd;
			if (nEnd >= iMin && nEnd < iMax)
			{
				return;
			}
		}
		BOOL bSkipGroupFocus = FALSE;//m_pControl->IsSkipGroupsFocusEnabled();
		BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
		BOOL bWasShiftKey = m_pControl->m_bWasShiftKey;

		if (m_nRowBlockBegin != -1)
			nBlockBegin = m_nRowBlockBegin;
		int nBegin(nBlockBegin), iB, iE;
		if (nBegin == -1 || nEnd == -1)
		{
			return;
		}
		BOOL bSwap = SwapIfNeed(nBegin, nEnd);
		int nArSz = (int) m_arrSelectedBlocks.GetSize();

		CUIntArray ar;
		if (nArSz > 0)
		{
			for (int k = 0; k < nArSz; k++)
			{
				int iB = m_arrSelectedBlocks[nArSz - 1 - k].nIndexBegin;
				int iE = m_arrSelectedBlocks[nArSz - 1 - k].nIndexEnd;
				if (iE == iB + 1 && iB == 0)
					k++; //this fix a case of initial selection from any row to any row with SHIFT+CONTROL pressed
				if (k < nArSz)
				{
					ar.Add(m_arrSelectedBlocks[k].nIndexBegin);
					ar.Add(m_arrSelectedBlocks[k].nIndexEnd);
				}
			}
		}

		XTPReportRowType nRowType = m_nRowType;
		Clear(GetNotifyOnSelectedRowsClear());
		m_nRowType = nRowType;

		if (m_nRowBlockBegin == -1)
			m_nRowBlockBegin = nBlockBegin;

		if (!bHasGroups || !bSkipGroupFocus) //<<>>
		{
			int k = 0;
			int N = (int) ar.GetSize();
			if (N > 0 && bControlKey && !bWasShiftKey)
			{
				for (k = 0; k < N / 2; k++)
				{
					iB = ar.GetAt(2 * k);
					iE = ar.GetAt(2 * k + 1);
					if (iE < nBegin || iB > nEnd)
					{
						_InsertBlock(k, iB, iE);
					}
					else if (iB >= nBegin && iE <= nEnd) //skip [iB:iE] segment - totally covered
					{
					}
					else if (iB <= nBegin && iE <= nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nBegin = iB;
					}
					else if (iB <= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nBegin = iB;
						nEnd = iE;
					}
					else if (iB >= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nEnd = iE;
					}
					else
					{
					}
				}

				if (bSwap)
				{
					_InsertBlock(0, nBegin, nEnd);
				}
				else
				{
					_InsertBlock(k, nEnd + 1, nBegin);
				}
			}
			else
			{
				_InsertBlock(0, nBegin, nEnd + 1);
			}

			CUIntArray aDel;
			for (int l = 0; l < m_arrSelectedBlocks.GetSize(); l++)
			{
				if (m_arrSelectedBlocks[l].nIndexBegin == m_arrSelectedBlocks[l].nIndexEnd)
					aDel.Add(l);

			}
			for (int ll = 0; ll < aDel.GetSize(); ll++)
				m_arrSelectedBlocks.RemoveAt(aDel.GetAt(ll));
		}
		else
		{
			for (int i = nBegin; i <= nEnd; i++)
			{
				CXTPReportRow* pRow = pRows->GetAt(i);
				if (!pRow)
					continue;

				if (!pRow->IsGroupRow()
					|| !bSkipGroupFocus
					|| !pRow->IsExpanded()
					|| i == nBegin
					|| i == nEnd)
					Add(pRow);
			}
		}

		// notify owner the selection state has changed.
		_NotifyStateChanged(nBegin, nEnd);
	}

	if (m_pControl->m_bSelectionExcludeGroupRows)
		m_pControl->UnselectGroupRows();

	//to show only selected childs under group rows
	//flag - m_bSelectionExcludeGroupRows default = TRUE - this is 12.1 way to show selection
TRACE(_T("return from SelectBlock with Count=%d\n"), GetCount());
}
Ejemplo n.º 7
0
UINT GetFormatType(UINT nIndex)
{
	return arFormatType.GetAt(nIndex);
}