SPPropertyGridItemImage.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #include "StdAfx.h"
  2. #include ".\sppropertygriditemimage.h"
  3. CSPPropertyGridItemImage::CSPPropertyGridItemImage( CString strCaption , LPCTSTR strValue , CString * pBindString ) : CSPPropertyGridItem( strCaption )
  4. {
  5. m_nFlags = SPGridItemHasEdit | SPGridItemHasExpandButton;
  6. }
  7. CSPPropertyGridItemImage::CSPPropertyGridItemImage( UINT nID ) : CSPPropertyGridItem( nID,NULL,NULL )
  8. {
  9. m_nFlags = SPGridItemHasEdit | SPGridItemHasExpandButton;
  10. }
  11. CSPPropertyGridItemImage::~CSPPropertyGridItemImage( void )
  12. {
  13. }
  14. void CSPPropertyGridItemImage::OnInplaceButtonDown()
  15. {
  16. if ( m_dlgImage.DoModal() == IDOK )
  17. {
  18. if ( m_dlgImage.m_wndImage.m_bSection )
  19. {
  20. OnValueChanged( m_dlgImage.m_wndImage.m_pImageSection->strImageName );
  21. }
  22. else
  23. {
  24. OnValueChanged( m_dlgImage.m_wndImage.m_pImageRect->strImageName );
  25. }
  26. m_pGrid->Invalidate( TRUE );
  27. }
  28. }
  29. ///////////////////////////////////////////////////////////////////////////////////////////////
  30. CSPPropertyGridItemText::CSPPropertyGridItemText( CString strCaption , LPCTSTR strValue , CString * pBindString ) : CSPPropertyGridItem( strCaption )
  31. {
  32. m_nFlags = SPGridItemHasEdit | SPGridItemHasExpandButton;
  33. }
  34. CSPPropertyGridItemText::CSPPropertyGridItemText( UINT nID ) : CSPPropertyGridItem( nID,NULL,NULL )
  35. {
  36. m_nFlags = SPGridItemHasEdit | SPGridItemHasExpandButton;
  37. }
  38. CSPPropertyGridItemText::~CSPPropertyGridItemText( void )
  39. {
  40. }
  41. void CSPPropertyGridItemText::OnInplaceButtonDown()
  42. {
  43. if ( m_dlgText.DoModal() == IDOK )
  44. {
  45. /*if(m_dlgImage.m_wndImage.m_bSection)
  46. {
  47. OnValueChanged(m_dlgImage.m_wndImage.m_pImageSection->strImageName);
  48. }
  49. else
  50. {
  51. OnValueChanged(m_dlgImage.m_wndImage.m_pImageRect->strImageName);
  52. }
  53. m_pGrid->Invalidate( TRUE );*/
  54. }
  55. }
  56. ////////////////////////////////////////////////////////////////////////////////////////////////
  57. class CSPPropertyGridItemRect::CCustomItemChildsAll : public CSPPropertyGridItemNumber
  58. {
  59. public:
  60. CCustomItemChildsAll( CString strCaption ) : CSPPropertyGridItemNumber( strCaption )
  61. {
  62. }
  63. virtual void OnValueChanged( CString strValue )
  64. {
  65. SetValue( strValue );
  66. CSPPropertyGridItemRect * pParent = ( ( CSPPropertyGridItemRect * ) m_pParent );
  67. CRect & rc = pParent->m_rcValue;
  68. rc.left = rc.right = rc.top = rc.bottom = GetNumber();
  69. pParent->OnValueChanged( pParent->RectToString( rc ) );
  70. }
  71. };
  72. class CSPPropertyGridItemRect::CCustomItemChildsPad : public CSPPropertyGridItemNumber
  73. {
  74. public:
  75. CCustomItemChildsPad( CString strCaption , LONG & nPad ) : CSPPropertyGridItemNumber( strCaption ) , m_nPad( nPad )
  76. {
  77. }
  78. virtual void OnValueChanged( CString strValue )
  79. {
  80. SetValue( strValue );
  81. CSPPropertyGridItemRect * pParent = ( ( CSPPropertyGridItemRect * ) m_pParent );
  82. m_nPad = GetNumber();
  83. pParent->OnValueChanged( pParent->RectToString( pParent->m_rcValue ) );
  84. }
  85. LONG& m_nPad;
  86. };
  87. CSPPropertyGridItemRect::CSPPropertyGridItemRect( CString strCaption , CRect rcValue ) : CSPPropertyGridItem( strCaption )
  88. {
  89. m_rcValue = rcValue;
  90. m_strValue = RectToString( rcValue );
  91. m_nFlags = 0;
  92. }
  93. CSPPropertyGridItemRect::CSPPropertyGridItemRect( UINT nID , CRect rcValue ) : CSPPropertyGridItem( nID,NULL,NULL )
  94. {
  95. m_rcValue = rcValue;
  96. m_strValue = RectToString( rcValue );
  97. m_nFlags = 0;
  98. }
  99. void CSPPropertyGridItemRect::OnAddChildItem()
  100. {
  101. m_itemLeft = ( CCustomItemChildsPad * ) AddChildItem( new CCustomItemChildsPad( _T( "Left" ),m_rcValue.left ) );
  102. m_itemTop = ( CCustomItemChildsPad * ) AddChildItem( new CCustomItemChildsPad( _T( "Top" ),m_rcValue.top ) );
  103. m_itemRight = ( CCustomItemChildsPad * ) AddChildItem( new CCustomItemChildsPad( _T( "Right" ),m_rcValue.right ) );
  104. m_itemBottom = ( CCustomItemChildsPad * ) AddChildItem( new CCustomItemChildsPad( _T( "Bottom" ),m_rcValue.bottom ) );
  105. Expand();
  106. UpdateChilds();
  107. }
  108. void CSPPropertyGridItemRect::UpdateChilds()
  109. {
  110. m_itemLeft->SetNumber( m_rcValue.left );
  111. m_itemRight->SetNumber( m_rcValue.right );
  112. m_itemTop->SetNumber( m_rcValue.top );
  113. m_itemBottom->SetNumber( m_rcValue.bottom );
  114. }
  115. void CSPPropertyGridItemRect::SetValue( CString strValue )
  116. {
  117. CSPPropertyGridItem::SetValue( strValue );
  118. UpdateChilds();
  119. }
  120. CString CSPPropertyGridItemRect::RectToString( CRect rc )
  121. {
  122. CString str;
  123. str.Format( _T( "%i; %i; %i; %i" ),rc.left,rc.top,rc.right,rc.bottom );
  124. return str;
  125. }
  126. void CSPPropertyGridItemRect::SetRect( CRect rc )
  127. {
  128. m_rcValue = rc;
  129. SetValue( RectToString( m_rcValue ) );
  130. UpdateChilds();
  131. }
  132. CRect CSPPropertyGridItemRect::GetRect()
  133. {
  134. return m_rcValue;
  135. }