📄 legendwnd.cpp
字号:
/* Author : Scott Pelger Date Created: 17MAY02 */
/* */
/* Revisions */
/* */
/* Engineer Date Description */
/* */
/* Scott Pelger 17MAY02 initial version */
/* */
/************************************************************************************************/
int CLegendWnd::_GetWindowMaxWidth() {
CPtrArray* pLegendList = _GetLegendList();
CLegendText* pLegendText;
CRect Rect;
int nCnt(pLegendList->GetSize());
int nWidest(0);
int nWidth;
for (int i(0);i<nCnt;i++) {
pLegendText = (CLegendText*)pLegendList->GetAt(i);
if (!pLegendText)
continue;
pLegendText->GetClientRect(&Rect);
nWidth = Rect.Width();
nWidest = nWidest>nWidth?nWidest:nWidth;
}
return nWidest;
}
/************************************************************************************************/
/* */
/* Function: CLegendWnd::_GetWindowMaxHeight() */
/* */
/* Purpose : Returns the maximum window height */
/* */
/* Inputs : NONE */
/* */
/* Outputs : int <- height of the window */
/* */
/* Author : Scott Pelger Date Created: 17MAY02 */
/* */
/* Revisions */
/* */
/* Engineer Date Description */
/* */
/* Scott Pelger 17MAY02 initial version */
/* */
/************************************************************************************************/
int CLegendWnd::_GetWindowMaxHeight() {
CPtrArray* pLegendList = _GetLegendList();
CLegendText* pLegendText;
CRect Rect;
if (!pLegendList->GetSize())
return 0;
pLegendText = (CLegendText*)pLegendList->GetAt(0);
if (!pLegendText)
return 0;
pLegendText->GetClientRect(&Rect);
return Rect.Height();
}
/************************************************************************************************/
/* */
/* Function: CLegendWnd::GetMinimumWindowRect() */
/* */
/* Purpose : Returns the minimum window dimesnions to show the entire legend */
/* */
/* Inputs : NONE */
/* */
/* Outputs : CRect* <- minimunm rect */
/* */
/* Author : Scott Pelger Date Created: 17MAY02 */
/* */
/* Revisions */
/* */
/* Engineer Date Description */
/* */
/* Scott Pelger 17MAY02 initial version */
/* */
/************************************************************************************************/
void CLegendWnd::GetMinimumWindowRect(CRect* pRect) {
int nWidth(_GetWindowMaxWidth());
int nXDelta(nWidth/2);
int nHeight(_GetWindowMaxHeight());
int nYDelta(nHeight/2);
CPtrArray* pLegendList = _GetLegendList();
int nCnt(pLegendList->GetSize());
if (!nCnt||m_rcClientRect.IsRectEmpty())
return;
int nTotalWidth(0);
int nTotalHeight(0);
switch (m_eLegendPosition) {
case eLEFT :
case eRIGHT : {
int nNumInCol(0);
for (int nCols(1);;nCols++) {
nNumInCol = nCnt/nCols + nCnt%nCols;
nTotalHeight = nHeight*nNumInCol + nYDelta*(nNumInCol-1);
if (nTotalHeight<m_rcClientRect.Height()) {
int nNumInRow(nCnt/nNumInCol + (nCnt%nNumInCol>0));
nTotalWidth = nWidth*nNumInRow + nXDelta*(nNumInRow-1);
break;
}
}
if (nTotalWidth>m_rcClientRect.Width()*m_yAutoHideWidth/100)
nTotalHeight = nTotalWidth = 0;
}
break;
default : {
int nNumInRow(0);
for (int nRows(1);;nRows++) {
nNumInRow = nCnt/nRows + nCnt%nRows;
nTotalWidth = nWidth*nNumInRow + nXDelta*(nNumInRow-1);
if (nTotalWidth<m_rcClientRect.Width()) {
int nNumInCol(nCnt/nNumInRow + (nCnt%nNumInRow>0));
nTotalHeight = nHeight*nNumInCol + nYDelta*(nNumInCol-1);
break;
}
}
if (nTotalHeight>m_rcClientRect.Height()*m_yAutoHideHeight/100)
nTotalHeight = nTotalWidth = 0;
}
}
pRect->SetRect(0, 0, nTotalWidth, nTotalHeight);
return;
}
/************************************************************************************************/
/* */
/* Function: CLegendWnd::SetFont() */
/* */
/* Purpose : sets the font for this window */
/* */
/* Inputs : BYTE byPointSize -> size of the font */
/* char* psFontName -> name of the font */
/* BYTE byStyle -> styles to be applied to the font */
/* */
/* Outputs : see CChartWndBase::SetFont() */
/* */
/* Author : Scott Pelger Date Created: 15MAY02 */
/* */
/* Revisions */
/* */
/* Engineer Date Description */
/* */
/* Scott Pelger 15MAY02 initial version */
/* */
/************************************************************************************************/
BOOL CLegendWnd::SetFont(BYTE yPointSize, char* psFontName, BYTE byStyle/*=0*/) {
m_yPointSize = yPointSize;
m_sFontName = *psFontName;
return CChartWndBase::SetFont(yPointSize, psFontName, byStyle);
}
/************************************************************************************************/
/* */
/* Function: CLegendWnd::SetWindowColor() */
/* */
/* Purpose : sets the window color for the legend window */
/* */
/* Inputs : COLORREF Color -> sets the color of the window as well as the background color for */
/* all legend items */
/* */
/* Outputs : see CChartWndBase::SetWindowColor() */
/* */
/* Author : Scott Pelger Date Created: 15MAY02 */
/* */
/* Revisions */
/* */
/* Engineer Date Description */
/* */
/* Scott Pelger 15MAY02 initial version */
/* */
/************************************************************************************************/
COLORREF CLegendWnd::SetWindowColor(COLORREF Color) {
m_crWindowColor = Color;
int nCnt(m_PointArray.GetSize());
CLegendText* pWnd;
for (int i(0);i<nCnt;i++) {
pWnd = (CLegendText*)m_PointArray.GetAt(i);
pWnd->SetBackgroundColor(Color);
}
nCnt = m_SeriesArray.GetSize();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -