📄 multisort.cpp.svn-base
字号:
m_rectDiff = CRect( x, y+2*height/3, x+width/3, m_rectAll.bottom );
// 5分钟涨幅排名区域
m_rectRiseMin5 = CRect( x+width/3, y, x+2*width/3, y+height/3 );
// 5分钟跌幅排名区域
m_rectFallMin5 = CRect( x+width/3, y+height/3, x+2*width/3, y+2*height/3 );
// 5分钟震幅排名区域
m_rectVolRatio = CRect( x+width/3, y+2*height/3, x+2*width/3, m_rectAll.bottom );
// 今日委比前六名区域
m_rectBSRatioAsc = CRect( x+2*width/3, y, m_rectAll.right, y+height/3 );
// 今日委比后六名区域
m_rectBSRatioDesc = CRect( x+2*width/3, y+height/3, m_rectAll.right, y+2*height/3 );
// 今日总金额排名区域
m_rectAmount = CRect( x+2*width/3, y+2*height/3, m_rectAll.right, m_rectAll.bottom );
}
int CMultiSort::GetClickPos( CRect rect, CPoint point )
{
if( !rect.PtInRect(point) )
return -1;
int y = rect.top+20;
int yStep = (rect.Height()-23) / 6 ;
if( yStep <= 0 )
return -1;
int nClickPos = -1;
for( int nIndex=0; nIndex<6; nIndex ++ )
{
CRect rectElement = rect;
rectElement.top = y + yStep * nIndex;
rectElement.bottom = y + yStep * (nIndex+1);
if( rectElement.PtInRect(point) )
{
nClickPos = nIndex;
break;
}
}
return nClickPos;
}
void CMultiSort::DrawSelection( CDC * pDC, int nSelectArea, int nSelectPos, COLORREF clr )
{
CRect rect(0,0,0,0);
if( -1 == nSelectPos )
return;
if( areaRise == nSelectArea )
rect = m_rectRise;
else if( areaFall == nSelectArea )
rect = m_rectFall;
else if( areaDiff == nSelectArea )
rect = m_rectDiff;
else if( areaRiseMin5 == nSelectArea )
rect = m_rectRiseMin5;
else if( areaFallMin5 == nSelectArea )
rect = m_rectFallMin5;
else if( areaVolRatio == nSelectArea )
rect = m_rectVolRatio;
else if( areaBSRatioAsc == nSelectArea )
rect = m_rectBSRatioAsc;
else if( areaBSRatioDesc == nSelectArea )
rect = m_rectBSRatioDesc;
else if( areaAmount == nSelectArea )
rect = m_rectAmount;
else
return;
int y = rect.top+20;
int yStep = (rect.Height()-23) / 6 ;
if( yStep <= 0 )
return;
int ySel = y + yStep*nSelectPos + 16;
if( ySel > rect.top && ySel < rect.bottom )
DrawLine( pDC, 2, clr, rect.left+5, ySel, rect.right-5, ySel );
}
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 );
}
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( int 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 );
}
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( int 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 );
}
// 今日涨幅排名
void CMultiSort::DrawRise( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_RISE );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msRise, rect, SLH_DIFFPERCENT, areaRise == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwRise, rect, SLH_DIFFPERCENT, areaRise == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日跌幅排名
void CMultiSort::DrawFall( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_FALL );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msFall, rect, SLH_DIFFPERCENT, areaFall == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwFall, rect, SLH_DIFFPERCENT, areaFall == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日震幅排名
void CMultiSort::DrawDiff( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_DIFF );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msDiff, rect, SLH_SCOPE, areaDiff == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwDiff, rect, SLH_SCOPE, areaDiff == m_nSelectArea ? m_nSelectPos : -1 );
}
// 5分钟涨幅排名
void CMultiSort::DrawRiseMin5( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_RISEMIN5 );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msRiseMin5, rect, SLH_DIFFPERCENT_MIN5, areaRiseMin5 == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwRiseMin5, rect, SLH_DIFFPERCENT_MIN5, areaRiseMin5 == m_nSelectArea ? m_nSelectPos : -1 );
}
// 5分钟跌幅排名
void CMultiSort::DrawFallMin5( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_FALLMIN5 );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msFallMin5, rect, SLH_DIFFPERCENT_MIN5, areaFallMin5 == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwFallMin5, rect, SLH_DIFFPERCENT_MIN5, areaFallMin5 == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日量比排名
void CMultiSort::DrawVolRatio( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_VOLRATIO );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msVolRatio, rect, SLH_RATIO_VOLUME, areaVolRatio == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwVolRatio, rect, SLH_RATIO_VOLUME, areaVolRatio == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日委比前六名
void CMultiSort::DrawBSRatioAsc( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_BSRATIOASC );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msBSRatioAsc, rect, SLH_SELLBUYRATIO, areaBSRatioAsc == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwBSRatioAsc, rect, SLH_SELLBUYRATIO, areaBSRatioAsc == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日委比后六名
void CMultiSort::DrawBSRatioDesc( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_BSRATIODESC );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msBSRatioDesc, rect, SLH_SELLBUYRATIO, areaBSRatioDesc == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwBSRatioDesc, rect, SLH_SELLBUYRATIO, areaBSRatioDesc == m_nSelectArea ? m_nSelectPos : -1 );
}
// 今日总金额排名
void CMultiSort::DrawAmount( CDC * pDC, CRect rect )
{
CString strTitle;
strTitle.LoadString( IDS_MULTISORT_AMOUNT );
DrawBorderAndTitle( pDC, rect, strTitle );
if( modeDirect == m_nRefreshMode )
DrawMultiSort( pDC, m_msAmount, rect, SLH_AMOUNT, areaAmount == m_nSelectArea ? m_nSelectPos : -1 );
else
DrawMultiSort( pDC, m_adwAmount, rect, SLH_AMOUNT, areaAmount == m_nSelectArea ? m_nSelectPos : -1 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -