|
// PropertyBrowser.cpp : implementation file
//
#include "stdafx.h"
#include "PropertyBrowser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropertyBrowser dialog
CPropertyBrowser::CPropertyBrowser(CWnd* pParent /*=NULL*/)
: CDialog(CPropertyBrowser::IDD, pParent)
{
//{{AFX_DATA_INIT(CPropertyBrowser)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hSize = ::LoadCursor(0, IDC_SIZENS);
m_hNormal = ::GetCursor();
}
CPropertyBrowser::~CPropertyBrowser()
{
::DeleteObject(m_hSize);
}
void CPropertyBrowser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropertyBrowser)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropertyBrowser, CDialog)
//{{AFX_MSG_MAP(CPropertyBrowser)
ON_WM_MOUSEMOVE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyBrowser message handlers
void CPropertyBrowser::PostCreate()
{
VERIFY(m_ctrlDescription.SubclassDlgItem(IDC_DESCRIPTION, this));
VERIFY(m_ctrlPropertyGrid.SubclassDlgItem(IDC_PROPERTYGRID, this));
GetClientRect(m_rcClient);
LayoutBrowser((double)0.75);
m_ctrlPropertyGrid.SetNotificationReciever(this);
TRACE("%d %d - %d %d\n", m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height());
LayoutControls();
}
void CPropertyBrowser::LayoutBrowser(int nBrowserHeight)
{
if(nBrowserHeight > m_rcClient.Height())
return;
GetClientRect(m_rcClient);
m_nBrowserHeight = nBrowserHeight;
m_nDescriptionHeight = m_rcClient.Height() - m_nBrowserHeight - CONTROLS_SPACING;
m_dRatio = double(m_nBrowserHeight / m_rcClient.Height());
LayoutControls();
}
void CPropertyBrowser::LayoutBrowser(double dBrowserHeight)
{
LayoutBrowser(int(m_rcClient.Height() * dBrowserHeight));
}
void CPropertyBrowser::LayoutControls()
{
m_ctrlPropertyGrid.MoveWindow(0, 0, m_rcClient.Width(), m_nBrowserHeight);
m_ctrlDescription.MoveWindow(0, m_nBrowserHeight + CONTROLS_SPACING, m_rcClient.Width(),
m_nDescriptionHeight - CONTROLS_SPACING);
}
/////////////////////////////////////////////////////////////////////////////
//
// IPropertyGridNotification
//
BOOL CPropertyBrowser::Ready()
{
return TRUE;
}
BOOL CPropertyBrowser::SupportsSynchronousNotifications()
{
return TRUE;
}
BOOL CPropertyBrowser::SupportsAsynchronousNotifications()
{
return FALSE;
}
BOOL CPropertyBrowser::CategorySelected(LPCTSTR pszCategoryName, LPCTSTR pszCategoryDescription)
{
m_ctrlDescription.UpdateText(pszCategoryDescription);
return TRUE;
}
BOOL CPropertyBrowser::ElementSelected(LPCTSTR pszElementName, LPCTSTR pszElementDescription)
{
m_ctrlDescription.UpdateText(pszElementDescription);
return TRUE;
}
void CPropertyBrowser::OnMouseMove(UINT nFlags, CPoint point)
{
/*if(Between(point.y, m_nBrowserHeight, 3))
::SetCursor(m_hSize);
else
::SetCursor(m_hNormal);*/
CDialog::OnMouseMove(nFlags, point);
}
void CPropertyBrowser::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(m_ctrlDescription)
m_ctrlDescription.Invalidate();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here