Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

120 lines
2.6 KiB
C++

// CPropInfo.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "stdafx.h"
#include "Resource.h"
#include "PropCtrl.h"
#include "PropInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define NOITEMSEL_PROMPT _T("当前没有选择")
/////////////////////////////////////////////////////////////////////////////
// CPropInfo
CPropInfo::CPropInfo() :
m_pProp(NULL)
{
}
CPropInfo::~CPropInfo()
{
}
BEGIN_MESSAGE_MAP(CPropInfo, CStatic)
//{{AFX_MSG_MAP(CPropInfo)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropInfo message handlers
void CPropInfo::SetPropOwner(CPropCtrl* pProp)
{
m_pProp = pProp;
}
void CPropInfo::OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect(rc);
dc.SelectObject(GetSysColorBrush(COLOR_BTNFACE));
dc.PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);
dc.DrawEdge(&rc, BDR_SUNKENOUTER, BF_RECT);
rc.DeflateRect(4, 4);
ASSERT(m_pProp!=NULL);
CPropItem* pItem = m_pProp->GetFocusedItem();
if (!m_pProp->IsWindowEnabled())
dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
else
dc.SetTextColor(GetSysColor(COLOR_BTNTEXT));
dc.SetBkMode(TRANSPARENT);
dc.SelectObject(m_pProp->GetBoldFont());
CString txt;
if (!pItem)
// txt.LoadString(IDS_NOITEMSEL); // 容易跟其它框架(cad)资源发生冲突
txt = NOITEMSEL_PROMPT;
else
{
txt = pItem->GetInfoText();
if (txt.IsEmpty())
txt = pItem->GetLabelText();
}
CRect ir;
ir = rc;
dc.SelectObject(m_pProp->GetNormalFont());
dc.DrawText(txt, &ir, DT_WORDBREAK);
// draw label
/* dc.DrawText(txt, &ir, DT_SINGLELINE|DT_CALCRECT);
dc.DrawText(txt, &ir, DT_SINGLELINE);
ir.top = ir.bottom;
ir.bottom = rc.bottom;
ir.right = rc.right;
if (pItem)
txt = pItem->GetInfoText();
else
txt.LoadString(IDS_SELFORINFO);
dc.SelectObject(m_pProp->GetNormalFont());
dc.DrawText(txt, &ir, DT_WORDBREAK);
*/
}