Files
GdCpp12/staticOnly/KsMFC/customcells.cpp

117 lines
3.1 KiB
C++

//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a sample for BCGControlBar Library Professional Edition
// Copyright (C) 1998-2024 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions
// of the accompanying license agreement.
//*******************************************************************************
//
// CustomCells.cpp: implementation of the CColorGridItem class.
//
//////////////////////////////////////////////////////////////////////
#include "pch.h"
//#include "BCGPGridExample.h"
#include "CustomCells.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
////////////////////////////////////////////////////////////////////////////////
// CButtonItem Class
CButtonItem::CButtonItem (LPCTSTR lpszText, UINT id) :
CBCGPGridItem (lpszText)
{
m_bAllowEdit = FALSE;
m_id = id;
}
//*****************************************************************************************
void CButtonItem::OnDrawValue (CDC* pDC, CRect rect)
{
ASSERT_VALID (pDC);
CBCGPGridCtrl* pGridCtrl = GetOwnerList ();
OnFillBackground (pDC, rect);
const int nMargin = globalUtils.ScaleByDPI(1, pGridCtrl);
rect.DeflateRect(nMargin, nMargin);
COLORREF clrText = globalData.clrBarText;
if (pGridCtrl != NULL && pGridCtrl->IsVisualManagerStyle())
{
clrText = CBCGPVisualManager::GetInstance()->OnDrawPropListPushButton(pDC, rect, NULL, TRUE, FALSE, IsEnabled(), FALSE, IsHighlighted());
}
else
{
clrText = CBCGPVisualManager::GetInstance()->CBCGPVisualManager::OnDrawPropListPushButton(pDC, rect, NULL, TRUE, FALSE, IsEnabled(), FALSE, IsHighlighted());
}
COLORREF clrTextOld = pDC->SetTextColor(clrText);
CString strText = (LPCTSTR)(_bstr_t) m_varValue;
pDC->DrawText (strText, rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
pDC->SetTextColor (clrTextOld);
}
//*****************************************************************************************
BOOL CButtonItem::OnClickValue (UINT uiMsg, CPoint point)
{
if (uiMsg != WM_LBUTTONDOWN)
{
return CBCGPGridItem::OnClickValue (uiMsg, point);
}
CBCGPGridCtrl* pGridCtrl = GetOwnerList();
ASSERT_VALID (pGridCtrl);
pGridCtrl->SendMessage (WM_COMMAND,
MAKEWPARAM (m_id, BN_CLICKED));
return TRUE;
}
//*****************************************************************************************
BOOL CButtonItem::PushChar (UINT nChar)
{
if (nChar == VK_SPACE || nChar == VK_RETURN)
{
CBCGPGridCtrl* pGridCtrl = GetOwnerList();
ASSERT_VALID (pGridCtrl);
pGridCtrl->SendMessage (WM_COMMAND,
MAKEWPARAM (m_id, BN_CLICKED));
return TRUE;
}
return CBCGPGridItem::PushChar(nChar);
}
//*****************************************************************************************
void CButtonItem::OnMouseMove(const CPoint& /*point*/)
{
if (!IsHighlighted())
{
Highlight();
Redraw();
}
}
//*****************************************************************************************
void CButtonItem::OnMouseLeave()
{
if (IsHighlighted())
{
Highlight(FALSE);
Redraw();
}
}