void CXTPReportInplaceList::Apply()
{
	if (!pControl)
		return;

	CXTPReportControl* pReportControl = pControl;

	int nIndex = GetCurSel();
	if (nIndex != LB_ERR)
	{
		m_bApply = TRUE;

		CXTPReportRecordItemConstraint* pConstraint = (CXTPReportRecordItemConstraint*)GetItemDataPtr(nIndex);

		XTP_REPORTRECORDITEM_ARGS itemArgs = *((XTP_REPORTRECORDITEM_ARGS*)this);
		itemArgs.AddRef();

		pItem->OnConstraintChanged(&itemArgs, pConstraint);
		pReportControl->RedrawControl();

		pReportControl->SendMessageToParent(itemArgs.pRow, itemArgs.pItem, itemArgs.pColumn, XTP_NM_REPORT_VALUECHANGED, 0);

		itemArgs.Release();
	}

	pReportControl->SetFocus();
}
void CXTPReportRecordItemIcon::GetCaptionRect(XTP_REPORTRECORDITEM_ARGS* pDrawArgs, CRect& rcItem)
{
	if (pDrawArgs == NULL)
		return;

	CXTPReportControl* pControl = DYNAMIC_DOWNCAST(CXTPReportControl, pDrawArgs->pControl);
	if (pControl && pControl->IsIconView())
	{
		// Adjust the rect for the text.
		pDrawArgs->rcItem.CopyRect(pDrawArgs->pRow->GetRect());
		pDrawArgs->rcItem.DeflateRect(1, 1);
		pDrawArgs->rcItem.top += pControl->m_iIconHeight;

		// The left coming in here is to the right of the icon, we need to get back to the beginning.
		pDrawArgs->rcItem.left = pDrawArgs->pRow->GetRect().left + 5;
		pDrawArgs->rcItem.DeflateRect(2, 1, 2, 0);

		rcItem = pDrawArgs->rcItem;
		return;
	}
	else
	{
		CXTPReportRecordItem::GetCaptionRect(pDrawArgs, rcItem);
	}
}
Example #3
0
void CMedic::RefreshReport( CMedicSet *pMedicSet )
{
	CMainFrame *p = (CMainFrame *)AfxGetMainWnd();
	CXTPReportControl *pReport = p->m_wndReportCtrl;
	CXTPReportRecords *pRecords = pReport->GetRecords();
	pRecords->RemoveAll();

	CXTPReportRecord *pRecord;
	CXTPReportRecordItem *pItem;
	CString strPrice;
	while(!pMedicSet->IsEOF())
	{
		pRecord = new CXTPReportRecord();
		pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicID));
		pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicName));
		pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicType));
		CTime ProduceData = pMedicSet->m_ProduceDate;
		pRecord->AddItem(new CXTPReportRecordItemText(ProduceData.Format(_T("%Y-%m-%d"))));
		if (0 == pMedicSet->m_MedicNumber)
		{
			pItem = pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_MedicNumber));
			pItem->SetBackgroundColor(RGB(255,0,0));
		}
		else
			pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_MedicNumber));
		strPrice.Format("%.2f",pMedicSet->m_MedicPrice);
		pRecord->AddItem(new CXTPReportRecordItemText(strPrice));
		pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_GuarantPeriod));
		pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_ProduceCompany));
		pReport->AddRecord(pRecord);
		pMedicSet->MoveNext();
	}
	pReport->Populate();
	
}
Example #4
0
BOOL CReportField::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();
	CXTPReportControl *pReportCtrl = pMainFrm->m_wndReportCtrl;
	pReportCtrl->GetReportHeader()->SetSubListCtrl(&m_wndReportSubList);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
int CXTPReportRecordItemIcon::Draw(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs)
{
	if (pDrawArgs == NULL)
		return CXTPReportRecordItem::Draw(pDrawArgs);

	CXTPReportControl* pControl = DYNAMIC_DOWNCAST(CXTPReportControl, pDrawArgs->pControl);
	if (pControl && pControl->IsIconView())
	{
		pDrawArgs->rcItem = pDrawArgs->pRow->GetRect();
		pDrawArgs->rcItem.DeflateRect(1, 1);
	}

	return CXTPReportRecordItem::Draw(pDrawArgs);
}
int CXTPReportRecordItemPreview::GetPreviewHeight(CDC* pDC, CXTPReportRow* pRow, int nWidth)
{
	int nHeight = 0;
	XTP_REPORTRECORDITEM_METRICS* pMetrics = new XTP_REPORTRECORDITEM_METRICS;
	pMetrics->strText = GetPreviewText();
	pRow->FillMetrics(NULL, this, pMetrics);

	CString strPreviewText = pMetrics->strText;

	if (strPreviewText.IsEmpty())
	{
		pMetrics->InternalRelease();
		return 0;
	}

	CXTPReportControl* pControl = pRow->GetControl();

	int nIndentWidth = pControl->GetHeaderIndent();


	CRect& rcIndent = pControl->GetPaintManager()->m_rcPreviewIndent;

	CRect rcPreviewItem(nIndentWidth + rcIndent.left, 0, nWidth - rcIndent.right, 0);

	if (m_pMarkupUIElement)
	{
		// Calculate Markup item height
		XTPMarkupSetDefaultFont(XTPMarkupElementContext(m_pMarkupUIElement), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground);
		CSize szMarkup = XTPMarkupMeasureElement(m_pMarkupUIElement, rcPreviewItem.Width(), INT_MAX);
		nHeight = szMarkup.cy + rcIndent.top + rcIndent.bottom;
	}
	else
	{
		// Calculate height of a usual text
		CXTPFontDC font(pDC, pMetrics->pFont);

		int nMaxPreviewLines = pControl->GetPaintManager()->GetPreviewLinesCount(pDC, rcPreviewItem, strPreviewText);
		int nFontHeight = pDC->GetTextExtent(_T(" "), 1).cy;


		nHeight = nFontHeight * nMaxPreviewLines + rcIndent.top + rcIndent.bottom;
	}

	// Cleanup
	pMetrics->InternalRelease();
	return nHeight;
}
void CXTPReportColumn::SetCaption(LPCTSTR lpszCaption)
{
	CString strCaption(lpszCaption);
	if (m_strName == strCaption)
		return;

	m_strName = strCaption;
	m_pColumns->GetReportHeader()->OnColumnsChanged(xtpReportColumnCaptionChanged, this);

	XTPMarkupReleaseElement(m_pMarkupUIElement);

	CXTPReportControl* pControl = m_pColumns->m_pControl;

	if (pControl && pControl->GetMarkupContext())
	{
		m_pMarkupUIElement = XTPMarkupParseText(pControl->GetMarkupContext(), strCaption);
	}

}
int CXTPReportColumn::GetBestFitWidth()
{
	CXTPReportControl* pControl = GetControl();
	CXTPReportPaintManager* pPaintManager = pControl->GetPaintManager();
	int nBestColumnWidth = 0;

	CClientDC dc(pControl);
	CXTPFontDC font(&dc, &pPaintManager->m_fontCaption);
	nBestColumnWidth = 6 + GetCaptionWidth(&dc);

	if (GetIconID() != XTP_REPORT_NOICON)
		nBestColumnWidth += pPaintManager->DrawBitmap(NULL, pControl, GetRect(), GetIconID()) + 2;

	if (HasSortTriangle() && pPaintManager->m_DrawSortTriangleStyle != xtpReportDrawSortTriangleNever)
		nBestColumnWidth += 27;

	int nDataWidth = pControl->OnGetColumnDataBestFitWidth(this);

	nBestColumnWidth = max(nBestColumnWidth, nDataWidth);
	nBestColumnWidth = max(nBestColumnWidth, m_nMaxItemWidth);

	return nBestColumnWidth;
}
void CXTPReportHeaderDragWnd::OnTimer(UINT_PTR nIDEvent)
{
	UNREFERENCED_PARAMETER(nIDEvent);

	if (!m_pHeader || !m_pHeader->GetControl())
	{
		return;
	}
	CXTPReportControl* pControl = m_pHeader->GetControl();

	ASSERT(pControl->m_bHScrollBarVisible);

	CRect rcHeaderScreen = m_pHeader->m_rcHeader;
	pControl->ClientToScreen(&rcHeaderScreen);

	CRect rcControlScreen(0,0,0,0);
	CRect rcDragScreen(0,0,0,0);

	pControl->GetWindowRect(&rcControlScreen);
	GetWindowRect(&rcDragScreen);


	CPoint ptMouseScreen(0, 0);
	if (!GetCursorPos(&ptMouseScreen) ||
		ptMouseScreen.y < rcHeaderScreen.top || ptMouseScreen.y > rcHeaderScreen.bottom)
	{
		return;
	}

	BOOL bScrolled = FALSE;
	BOOL bLayoutRTL = pControl->GetExStyle() & WS_EX_LAYOUTRTL;

	int nDiffRight = bLayoutRTL ? rcControlScreen.left - rcDragScreen.left :
		rcDragScreen.right - rcControlScreen.right;

	//-----------------------------------------------------------------------
	CXTPReportColumn *pPrev = NULL, *pCurr = NULL, *pNext = NULL;
	int nScrollPos = 0, nScrollMax = 0;
	int nFreezOffset = 0;
	BOOL bFullColumnScrolling = pControl->IsFullColumnScrolling();
	if (bFullColumnScrolling)
		nFreezOffset = m_pHeader->GetFulColScrollInfo(pPrev, pCurr, pNext, nScrollPos, nScrollMax);
	//-----------------------------------------------------------------------

	if (nDiffRight > 0)
	{
		int nStep = max(min(7, nDiffRight/10), CXTPReportHeader::s_nMinAutoScrollStep);
		UINT uTimer = bFullColumnScrolling ? max(30, 800 - nDiffRight * 10) : max(10, 100 - nDiffRight);
		SCROLLINFO scrollInfo;

		BOOL bRes = pControl->GetScrollInfo(SB_HORZ, &scrollInfo);
		if (bRes)
		{
			if (!bFullColumnScrolling && scrollInfo.nPos < scrollInfo.nMax ||
				bFullColumnScrolling && nScrollPos < nScrollMax)
			{
				if (bFullColumnScrolling)
					pControl->SendMessage(WM_HSCROLL, SB_LINERIGHT);
				else
					pControl->SetLeftOffset(scrollInfo.nPos + nStep);

				KillTimer(1);
				SetTimer(1, uTimer, NULL);
				bScrolled = TRUE;
			}
		}
	}
	else
	{
		int nLeftBorderX = bLayoutRTL ? rcControlScreen.right : rcControlScreen.left;

		int nFreezCols = pControl->GetFreezeColumnsCount();
		if (nFreezCols && pControl->GetColumns())
		{
			CXTPReportColumn* pLastFCol = pControl->GetColumns()->GetVisibleAt(nFreezCols - 1);
			if (pLastFCol)
			{
				CRect rcLastFCol = pLastFCol->GetRect();
				pControl->ClientToScreen(&rcLastFCol);

				int nLastFCol_middleX = rcLastFCol.left + rcLastFCol.Width() / 2;
				if (rcDragScreen.left < rcLastFCol.right &&
					ptMouseScreen.x > nLastFCol_middleX )
				{
					nLeftBorderX = rcLastFCol.right;
				}
			}
		}

		int nDiffLeft = bLayoutRTL ? rcDragScreen.right - nLeftBorderX : nLeftBorderX - rcDragScreen.left;

		if (nDiffLeft > 0)
		{
			int nStep = max(min(7, nDiffLeft/10), CXTPReportHeader::s_nMinAutoScrollStep);
			UINT uTimer = bFullColumnScrolling ? max(30, 800 - nDiffLeft * 10) : max(10, 100 - nDiffLeft);
			SCROLLINFO scrollInfo;

			BOOL bRes = pControl->GetScrollInfo(SB_HORZ, &scrollInfo);
			if (bRes)
			{
				if (scrollInfo.nPos > scrollInfo.nMin)
				{
					if (bFullColumnScrolling)
						pControl->SendMessage(WM_HSCROLL, SB_LINELEFT);
					else
						pControl->SetLeftOffset(scrollInfo.nPos - nStep);

					SetTimer(1, uTimer, NULL);
					bScrolled = TRUE;
				}
			}
		}
	}

	//-------------------------------------------------------------------------
	if (bScrolled)
	{
		CPoint ptMouse = ptMouseScreen;
		pControl->ScreenToClient(&ptMouse);

		pControl->RedrawControl();
		pControl->UpdateWindow();

		m_pHeader->OnMouseMove(0, ptMouse);
	}
}
Example #10
0
void CXTPReportColumn::EnsureVisible()
{
	CXTPReportControl* pControl = GetControl();
	if (pControl)
		pControl->EnsureVisible(this);
}
void CXTPReportRecordItemIcon::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics)
{
	if (pDrawArgs == NULL)
		return;

	CXTPReportControl* pControl = DYNAMIC_DOWNCAST(CXTPReportControl, pDrawArgs->pControl);
	if (pControl && pControl->IsIconView())
	{
		// Adjust the rect for the text.
		pDrawArgs->rcItem.DeflateRect(1, 1);
		pDrawArgs->rcItem.top += pControl->m_iIconHeight;

		CXTPReportPaintManager * pPaintManager = pControl->GetPaintManager();

		const UINT c_uiDrawFlags = pDrawArgs->nTextAlign | DT_CENTER | DT_NOPREFIX | DT_WORDBREAK | DT_EDITCONTROL | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS;

		// Get rect for text
		CRect rcItem(pDrawArgs->rcItem);
		rcItem.DeflateRect(2, 1, 2, 0);
		rcItem = pPaintManager->CalculateMaxTextRect(pDrawArgs->pDC, pMetrics->strText, rcItem, TRUE, TRUE, c_uiDrawFlags);

		int nWidth = min(rcItem.Width() + 4, pDrawArgs->rcItem.Width());

		// Center the rect.
		int nLeft = (pDrawArgs->rcItem.left + pDrawArgs->rcItem.right - nWidth) / 2;

		rcItem.left = nLeft;
		rcItem.right = rcItem.left + nWidth;

		if (rcItem.bottom >= pDrawArgs->rcItem.bottom)
		  rcItem.bottom -= 2;

		pDrawArgs->rcItem.left = rcItem.left;
		pDrawArgs->rcItem.right = rcItem.right;

		//Draw the selection
		if (pDrawArgs->pRow->IsSelected() && (pDrawArgs->pDC && !pDrawArgs->pDC->IsPrinting()))
		{
			COLORREF clrBackground = 0;

			if (pControl->HasFocus())
			{
				pMetrics->clrForeground = pPaintManager->m_clrHighlightText;
				pDrawArgs->pDC->SetTextColor(pMetrics->clrForeground);
				clrBackground = pPaintManager->m_clrHighlight;
			}
			else if (!pPaintManager->m_bHideSelection)
			{
				pMetrics->clrForeground = pPaintManager->m_clrSelectedRowText;
				pDrawArgs->pDC->SetTextColor(pMetrics->clrForeground);
				clrBackground = pPaintManager->m_clrSelectedRow;
			}

			// fill select rect
			pDrawArgs->pDC->FillSolidRect(rcItem, clrBackground);
		}

		if (pDrawArgs->pRow->IsFocused() && pControl->HasFocus() && pControl->IsRowFocusVisible())
		{
			rcItem.InflateRect(1, 1);
			pPaintManager->DrawFocusedRow(pDrawArgs->pDC, rcItem);
		}

		pDrawArgs->nTextAlign |= c_uiDrawFlags;
	}

	CXTPReportRecordItem::OnDrawCaption(pDrawArgs, pMetrics);
}
Example #12
-1
void CMedic::MedicSearchOutDate()
{
	CMainFrame *p = (CMainFrame *)AfxGetMainWnd();
	CXTPReportControl *pReport = p->m_wndReportCtrl;
	CXTPReportRecords *pRecords = pReport->GetRecords();
	pRecords->RemoveAll();
	

	CXTPReportRecord *pRecord;

	CMedicSet *pMedicSet = &p->medicSet;
	pMedicSet->m_strFilter = "";
	pMedicSet->Requery();
	CMedicManage ManMedic;
	CTime CurDate = CTime::GetCurrentTime();
	CString strPrice;
	while(!pMedicSet->IsEOF())
	{
		ManMedic.SetMedicSet(pMedicSet);
		CTime OutDate = ManMedic.GetOutDateTime();
		/*CString k = OutDate.Format(_T("%Y-%m-%d"));*/
		
		if (OutDate < CurDate)
		{
			pRecord = new CXTPReportRecord();
			pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicID));
			pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicName));
			pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_MedicType));
			CTime ProduceData = pMedicSet->m_ProduceDate;
			pRecord->AddItem(new CXTPReportRecordItemText(ProduceData.Format(_T("%Y-%m-%d"))));
			pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_MedicNumber));
			strPrice.Format("%.2f",pMedicSet->m_MedicPrice);
			pRecord->AddItem(new CXTPReportRecordItemText(strPrice));
			pRecord->AddItem(new CXTPReportRecordItemNumber(pMedicSet->m_GuarantPeriod));
			pRecord->AddItem(new CXTPReportRecordItemText(pMedicSet->m_ProduceCompany));
			pReport->AddRecord(pRecord);
		}
		pMedicSet->MoveNext();
	}
	pReport->Populate();
}