//------------------------------------------------------------------------
//! CGridColumnTraitImage - Constructor
//!
//! @param nImageIndex The first index in list control imagelist
//! @param nImageCount The number of images to switch between in the imagelist
//------------------------------------------------------------------------
CGridColumnTraitImage::CGridColumnTraitImage(int nImageIndex, int nImageCount)
:m_SortImageIndex(false)
,m_ToggleSelection(false)
{
	for(int i = nImageIndex; i < nImageIndex + nImageCount; ++i)
		AddImageIndex(i);
}
//------------------------------------------------------------------------
//! Updates the image text for the specified image index
//!
//! @param nImageIdx The index of the image in the list control imagelist
//! @param strImageText The associated cell text to the image
//! @param bEditable Is the cell editable when this image is displayed
//------------------------------------------------------------------------
void CGridColumnTraitImage::SetImageText(int nImageIdx, const CString& strImageText, bool bEditable)
{
	int nIndex = m_ImageIndexes.FindKey(nImageIdx);
	if (nIndex==-1)
		AddImageIndex(nImageIdx, strImageText, bEditable);
	else
		m_ImageIndexes.GetValueAt(nIndex) = ImageCell(strImageText,bEditable);
}
//------------------------------------------------------------------------
//! CGridColumnTraitImage - Constructor
//!
//! @param nImageIndex The first index in list control imagelist
//! @param nImageCount The number of images to switch between in the imagelist
//------------------------------------------------------------------------
CGridColumnTraitImage::CGridColumnTraitImage(int nImageIndex, int nImageCount)
	: m_SortImageIndex(false)
	, m_ToggleSelection(false)
	, m_SingleClickEdit(false)
	, m_IconClickBeginEdit(false)
{
	for (int i = nImageIndex; i < nImageIndex + nImageCount; ++i)
		AddImageIndex(i);
}
void CXTPRibbonBuilder::BuildControl(CXTPPropExchange* pPX, CXTPControl* pControl)
{
	CString strName;
	PX_String(pPX, _T("TEXT"), strName);


	CXTPPropExchangeSection pxId(pPX->GetSection(_T("ID")));
	int nId = 0;
	PX_Int(&pxId, _T("VALUE"), nId);


	pControl->SetCaption(strName);
	pControl->SetID(nId);

	CString strKeys;
	PX_String(pPX, _T("KEYS"), strKeys);

	pControl->SetKeyboardTip(strKeys);

	CString strAlwaysLarge;
	PX_String(pPX, _T("ALWAYS_LARGE"), strAlwaysLarge);
	if (strAlwaysLarge == _T("TRUE"))
	{
		pControl->SetStyle(xtpButtonIconAndCaptionBelow);
	}

	int nIndexSmall = -1;
	PX_Int(pPX, _T("INDEX_SMALL"), nIndexSmall);
	if (nIndexSmall >= 0)
	{
		AddImageIndex(nIndexSmall, nId, ICON_SMALL);
	}

	int nIndexLarge = -1;
	PX_Int(pPX, _T("INDEX_LARGE"), nIndexLarge);
	if (nIndexLarge >= 0)
	{
		AddImageIndex(nIndexLarge, nId, ICON_BIG);
	}

}
//------------------------------------------------------------------------
//! Updates the image text for the specified image index
//!
//! @param nImageIdx The index of the image in the list control imagelist
//! @param strImageText The associated cell text to the image
//! @param bEditable Is the cell editable when this image is displayed
//------------------------------------------------------------------------
void CGridColumnTraitImage::SetImageText(int nImageIdx, const CString& strImageText, bool bEditable)
{
	int nIndex = m_ImageCellText.FindKey(nImageIdx);
	if (nIndex == -1)
	{
		AddImageIndex(nImageIdx, strImageText, bEditable);
	}
	else
	{
		m_ImageCellText.GetValueAt(nIndex) = strImageText;
		m_ImageCellEdit.GetValueAt(nIndex) = bEditable;
	}
}