| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- #include "StdAfx.h"
- #include "PropertyGridInplaceEdit.h"
- #include "PropertyGridInplaceButton.h"
- #include "PropertyGridInplaceList.h"
- #include "PropertyGridItem.h"
- #include "PropertyGridItemSubSelect.h"
- #include "PropertyGridItemColor.h"
- #include "PropertyGridItemButton.h"
- #include "PropertyGrid_DrawHelpers.h"
- const TCHAR TRUE_VALUE[] = _T("True");
- const TCHAR FALSE_VALUE[] = _T("False");
- /////////////////////////////////////////////////////////////////////////////
- // CPropertyGridItemSize::CPropertyGridItemSizeWidth
- class CPropertyGridItemSubSelect::CPropertyGridItemSubSelectColor : public CPropertyGridItemColor
- {
- public:
- CPropertyGridItemSubSelectColor(CString strCaption)
- : CPropertyGridItemColor(strCaption) {}
-
- virtual void OnValueChanged(COLORREF clr)
- {
- ((CPropertyGridItemSubSelect*)m_pParent)->SetColor(clr);
- }
- };
- /////////////////////////////////////////////////////////////////////////////
- // CPropertyGridItemSize::CPropertyGridItemSizeHeight
- class CPropertyGridItemSubSelect::CPropertyGridItemSubSelectString : public CPropertyGridItemButton
- {
- public:
- CPropertyGridItemSubSelectString(CString strCaption,HWND hNotifyWnd, UINT nNotifyMsg)
- : CPropertyGridItemButton(strCaption,hNotifyWnd,nNotifyMsg) {}
- //virtual void OnValueChanged(CString strName)
- //{
- // ((CPropertyGridItemSubSelect*)m_pParent)->SetDescription(strName);
- //}
- // 当用户点击按钮时,调用此虚函数,(未写)
- virtual void OnInplaceButtonDown()
- {
- // m_pGrid->SetFocus();
- //
- // CColorDialog dlg( m_clrValue);
- // if ( dlg.DoModal( ) == IDOK )
- // OnValueChanged( RGBToString( dlg.GetColor( ) ) );
- CPropertyGridItemButton::OnInplaceButtonDown();
- }
- };
- /////////////////////////////////////////////////////////////////////////////
- // CPropertyGridItemSize
- CPropertyGridItemSubSelect::CPropertyGridItemSubSelect(CString strCaption ,HWND hNotifyWnd, UINT nNotifyMsg, BOOL bValue)
- : CPropertyGridItem(strCaption)
- {
- //ASSERT(hNotifyWnd);
- _Init(bValue);
- m_hNotifyWnd = hNotifyWnd;
- m_nNotifyMsg = nNotifyMsg;
- }
- CPropertyGridItemSubSelect::CPropertyGridItemSubSelect(UINT nID ,HWND hNotifyWnd, UINT nNotifyMsg, BOOL bValue)
- : CPropertyGridItem(nID)
- {
- _Init(bValue);
- m_hNotifyWnd = hNotifyWnd;
- m_nNotifyMsg = nNotifyMsg;
- }
- CPropertyGridItemSubSelect::~CPropertyGridItemSubSelect(void)
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- void CPropertyGridItemSubSelect::_Init(BOOL bValue)
- {
- m_pBindBool = NULL;
- SetBool(bValue);
- m_nFlags = pgitemHasComboButton | pgitemHasEdit;
- m_lstContraints.AddConstraint(TRUE_VALUE);
- m_lstContraints.AddConstraint(FALSE_VALUE);
- }
- void CPropertyGridItemSubSelect::OnAddChildItem()
- {
- m_itemColor = (CPropertyGridItemSubSelectColor*)AddChildItem(new CPropertyGridItemSubSelectColor(_T("Color")));
- m_itemString = (CPropertyGridItemSubSelectString*)AddChildItem(new CPropertyGridItemSubSelectString(_T("String"), m_hNotifyWnd, m_nNotifyMsg));
- UpdateChilds();
- }
- // CString CPropertyGridItemSubSelect::SizeToString(CSize size)
- // {
- // CString str;
- // str.Format(_T("%i; %i"), size.cx, size.cy);
- // return str;
- // }
- // CSize CPropertyGridItemSubSelect::StringToSize(CString str)
- // {
- // CString strWidth, strHeight;
- //
- // AfxExtractSubString(strWidth, str, 0, _T(';') );
- // AfxExtractSubString(strHeight, str, 1, _T(';') );
- //
- // return CSize(_ttoi(strWidth), _ttoi(strHeight));
- // }
- void CPropertyGridItemSubSelect::SetValue(CString strValue)
- {
- SetBool(strValue.CompareNoCase(TRUE_VALUE) == 0);
- }
- void CPropertyGridItemSubSelect::SetBool(BOOL bValue)
- {
- m_bValue = bValue;
- CPropertyGridItem::SetValue(bValue? TRUE_VALUE: FALSE_VALUE);
- if (m_pBindBool)
- *m_pBindBool = m_bValue;
- }
- void CPropertyGridItemSubSelect::UpdateChilds()
- {
- //m_itemColor->SetColor();
- //m_itemString->SetEditText();
- }
- void CPropertyGridItemSubSelect::SetColor(COLORREF clr)
- {
- //OnValueChanged(RGBToString(CSize(_ttoi(strWidth), m_szValue.cy)));
- m_itemColor->SetColor(clr);
-
- }
- void CPropertyGridItemSubSelect::SetString(CString strName)
- {
- //OnValueChanged(SizeToString(CSize(m_szValue.cx, _ttoi(strHeight))));
- //m_itemString->SetEditText(strName);
- m_itemString->SetDescription(strName);
- }
|