GridCell.cpp
资源名称:MyStock.rar [点击查看]
上传用户:wenjimin
上传日期:2014-08-12
资源大小:111k
文件大小:2k
源码类别:
金融证券系统
开发平台:
Visual C++
- // GridCell.cpp: implementation of the CGridCell class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "GridCell.h"
- #include "GridDefaultCell.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNCREATE(CGridCell, CGridCellBase)
- CGridCell::CGridCell()
- {
- m_plfFont = NULL;
- m_strText.Empty();
- m_pGrid = NULL;
- m_crBkClr = CLR_DEFAULT; // Background colour (or CLR_DEFAULT)
- m_crFgClr = CLR_DEFAULT; // Forground colour (or CLR_DEFAULT)
- delete m_plfFont;
- m_plfFont = NULL; // Cell font
- }
- CGridCell::~CGridCell()
- {
- delete m_plfFont;
- }
- void CGridCell::operator=(const CGridCell& cell)
- {
- if (this != &cell) CGridCellBase::operator=(cell);
- }
- void CGridCell::SetFont(const LOGFONT* plf)
- {
- if (plf == NULL)
- {
- delete m_plfFont;
- m_plfFont = NULL;
- }
- else
- {
- if (!m_plfFont)
- m_plfFont = new LOGFONT;
- if (m_plfFont)
- memcpy(m_plfFont, plf, sizeof(LOGFONT));
- }
- }
- LOGFONT* CGridCell::GetFont() const
- {
- if (m_plfFont == NULL)
- {
- CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell();
- if (!pDefaultCell)
- return NULL;
- return pDefaultCell->GetFont();
- }
- return m_plfFont;
- }
- CFont* CGridCell::GetFontObject() const
- {
- // If the default font is specified, use the default cell implementation
- if (m_plfFont == NULL)
- {
- CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell();
- if (!pDefaultCell)
- return NULL;
- return pDefaultCell->GetFontObject();
- }
- else
- {
- static CFont Font;
- Font.DeleteObject();
- Font.CreateFontIndirect(m_plfFont);
- return &Font;
- }
- }