RectItem.cpp 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "StdAfx.h"
  2. #include "RectItem.h"
  3. #include "RectEditDlg.h"
  4. CRectItem::CRectItem(void)
  5. {
  6. m_left = 20;
  7. m_top = 20;
  8. m_right = 100;
  9. m_bottom = 100;
  10. }
  11. CRectItem::~CRectItem(void)
  12. {
  13. }
  14. CPropertyGrid::EEditMode CRectItem::GetEditMode()
  15. {
  16. return CPropertyGrid::EM_MODAL;
  17. }
  18. void CRectItem::DrawItem(CDC& dc, CRect rc, bool focused)
  19. {
  20. CString str;
  21. str.Format("%d; %d; %d; %d", m_left, m_top, m_right, m_bottom);
  22. rc.left += m_pGrid->GetTextMargin();
  23. dc.DrawText(str, rc, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS|DT_NOPREFIX);
  24. }
  25. bool CRectItem::OnEditItem()
  26. {
  27. CRectEditDlg dlg(m_pGrid);
  28. dlg.m_left = m_left;
  29. dlg.m_top = m_top;
  30. dlg.m_right = m_right;
  31. dlg.m_bottom = m_bottom;
  32. if (dlg.DoModal() == IDOK)
  33. {
  34. m_left = dlg.m_left;
  35. m_top = dlg.m_top;
  36. m_right = dlg.m_right;
  37. m_bottom = dlg.m_bottom;
  38. return true;
  39. }
  40. return false;
  41. }