PropertyGridItemBool.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "StdAfx.h"
  2. #include "PropertyGridInplaceEdit.h"
  3. #include "PropertyGridInplaceButton.h"
  4. #include "PropertyGridInplaceList.h"
  5. #include "PropertyGridItem.h"
  6. #include "PropertyGriditemBool.h"
  7. const TCHAR TRUE_VALUE[] = _T("True");
  8. const TCHAR FALSE_VALUE[] = _T("False");
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CPropertyGridItemBool
  11. CPropertyGridItemBool::CPropertyGridItemBool(CString strCaption, BOOL bValue)
  12. : CPropertyGridItem(strCaption)
  13. {
  14. _Init(bValue);
  15. }
  16. CPropertyGridItemBool::CPropertyGridItemBool(UINT nID, BOOL bValue)
  17. : CPropertyGridItem(nID)
  18. {
  19. _Init(bValue);
  20. }
  21. CPropertyGridItemBool::~CPropertyGridItemBool(void)
  22. {
  23. }
  24. /////////////////////////////////////////////////////////////////////////////
  25. //
  26. void CPropertyGridItemBool::_Init(BOOL bValue)
  27. {
  28. m_pBindBool = NULL;
  29. SetBool(bValue);
  30. m_nFlags = pgitemHasComboButton | pgitemHasEdit;
  31. m_lstContraints.AddConstraint(TRUE_VALUE);
  32. m_lstContraints.AddConstraint(FALSE_VALUE);
  33. }
  34. void CPropertyGridItemBool::SetValue(CString strValue)
  35. {
  36. SetBool(strValue.CompareNoCase(TRUE_VALUE) == 0);
  37. }
  38. void CPropertyGridItemBool::SetBool(BOOL bValue)
  39. {
  40. m_bValue = bValue;
  41. CPropertyGridItem::SetValue(bValue? TRUE_VALUE: FALSE_VALUE);
  42. if (m_pBindBool)
  43. *m_pBindBool = m_bValue;
  44. }