⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartctrl.cpp

📁 The application wizard has created this SoccerDoctor application for you. This application not onl
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::SetWindowColor()                                                       */
/*                                                                                              */
/* Purpose : sets the color of all chart control windows                                        */
/*                                                                                              */
/* Inputs  : COLORREF Color -> desired color                                                    */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::SetWindowColor(COLORREF Color) {
    
    m_wndChartWnd.SetWindowColor(Color);
	m_wndHeaderWnd.SetWindowColor(Color);
	m_wndFooterWnd.SetWindowColor(Color);
	m_wndLegendWnd.SetWindowColor(Color);

    return;
    }

int CChartCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) {
	
    if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	COLORREF textColor = ::GetSysColor(COLOR_WINDOWTEXT);
	COLORREF winColor = ::GetSysColor(COLOR_MENU);
	m_wndChartWnd.Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, ID_CHART);
    m_wndChartWnd.SetFont(10, "Arial", 0/*BOLD|ITALIC|UNDERLINE*/);
    m_wndChartWnd.SetTextColor(textColor);
	m_wndChartWnd.SetWindowColor(winColor);
	m_wndChartWnd.SetLineColor(textColor);
	
    m_wndHeaderWnd.Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, ID_HEADER_TITLE);
    m_wndHeaderWnd.SetFont(10, "Arial", 0/*BOLD|ITALIC|UNDERLINE*/);
    m_wndHeaderWnd.SetTextColor(textColor);
    m_wndHeaderWnd.SetWindowColor(winColor);
	
    m_wndFooterWnd.Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, ID_FOOTER_TITLE);
    m_wndFooterWnd.SetFont(10, "Arial", 0/*BOLD|ITALIC|UNDERLINE*/);
    m_wndFooterWnd.SetTextColor(textColor);
    m_wndFooterWnd.SetWindowColor(winColor);
	
    m_wndLegendWnd.Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, ID_LEGEND);
    m_wndLegendWnd.SetFont(10, "Arial", 0/*BOLD|ITALIC|UNDERLINE*/);
    m_wndLegendWnd.SetTextColor(textColor);
    m_wndLegendWnd.SetWindowColor(winColor);
    m_wndLegendWnd.SetAutoHide(20, 10);
	
    return 0;
    }

void CChartCtrl::OnSize(UINT nType, int cx, int cy) {
	
    CWnd::OnSize(nType, cx, cy);
    _RecalculateAllWindows();
}

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_RecalculateLegend()                                                   */
/*                                                                                              */
/* Purpose : based on how many items are in the legend as well as window orientation this       */
/*           function will set the window size                                                  */
/*                                                                                              */
/* Inputs  : CRect& WindowRect -> dimensions of the chart control rect                          */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_RecalculateLegend(CRect& WindowRect) {

    /****The Legend Window****/
    if (m_bLegendVisible) {
        //we need to ask the legend what its dimensions are
        //this is based on both position and the number of
        //data series contained in the chart
        CRect Rect(m_LegendRect);
        if ((m_eLegendPosition==eLEFT||m_eLegendPosition==eRIGHT)&&m_bHeaderVisible)
            Rect.top += (long)(WindowRect.Height()*.1);
        if ((m_eLegendPosition==eLEFT||m_eLegendPosition==eRIGHT)&&m_bFooterVisible)
            Rect.bottom -= (long)(WindowRect.Height()*.1);
        
        m_wndLegendWnd.SetInitialWindowSize(&Rect);
        Rect.SetRectEmpty();
        m_wndLegendWnd.GetMinimumWindowRect(Rect);
        long lHeight(Rect.Height());
        lHeight += lHeight==0?0:20;
        long lWidth(Rect.Width());
        lWidth += lWidth==0?0:20;
        switch (m_eLegendPosition) {
            case eTOP :
                m_LegendRect.bottom = lHeight;
                break;
            case eBOTTOM :
                m_LegendRect.top = WindowRect.Height()-lHeight;
                break;
            case eLEFT : {
                m_LegendRect.right = lWidth;
                break;
                }
            case eRIGHT :
                m_LegendRect.left = WindowRect.Width()-lWidth;
                break;
            }
        switch (m_eLegendPosition) {
            case eLEFT :
            case eRIGHT :
                if (m_bHeaderVisible)
                    m_LegendRect.top = (long)(WindowRect.Height()*.1);
                if (m_bFooterVisible)
                    m_LegendRect.bottom = (long)(WindowRect.Height()*.9);
                break;
            }
        }
    else
        m_LegendRect.SetRectEmpty();
    
    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_RecalculateHeader()                                                   */
/*                                                                                              */
/* Purpose : based on window orientation this function will set the window size                 */
/*                                                                                              */
/* Inputs  : CRect& WindowRect -> dimensions of the chart control rect                          */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_RecalculateHeader(CRect& WindowRect) {

    if (m_bLegendVisible&&m_bHeaderVisible) {
        switch (m_eLegendPosition) {
            case eTOP :
                m_HeaderRect.top = m_LegendRect.bottom;
                m_HeaderRect.bottom = m_HeaderRect.top + (long)(WindowRect.Height()*.1);
                break;
            case eBOTTOM :
            case eLEFT :
            case eRIGHT :
                m_HeaderRect.bottom = (long)(WindowRect.Height()*.1);
                break;
            }
        }
    else if (m_bHeaderVisible) {
        m_HeaderRect.bottom = (long)(WindowRect.Height()*.1);
        }
    else
        m_HeaderRect.SetRectEmpty();

    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_RecalculateFooter()                                                   */
/*                                                                                              */
/* Purpose : based on window orientation this function will set the window size                 */
/*                                                                                              */
/* Inputs  : CRect& WindowRect -> dimensions of the chart control rect                          */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_RecalculateFooter(CRect& WindowRect) {

    if (m_bLegendVisible&&m_bFooterVisible) {
        switch (m_eLegendPosition) {
            case eBOTTOM :
                m_FooterRect.bottom = m_LegendRect.top;
                m_FooterRect.top = m_FooterRect.bottom - (long)(WindowRect.Height()*.1);
                break;
            case eTOP :
            case eLEFT :
            case eRIGHT :
                m_FooterRect.top = (long)(WindowRect.Height()*.9);
                break;
            }
        }
    else if (m_bFooterVisible) {
        m_FooterRect.top = (long)(WindowRect.Height()*.9);
        }
    else
        m_FooterRect.SetRectEmpty();

    return;
    }

/************************************************************************************************/
/*                                                                                              */
/* Function: CChartCtrl::_RecalculateChart()                                                    */
/*                                                                                              */
/* Purpose : based on window orientation this function will set the window size                 */
/*                                                                                              */
/* Inputs  : CRect& WindowRect -> dimensions of the chart control rect                          */
/*                                                                                              */
/* Outputs : NONE                                                                               */
/*                                                                                              */
/* Author  : Scott Pelger                                             Date Created: 7JUN02      */
/*                                                                                              */
/* Revisions                                                                                    */
/*                                                                                              */
/* Engineer              Date        Description                                                */
/*                                                                                              */
/* Scott Pelger          7JUN02      initial version                                            */
/*                                                                                              */
/************************************************************************************************/
void CChartCtrl::_RecalculateChart(CRect& WindowRect) {

    if (m_bLegendVisible) {
        switch (m_eLegendPosition) {
            case eLEFT :
                m_ChartRect.left = m_LegendRect.right;
                break;
            case eRIGHT :

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -