Ejemplo n.º 1
0
void CXTPReportGroupRow::UpdateSelectedChilds()
{
	for (int II = 0; II < m_pControl->m_pPlainTree->GetCount(); II++)
	{
		CXTPReportRow* pTRow = m_pControl->m_pPlainTree->GetAt(II);
		if (pTRow)
		{
			if (pTRow->IsGroupRow())
			{
				CXTPReportGroupRow* pTgRow = (CXTPReportGroupRow*) pTRow;
				if (pTgRow->GetChilds(FALSE) && pTgRow->IsExpanded())
				{
					for (int J = 0; J < pTgRow->GetChilds()->GetCount(); J++)
					{
						CXTPReportRow* pChRow = pTgRow->GetChilds(FALSE)->GetAt(J);
						if (pChRow)
						{
							CXTPReportRecord* pChRec = pChRow->GetRecord();
							if (pChRec)
							{
								CXTPReportRow* ptRow = m_pControl->m_pPlainTree->FindInTree(pChRec);
								if (ptRow && !ptRow->IsGroupRow())
									ptRow->SetSelected(pChRec->m_bSelectedAsChildFlag);
							}
						}
					}
				}
			}
		}
	}
}
void CXTPReportGroupRow::SetSelectedChilds()
{
	for (int I = 0; I < m_pSection->m_pTree->GetCount(); I++)
	{
		CXTPReportRow* pTRow = m_pSection->m_pTree->GetAt(I);
		if (pTRow)
		{
			if (pTRow->IsGroupRow())
			{
				CXTPReportGroupRow* pTgRow = (CXTPReportGroupRow*) pTRow;
				if (pTgRow->GetChilds(FALSE) && pTgRow->IsExpanded())
				{
					for (int J = 0; J < pTgRow->GetChilds()->GetCount(); J++)
					{
						CXTPReportRow* pChRow = pTgRow->GetChilds(FALSE)->GetAt(J);
						if (pChRow)
						{
							CXTPReportRecord* pChRec = pChRow->GetRecord();
							if (pChRec)
								pChRec->SetSelected(pChRow->IsSelected());
						}
					}
				}
			}
		}
	}
}
Ejemplo n.º 3
0
void CSimpleReport::RowSetFocused(CXTPReportRecord* pRec)
{
	CXTPReportRows* pRows = GetRows();
	for (int i = 0; i < pRows->GetCount(); i++) {
		CXTPReportRow* pRow = pRows->GetAt(i);
		if (pRow->GetRecord() == pRec) {
			SetFocusedRow(pRow);
			return;
		}
	}
}
Ejemplo n.º 4
0
void CXTPReportGroupRow::SetSelectedMostDeepChilds()
{
	for (int II = 0; II < m_pControl->GetRows()->GetCount(); II++)
	{
		CXTPReportRow* pRow = m_pControl->GetRows()->GetAt(II);
		if (pRow->GetChilds(FALSE)) continue;
		CXTPReportRecord* pChRec = pRow->GetRecord();
		if (pChRec)
			pChRec->m_bSelectedAsChildFlag = pRow->IsSelected();
	}
}
Ejemplo n.º 5
0
void CXTPReportGroupRow::UpdateSelectedMostDeepChilds()
{
	for (int II = 0; II < m_pControl->GetRows()->GetCount(); II++)
	{
		CXTPReportRow* pRow = m_pControl->GetRows()->GetAt(II);
		if (pRow->GetChilds(FALSE)) continue;
		CXTPReportRecord* pChRec = pRow->GetRecord();
		if (pChRec)
			pRow->SetSelected(pChRec->m_bSelectedAsChildFlag);
		//if (pChRec && !pRow->IsGroupRow())
		//  pRow->SetSelected(pChRec->m_bSelectedAsChildFlag);
		//else if (pRow->IsGroupRow())
		//  pRow->SetSelected(FALSE);
	}
}
void CXTPReportGroupRow::UpdateSelectedMostDeepChilds()
{
	for (int nRow=0; nRow<m_pSection->GetRows()->GetCount(); nRow++)
	{
		CXTPReportRow *pRow = m_pSection->GetRows()->GetAt(nRow);

		if (pRow->GetChilds(FALSE))
			continue;

		CXTPReportRecord *pRecord = pRow->GetRecord();
		if (pRecord)
		{
			pRow->SetSelected(pRecord->IsSelected());
		}
	}
}
void CXTPReportIconNavigator::BeginEdit()
{
	if (!m_pReportControl)
		return;

	CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow();
	if (!pFocusedRow)
		return;

	CXTPReportColumn* pIconColumn = m_pReportControl->GetColumns()->Find(m_pReportControl->m_iIconViewColumn);

	if (pIconColumn &&
		pFocusedRow && pFocusedRow->GetRecord())
	{
		XTP_REPORTRECORDITEM_ARGS itemArgs(m_pReportControl, pFocusedRow, pIconColumn);

		if (itemArgs.pItem && itemArgs.pItem->IsAllowEdit(&itemArgs))
			m_pReportControl->EditItem(&itemArgs);
	}
}
Ejemplo n.º 8
0
void CSimpleReport::RowInsert(CXTPReportRecord* pRec, bool bAdd)
{
	if (!pRec)
		return;

	CXTPReportRow* pRow = GetFocusedRow();
	if (bAdd) {
		pRec = GetRecords()->Add(pRec);	// 맨 뒤에 추가
	}
	else {
		if (pRow != NULL) {		
			int n = pRow->GetRecord()->GetIndex();
			GetRecords()->InsertAt(n, pRec);
		}
		else { // 데이터 처음으로 넣음
			pRec = GetRecords()->Add(pRec);
		}
	}
	Populate();
	RowSetFocused(pRec);
}
BOOL CXTPReportGroupRow::CalculateByChilds(CXTPReportRow* pPassedRow, int col_start, int col_end, double& dPassedValue)
{
	BOOL bRet = FALSE;

	CXTPReportRow* pRow = NULL;
	CXTPReportRecord* pRec = NULL;
	CXTPReportRecordItem* pItem = NULL;

	for (int row = 0; row < pPassedRow->GetChilds(FALSE)->GetCount(); row++)
	{
		pRow = pPassedRow->GetChilds(FALSE)->GetAt(row);
		if (pRow && !pRow->IsGroupRow())
		{
			pRec = pRow->GetRecord();
			if (pRec)
			{
				bRet = TRUE;
				for (int col = col_start; col < col_end; col++)
				{
					if (col < pRec->GetItemCount())
					{
						pItem = pRec->GetItem(col);
						if (pItem)
						{
							CString s = pItem->GetCaption(NULL);
							dPassedValue += pItem->StringToDouble(s);
						}
					}
				}
			}
		}
		else if (pRow && pRow->IsGroupRow())
		{
			bRet = CalculateByChilds(pRow, col_start, col_end, dPassedValue);
		}
	}
	return bRet;
}
Ejemplo n.º 10
0
bool CSimpleReport::doCutPaste(CPoint pt, int op)
{
	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (pRows == NULL)
		return false;

	CXTPReportRow* pRow = pRows->GetAt(0);
	int nRow = 0;
	if (pRow)
		nRow = pRows->GetAt(0)->GetIndex();

	int n;
	CMenu menu;
	if (!menu.CreatePopupMenu())
		return false;

	if ((op & DO_ADD) != 0)	{
		menu.AppendMenu(MF_STRING, 10, "Add New");
		menu.AppendMenu(MF_STRING, 13, "Insert");
	}
	if (CanCopy() && (op & DO_COPY) != 0)
		menu.AppendMenu(MF_STRING, 11, "Copy");
	if (CanCut() && (op & DO_CUT) != 0)
		menu.AppendMenu(MF_STRING, 12, "Delete");

	n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this);
	menu.DestroyMenu();

	switch (n) {
		case 10:	// add
		case 13:	// insert
			{
				CXTPReportRecord* pRec = newRec();
				if (callback_add) {
					if (!callback_add(this, pRec)) {
						delete pRec;
						return false;
					}
				}
				RowInsert(pRec, (n == 10));
			}
			break;

		case 11:	// copy
			{
				pRow = GetFocusedRow();
				if (!pRow)
					return false;

				CXTPReportRecord* pSource = pRow->GetRecord();
				CXTPReportRecord* pTarget  = newRec();
		
				if (callback_copy) {
					if (!callback_copy(this, pSource, pTarget)) {
						delete pTarget;
						return false;
					}
				}
				RowInsert(pTarget);
			}
			break;
		case 12:	// delete
			{
				n = pRows->GetCount();
				for (int i = 0; i < n; i++) {
					if (callback_del) {
						CXTPReportRecord* pRec = pRows->GetAt(i)->GetRecord();
						if (!callback_del(this, pRec)) {
							return false;
						}
					}
				}

				for (int i = n - 1; i >= 0; i--) {
					pRow = pRows->GetAt(i);
					GetRecords()->RemoveAt(pRow->GetRecord()->GetIndex());
				}
				Populate();
				RowSetFocused(nRow);
			}
			break;
		default:
			return false;
	}
	return true;
}
Ejemplo n.º 11
0
void CSimpleReport::Paste()
{
	if (IsVirtualMode())
		return;

	CWaitCursor _WC;

	CLIPFORMAT uCF_Records = (CLIPFORMAT)::RegisterClipboardFormat(XTPREPORTCTRL_CF_RECORDS);

	CXTPReportRecords arRecords;
	BOOL bTryPasteFromText = TRUE;

	// Retrieve text from the clipboard
	if (!OpenClipboard())
		return;

	if (::IsClipboardFormatAvailable(uCF_Records))
	{
		HGLOBAL hPasteData = ::GetClipboardData(uCF_Records);

		if (hPasteData)
		{
			bTryPasteFromText = FALSE;

			const int cErrTextSize = 1024;
			TCHAR szErrText[cErrTextSize + 1];

			CSharedFile fileSahred;
			fileSahred.SetHandle(hPasteData, FALSE);
			CArchive ar(&fileSahred, CArchive::load);

			try
			{
				CXTPPropExchangeArchive px(ar);
				BOOL bread = FALSE;
			#if _XTPLIB_VERSION_PREFIX == 1502
				bread = _ReadRecordsFromData(&px, arRecords);
			#else
				bread = _ReadRecodsFromData(&px, arRecords);
			#endif
				if (!bread)
				{
					arRecords.RemoveAll();
				}
			}
			catch(CArchiveException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(CFileException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(...)
			{
				TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - Unhandled Exception!\n"));
			}

			//*********
			ar.Close(); // detach from file
			fileSahred.Detach(); //detach from data
			::GlobalUnlock(hPasteData); // unlock data
		}
	}

	UINT uCF_TText = sizeof(TCHAR) == 2 ? CF_UNICODETEXT : CF_TEXT;

	if (bTryPasteFromText && ::IsClipboardFormatAvailable(uCF_TText))
	{
		// Try to get text data from the clipboard
		HGLOBAL hglbPaste = ::GetClipboardData(uCF_TText);

		// Import Text data into the control
		if (hglbPaste != NULL)
		{
			TCHAR* lpszClipboard = (TCHAR*)GlobalLock(hglbPaste);
			BOOL bRead = FALSE;
		#if _XTPLIB_VERSION_PREFIX == 1502	 
			bRead = _ReadRecordsFromText(lpszClipboard, arRecords);
		#else
			bRead = _ReadRecodsFromText(lpszClipboard, arRecords);
		#endif
			if (!bRead)
			{
				arRecords.RemoveAll();
			}
			::GlobalUnlock(hglbPaste);
		}
	}

	::CloseClipboard();
	//////////////////////////////////////////////////////////////////////////

	CUpdateContext updateContext(this);

	// Add and Populate records
	CXTPReportRow* pRow = GetFocusedRow();
	if (pRow == NULL)
		return;

	int n = pRow->GetRecord()->GetIndex();
	int nRecordsCount = arRecords.GetCount();
	if (nRecordsCount > 0) {
		for (int i = nRecordsCount - 1; i >= 0; i--) {
			CXTPReportRecord* pRecord = arRecords.GetAt(i);
			if (pRecord) {
				CMDTARGET_ADDREF(pRecord);
				if (m_bAdd)
					GetRecords()->Add(arRecords.GetAt(i));
				else
					GetRecords()->InsertAt(n, arRecords.GetAt(i));
			}
		}
		Populate();
		_SelectRows(&arRecords);
	}
	m_bAdd = false;
}