Ejemplo n.º 1
0
void DrawBorderAndTitle( CDC * pDC, CRect rect, LPCTSTR lpszTitle )
{
	DECLARE_COLOR_DEFINATION

	// Draw Border
	CRect	rectTitle	=	CRect( rect.left, rect.top, rect.right, rect.top+18 );
	pDC->Draw3dRect( &rect, clrBorder, clrBorder );
	pDC->Draw3dRect( &rectTitle, clrBorder, clrBorder );

	// Draw Title
	CFont	* pOldFont	=	AfxSelectDCFont( pDC, 14 );
	pDC->SetBkColor( clrBK );
	pDC->SetTextColor( clrText );
	pDC->DrawText( lpszTitle, rectTitle, DT_CENTER | DT_VCENTER | DT_SINGLELINE );

	pDC->SelectObject( pOldFont );
}
Ejemplo n.º 2
0
void CMultiSort::DrawMultiSort( CDC * pDC, MULTISORT &ms, CRect rect, UINT nSLH, int nSelectPos )
{
	DECLARE_COLOR_DEFINATION

	int	x	=	rect.left+8;
	int	x2	=	(int)( rect.left+0.56*rect.Width() );
	int	x3	=	rect.right-8;
	int	y	=	rect.top+20;
	int	yStep	=	(rect.Height()-23) / 6 ;
	if( yStep <= 0 )
		return;
	
	CFont	* pOldFont	=	AfxSelectDCFont( pDC, 14 );
	pDC->SetBkColor( clrBK );

	int size = sizeof(m_msRise.m_stocks)/sizeof(m_msRise.m_stocks[0]);
	for( int i=0; i<size; i++ )
	{
		CStockInfo	info;
		char	buf_code[sizeof(ms.m_stocks[i].m_code)+1];
		memset( buf_code, 0, sizeof(buf_code) );
		memcpy( buf_code, ms.m_stocks[i].m_code, sizeof(ms.m_stocks[i].m_code) );
		if( !AfxGetStockContainer().GetStockInfo(buf_code, &info) )
			continue;
		info.m_fClose	=	float(0.001*ms.m_stocks[i].m_data1);

		pDC->SetTextColor( clrText );
//#ifdef	CLKLAN_ENGLISH_US
//		pDC->TextOut( x, y, info.GetStockCode() );
//#else
		pDC->TextOut( x, y, info.GetStockName() );
//#endif

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->SetTextColor( AfxGetVariantColor(SLH_CLOSE,info) );
		pDC->TextOut( x2, y, (LPCTSTR)AfxGetVariantDispString(SLH_CLOSE,info,NULL) );

		CString strTemp;
		if( CStock::classVolRatio == ms.m_class )
			strTemp.Format( "%.2f", 0.01*ms.m_stocks[i].m_data2 );
		else if( CStock::classAmount == ms.m_class )
			strTemp.Format( "%.0f", 0.001*ms.m_stocks[i].m_data2 );
		else
			strTemp.Format( "%.2f%%", 0.01*ms.m_stocks[i].m_data2 );
		pDC->TextOut( x3, y, strTemp );

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );

		// 选中股票
		if( nSelectPos == i )
		{
			int	ySel = y-yStep+16;
			if( ySel > rect.top && ySel < rect.bottom )
				DrawLine( pDC, 2, clrBorder, rect.left+5, ySel, rect.right-5, ySel );
		}
	}

	// 补足股票排名
	for( i=size; i<6; i++ )
	{
		pDC->SetTextColor( clrText );
		pDC->TextOut( x, y, "-" );

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->TextOut( x2, y, "-" );

		pDC->TextOut( x3, y, "-" );

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );
	}

	pDC->SelectObject( pOldFont );
}
Ejemplo n.º 3
0
void CMultiSort::DrawMultiSort( CDC * pDC, CSPDWordArray &adwSortID, CRect rect, UINT nSLH, int nSelectPos )
{
	DECLARE_COLOR_DEFINATION

	int	x	=	rect.left+8;
	int	x2	=	(int)( rect.left+0.56*rect.Width() );
	int	x3	=	rect.right-8;
	int	y	=	rect.top+20;
	int	yStep	=	(rect.Height()-23) / 6 ;
	if( yStep <= 0 )
		return;
	
	CFont	* pOldFont	=	AfxSelectDCFont( pDC, 14 );
	pDC->SetBkColor( clrBK );

	for( int i=0; i<adwSortID.GetSize(); i++ )
	{
		if( (int)adwSortID[i] < 0 || (int)adwSortID[i] >= AfxGetStockContainer().GetSize() )
			continue;

		CStockInfo	& info	=	AfxGetStockContainer().ElementAt(adwSortID[i]);

		pDC->SetTextColor( clrText );
//#ifdef	CLKLAN_ENGLISH_US
//		pDC->TextOut( x, y, info.GetStockCode() );
//#else
		pDC->TextOut( x, y, info.GetStockName() );
//#endif

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->SetTextColor( AfxGetVariantColor(SLH_CLOSE,info) );
		pDC->TextOut( x2, y, (LPCTSTR)AfxGetVariantDispString(SLH_CLOSE,info,NULL) );

		pDC->SetTextColor( AfxGetVariantColor(nSLH,info) );
		if( SLH_RATIO_VOLUME == nSLH )
		{
			double	dVolRatio	=	1;
			CSPTime	tTrade;
			if( AfxGetVariantValue(nSLH,info,&dVolRatio,NULL)
				&& tTrade.FromStockTimeDay( info.m_datetech ) )
				dVolRatio = dVolRatio / CSPTime::GetTimeTradeRatioOfOneDay( tTrade, CSPTime::GetCurrentTime() );

			CString	strTemp;
			strTemp.Format( "%.2f", dVolRatio );
			pDC->TextOut( x3, y, strTemp );
		}
		else
		{
			pDC->TextOut( x3, y, (LPCTSTR)AfxGetVariantDispString(nSLH,info,NULL) );
		}

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );

		// 选中股票
		if( nSelectPos == i )
		{
			int	ySel = y-yStep+16;
			if( ySel > rect.top && ySel < rect.bottom )
				DrawLine( pDC, 2, clrBorder, rect.left+5, ySel, rect.right-5, ySel );
		}
	}

	// 补足股票排名
	for( i=adwSortID.GetSize(); i<6; i++ )
	{
		pDC->SetTextColor( clrText );
		pDC->TextOut( x, y, "-" );

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->TextOut( x2, y, "-" );

		pDC->TextOut( x3, y, "-" );

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );
	}

	pDC->SelectObject( pOldFont );
}
Ejemplo n.º 4
0
/***
	画曲线
*/
BOOL CCurveButton::DrawCurve( CDC * pDC, CRect rectClient, int nStart )
{
	CRect	rectDraw;
	int nCount;
	double	dMin, dMax;
	if( !PrepareDrawData( rectClient, nStart, m_nStepWeight, &rectDraw, &nStart, &nCount, &dMin, &dMax ) )
		return FALSE;

	DrawAxis( pDC, rectDraw, 15, 5, dMin, dMax, FALSE, TRUE, 2 );

	COLORREF	clrBK		=	AfxGetProfile().GetColor(CColorClass::clrGraphBK);
	COLORREF	clrLine1	=	AfxGetProfile().GetColor(CColorClass::clrLine1);
	COLORREF	clrLine2	=	AfxGetProfile().GetColor(CColorClass::clrLine3);
	COLORREF	clrBorder	=	AfxGetProfile().GetColor(CColorClass::clrBorder);
	COLORREF	clrText		=	AfxGetProfile().GetColor(CColorClass::clrText);
	int	yYieldLast, yYieldNow, yStoreLast, yStoreNow;
	int	xDateLast = 0;
	int	xMedium	= rectDraw.left;
	BOOL	bHasLast = FALSE;
	double	dYield = 1, dStore = 0;

	CFont	* pOldFont	=	AfxSelectDCFont( pDC, 12 );
	pDC->SetBkColor( clrBK );
	pDC->SetTextColor( clrText );
	for( int k=nStart; k<nStart+nCount && k<m_AssetSerial.GetSize(); k++ )
	{
		ASSETSERIAL	&	serial	=	m_AssetSerial.ElementAt(k);
		dYield	=	serial.dAsset / m_dStartAmount;
		if( serial.dAsset > 1e-4 )
			dStore	=	(serial.dAsset - serial.dCash) / serial.dAsset;

		xMedium	+=	m_nStepWeight;

		// Draw
		yYieldNow	=	int( rectDraw.bottom - (rectDraw.Height()-2) * (dYield - dMin) / (dMax-dMin) );
		yStoreNow	=	int( rectDraw.bottom - (rectDraw.Height()-2) * (dStore - dMin) / (dMax-dMin) );
		if( bHasLast )
		{
			if( yYieldLast > rectDraw.bottom || yYieldLast < rectDraw.top
				|| yYieldNow > rectDraw.bottom || yYieldNow < rectDraw.top )
				continue;
			if( yStoreLast > rectDraw.bottom || yStoreLast < rectDraw.top
				|| yStoreNow > rectDraw.bottom || yStoreNow < rectDraw.top )
				continue;
			CPen	penLocal1( PS_SOLID, 1, clrLine1 );
			CPen * pOldPen = pDC->SelectObject( &penLocal1 );
			pDC->MoveTo( xMedium-m_nStepWeight, yYieldLast );
			pDC->LineTo( xMedium, yYieldNow );

			CPen	penLocal2( PS_SOLID, 1, clrLine2 );
			pDC->SelectObject( &penLocal2 );
			pDC->MoveTo( xMedium-m_nStepWeight, yStoreLast );
			pDC->LineTo( xMedium, yStoreNow );
			pDC->SelectObject( pOldPen );
		}
		yYieldLast		=	yYieldNow;
		yStoreLast		=	yStoreNow;
		bHasLast	=	TRUE;

		if( k > 0 )	//	Draw Date
		{
			CSPTime	tmLast(m_AssetSerial.ElementAt(k-1).time);
			CSPTime	tmNow(serial.time);

			CString	strText;
			if( tmLast.GetYear() != tmNow.GetYear()
				|| tmLast.GetMonth() != tmNow.GetMonth() )
				strText	=	tmNow.Format( "%y/%m/%d" );
			if( strText.GetLength() > 0 && xDateLast < xMedium && xMedium+pDC->GetTextExtent(strText).cx < rectDraw.right )
			{
				pDC->TextOut( xMedium+2, rectDraw.bottom+1, strText );
				xDateLast	=	xMedium+2 + pDC->GetTextExtent(strText).cx;

				CPen	penLocal( PS_SOLID, 1, clrBorder );
				CPen * pOldPen = pDC->SelectObject( &penLocal );
				pDC->MoveTo( xMedium, rectDraw.bottom );
				pDC->LineTo( xMedium, rectDraw.bottom+13 );
				pDC->SelectObject( pOldPen );
			}
		}
	}

	// Draw Text
	pDC->SetBkColor( clrBK );
	AfxSelectDCFont( pDC, 14 );
	CString	strText;
	strText.LoadString( IDS_SIMUREPORT_YIELDLINE );
	pDC->SetTextColor( clrLine1 );
	pDC->TextOut( rectDraw.left+rectDraw.Width()/10, rectDraw.bottom+17, strText );

	strText.LoadString( IDS_SIMUREPORT_STORELINE );
	pDC->SetTextColor( clrLine2 );
	pDC->TextOut( rectDraw.left+6*rectDraw.Width()/10, rectDraw.bottom+17, strText );
	pDC->SelectObject( pOldFont );

	return TRUE;
}
Ejemplo n.º 5
0
void CQuoteTipDlg::OnPaint() 
{
	// Do not call CTipDialog::OnPaint() for painting messages
	// CTipDialog::OnPaint();

	CPaintDC dc(this); // device context for painting
	
	dc.SetBkMode( TRANSPARENT );
	CFont * pOldFont = AfxSelectDCFont(&dc,14);

	CRect rectAll;
	GetClientRect( &rectAll );
	int nWidthTotal = rectAll.Width();
	double o = (nWidthTotal-10) / 26;

	CRect rect;
	int x = 5, y = 5;
	int nCount = 0;
	CStockContainer & container = AfxGetSListStockContainer();

	// Draw Header Title
	{
		CString strCode = AfxGetVariantName(SLH_CODE,FALSE);
		CString strClose = AfxGetVariantName(SLH_CLOSE,FALSE);
		CString strDiffPercent = AfxGetVariantName(SLH_DIFFPERCENT,FALSE);
		CString strVolume = AfxGetVariantName(SLH_VOLUME,FALSE);

		dc.SetTextColor( AfxGetProfile().GetColor(CColorClass::clrTitle) );
		rect = CRect(x,y,x+6*o,y+m_nItemHeight-1);
		dc.DrawText( strCode, rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+6*o,y,x+13*o,y+m_nItemHeight-1);
		dc.DrawText( strClose, rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+13*o,y,x+19*o,y+m_nItemHeight-1);
		dc.DrawText( strDiffPercent, rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+19*o,y,rectAll.right-5,y+m_nItemHeight-1);
		dc.DrawText( strVolume, rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS );

		y += m_nItemHeight;
	}

	y += 2;

	for( int nIndex=m_nIndexStart; nIndex<container.GetSize(); nIndex++ )
	{
		nCount ++;
		if( nCount > m_nPageCount )
			break;

		CStockInfo & info = container.ElementAt(nIndex);
		CString strCode = AfxGetVariantDispString(SLH_CODE,info,NULL);
		CString strClose = AfxGetVariantDispString(SLH_CLOSE,info,NULL);
		CString strDiffPercent = AfxGetVariantDispString(SLH_DIFFPERCENT,info,NULL);
		CString strVolume = AfxGetVariantDispString(SLH_VOLUME,info,NULL);

		rect = CRect(x,y,x+6*o,y+m_nItemHeight-1);
		dc.SetTextColor( AfxGetVariantColor(SLH_CODE,info) );
		dc.DrawText( strCode, rect, DT_VCENTER | DT_RIGHT | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+6*o,y,x+13*o,y+m_nItemHeight-1);
		dc.SetTextColor( AfxGetVariantColor(SLH_CLOSE,info) );
		dc.DrawText( strClose, rect, DT_VCENTER | DT_RIGHT | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+13*o,y,x+18*o,y+m_nItemHeight-1);
		dc.SetTextColor( AfxGetVariantColor(SLH_DIFFPERCENT,info) );
		dc.DrawText( strDiffPercent, rect, DT_VCENTER | DT_RIGHT | DT_SINGLELINE | DT_WORD_ELLIPSIS );
		rect = CRect(x+18*o,y,rectAll.right-10,y+m_nItemHeight-1);
		dc.SetTextColor( AfxGetVariantColor(SLH_VOLUME,info) );
		dc.DrawText( strVolume, rect, DT_VCENTER | DT_RIGHT | DT_SINGLELINE | DT_WORD_ELLIPSIS );

		y += m_nItemHeight;
	}

	dc.SelectObject(pOldFont);
}