You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
5.5 KiB
C++
200 lines
5.5 KiB
C++
|
|
#include "stdafx.h"
|
|
|
|
#include "PropertiesWnd.h"
|
|
#include "Resource.h"
|
|
#include "MainFrm.h"
|
|
#include "LaiPuLaser.h"
|
|
#include "Propertie.h"
|
|
#include "Module.h"
|
|
#include "LogMgr.h"
|
|
#include "PropertieMgr.h"
|
|
#include "ModuleDeviceMgr.h"
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CResourceViewBar
|
|
|
|
CPanePropertiesWnd::CPanePropertiesWnd()
|
|
{
|
|
m_bUseObjectCombo = true;//使用下拉列表
|
|
}
|
|
CPanePropertiesWnd::~CPanePropertiesWnd()
|
|
{
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CPanePropertiesWnd, CDockablePane)
|
|
ON_WM_CREATE()
|
|
ON_WM_SIZE()
|
|
ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties)
|
|
ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties)
|
|
ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties)
|
|
ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties)
|
|
ON_WM_SETFOCUS()
|
|
ON_WM_SETTINGCHANGE()
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CResourceViewBar 消息处理程序
|
|
void CPanePropertiesWnd::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDockablePane::DoDataExchange(pDX);
|
|
DDX_Control(pDX, ID_PROPERTY_COMB, m_wndObjectCombo);
|
|
}
|
|
#if 1
|
|
int CPanePropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
{
|
|
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
|
|
return -1;
|
|
|
|
CRect rectDummy;
|
|
rectDummy.SetRectEmpty();
|
|
|
|
// 创建组合:
|
|
//const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
|
const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
|
|
|
if(m_bUseObjectCombo)
|
|
{
|
|
if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, ID_PROPERTY_COMB))
|
|
{
|
|
TRACE0("未能创建属性组合 \n");
|
|
return -1; // 未能创建
|
|
}
|
|
IniObjectCombo();
|
|
}
|
|
if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
|
|
{
|
|
TRACE0("未能创建属性网格\n");
|
|
return -1; // 未能创建
|
|
}
|
|
|
|
InitPropList();
|
|
|
|
m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES);
|
|
m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* 已锁定*/);
|
|
m_wndToolBar.CleanUpLockedImages();
|
|
m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* 锁定*/);
|
|
|
|
m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
|
|
m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
|
|
m_wndToolBar.SetOwner(this);
|
|
|
|
// 所有命令将通过此控件路由,而不是通过主框架路由:
|
|
m_wndToolBar.SetRouteCommandsViaFrame(FALSE);
|
|
|
|
AdjustLayout();
|
|
return 0;
|
|
}
|
|
void CPanePropertiesWnd::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDockablePane::OnSize(nType, cx, cy);
|
|
AdjustLayout();
|
|
}
|
|
#endif
|
|
void CPanePropertiesWnd::OnExpandAllProperties()
|
|
{
|
|
m_wndPropList.ExpandAll();
|
|
}
|
|
|
|
void CPanePropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */)
|
|
{
|
|
}
|
|
|
|
void CPanePropertiesWnd::OnSortProperties()
|
|
{
|
|
m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode());
|
|
}
|
|
|
|
void CPanePropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI)
|
|
{
|
|
pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode());
|
|
}
|
|
|
|
void CPanePropertiesWnd::InitPropList()
|
|
{
|
|
SetPropListFont();
|
|
m_wndPropList.EnableHeaderCtrl(FALSE);
|
|
m_wndPropList.EnableDescriptionArea();//属性说明area
|
|
m_wndPropList.SetVSDotNetLook();
|
|
//m_wndPropList.MarkModifiedProperties();//标记被修改的属性
|
|
}
|
|
//插入一个属性
|
|
void CPanePropertiesWnd::InsertGridProperty(CMFCPropertyGridProperty* pProp)
|
|
{
|
|
if(pProp)
|
|
{
|
|
m_wndPropList.AddProperty(pProp);
|
|
}
|
|
}
|
|
void CPanePropertiesWnd::OnSetFocus(CWnd* pOldWnd)
|
|
{
|
|
CDockablePane::OnSetFocus(pOldWnd);
|
|
m_wndPropList.SetFocus();
|
|
}
|
|
|
|
void CPanePropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
|
|
{
|
|
CDockablePane::OnSettingChange(uFlags, lpszSection);
|
|
SetPropListFont();
|
|
}
|
|
|
|
void CPanePropertiesWnd::SetPropListFont()
|
|
{
|
|
::DeleteObject(m_fntPropList.Detach());
|
|
|
|
LOGFONT lf;
|
|
afxGlobalData.fontRegular.GetLogFont(&lf);
|
|
|
|
NONCLIENTMETRICS info;
|
|
info.cbSize = sizeof(info);
|
|
|
|
afxGlobalData.GetNonClientMetrics(info);
|
|
|
|
lf.lfHeight = info.lfMenuFont.lfHeight;
|
|
lf.lfWeight = info.lfMenuFont.lfWeight;
|
|
lf.lfItalic = info.lfMenuFont.lfItalic;
|
|
|
|
m_fntPropList.CreateFontIndirect(&lf);
|
|
|
|
m_wndPropList.SetFont(&m_fntPropList);
|
|
if(m_bUseObjectCombo)
|
|
{
|
|
m_wndObjectCombo.SetFont(&m_fntPropList);
|
|
}
|
|
}
|
|
#if 1
|
|
//刷新控件的位置
|
|
void CPanePropertiesWnd::AdjustLayout()
|
|
{
|
|
if (GetSafeHwnd() == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CRect rectClient,rectCombo;
|
|
GetClientRect(rectClient);
|
|
|
|
int cyCmb = 0;
|
|
if(m_bUseObjectCombo)
|
|
{
|
|
m_wndObjectCombo.GetWindowRect(&rectCombo);
|
|
cyCmb = rectCombo.Size().cy;
|
|
}
|
|
int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy;
|
|
if(m_bUseObjectCombo)
|
|
{
|
|
//300 是下拉框的高度
|
|
m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 300, SWP_NOACTIVATE | SWP_NOZORDER);
|
|
}
|
|
m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
|
|
m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER);
|
|
}
|
|
#endif
|